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
roleName
bytes32
- bytes32 representation of a role name
user
address
- address of a user that is assigned a role above
RoleRemoved
Event fired upon removing a role for an address.
Parameters
roleName
bytes32
- bytes32 representation of a role name
user
address
- address of a user that for which the above role is removed
RequestConfirmed
Event fired upon submission/confirmation of a governor addition/removal request.See {submitGovernorRequest}.
Parameters
sender
address
- person who called {submitGovernorRequest} and sent the request
govAddress
address
- address of the governor candidate to appoint/remove the role for
operationType
enum RoleManager.OperationType
- an {OperationType} enum value representing if it's an addition or removal call
ConfirmationRevoked
Event fired upon revoking a request for addition/removal of a governor.See {revokeGovernorRequestConfirmation}.
Parameters
sender
address
- person who called {revokeGovernorRequestConfirmation} and sent the request
govAddress
address
- address of a governor candidate for whom request is being revoked
GovernorAdded
Event fired upon successful addition of a new governor.
Parameters
govAddress
address
- address of a new governor added
GovernorRemoved
Event fired upon successful removal of a governor.
Parameters
govAddress
address
- address of a new governor removed
Modifiers
onlyRole
onlyRole
Modifier preventing unauthorized addresses from calling protected functions.
Arguments
roleName
bytes32
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
governors
address[]
array of addresses to be added as governors
_confirmationsRequired
uint256
number of confirmations required to add/remove governor
appointAdmins
Adds an ADMIN_ROLE_NAME
for the provided array of admins
.
Arguments
admins
address[]
array of addresses to be added as admins
addRoleForAddress
Function to assign a role to an address
Arguments
addr
address
address to add role to
roleName
bytes32
name of the role to add
addRolesForAddresses
Assigns multiple roles to addresses.
Arguments
addresses
address[]
array of user addresses for which roles should be added
rolesArr
bytes32[]
array of respective roles
removeRoleForAddress
Removes a roleName
for the provided addr
.
Arguments
addr
address
address to remove role from
roleName
bytes32
name of the role to remove See {removeRole}.
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
govAddress
address
account address for which governor
role is requested to be added
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
govAddress
address
account address for which governor
role is requested to be removed
revokeGovernorRequestConfirmation
Function to provide ability for current governors to revoke previously granted confirmation of adding or removing a new governor.
Arguments
govAddress
address
account address for which confirmation was granted before and needs to be removed
checkRole
Checks the existence of a roleName
value for the given addr
. Function reverts if account does not have required role
Arguments
addr
address
address to check role for
roleName
bytes32
name of the role to be checked
hasRole
See {Roles.has}.
Arguments
addr
address
roleName
bytes32
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
addr
address
roleName
bytes32
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
addr
address
roleName
bytes32
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
govAddress
address
- address of a governor candidate to add or remove
operationType
enum RoleManager.OperationType
- enum value signifying type of the operation (add or remove)
acceptGovernorRequest
Function that adds/removes a governor.This function is launched automatically when the number of requests required is reached.
Arguments
govAddress
address
- address of a governor candidate to add or remove
operationType
enum RoleManager.OperationType
- enum value signifying type of the operation (add or remove)
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
addr
address
address to check governor role for See {Roles.add}.
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
addr
address
address to check governor role for See {Roles.remove}.
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
govAddress
address
address identifier of governor requests
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
govAddress
address
address identifier of governor requests
Last updated
Was this helpful?