Skip to content

ModuleManager

Rahul Saxena edited this page Aug 8, 2023 · 9 revisions

File: ModuleManager.sol

Things to know

  1. This is a contract to manage modules that can execute transactions via this contract. Also used to manage own role-based access control mechanisms.
  2. The role-based access control mechanism is based on OpenZeppelin's AccessControl contract.
  3. Each module has it's own access control context which it is able to freely manage.

Modifier(s)

1. ModuleManager_onlyAuthorized

modifier __ModuleManager_onlyAuthorized

Modifier to ensure that _msgSender() is authorized to mutate the module manager's state.

2. onlyModule

modifier onlyModule()

Modifier to ensure that the _msgSender() is a valid module. The _msgSender() is in the _modules list

3. validModule

modifier validModule(address module)

Modifier to ensure that the address module is a valid module. This is the same as the isModule check plus also checking if address module is not the same as the address(ModuleManager).

4. isModule_

modifier isModule_(address module)

Modifier to ensure that the address module is a valid module. The module address is in the _modules list.

5. isNotModule

modifier isNotModule(address module)

Modifier to ensure that the address module is not a valid module.

6. moduleLimitNotExceeded

modifier moduleLimitNotExceeded()

Modifier to ensure that the maximum permissible limit of 128 modules inside of an orchestrator is not breached.

View Function(s)

1. hasRole

function hasRole(address module, bytes32 role, address account)
        external
        returns (bool);

Returns whether the account account holds the role role in the module's module access control context.

Parameter(s)

  1. address module: The module in whose access control context the role is to be checked.
  2. bytes32 role: The access control role.
  3. address account: The account to check the role for.

Return Data

bool: Returns true if the account account holds the role role in the module's module access control context otherwise, returns false.

2. isModule

function isModule(address module) external returns (bool);

Returns whether the address module is added as module in the orchestrator contract (that extends this ModuleManager contract)

Parameter(s)

  1. address module: The module to check.

Return Data

bool: True if address module was a valid module else false.

3. listModules

function listModules() external view returns (address[] memory);

Returns the list of all modules.

Return Data

address[]: the array of addresses containing all valid modules.

4. modulesSize

function modulesSize() external view returns (unit);

Returns the number of modules.

Return Data

uint8: the number of modules.

Write Function(s)

1. addModule

function addModule(address module) external;

Adds address module as a module in the orchestrator contract. This function is only callable by authorized address and fails if the address is invalid or the address is already added as module.

Parameter(s)

  1. address module: The module address to add.

2. removeModule

function removeModule(address module) external;

Removes address module as a module from the orchestrator. This function is only callable by authorized address and fails if the address was not added as a module.

Parameter(s)

  1. address module: The module address to remove.

3. executeTxFromModule

function executeTxFromModule(address to, bytes memory data)
        external
        returns (bool, bytes memory);

Executes a call to to with call data data via a low-level solidity call. This function is only callable by enabled modules.

Parameter(s)

  1. address to: The address where we need to make a call.
  2. bytes data: The call data to be sent with the call.

Return Data

  1. bool: Boolean indicating whether the call succeeded.
  2. bytes: The return data of the call (in bytes).

4. grantRole

function grantRole(bytes32 role, address account) external;

Grants role role to account account in caller's access control context. This function is only callable by enabled modules.

Parameter(s)

  1. bytes32 role: The access control role.
  2. address account: The account to grant the role.

5. revokeRole

function revokeRole(bytes32 role, address account) external;

Revokes role role from account account in caller's access control context. This function is only callable by enabled modules.

Parameter(s)

  1. bytes32 role: The access control role.
  2. address account: The account to revoke the role for.

6. renounceRole

function renounceRole(address module, bytes32 role) external;

Renounces the caller's role role in the module's module access control context.

Parameter(s)

  1. address module: The module in which's access control context the role should be renounced.
  2. bytes32 role: The access control role.