AtomWallet

Git Source

Inherits: Initializable, BaseAccount, Ownable2StepUpgradeable, ReentrancyGuardUpgradeable

Author: 0xIntuition

Core contract of the Intuition protocol. This contract is an abstract account associated with a corresponding atom.

State Variables

ethMultiVault

The EthMultiVault contract address

IEthMultiVault public ethMultiVault;

isClaimed

The flag to indicate if the wallet's ownership has been claimed by the user

bool public isClaimed;

AtomWalletOwnerStorageLocation

The storage slot for the AtomWallet owner

bytes32 private constant AtomWalletOwnerStorageLocation =
    0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

AtomWalletPendingOwnerStorageLocation

The storage slot for the AtomWallet pending owner

bytes32 private constant AtomWalletPendingOwnerStorageLocation =
    0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;

_entryPoint

The entry point contract address

IEntryPoint private _entryPoint;

__gap

Gap for upgrade safety

uint256[50] private __gap;

Functions

onlyOwnerOrEntryPoint

Modifier to allow only the owner or entry point to call a function

modifier onlyOwnerOrEntryPoint();

init

Initialize the AtomWallet contract

function init(IEntryPoint anEntryPoint, IEthMultiVault _ethMultiVault) external initializer;

Parameters

NameTypeDescription
anEntryPointIEntryPointthe entry point contract address
_ethMultiVaultIEthMultiVaultthe EthMultiVault contract address

receive

receive() external payable;

execute

function execute(address dest, uint256 value, bytes calldata func)
    external
    payable
    onlyOwnerOrEntryPoint
    nonReentrant;

Parameters

NameTypeDescription
destaddressthe target address
valueuint256the value to send
funcbytesthe function call data

executeBatch

Execute a sequence (batch) of transactions

function executeBatch(address[] calldata dest, uint256[] calldata values, bytes[] calldata func)
    external
    payable
    onlyOwnerOrEntryPoint
    nonReentrant;

Parameters

NameTypeDescription
destaddress[]the target addresses array
valuesuint256[]
funcbytes[]the function call data array

addDeposit

Add deposit to the account in the entry point contract

function addDeposit() public payable;

withdrawDepositTo

Withdraws value from the account's deposit

function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public;

Parameters

NameTypeDescription
withdrawAddressaddress payabletarget to send to
amountuint256to withdraw

transferOwnership

Initiates the ownership transfer over the wallet to a new owner.

function transferOwnership(address newOwner) public override onlyOwner;

Parameters

NameTypeDescription
newOwneraddressthe new owner of the wallet (becomes the pending owner) NOTE: Overrides the transferOwnership function of Ownable2StepUpgradeable

acceptOwnership

The new owner accepts the ownership over the wallet. If the wallet's ownership is being accepted by the user, the wallet is considered claimed. Once claimed, wallet is considered owned by the user and this action cannot be undone. NOTE: Overrides the acceptOwnership function of Ownable2StepUpgradeable

function acceptOwnership() public override;

getDeposit

Returns the deposit of the account in the entry point contract

function getDeposit() public view returns (uint256);

entryPoint

Get the entry point contract address

function entryPoint() public view virtual override returns (IEntryPoint);

Returns

NameTypeDescription
<none>IEntryPointthe entry point contract address NOTE: Overrides the entryPoint function of BaseAccount

owner

Returns the owner of the wallet. If the wallet has been claimed, the owner is the user. Otherwise, the owner is the atomWarden.

function owner() public view override returns (address);

Returns

NameTypeDescription
<none>addressthe owner of the wallet NOTE: Overrides the owner function of OwnableUpgradeable

_validateSignature

Validate the signature of the user operation

function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
    internal
    virtual
    override
    returns (uint256 validationData);

Parameters

NameTypeDescription
userOpUserOperationthe user operation
userOpHashbytes32the hash of the user operation

Returns

NameTypeDescription
validationDatauint256the validation data (0 if successful) NOTE: Implements the template method of BaseAccount

_call

An internal method that calls a target address with value and data

function _call(address target, uint256 value, bytes memory data) internal;

Parameters

NameTypeDescription
targetaddressthe target address
valueuint256the value to send
databytesthe function call data

extractValidUntilAndValidAfter

Extract the validUntil and validAfter from the call data

function extractValidUntilAndValidAfter(bytes calldata callData)
    internal
    pure
    returns (uint256 validUntil, uint256 validAfter, bytes memory actualCallData);

Parameters

NameTypeDescription
callDatabytesthe call data

Returns

NameTypeDescription
validUntiluint256the valid until timestamp
validAfteruint256the valid after timestamp
actualCallDatabytesthe actual call data of the user operation

_getAtomWalletOwnerStorage

Get the storage slot for the AtomWallet contract owner

function _getAtomWalletOwnerStorage() private pure returns (OwnableStorage storage $);

Returns

NameTypeDescription
$OwnableStoragethe storage slot

_getAtomWalletPendingOwnerStorage

Get the storage slot for the AtomWallet contract pending owner

function _getAtomWalletPendingOwnerStorage() private pure returns (Ownable2StepStorage storage $);

Returns

NameTypeDescription
$Ownable2StepStoragethe storage slot