IRoles is an interface that abstracts the implementation of a contract with role control features. It’s commonly included for the functionality to get current role, transfer role, and propose and accept role.
error InvalidProposedAccount(address account)
function hasAllTheRoles(address account, uint8[] roles) external view returns (bool)
Checks if an account has all the roles.
Name | Type | Description |
---|---|---|
account | address | The address to check |
roles | uint8[] | The roles to check |
Name | Type | Description |
---|---|---|
[0] | bool | True if the account has all the roles, false otherwise |
function hasAnyOfRoles(address account, uint8[] roles) external view returns (bool)
Checks if an account has any of the roles.
Name | Type | Description |
---|---|---|
account | address | The address to check |
roles | uint8[] | The roles to check |
Name | Type | Description |
---|---|---|
[0] | bool | True if the account has any of the roles, false otherwise |
function getAccountRoles(address account) external view returns (uint256 accountRoles)
Returns the roles of an account.
Name | Type | Description |
---|---|---|
account | address | The address to get the roles for |
Name | Type | Description |
---|---|---|
accountRoles | uint256 | The roles of the account in uint256 format |
function getProposedRoles(address fromAccount, address toAccount) external view returns (uint256 proposedRoles_)
Returns the pending role of the contract.
Name | Type | Description |
---|---|---|
fromAccount | address | The address with the current roles |
toAccount | address | The address with the pending roles |
Name | Type | Description |
---|---|---|
proposedRoles_ | uint256 | The pending role of the contract in uint256 format |
function transferRoles(address toAccount, uint8[] roles) external
Transfers roles of the contract to a new account.
Can only be called by the account with all the roles. Emits RolesRemoved and RolesAdded events.
Name | Type | Description |
---|---|---|
toAccount | address | The address to transfer role to |
roles | uint8[] | The roles to transfer |
function proposeRoles(address toAccount, uint8[] roles) external
Propose to transfer roles of message sender to a new account.
Can only be called by the account with all the proposed roles. emits a RolesProposed event. Roles are not transferred until the new role accepts the role transfer.
Name | Type | Description |
---|---|---|
toAccount | address | The address to transfer role to |
roles | uint8[] | The roles to transfer |
function acceptRoles(address fromAccount, uint8[] roles) external
Accepts roles transferred from another account.
Can only be called by the pending account with all the proposed roles. Emits RolesRemoved and RolesAdded events.
Name | Type | Description |
---|---|---|
fromAccount | address | The address of the current role |
roles | uint8[] | The roles to accept |