RoleManager
Central contract in the system that keeps and manages account roles and access to the system. Most crucial logic like setting address, changing {Resolver}'s signatures, contract initizlizing logic, trade settlement are restricted to accounts that have valid roles. See docs/SystemAccess.md for more details about roles (RoleManager.sol)
View Source: @nomisma/elektro-protocol-aux/contracts/access/RoleManager.sol
↗ Extends: IRoleManager ↘ Derived Contracts: RoleManagerProxy
RoleManager
Enums
OperationType
Structs
GovernorRequest
Contract Members
Constants & Variables
All add-governor requests already sumbitted to the system. Maps governor candidate address to {GovernorRequest} struct holding data of all requests for a particular candidate.
Variable set upon construction representing how many request are required to assing a new governor for the system.
Maps role name to {Roles} library to access all base role related functionality.
RoleAdded
Event fired upon adding a role for an address.
Parameters
RoleRemoved
Event fired upon removing a role for an address.
Parameters
RequestConfirmed
Event fired upon submission/confirmation of a governor addition/removal request.See {submitGovernorRequest}.
Parameters
ConfirmationRevoked
Event fired upon revoking a request for addition/removal of a governor.See {revokeGovernorRequestConfirmation}.
Parameters
GovernorAdded
Event fired upon successful addition of a new governor.
Parameters
GovernorRemoved
Event fired upon successful removal of a governor.
Parameters
Modifiers
onlyRole
onlyRole
Modifier preventing unauthorized addresses from calling protected functions.
Arguments
Functions
(address[] governors, uint256 _confirmationsRequired)
appointAdmins(address[] admins)
addRoleForAddress(address addr, bytes32 roleName)
addRolesForAddresses(address[] addresses, bytes32[] rolesArr)
removeRoleForAddress(address addr, bytes32 roleName)
submitAddGovernorRequest(address govAddress)
submitRemoveGovernorRequest(address govAddress)
revokeGovernorRequestConfirmation(address govAddress)
checkRole(address addr, bytes32 roleName)
hasRole(address addr, bytes32 roleName)
addRole(address addr, bytes32 roleName)
removeRole(address addr, bytes32 roleName)
submitGovernorRequest(address govAddress, enum RoleManager.OperationType operationType)
acceptGovernorRequest(address govAddress, enum RoleManager.OperationType operationType)
addGovernorRole(address addr)
removeGovernorRole(address addr)
isGovernorRequestConfirmed(address govAddress)
isNotConfirmedBySender(address govAddress)
Constructor that assigns accounts with governor
role Governor role can be only added during contract construction and when {_confirmationsRequired} number of governors {submitAddGovernorRequest}. Note that governors.length >= _confirmationsRequired
Arguments
appointAdmins
Adds an ADMIN_ROLE_NAME
for the provided array of admins
.
Arguments
addRoleForAddress
Function to assign a role to an address
Arguments
addRolesForAddresses
Assigns multiple roles to addresses.
Arguments
removeRoleForAddress
Removes a roleName
for the provided addr
.
Arguments
submitAddGovernorRequest
Multisig implementation for adding new governor. In order to add new governor at least confirmationsRequired
amount of governors need to call this function for same govAddress
. For the first governor that calls this function with new govAddress
, new GovernorRequest
is created and stored in RoleManager. Only after last governor executed this function, governor
role is added for govAddress
.
Arguments
submitRemoveGovernorRequest
Multisig implementation for removing governor. In order to remove governor at least confirmationsRequired
amount of governors need to call this function for same govAddress
. For the first governor that calls this function with new govAddress
, new GovernorRequest
is created and stored in {RoleManager.govRequests}. Only after last governor executed this function, governor
role is removed for govAddress
.
Arguments
revokeGovernorRequestConfirmation
Function to provide ability for current governors to revoke previously granted confirmation of adding or removing a new governor.
Arguments
checkRole
Checks the existence of a roleName
value for the given addr
. Function reverts if account does not have required role
Arguments
hasRole
See {Roles.has}.
Arguments
addRole
Adds a roleName
for the provided addr
and emits a RoleAdded
event that can be found in the transaction events. See {Roles.add}.
Arguments
removeRole
Removes a role for the provided addr
and emits a RoleRemoved
event that can be found in the transaction events. See {Roles.remove}.
Arguments
submitGovernorRequest
Internal function with base functionality for both adding and removing governors.Checks if this is a first request, in which case it would initialize new slot in {govRequests} adding request data or, in case of subsequent requests, would add new request to an existing mapping slot. Also fires an event and checks if the required number of requests reached, in which case it will add or remove new governor automatically.
Arguments
acceptGovernorRequest
Function that adds/removes a governor.This function is launched automatically when the number of requests required is reached.
Arguments
addGovernorRole
Adds a GOVERNOR_ROLE_NAME
for the provided addr
and emit a RoleAdded
event that can be found in the transaction events. Can only be run as a part of governor request/confirmation flow.
Arguments
removeGovernorRole
Removes a GOVERNOR_ROLE_NAME
for the provided addr
and emit a RoleRemoved
event that can be found in the transaction events. Can only be run as a part of governor request/confirmation flow.
Arguments
isGovernorRequestConfirmed
Function to check if governor request for govAddress
has enough confirmations to be executed
Returns
true if at least confirmationsRequired number of requests are confirmed for govAddress
Arguments
isNotConfirmedBySender
Function to check if governor request has been already confirmed by this msg.sender
Returns
true if govAddress
is not already confirmed by msg.sender
Arguments
Last updated