IPAccountImpl.sol

Git Source


The Story Protocol's implementation of the IPAccount.

State Variables

ACCESS_CONTROLLER

address public immutable ACCESS_CONTROLLER;

Functions

receive

receive() external payable override(Receiver, IIPAccount);

constructor

Creates a new IPAccountImpl contract instance

Initializes the IPAccountImpl with an AccessController address which is stored
in the implementation code's storage.
This means that each cloned IPAccount will inherently use the same AccessController
without the need for individual configuration.

constructor(address accessController, address ipAssetRegistry, address licenseRegistry, address moduleRegistry)
    IPAccountStorage(ipAssetRegistry, licenseRegistry, moduleRegistry);

Parameters

NameTypeDescription
accessControlleraddressThe address of the AccessController contract to be used for permission checks
ipAssetRegistryaddress
licenseRegistryaddress
moduleRegistryaddress

supportsInterface

Checks if the contract supports a specific interface

function supportsInterface(bytes4 interfaceId)
    public
    view
    override(ERC6551, IPAccountStorage, IERC165)
    returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier, as specified in ERC-165

Returns

NameTypeDescription
<none>boolbool is true if the contract supports the interface, false otherwise

token

Returns the identifier of the non-fungible token which owns the account

function token() public view override(ERC6551, IIPAccount) returns (uint256, address, uint256);

Returns

NameTypeDescription
<none>uint256chainId The EIP-155 ID of the chain the token exists on
<none>addresstokenContract The contract address of the token
<none>uint256tokenId The ID of the token

isValidSigner

Checks if the signer is valid for executing specific actions on behalf of the IP Account.

function isValidSigner(address signer, bytes calldata data)
    public
    view
    override(ERC6551, IIPAccount)
    returns (bytes4 result);

Parameters

NameTypeDescription
signeraddressThe signer to check
databytesThe data to be checked. The data should be encoded as abi.encode(address to, bytes calldata), where address to is the recipient and bytes calldata is the calldata passed to the recipient. If data.length == 0, it is also considered valid, implying that the signer is valid for all actions.

Returns

NameTypeDescription
resultbytes4The function selector if the signer is valid, 0 otherwise

owner

Returns the owner of the IP Account.

function owner() public view override(ERC6551, IIPAccount) returns (address);

Returns

NameTypeDescription
<none>addressThe address of the owner.

state

Returns the IPAccount's internal nonce for transaction ordering.

function state() public view override(ERC6551, IIPAccount) returns (bytes32 result);

isValidSigner

Checks if the signer is valid for the given data and recipient via the AccessController permission system.

function isValidSigner(address signer, address to, bytes calldata data) public view returns (bool);

Parameters

NameTypeDescription
signeraddressThe signer to check
toaddressThe recipient of the transaction
databytesThe calldata to check against

Returns

NameTypeDescription
<none>boolbool is true if the signer is valid, false otherwise

executeWithSig

Executes a transaction from the IP Account on behalf of the signer.

function executeWithSig(
    address to,
    uint256 value,
    bytes calldata data,
    address signer,
    uint256 deadline,
    bytes calldata signature
) external payable returns (bytes memory result);

Parameters

NameTypeDescription
toaddressThe recipient of the transaction.
valueuint256The amount of Ether to send.
databytesThe data to send along with the transaction.
signeraddressThe signer of the transaction.
deadlineuint256The deadline of the transaction signature.
signaturebytesThe signature of the transaction, EIP-712 encoded.

execute

Executes a transaction from the IP Account.

function execute(address to, uint256 value, bytes calldata data) external payable returns (bytes memory result);

Parameters

NameTypeDescription
toaddressThe recipient of the transaction.
valueuint256The amount of Ether to send.
databytesThe data to send along with the transaction.

Returns

NameTypeDescription
resultbytesThe return data from the transaction.

execute

Override 6551 execute function.
Only "CALL" operation is supported.

function execute(address to, uint256 value, bytes calldata data, uint8 operation)
    public
    payable
    override
    returns (bytes memory result);

Parameters

NameTypeDescription
toaddressThe recipient of the transaction.
valueuint256The amount of Ether to send.
databytesThe data to send along with the transaction.
operationuint8The operation type to perform, only 0 - CALL is supported.

Returns

NameTypeDescription
resultbytesThe return data from the transaction.

executeBatch

Executes a batch of transactions from the IP Account.

function executeBatch(Call[] calldata calls, uint8 operation)
    public
    payable
    override
    returns (bytes[] memory results);

Parameters

NameTypeDescription
callsCall[]The array of calls to execute.
operationuint8The operation type to perform, only 0 - CALL is supported.

Returns

NameTypeDescription
resultsbytes[]The return data from the transactions.

_execute

Executes a transaction from the IP Account.

function _execute(address signer, address to, uint256 value, bytes calldata data)
    internal
    returns (bytes memory result);

_updateStateForExecute

Updates the IP Account's state all execute transactions.

function _updateStateForExecute(address to, uint256 value, bytes calldata data) internal;

Parameters

NameTypeDescription
toaddressThe "target" of the execute transactions.
valueuint256The amount of Ether to send.
databytesThe data to send along with the transaction.

_isValidSigner

Override Solady 6551 _isValidSigner function.

function _isValidSigner(address signer, bytes32 extraData, bytes calldata context)
    internal
    view
    override
    returns (bool);

Parameters

NameTypeDescription
signeraddressThe signer to check
extraDatabytes32The extra data to check against, it should bethe address of the recipient for IPAccount
contextbytesThe context for validating the signer

Returns

NameTypeDescription
<none>boolbool is true if the signer is valid, false otherwise

_domainNameAndVersion

Override Solady EIP712 function and return EIP712 domain name for IPAccount.

function _domainNameAndVersion() internal view override returns (string memory name, string memory version);
function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) public pure returns (bytes4)

_execute

function _execute(address signer, address to, uint256 value, bytes data) internal returns (bytes result)