Skip to content

Commit 94f31d9

Browse files
Amxxernestognw
andauthored
Add ERC-7579 account extension (#46)
Co-authored-by: ernestognw <[email protected]>
1 parent aa642cc commit 94f31d9

28 files changed

+1607
-40
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
run: npm run test
4444
- name: Check linearisation of the inheritance graph
4545
run: npm run test:inheritance
46+
- name: Check pragma consistency between files
47+
run: npm run test:pragma
4648

4749
coverage:
4850
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## XX-XX-XXXX
2+
3+
- `AccountCore`: Add an internal `_validateUserOp` function to validate user operations.
4+
- `AccountERC7579`: Extension of `AccountCore` that implements support for ERC-7579 modules of type executor, validator, and fallback handler.
5+
- `AccountERC7579Hooked`: Extension of `AccountERC7579` that implements support for ERC-7579 hook modules.
6+
17
## 13-01-2025
28

39
- Rename `ERC7739Signer` into `ERC7739` to avoid confusion with the `AbstractSigner` family of contracts.

contracts/account/AccountCore.sol

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,28 @@ abstract contract AccountCore is AbstractSigner, IAccount {
7272
bytes32 userOpHash,
7373
uint256 missingAccountFunds
7474
) public virtual onlyEntryPoint returns (uint256) {
75-
uint256 validationData = _rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), userOp.signature)
76-
? ERC4337Utils.SIG_VALIDATION_SUCCESS
77-
: ERC4337Utils.SIG_VALIDATION_FAILED;
75+
uint256 validationData = _validateUserOp(userOp, userOpHash);
7876
_payPrefund(missingAccountFunds);
7977
return validationData;
8078
}
8179

80+
/**
81+
* @dev Returns the validationData for a given user operation. By default, this checks the signature of the
82+
* signable hash (produced by {_signableUserOpHash}) using the abstract signer ({_rawSignatureValidation}).
83+
*
84+
* NOTE: The userOpHash is assumed to be correct. Calling this function with a userOpHash that does not match the
85+
* userOp will result in undefined behavior.
86+
*/
87+
function _validateUserOp(
88+
PackedUserOperation calldata userOp,
89+
bytes32 userOpHash
90+
) internal virtual returns (uint256) {
91+
return
92+
_rawSignatureValidation(_signableUserOpHash(userOp, userOpHash), userOp.signature)
93+
? ERC4337Utils.SIG_VALIDATION_SUCCESS
94+
: ERC4337Utils.SIG_VALIDATION_FAILED;
95+
}
96+
8297
/**
8398
* @dev Virtual function that returns the signable hash for a user operations. Some implementation may return
8499
* `userOpHash` while other may prefer a signer-friendly value such as an EIP-712 hash describing the `userOp`

contracts/account/README.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory includes contracts to build accounts for ERC-4337. These include:
77
* {AccountCore}: An ERC-4337 smart account implementation that includes the core logic to process user operations.
88
* {Account}: An extension of `AccountCore` that implements the recommended features for ERC-4337 smart accounts.
99
* {AccountSignerERC7702}: An account implementation with low-level signature validation performed by an EOA.
10-
* {ERC7821}: Minimal batch executor implementation contracts. Useful to enable easy batch execution for smart contracts.
10+
* {ERC7821}: Minimal batch executor implementation contracts. Useful to enable easy batch execution for smart contracts.
1111

1212
== Core
1313

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

2020
{{SignerERC7702}}
2121

22+
{{AccountERC7759}}
23+
24+
{{AccountERC7759Hooked}}
25+
2226
{{ERC7821}}

0 commit comments

Comments
 (0)