-
Notifications
You must be signed in to change notification settings - Fork 3
ModuleManager
- Table of Contents
-
ModuleManager
-
Functions
- onlyExecutorModule
- withHook
- fallback
- getValidatorsPaginated
- getExecutorsPaginated
- getActiveHook
- getFallbackHandlerBySelector
- _initModuleManager
- _installValidator
- _uninstallValidator
- _installExecutor
- _uninstallExecutor
- _installHook
- _uninstallHook
- _setHook
- _installFallbackHandler
- _uninstallFallbackHandler
- _isFallbackHandlerInstalled
- _isFallbackHandlerInstalled
- _isValidatorInstalled
- _isExecutorInstalled
- _isHookInstalled
- _getHook
- _paginate
-
Functions
Inherits: Storage, Receiver, IModuleManagerEventsAndErrors
Manages Validator, Executor, Hook, and Fallback modules within the Nexus suite, supporting
Implements SentinelList for managing modules via a linked list structure, adhering to ERC-7579.
Ensures the message sender is a registered executor module.
modifier onlyExecutorModule() virtual;
Does pre-checks and post-checks using an installed hook on the account.
sender, msg.data and msg.value is passed to the hook to implement custom flows.
modifier withHook();
Fallback function to manage incoming calls using designated handlers based on the call type.
fallback() external payable override(Receiver) receiverFallback;
Retrieves a paginated list of validator addresses from the linked list. This utility function is not defined by the ERC-7579 standard and is implemented to facilitate easier management and retrieval of large sets of validator modules.
function getValidatorsPaginated(address cursor, uint256 size) external view returns (address[] memory array, address next);
Parameters
Name | Type | Description |
---|---|---|
cursor |
address |
The address to start pagination from, or zero to start from the first entry. |
size |
uint256 |
The number of validator addresses to return. |
Returns
Name | Type | Description |
---|---|---|
array |
address[] |
An array of validator addresses. |
next |
address |
The address to use as a cursor for the next page of results. |
Retrieves a paginated list of executor addresses from the linked list. This utility function is not defined by the ERC-7579 standard and is implemented to facilitate easier management and retrieval of large sets of executor modules.
function getExecutorsPaginated(address cursor, uint256 size) external view returns (address[] memory array, address next);
Parameters
Name | Type | Description |
---|---|---|
cursor |
address |
The address to start pagination from, or zero to start from the first entry. |
size |
uint256 |
The number of executor addresses to return. |
Returns
Name | Type | Description |
---|---|---|
array |
address[] |
An array of executor addresses. |
next |
address |
The address to use as a cursor for the next page of results. |
Retrieves the currently active hook address.
function getActiveHook() external view returns (address hook);
Returns
Name | Type | Description |
---|---|---|
hook |
address |
The address of the active hook module. |
Fetches the fallback handler for a specific selector.
function getFallbackHandlerBySelector(bytes4 selector) external view returns (CallType, address);
Parameters
Name | Type | Description |
---|---|---|
selector |
bytes4 |
The function selector to query. |
Returns
Name | Type | Description |
---|---|---|
<none> |
CallType |
calltype The type of call that the handler manages. |
<none> |
address |
handler The address of the fallback handler. |
Initializes the module manager by setting up default states for validators and executors.
function _initModuleManager() internal virtual;
Installs a new validator module after checking if it matches the required module type.
function _installValidator(address validator, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
validator |
address |
The address of the validator module to be installed. |
data |
bytes |
Initialization data to configure the validator upon installation. |
Important
_installValidator: Ensure the validator module to be installed matches the required module type. Incorrect modules could lead to unexpected behavior or security vulnerabilities.
Uninstalls a validator module /!\ ensuring the account retains at least one validator.
function _uninstallValidator(address validator, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
validator |
address |
The address of the validator to be uninstalled. |
data |
bytes |
De-initialization data to configure the validator upon uninstallation. |
Caution
_uninstallValidator: Uninstalling the last validator could leave the account without necessary validation. Ensure the account retains at least one validator.
Installs a new executor module after checking if it matches the required module type.
function _installExecutor(address executor, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
executor |
address |
The address of the executor module to be installed. |
data |
bytes |
Initialization data to configure the executor upon installation. |
Uninstalls an executor module by removing it from the executors list.
function _uninstallExecutor(address executor, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
executor |
address |
The address of the executor to be uninstalled. |
data |
bytes |
De-initialization data to configure the executor upon uninstallation. |
Installs a hook module, ensuring no other hooks are installed before proceeding.
function _installHook(address hook, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
hook |
address |
The address of the hook to be installed. |
data |
bytes |
Initialization data to configure the hook upon installation. |
Uninstalls a hook module, ensuring the current hook matches the one intended for uninstallation.
function _uninstallHook(address hook, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
hook |
address |
The address of the hook to be uninstalled. |
data |
bytes |
De-initialization data to configure the hook upon uninstallation. |
Sets the current hook in the storage to the specified address.
function _setHook(address hook) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
hook |
address |
The new hook address. |
Installs a fallback handler for a given selector with initialization data.
function _installFallbackHandler(address handler, bytes calldata params) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
handler |
address |
The address of the fallback handler to install. |
params |
bytes |
The initialization parameters including the selector and call type. |
Uninstalls a fallback handler for a given selector.
function _uninstallFallbackHandler(address fallbackHandler, bytes calldata data) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
fallbackHandler |
address |
The address of the fallback handler to uninstall. |
data |
bytes |
The de-initialization data containing the selector. |
Checks if a fallback handler is set for a given selector.
function _isFallbackHandlerInstalled(bytes4 selector) internal view virtual returns (bool);
Parameters
Name | Type | Description |
---|---|---|
selector |
bytes4 |
The function selector to check. |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if a fallback handler is set, otherwise false. |
Checks if the expected fallback handler is installed for a given selector.
function _isFallbackHandlerInstalled(bytes4 selector, address expectedHandler) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
selector |
bytes4 |
The function selector to check. |
expectedHandler |
address |
The address of the handler expected to be installed. |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the installed handler matches the expected handler, otherwise false. |
Checks if a validator is currently installed.
function _isValidatorInstalled(address validator) internal view virtual returns (bool);
Parameters
Name | Type | Description |
---|---|---|
validator |
address |
The address of the validator to check. |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the validator is installed, otherwise false. |
Checks if an executor is currently installed.
function _isExecutorInstalled(address executor) internal view virtual returns (bool);
Parameters
Name | Type | Description |
---|---|---|
executor |
address |
The address of the executor to check. |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the executor is installed, otherwise false. |
Checks if a hook is currently installed.
function _isHookInstalled(address hook) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
hook |
address |
The address of the hook to check. |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the hook is installed, otherwise false. |
Retrieves the current hook from the storage.
function _getHook() internal view returns (address hook);
Returns
Name | Type | Description |
---|---|---|
hook |
address |
The address of the current hook. |
Helper function to paginate entries in a SentinelList.
function _paginate(
SentinelListLib.SentinelList storage list,
address cursor,
uint256 size
)
private
view
returns (address[] memory array, address nextCursor);
Parameters
Name | Type | Description |
---|---|---|
list |
SentinelListLib.SentinelList |
The SentinelList to paginate. |
cursor |
address |
The cursor to start paginating from. |
size |
uint256 |
The number of entries to return. |
Returns
Name | Type | Description |
---|---|---|
array |
address[] |
The array of addresses in the list. |
nextCursor |
address |
The cursor for the next page of entries. |
- Home
- Nexus Architecture
- Access Control
- Execution Framework
- Modules
- Factories
- Migration Guide
- Testing Documentation
- Configuration and Security
- Libraries
- FAQ
- Biconomy Solidity Style Guide
- Security Considerations
- Team
-
Contracts
- Nexus
- Base
- Common
- Factory
- AbstractNexusFactory
- BiconomyMetaFactory
- K1ValidatorFactory
- ModuleWhitelistFactory
- NexusAccountFactory
- Modules
- Utils