Skip to main content

Axir Storage Layout

The AxirStorage library provides a structured layout for storing various data associated with Axir Smart Account contracts. It utilizes a single storage slot to optimize gas usage and simplifies access to frequently used variables.

Layout:

The storage is divided into sections for different functionalities:

  • Ownership Data:
    • r1Owners: A mapping that stores R1 owners (represented by 64-byte secp256r1 public keys) and their associated data (implementation-specific).
    • k1Owners: A mapping that stores K1 owners (represented by standard Ethereum addresses) and their associated data (implementation-specific).
  • Fallback:
    • defaultFallbackContract: Address of the default fallback module for handling unrecognized function calls.
  • Validation:
    • validators: A mapping that stores validator module addresses and their associated data (implementation-specific).
  • Module:
    • executors: A mapping that stores executor module addresses and their associated data (implementation-specific).
  • Hooks (Not currently implemented):
    • Placeholder for future functionalities related to hooks.

Key Points:

  • Each section utilizes mappings for efficient storage and retrieval of data based on keys (public keys, addresses).
  • Gap variables (__gap_[number]) are added between sections to optimize storage layout and avoid potential conflicts during future upgrades.
  • The layout() function provides a convenient way to access the storage structure within a contract.

Benefits:

  • Organized storage for various Axir smart account functionalities.
  • Efficient gas usage by utilizing a single storage slot.
  • Clear separation of concerns for better code readability and maintainability.

Further Considerations:

  • Refer to the specific implementation of each Axir smart account contract to understand how they interact with the AxirStorage library.
  • The hooks section is currently reserved for future development and might not be used in all Axir contracts.

Example Usage (refer to specific contract documentation for actual usage):

// Get the address of the default fallback module
address fallbackHandler = AxirStorage.layout().defaultFallbackContract;

// Check if a specific address is a registered validator
address validatorAddress = 0x...;
bool isValidator = AxirStorage.layout().validators.exists(validatorAddress);

By understanding the AxirStorage layout, you can gain insights into how data is organized within Axir smart account contracts and how they interact with various functionalities.