Skip to content

ModuleWhitelistFactory

aboudjem edited this page Jun 7, 2024 · 1 revision

ModuleWhitelistFactory

Git Source

Inherits: AbstractNexusFactory

Factory for creating Nexus accounts with whitelisted modules. Ensures compliance with ERC-7579 and ERC-4337 standards.

State Variables

moduleWhitelist

Mapping to store the addresses of whitelisted modules.

mapping(address => bool) public moduleWhitelist;

Functions

constructor

Constructor to set the smart account implementation address and owner.

constructor(address implementation_, address owner_) AbstractNexusFactory(implementation_, owner_);

Parameters

Name Type Description
implementation_ address The address of the Nexus implementation to be used for all deployments.
owner_ address The address of the owner of the factory.

Important

constructor: The constructor sets critical state variables that define the behavior and ownership of the factory. Ensure that the addresses provided are accurate.


addModuleToWhitelist

Adds an address to the module whitelist.

function addModuleToWhitelist(address module) external onlyOwner;

Parameters

Name Type Description
module address The address to be whitelisted.

removeModuleFromWhitelist

Removes an address from the module whitelist.

function removeModuleFromWhitelist(address module) external onlyOwner;

Parameters

Name Type Description
module address The address to be removed from the whitelist.

createAccount

Creates a new Nexus account with the provided initialization data.

function createAccount(bytes calldata initData, bytes32 salt) external payable override returns (address payable);

Parameters

Name Type Description
initData bytes Initialization data to be called on the new Smart Account.
salt bytes32 Unique salt for the Smart Account creation.

Returns

Name Type Description
<none> address payable The address of the newly created Nexus.

Caution

createAccount: Ensure that the initData and salt are correctly specified to avoid deploying multiple accounts at the same address or creating unintended behavior.


computeAccountAddress

Computes the expected address of a Nexus contract using the factory's deterministic deployment algorithm.

function computeAccountAddress(bytes calldata, bytes32) external view override returns (address payable expectedAddress);

Parameters

Name Type Description
<none> bytes N/A (read from the calldata directly from the assembly code).
<none> bytes32 N/A (read from the calldata directly from the assembly code).

Returns

Name Type Description
expectedAddress address payable The expected address at which the Nexus contract will be deployed if the provided parameters are used.

Note

computeAccountAddress: The function reads from the calldata directly using assembly code, ensuring deterministic address computation.


isModuleWhitelisted

Checks if a module is whitelisted.

function isModuleWhitelisted(address module) public view returns (bool);

Parameters

Name Type Description
module address The address of the module to check.

Returns

Name Type Description
<none> bool True if the module is whitelisted, false otherwise.

Errors

ModuleNotWhitelisted

Error thrown when a non-whitelisted module is used.

error ModuleNotWhitelisted(address module);

Parameters

Name Type Description
module address The module address that is not whitelisted.

ZeroAddressNotAllowed

Error thrown when a zero address is provided.

error ZeroAddressNotAllowed();