Skip to content
Lattice

ERC7821ExecutorLib

Git Source

Title: ERC7821ExecutorLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Solady (https://github.com/Vectorized/solady)

Logic for the ERC-7821 minimal batch executor facet. Stateless: authorization is derived from the caller (self / configured EntryPoint / DEFAULT_ADMIN_ROLE) and the calls run from the account.

Authorization is either direct (caller is self / EntryPoint / DEFAULT_ADMIN_ROLE) or, for the opData mode, an EIP-712 Execute envelope abi.encode(nonce, signature) signed by the owner (full authority) or by a registered, in-policy session key (see SessionKeyLib) — letting a relayer submit a batch authorized off-chain, replay-protected via the shared NoncesLib. A failing inner call bubbles its revert data.

Functions

__ERC7821Executor_init

Registers the IERC7821 ERC-165 id.

function __ERC7821Executor_init() internal;

registerInterface

Writes true to the ERC-165 map slot for IERC7821.

function registerInterface() internal;

supportsExecutionMode

Whether mode is a supported batch execution mode (with or without opData).

function supportsExecutionMode(bytes32 mode) internal pure returns (bool);

Parameters

NameTypeDescription
modebytes32

Returns

NameTypeDescription
<none>bool

execute

Executes a batch of calls per mode. Reverts UnsupportedExecutionMode on an unknown mode and UnauthorizedExecutor if the caller is not self / the EntryPoint / an admin.

function execute(bytes32 mode, bytes calldata executionData) internal;

Parameters

NameTypeDescription
modebytes32
executionDatabytes

decodeBatch

Validates mode and decodes the call batch (and any trailing opData). Shared by execute and the ERC-7579 executeFromExecutor path.

function decodeBatch(bytes32 mode, bytes calldata executionData)
        internal
        pure
        returns (Call[] memory calls, bytes memory opData);

Parameters

NameTypeDescription
modebytes32
executionDatabytes

Returns

NameTypeDescription
callsCall[]
opDatabytes

runCalls

Runs a decoded batch from the account, bubbling any inner revert and collecting return data.

function runCalls(Call[] memory calls) internal returns (bytes[] memory results);

Parameters

NameTypeDescription
callsCall[]

Returns

NameTypeDescription
resultsbytes[]

_isDirectlyAuthorized

True if the caller is the account itself, the configured EntryPoint, or an admin.

function _isDirectlyAuthorized() private view returns (bool);

Returns

NameTypeDescription
<none>bool

_verifySignedOpData

Verifies a nonce-protected EIP-712 Execute authorization for this batch, then consumes the account nonce. The owner signature grants full authority; otherwise the recovered ECDSA signer must be a registered session key whose policy permits every call (see SessionKeyLib). Reverts UnauthorizedExecutor on a bad signature, the session-key errors on a policy/validity failure, and InvalidAccountNonce on replay / wrong nonce.

function _verifySignedOpData(bytes32 mode, Call[] memory calls, bytes memory opData)
        private
        returns (address sessionKey);

Parameters

NameTypeDescription
modebytes32
callsCall[]
opDatabytes

Returns

NameTypeDescription
sessionKeyaddressThe authorizing session key, or address(0) when the owner signed (full authority,
no spend limit). Callers settle spend for a non-zero session key.