-
Notifications
You must be signed in to change notification settings - Fork 34
Add ERC-4337 and ERC-7702 account implementations #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
a7b170a
WIP: Migrate Account code
ernestognw 1859385
Merge branch 'master' into aa/accounts
ernestognw 7847e80
Merge branch 'master' into aa/accounts
ernestognw 25de3ac
Checkpoint
ernestognw 292dae1
Fix lint
ernestognw f8657e7
Checkpoint
ernestognw 8699232
up
ernestognw 7bdf69e
up
ernestognw efd52cd
Adjust
ernestognw 87fcd0e
up
ernestognw 549ab8e
Simplify CallReceiverMock
ernestognw 90c7f5e
Fix slither + Codespell
ernestognw 2e345c3
Fix coverage
ernestognw af200e4
Merge branch 'master' into aa/accounts
ernestognw 4d03f45
Remove entrypoint
ernestognw 9caded9
Readd entrypoint
ernestognw f6b4454
Run --ir-minimum in forge coverage
ernestognw 2d2300f
up
ernestognw d6ba190
Make Accounts initializable
ernestognw 208386f
Finish docs
ernestognw 49fc47d
Merge branch 'master' into aa/accounts
ernestognw d715e4c
rewrite helpers/signers as alternative to ethers.SigningKey and
Amxx 8ad95a1
Rename _validateNestedEIP712Signature -> _validateSignature
ernestognw 885efdd
Read virtual to ERC7739Signer functions
ernestognw d5f0dac
lint
ernestognw 130ce04
Implement review recommendations
ernestognw dcdae8d
Include signer into account factory hash
ernestognw 03d935d
Update Account inheritance order
ernestognw 5456f26
up
ernestognw 9412b65
Merge branch 'master' into aa/accounts
ernestognw 524bf15
Remove ERC1155HolderLean
ernestognw 4718b87
Abstract AccountSignerDomain
ernestognw c8ad19d
up
ernestognw ed66cca
Merge branch 'master' into aa/accounts
ernestognw c41956c
Remove signed hash fn
ernestognw 7e51cd2
Add standalone example of usage
ernestognw 459d594
Merge branch 'master' into aa/accounts
ernestognw f497fd1
Remove docs
ernestognw 6409cb3
ERC4337 userOp validation should not be 7739 wrapped
Amxx 97b33df
documentation
Amxx ddd17e9
Rename `_validateSignature` to `_rawSignatureValidation` and remove _…
ernestognw e8ef6d1
errata
ernestognw d706876
Default _signableUserOpHash to a typed userop signature
ernestognw 188e71d
Remove docs mocks
ernestognw 6ace1a7
Remove ERC7739 from AccountBase
ernestognw 9793e49
Make ERC7739Signer validations private
ernestognw 9e34432
Move EIP712 userop signing to Accountbase
ernestognw ae6a665
Split AccountCore / Account
Amxx 07ca067
remove intermediary variable
Amxx 6aa5597
doc
Amxx 0513f3a
spelling
Amxx e3ce6b5
abstract signer
Amxx 69cc3da
docs
Amxx d0bd34f
ERC7702 signer
Amxx 3b1c1f4
fix
Amxx 190b5a5
doc example for ERC7739 use signers
Amxx a6ab43b
Complete minimal documentation
ernestognw 5c210cf
Update CHANGELOG.md
ernestognw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Finish docs
- Loading branch information
commit 208386fe59a0405838af3c6a4a62f9d8fd6f4f56
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // contracts/MyAccountCustom.sol | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; | ||
| import {ERC4337Utils, PackedUserOperation} from "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol"; | ||
| import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
| import {AccountBase} from "../../../account/draft-AccountBase.sol"; | ||
| import {ERC7739Signer} from "../../../utils/cryptography/draft-ERC7739Signer.sol"; | ||
|
|
||
| contract MyAccountCustom is ERC7739Signer, AccountBase, Initializable { | ||
| /** | ||
| * NOTE: EIP-712 domain is set at construction because each account clone | ||
| * will recalculate its domain separator based on their own address. | ||
| */ | ||
| constructor() EIP712("MyAccountCustom", "1") { | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| /// @dev Set up the account (e.g. load public keys to storage). | ||
| function initialize() public virtual initializer { | ||
| // Custom initialization logic | ||
| } | ||
|
|
||
| /// @dev Receives an `userOpSignedHash` to validate. See {_userOpSignedHash}. | ||
| function _validateUserOp( | ||
| PackedUserOperation calldata userOp, | ||
| bytes32 userOpSignedHash | ||
| ) internal view virtual override returns (uint256) { | ||
| return | ||
| _isValidSignature(userOpSignedHash, userOp.signature) | ||
| ? ERC4337Utils.SIG_VALIDATION_SUCCESS | ||
| : ERC4337Utils.SIG_VALIDATION_FAILED; | ||
| } | ||
|
|
||
| /// @dev Receives a hash wrapped in an EIP-712 domain separator. | ||
| function _validateNestedEIP712Signature( | ||
| bytes32 hash, | ||
| bytes calldata signature | ||
| ) internal view virtual override returns (bool) { | ||
| // Custom signing logic | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // contracts/MyAccountECDSA.sol | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; | ||
| import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
| import {AccountECDSA} from "../../../account/draft-AccountECDSA.sol"; | ||
|
|
||
| contract MyAccountECDSA is AccountECDSA, Initializable { | ||
| /** | ||
| * NOTE: EIP-712 domain is set at construction because each account clone | ||
| * will recalculate its domain separator based on their own address. | ||
| */ | ||
| constructor() EIP712("MyAccountECDSA", "1") { | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| function initializeSigner(address signerAddr) public virtual initializer { | ||
| _initializeSigner(signerAddr); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // contracts/MyAccountP256.sol | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; | ||
| import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
| import {AccountP256} from "../../../account/draft-AccountP256.sol"; | ||
|
|
||
| contract MyAccountP256 is AccountP256, Initializable { | ||
| /** | ||
| * NOTE: EIP-712 domain is set at construction because each account clone | ||
| * will recalculate its domain separator based on their own address. | ||
| */ | ||
| constructor() EIP712("MyAccountP256", "1") { | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| function initializeSigner(bytes32 qx, bytes32 qy) public virtual initializer { | ||
| _initializeSigner(qx, qy); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // contracts/MyAccountRSA.sol | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; | ||
| import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
| import {AccountRSA} from "../../../account/draft-AccountRSA.sol"; | ||
|
|
||
| contract MyAccountRSA is AccountRSA, Initializable { | ||
| /** | ||
| * NOTE: EIP-712 domain is set at construction because each account clone | ||
| * will recalculate its domain separator based on their own address. | ||
| */ | ||
| constructor() EIP712("MyAccountRSA", "1") { | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| function initializeSigner(bytes memory e, bytes memory n) public virtual initializer { | ||
| _initializeSigner(e, n); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // contracts/MyFactoryAccountECDSA.sol | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
| import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
| import {MyAccountECDSA} from "./MyAccountECDSA.sol"; | ||
|
|
||
| /** | ||
| * @dev An abstract factory contract to create ECDSA accounts on demand. | ||
| */ | ||
| contract MyFactoryAccountECDSA { | ||
| using Clones for address; | ||
|
|
||
| address private immutable _impl = address(new MyAccountECDSA()); | ||
|
|
||
| /// @dev Predict the address of the account | ||
| function predictAddress(bytes32 salt) public view returns (address) { | ||
| return _impl.predictDeterministicAddress(salt, address(this)); | ||
| } | ||
|
|
||
| /// @dev Create clone accounts on demand | ||
| function cloneAndInitialize(bytes32 salt, address signer) public returns (address) { | ||
| return _cloneAndInitialize(salt, signer); | ||
ernestognw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// @dev Create clone accounts on demand and return the address. Uses `signer` to initialize the clone. | ||
| function _cloneAndInitialize(bytes32 salt, address signer) internal returns (address) { | ||
| address predicted = predictAddress(salt); | ||
| if (predicted.code.length == 0) { | ||
| _impl.cloneDeterministic(salt); | ||
| Address.functionCall(predicted, abi.encodeCall(MyAccountECDSA.initializeSigner, (signer))); | ||
ernestognw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return predicted; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| * xref:index.adoc[Overview] | ||
| * xref:account-abstraction.adoc[Account Abstraction] | ||
| * xref:utilities.adoc[Utilities] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mixes vanilla contracts (EIP712) with an upgradeable design (the initializer).
I'm wondering what will happen when we get an upgradeable version of the community repo. Like
AccountBaseUpgradeable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the EIP712 contract will be transpiled into EIP712Upgradeable. In that case, the contract will remain initializable and perhaps we should document that the
_initializeSignerfunction must be called within the initializer function in the upgradeable version (this could go in a community-contracts version of anupgradeable.patch)