IAxir7579Account
IAxir7579Account
Interface
The IAxir7579Account
interface defines the standard functions and events that must be implemented by modules developed for the Axir7579 wallet. This interface ensures that all modules interact seamlessly with the wallet's core functionality.
Code Snippet
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
import {CallType, ExecType, ModeCode} from "../utils/lib/ModeLib.sol";
struct Execution {
address target;
uint256 value;
bytes callData;
}
interface IAxir7579Account {
event ModuleInstalled(uint256 moduleTypeId, address module);
event ModuleUninstalled(uint256 moduleTypeId, address module);
error UnsupportedModuleType(uint256 moduleTypeId);
// Error thrown when an execution with an unsupported CallType was made
error UnsupportedCallType(CallType callType);
// Error thrown when an execution with an unsupported ExecType was made
error UnsupportedExecType(ExecType execType);
// Error thrown when account initialization fails
error AccountInitializationFailed();
error MismatchModuleTypeId(uint256 moduleTypeId);
function initialize(
address initialK1Owner,
address[] calldata modules,
uint256[] calldata moduleTypeIds,
bytes[] calldata initData
) external;
/**
* @dev Executes a transaction on behalf of the account.
* This function is intended to be called by ERC-4337 EntryPoint.sol
* @dev Ensure adequate authorization control: i.e. onlyEntryPointOrSelf
*
* @dev MSA MUST implement this function signature.
* If a mode is requested that is not supported by the Account, it MUST revert
* @param mode The encoded execution mode of the transaction. See ModeLib.sol for details
* @param executionCalldata The encoded execution call data
*/
function execute(
ModeCode mode,
bytes calldata executionCalldata
) external payable;
/**
* @dev Executes a transaction on behalf of the account.
* This function is intended to be called by Executor Modules
* @dev Ensure adequate authorization control: i.e. onlyExecutorModule
*
* @dev MSA MUST implement this function signature.
* If a mode is requested that is not supported by the Account, it MUST revert
* @param mode The encoded execution mode of the transaction. See ModeLib.sol for details
* @param executionCalldata The encoded execution call data
*/
function executeFromExecutor(
ModeCode mode,
bytes calldata executionCalldata
) external payable returns (bytes[] memory returnData);
/**
* @dev ERC-1271 isValidSignature
* This function is intended to be used to validate a smart account signature
* and may forward the call to a validator module
*
* @param hash The hash of the data that is signed
* @param data The data that is signed
*/
function isValidSignature(
bytes32 hash,
bytes calldata data
) external view returns (bytes4);
/**
* @dev installs a Module of a certain type on the smart account
* @dev Implement Authorization control of your chosing
* @param moduleTypeId the module type ID according the ERC-7579 spec
* @param module the module address
* @param initData arbitrary data that may be required on the module during `onInstall`
* initialization.
*/
function installModule(
uint256 moduleTypeId,
address module,
bytes calldata initData
) external payable;
/**
* @dev uninstalls a Module of a certain type on the smart account
* @dev Implement Authorization control of your chosing
* @param moduleTypeId the module type ID according the ERC-7579 spec
* @param module the module address
* @param deInitData arbitrary data that may be required on the module during `onUninstall`
* de-initialization.
*/
function uninstallModule(
uint256 moduleTypeId,
address module,
bytes calldata deInitData
) external payable;
/**
* Function to check if the account supports a certain CallType or ExecType (see ModeLib.sol)
* @param encodedMode the encoded mode
*/
function supportsExecutionMode(
ModeCode encodedMode
) external view returns (bool);
/**
* Function to check if the account supports installation of a certain module type Id
* @param moduleTypeId the module type ID according the ERC-7579 spec
*/
function supportsModule(uint256 moduleTypeId) external view returns (bool);
/**
* Function to check if the account has a certain module installed
* @param moduleTypeId the module type ID according the ERC-7579 spec
* Note: keep in mind that some contracts can be multiple module types at the same time. It
* thus may be necessary to query multiple module types
* @param module the module address
* @param additionalContext additional context data that the smart account may interpret to
* identifiy conditions under which the module is installed.
* usually this is not necessary, but for some special hooks that
* are stored in mappings, this param might be needed
*/
function isModuleInstalled(
uint256 moduleTypeId,
address module,
bytes calldata additionalContext
) external view returns (bool);
/**
* @dev Returns the account id of the smart account
* @return accountImplementationId the account id of the smart account
* the accountId should be structured like so:
* "vendorname.accountname.semver"
*/
function accountId()
external
view
returns (string memory accountImplementationId);
}
Events
ModuleInstalled
event ModuleInstalled(uint256 moduleTypeId, address module);
This event is emitted when a module is successfully installed.
moduleTypeId
: The type ID of the installed module.module
: The address of the installed module.
ModuleUninstalled
event ModuleUninstalled(uint256 moduleTypeId, address module);
This event is emitted when a module is successfully uninstalled.
moduleTypeId
: The type ID of the uninstalled module.module
: The address of the uninstalled module.
Errors
UnsupportedModuleType
error UnsupportedModuleType(uint256 moduleTypeId);
This error is thrown when an unsupported module type is provided.
UnsupportedCallType
error UnsupportedCallType(CallType callType);
This error is thrown when an unsupported CallType
is used during execution.
UnsupportedExecType
error UnsupportedExecType(ExecType execType);
This error is thrown when an unsupported ExecType
is used during execution.
AccountInitializationFailed
error AccountInitializationFailed();
This error is thrown when the account initialization fails.
MismatchModuleTypeId
error MismatchModuleTypeId(uint256 moduleTypeId);
This error is thrown when there is a mismatch in the module type ID.
Functions
initialize
function initialize(
address initialK1Owner,
address[] calldata modules,
uint256[] calldata moduleTypeIds,
bytes[] calldata initData
) external;
Initializes the account with the specified modules and owner.
initialK1Owner
: The initial owner of the account.modules
: An array of module addresses to be installed.moduleTypeIds
: An array of module type IDs corresponding to the modules.initData
: An array of initialization data for each module.
execute
function execute(
ModeCode mode,
bytes calldata executionCalldata
) external payable;
Executes a transaction on behalf of the account, typically called by the ERC-4337 EntryPoint.sol
.
mode
: The encoded execution mode of the transaction.executionCalldata
: The encoded execution call data.
executeFromExecutor
function executeFromExecutor(
ModeCode mode,
bytes calldata executionCalldata
) external payable returns (bytes[] memory returnData);
Executes a transaction on behalf of the account, called by Executor Modules.
mode
: The encoded execution mode of the transaction.executionCalldata
: The encoded execution call data.- Returns: An array of bytes representing the return data from the execution.
isValidSignature
function isValidSignature(
bytes32 hash,
bytes calldata data
) external view returns (bytes4);
Validates a smart account signature, which may involve forwarding the call to a validator module.
hash
: The hash of the data that is signed.data
: The data that is signed.- Returns: A bytes4 value indicating whether the signature is valid.
installModule
function installModule(
uint256 moduleTypeId,
address module,
bytes calldata initData
) external payable;
Installs a module of a certain type on the smart account.
moduleTypeId
: The type ID of the module according to the ERC-7579 spec.module
: The address of the module.initData
: Arbitrary data required during the module'sonInstall
initialization.
uninstallModule
function uninstallModule(
uint256 moduleTypeId,
address module,
bytes calldata deInitData
) external payable;
Uninstalls a module of a certain type on the smart account.
moduleTypeId
: The type ID of the module according to the ERC-7579 spec.module
: The address of the module.deInitData
: Arbitrary data required during the module'sonUninstall
de-initialization.
supportsExecutionMode
function supportsExecutionMode(
ModeCode encodedMode
) external view returns (bool);
Checks if the account supports a certain CallType
or ExecType
.
encodedMode
: The encoded mode to be checked.- Returns: A boolean value indicating whether the mode is supported.
supportsModule
function supportsModule(uint256 moduleTypeId) external view returns (bool);
Checks if the account supports installation of a certain module type ID.
moduleTypeId
: The type ID of the module according to the ERC-7579 spec.- Returns: A boolean value indicating whether the module type is supported.
isModuleInstalled
function isModuleInstalled(
uint256 moduleTypeId,
address module,
bytes calldata additionalContext
) external view returns (bool);
Checks if a module of a certain type is installed on the account.
moduleTypeId
: The type ID of the module according to the ERC-7579 spec.module
: The address of the module.additionalContext
: Additional context data that may be needed to identify conditions under which the module is installed.- Returns: A boolean value indicating whether the module is installed.
accountId
function accountId()
external
view
returns (string memory accountImplementationId);
Returns the account ID of the smart account.
- Returns: A string representing the account implementation ID.