ERC4337ValidationLib
Title: ERC4337ValidationLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from eth-infinitism account-abstraction (https://github.com/eth-infinitism/account-abstraction)
Logic + ERC-7201 storage for the ERC-4337 validation facet. validateUserOp is gated to the
configured EntryPoint, validates the user op signature against the AccountSigner owner, and pays
the EntryPoint its prefund.
The user op signature is checked over the EIP-191 (personal_sign) digest of userOpHash
(SimpleAccount convention), routed through AccountSignerLib so the owner may be an EOA or an
ERC-1271 contract. Per ERC-4337, a signature mismatch returns SIG_VALIDATION_FAILED (1) rather than
reverting; only an unauthorized caller reverts. No validUntil/validAfter time-range in v1.
Functions
erc4337ValidationStorage
function erc4337ValidationStorage() internal pure returns (ERC4337ValidationStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | ERC4337ValidationStorage |
__ERC4337Validation_init
Seeds the trusted EntryPoint during diamond initialization.
function __ERC4337Validation_init(address entryPoint_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| entryPoint_ | address |
entryPoint
function entryPoint() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
setEntryPoint
Sets the trusted EntryPoint. Admin only.
function setEntryPoint(address entryPoint_) internal;Parameters
| Name | Type | Description |
|---|---|---|
| entryPoint_ | address |
validateUserOp
ERC-4337 account validation. Only the EntryPoint may call.
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
internal
returns (uint256 validationData);Parameters
| Name | Type | Description |
|---|---|---|
| userOp | PackedUserOperation | |
| userOpHash | bytes32 | |
| missingAccountFunds | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| validationData | uint256 |
_setEntryPoint
function _setEntryPoint(address entryPoint_) private;Parameters
| Name | Type | Description |
|---|---|---|
| entryPoint_ | address |
_payPrefund
Pays the EntryPoint (msg.sender) its prefund. Result is intentionally ignored: per ERC-4337
the EntryPoint validates its own balance change, and reverting here would block validation.
function _payPrefund(uint256 missingAccountFunds) private;Parameters
| Name | Type | Description |
|---|---|---|
| missingAccountFunds | uint256 |