OwnerManager
This section describes the OwnerManager
contract, a key element of the Axir Smart Account system responsible for managing ownership within the smart account. The contract implements the IOwnerManager
interface, defining the essential functionalities for adding, removing, resetting, and verifying owners.
Purpose:
- Manages the addition, removal, and verification of owners within a smart account.
- Supports two owner types:
- R1 Owners: Represented by 64-byte secp256r1 public keys.
- K1 Owners: Represented by standard Ethereum addresses (secp256k1).
Functionalities Explained:
-
Adding Owners:
r1AddOwner(bytes calldata pubKey)
: Adds a new R1 owner using a 64-byte public key. This function ensures that only authorized modules or the contract itself can add owners, and the public key must meet the specified length criteria.k1AddOwner(address addr)
: Adds a K1 owner by specifying their Ethereum address. The address cannot be zero, and access is restricted to authorized modules or the contract itself.
-
Removing Owners:
r1RemoveOwner(bytes calldata pubKey)
: Removes an R1 owner by their public key, ensuring that the last R1 owner cannot be removed to maintain account functionality.k1RemoveOwner(address addr)
: Removes a K1 owner by their address, ensuring that removal actions are controlled and can only be executed by authorized entities.
-
Resetting Owners:
resetOwners(bytes calldata pubKey)
: Clears all existing owners (both R1 and K1) and adds a single new R1 owner. This function enforces strict controls to ensure the integrity of the reset process, allowing only authorized invocations.
-
Owner Verification:
r1IsOwner(bytes calldata pubKey)
: Checks if a given public key corresponds to an existing R1 owner, returning a boolean value based on the verification outcome.k1IsOwner(address addr)
: Verifies whether a specified Ethereum address is a K1 owner, enabling access control checks within the smart account.
-
Listing Owners:
r1ListOwners()
: Returns an array of public keys representing all currently configured R1 owners, enabling the account to maintain an up-to-date record of R1 ownership.k1ListOwners()
: Provides a list of all K1 owner addresses associated with the smart account, supporting the dynamic management of owners.
Key Points:
- The
OwnerManager
implements theIOwnerManager
interface, ensuring standardized methods for handling owners. - Owner management functionalities require access control mechanisms (inherited from the Authority contract).
- The contract utilizes linked lists to efficiently manage R1 and K1 owners.
- Security measures are in place to prevent removing all R1 owners, ensuring the account remains operational.
Events:
R1AddOwner(bytes pubKey)
: Emitted when an R1 owner is successfully added.K1AddOwner(address indexed addr)
: Emitted upon the addition of a K1 owner.R1RemoveOwner(bytes pubKey)
: Triggered when an R1 owner is removed.K1RemoveOwner(address indexed addr)
: Fired when a K1 owner is removed.ResetOwners()
: Emitted whenever all owners are reset, signifying a major change in the ownership structure.
Benefits:
- Offers fine-tuned control over ownership, accommodating both traditional Ethereum addresses and alternative key types.
- Supports multi-signature setups and enhanced security configurations for smart accounts.
- Provides clear audit trails of ownership changes, fostering transparency and accountability.
Further Considerations:
- Refer to the specific implementation of the
OwnerManager
contract for detailed function calls and usage instructions. - Carefully manage owner privileges to ensure the security of your smart account.
Example Usage:
-
Add an R1 owner:
bytes memory pubKey = hex"0x..."; // Replace with the actual public key
AxirWallet.r1AddOwner(pubKey); -
Verify if an address is a K1 owner:
address ownerAddr = 0x...; // Replace with the address to check
bool isOwner = AxirWallet.k1IsOwner(ownerAddr); -
Reset owners to a single new R1 owner:
bytes memory newPubKey = hex"0x..."; // Replace with the new public key
AxirWallet.resetOwners(newPubKey);
By understanding the OwnerManager
contract and its implementation of the IOwnerManager
interface, you can effectively manage the ownership of your Axir Smart Account and establish a secure access control structure.