ERC7579Utils
Library with common ERC-7579 utility functions. See https://eips.ethereum.org/EIPS/eip-7579[ERC-7579].
State Variables
CALLTYPE_SINGLE
A single call execution.
CallType internal constant CALLTYPE_SINGLE = CallType.wrap(0x00);
CALLTYPE_BATCH
A batch of call executions.
CallType internal constant CALLTYPE_BATCH = CallType.wrap(0x01);
CALLTYPE_DELEGATECALL
A delegatecall execution.
CallType internal constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);
EXECTYPE_DEFAULT
Default execution type that reverts on failure.
ExecType internal constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);
EXECTYPE_TRY
Execution type that does not revert on failure.
ExecType internal constant EXECTYPE_TRY = ExecType.wrap(0x01);
Functions
execSingle
Executes a single call.
function execSingle(bytes calldata executionCalldata, ExecType execType) internal returns (bytes[] memory returnData);
execBatch
Executes a batch of calls.
function execBatch(bytes calldata executionCalldata, ExecType execType) internal returns (bytes[] memory returnData);
execDelegateCall
Executes a delegate call.
function execDelegateCall(bytes calldata executionCalldata, ExecType execType)
internal
returns (bytes[] memory returnData);
encodeMode
Encodes the mode with the provided parameters. See decodeMode.
function encodeMode(CallType callType, ExecType execType, ModeSelector selector, ModePayload payload)
internal
pure
returns (Mode mode);
decodeMode
Decodes the mode into its parameters. See encodeMode.
function decodeMode(Mode mode)
internal
pure
returns (CallType callType, ExecType execType, ModeSelector selector, ModePayload payload);
encodeSingle
Encodes a single call execution. See decodeSingle.
function encodeSingle(address target, uint256 value, bytes calldata callData)
internal
pure
returns (bytes memory executionCalldata);
decodeSingle
Decodes a single call execution. See encodeSingle.
function decodeSingle(bytes calldata executionCalldata)
internal
pure
returns (address target, uint256 value, bytes calldata callData);
encodeDelegate
Encodes a delegate call execution. See decodeDelegate.
function encodeDelegate(address target, bytes calldata callData)
internal
pure
returns (bytes memory executionCalldata);
decodeDelegate
Decodes a delegate call execution. See encodeDelegate.
function decodeDelegate(bytes calldata executionCalldata)
internal
pure
returns (address target, bytes calldata callData);
encodeBatch
Encodes a batch of executions. See decodeBatch.
function encodeBatch(Execution[] memory executionBatch) internal pure returns (bytes memory executionCalldata);
decodeBatch
Decodes a batch of executions. See encodeBatch. NOTE: This function runs some checks and will throw a {ERC7579DecodingError} if the input is not properly formatted.
function decodeBatch(bytes calldata executionCalldata) internal pure returns (Execution[] calldata executionBatch);
_call
Executes a call to the target with the provided {ExecType}.
function _call(uint256 index, ExecType execType, address target, uint256 value, bytes calldata data)
private
returns (bytes memory);
_delegatecall
Executes a delegatecall to the target with the provided {ExecType}.
function _delegatecall(uint256 index, ExecType execType, address target, bytes calldata data)
private
returns (bytes memory);
_validateExecutionMode
Validates the execution mode and returns the returndata.
function _validateExecutionMode(uint256 index, ExecType execType, bool success, bytes memory returndata)
private
returns (bytes memory);
Events
ERC7579TryExecuteFail
Emits when an {EXECTYPE_TRY} execution fails.
event ERC7579TryExecuteFail(uint256 batchExecutionIndex, bytes returndata);
Parameters
| Name | Type | Description |
|---|---|---|
batchExecutionIndex | uint256 | The index of the failed call in the execution batch. |
returndata | bytes | The returned data from the failed call. |
Errors
ERC7579UnsupportedCallType
The provided {CallType} is not supported.
error ERC7579UnsupportedCallType(CallType callType);
ERC7579UnsupportedExecType
The provided {ExecType} is not supported.
error ERC7579UnsupportedExecType(ExecType execType);
ERC7579MismatchedModuleTypeId
The provided module doesn't match the provided module type.
error ERC7579MismatchedModuleTypeId(uint256 moduleTypeId, address module);
ERC7579UninstalledModule
The module is not installed.
error ERC7579UninstalledModule(uint256 moduleTypeId, address module);
ERC7579AlreadyInstalledModule
The module is already installed.
error ERC7579AlreadyInstalledModule(uint256 moduleTypeId, address module);
ERC7579UnsupportedModuleType
The module type is not supported.
error ERC7579UnsupportedModuleType(uint256 moduleTypeId);
ERC7579DecodingError
Input calldata not properly formatted and possibly malicious.
error ERC7579DecodingError();