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

enum OperationType {
 AddGovernor,
 RemoveGovernor
}

Structs

GovernorRequest

struct GovernorRequest {
 uint256 confirmationCount,
 address[] confirmations
}

Contract Members

Constants & Variables

bytes32 public constant GOVERNOR_ROLE_NAME;

bytes32 public constant ADMIN_ROLE_NAME;

bytes32 public constant UTILITY_ACCOUNT_ROLE_NAME;

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.

mapping(address => struct RoleManager.GovernorRequest) public govRequests;

Variable set upon construction representing how many request are required to assing a new governor for the system.

uint256 private confirmationsRequired;

Maps role name to {Roles} library to access all base role related functionality.

mapping(bytes32 => struct Roles.Role) private roles;

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.

modifier onlyRole(bytes32 roleName) internal

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

function (address[] governors, uint256 _confirmationsRequired) public nonpayable

Arguments

appointAdmins

Adds an ADMIN_ROLE_NAME for the provided array of admins.

function appointAdmins(address[] admins) external nonpayable onlyRole 

Arguments

addRoleForAddress

Function to assign a role to an address

function addRoleForAddress(address addr, bytes32 roleName) external nonpayable onlyRole 

Arguments

addRolesForAddresses

Assigns multiple roles to addresses.

function addRolesForAddresses(address[] addresses, bytes32[] rolesArr) external nonpayable onlyRole 

Arguments

removeRoleForAddress

Removes a roleName for the provided addr.

function removeRoleForAddress(address addr, bytes32 roleName) external nonpayable onlyRole 

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.

function submitAddGovernorRequest(address govAddress) external nonpayable onlyRole 

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.

function submitRemoveGovernorRequest(address govAddress) external nonpayable onlyRole 

Arguments

revokeGovernorRequestConfirmation

Function to provide ability for current governors to revoke previously granted confirmation of adding or removing a new governor.

function revokeGovernorRequestConfirmation(address govAddress) external nonpayable onlyRole 

Arguments

checkRole

Checks the existence of a roleName value for the given addr. Function reverts if account does not have required role

function checkRole(address addr, bytes32 roleName) public view

Arguments

hasRole

See {Roles.has}.

function hasRole(address addr, bytes32 roleName) public view
returns(bool)

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}.

function addRole(address addr, bytes32 roleName) internal nonpayable

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}.

function removeRole(address addr, bytes32 roleName) internal nonpayable

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.

function submitGovernorRequest(address govAddress, enum RoleManager.OperationType operationType) internal nonpayable

Arguments

acceptGovernorRequest

Function that adds/removes a governor.This function is launched automatically when the number of requests required is reached.

function acceptGovernorRequest(address govAddress, enum RoleManager.OperationType operationType) internal nonpayable

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.

function addGovernorRole(address addr) internal nonpayable

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.

function removeGovernorRole(address addr) internal nonpayable

Arguments

isGovernorRequestConfirmed

Function to check if governor request for govAddress has enough confirmations to be executed

function isGovernorRequestConfirmed(address govAddress) internal view
returns(bool)

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

function isNotConfirmedBySender(address govAddress) internal view
returns(bool)

Returns

true if govAddress is not already confirmed by msg.sender

Arguments

Last updated