Skip to main content

Module Manager

This document explains the ModuleManager contract, a core component of the Axir Smart Account system. It facilitates the installation, management, and execution of various modules that extend the functionalities of a smart account.

Purpose

  • Manages the lifecycle of ERC-7579 compliant modules within a smart account.
  • Provides functionalities for installing, uninstalling, and interacting with validators, executors, and fallback modules.

Components

  • Validators: Modules responsible for validating user operations before execution.
  • Executors: Modules that carry out authorized actions on behalf of the smart account.
  • Fallback: A single module that serves as a default handler for unrecognized function calls.

Functionalities

Interface Overview

The IModuleManager interface defines the core functionalities required for managing modules within the smart account system. Below is a brief explanation of its key functions:

  • addModule(bytes calldata moduleAndData):

    • Adds a module to the list of installed modules and initializes it with the provided data. This function can only be called by the account itself or an already installed module.
  • removeModule(address module):

    • Removes a module from the list of installed modules and de-initializes it using its specific disable function. Only callable by the account or an installed module.
  • executeFromModule(address to, uint256 value, bytes memory data):

    • Allows installed modules to execute arbitrary calls on behalf of the account. This function enables modules to perform actions such as sending funds or interacting with other contracts.
  • isModule(address addr):

    • Checks if a specific address is currently installed as a module. Returns true if the address is recognized as a module, false otherwise.
  • listModules():

    • Retrieves the full list of currently installed modules. This function helps manage and track active modules within the smart account.

Module Installation

  • Allows the installation of validators, executors, and the fallback module with initialization data.
  • Initializes the installed module using the onInstall function.

Module Uninstallation

  • Enables the removal of installed modules with de-initialization data.
  • Calls the onUninstall function of the module being removed.

Module Management

  • Provides functions to check if a specific module is installed.
  • Retrieves a list of installed modules (paginated for larger sets).

Fallback Handling

  • Defines a fallback handler to manage unrecognized function calls to the smart account.

Key Points

  • The ModuleManager utilizes linked lists to efficiently track installed validators and executors.
  • Access control mechanisms ensure only authorized modules can be installed or removed.
  • The fallback handler offers a safety net for unexpected function calls.

Benefits

  • Extends the capabilities of smart accounts through modular functionalities.
  • Enhances flexibility and customization for users.
  • Promotes secure and controlled interaction with external services.

Further Considerations

  • Refer to the specific implementation of the ModuleManager contract for detailed function calls and usage instructions.
  • Carefully evaluate the trustworthiness of modules before installation.

Example Usage

  1. Install a Validator Module:
   address validatorModule = 0x...;
bytes memory initData = abi.encode(...); // Module specific initialization data
AxirWallet.installValidator(validatorModule, initData);
  1. Check if a validator is installed:
address validatorModule = 0x...;

bool isInstalled = AxirWallet.isValidatorInstalled(validatorModule);
  1. Uninstall a module (similar for executors and fallback):
address module = 0x...;
bytes memory data = abi.encode(...); // Module specific de-initialization data

AxirWallet.uninstallModule(module, data);

By understanding the ModuleManager contract, you can effectively manage the modules within your Axir Smart Account and leverage their functionalities to suit your needs.