-
Notifications
You must be signed in to change notification settings - Fork 15
ModuleManager
File: ModuleManager.sol
- This is a contract to manage modules that can execute transactions via this contract. Also used to manage own role-based access control mechanisms.
- The role-based access control mechanism is based on OpenZeppelin's AccessControl contract.
- Each module has it's own access control context which it is able to freely manage.
1. __ModuleManager_onlyAuthorized
Modifier to ensure that msg.sender
is authorized to mutate module manager's state.
2. onlyModule
Modifier to ensure that the msg.sender
is a valid module. The msg.sender
is in the _modules
list
3. validModule(address module)
Modifier to ensure that the address module
is a valid module. This is same as isModule_ check plus also checking if address module
is not the same as the address(ModuleManager).
4. isModule_(address module)
Modifier to ensure that the address module
is a valid module. The module
address is in the _modules
list.
5. isNotModule(address module)
Modifier to ensure that the address module
is not a valid module.
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)
-
address module
-> The module in which's access control context the role is checked. -
bytes32 role
-> The access control role. -
address account
-> The account to check role for.
Return Data
bool
-> Returns true if the account account
holds the role role
in the module's module
access control context else returns false
.
2. isModule
function isModule(address module) external returns (bool);
Returns whether the address module
is added as module.
Parameter(s)
-
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 valid modules.
4. modulesSize
function modulesSize() external view returns (unit);
Returns the number of modules.
Return Data
uint
-> the number of modules.
Parameter(s)
-
address module
-> The address of which the previous element in the list should be found.
Return Data
-
address previousModule
-> The address of the previous module.
1. addModule
function addModule(address module) external;
Adds address module
as module. This function is only callable by authorized address and fails if address is invalid or address already added as module.
Parameter(s)
-
address module
-> The module address to add.
2. removeModule
function removeModule(address module) external;
Removes address module
as module. This function is only callable by authorized address and fails if address not added as module.
Parameter(s)
-
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
either via call. This function is only callable by enabled modules.
Parameter(s)
-
address to
-> The address where we need to make a call. -
bytes data
-> The call data to be sent with the call.
Return Data
-
bool
-> Boolean indicating whether the call succeeded. -
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 module.
Parameter(s)
-
bytes32 role
-> The access control role. -
address account
-> The account to revoke role for.
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 module.
Parameter(s)
-
bytes32 role
-> The access control role. -
address account
-> The account to revoke role for.
6. renounceRole
function renounceRole(address module, bytes32 role) external;
Renounces the caller's role role
in module's module
access control context.
Parameter(s)
-
address module
-> The module in which's access control context the role should be renounced. -
bytes32 role
-> The access control role.