Skip to content

Commit

Permalink
Add ERC-7579 account extension (#46)
Browse files Browse the repository at this point in the history
Co-authored-by: ernestognw <[email protected]>
  • Loading branch information
Amxx and ernestognw authored Jan 15, 2025
1 parent aa642cc commit 94f31d9
Show file tree
Hide file tree
Showing 28 changed files with 1,607 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
run: npm run test
- name: Check linearisation of the inheritance graph
run: npm run test:inheritance
- name: Check pragma consistency between files
run: npm run test:pragma

coverage:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## XX-XX-XXXX

- `AccountCore`: Add an internal `_validateUserOp` function to validate user operations.
- `AccountERC7579`: Extension of `AccountCore` that implements support for ERC-7579 modules of type executor, validator, and fallback handler.
- `AccountERC7579Hooked`: Extension of `AccountERC7579` that implements support for ERC-7579 hook modules.

## 13-01-2025

- Rename `ERC7739Signer` into `ERC7739` to avoid confusion with the `AbstractSigner` family of contracts.
Expand Down
21 changes: 18 additions & 3 deletions contracts/account/AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,28 @@ abstract contract AccountCore is AbstractSigner, IAccount {
bytes32 userOpHash,
uint256 missingAccountFunds
) public virtual onlyEntryPoint returns (uint256) {
uint256 validationData = _rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), userOp.signature)
? ERC4337Utils.SIG_VALIDATION_SUCCESS
: ERC4337Utils.SIG_VALIDATION_FAILED;
uint256 validationData = _validateUserOp(userOp, userOpHash);
_payPrefund(missingAccountFunds);
return validationData;
}

/**
* @dev Returns the validationData for a given user operation. By default, this checks the signature of the
* signable hash (produced by {_signableUserOpHash}) using the abstract signer ({_rawSignatureValidation}).
*
* NOTE: The userOpHash is assumed to be correct. Calling this function with a userOpHash that does not match the
* userOp will result in undefined behavior.
*/
function _validateUserOp(
PackedUserOperation calldata userOp,
bytes32 userOpHash
) internal virtual returns (uint256) {
return
_rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), userOp.signature)
? ERC4337Utils.SIG_VALIDATION_SUCCESS
: ERC4337Utils.SIG_VALIDATION_FAILED;
}

/**
* @dev Virtual function that returns the signable hash for a user operations. Some implementation may return
* `userOpHash` while other may prefer a signer-friendly value such as an EIP-712 hash describing the `userOp`
Expand Down
6 changes: 5 additions & 1 deletion contracts/account/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This directory includes contracts to build accounts for ERC-4337. These include:
* {AccountCore}: An ERC-4337 smart account implementation that includes the core logic to process user operations.
* {Account}: An extension of `AccountCore` that implements the recommended features for ERC-4337 smart accounts.
* {AccountSignerERC7702}: An account implementation with low-level signature validation performed by an EOA.
* {ERC7821}: Minimal batch executor implementation contracts. Useful to enable easy batch execution for smart contracts.
* {ERC7821}: Minimal batch executor implementation contracts. Useful to enable easy batch execution for smart contracts.

== Core

Expand All @@ -19,4 +19,8 @@ This directory includes contracts to build accounts for ERC-4337. These include:

{{SignerERC7702}}

{{AccountERC7759}}

{{AccountERC7759Hooked}}

{{ERC7821}}
Loading

0 comments on commit 94f31d9

Please sign in to comment.