Skip to content
Merged
Show file tree
Hide file tree
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 Nov 26, 2024
1859385
Merge branch 'master' into aa/accounts
ernestognw Nov 29, 2024
7847e80
Merge branch 'master' into aa/accounts
ernestognw Dec 3, 2024
25de3ac
Checkpoint
ernestognw Dec 5, 2024
292dae1
Fix lint
ernestognw Dec 5, 2024
f8657e7
Checkpoint
ernestognw Dec 5, 2024
8699232
up
ernestognw Dec 6, 2024
7bdf69e
up
ernestognw Dec 6, 2024
efd52cd
Adjust
ernestognw Dec 6, 2024
87fcd0e
up
ernestognw Dec 6, 2024
549ab8e
Simplify CallReceiverMock
ernestognw Dec 6, 2024
90c7f5e
Fix slither + Codespell
ernestognw Dec 6, 2024
2e345c3
Fix coverage
ernestognw Dec 6, 2024
af200e4
Merge branch 'master' into aa/accounts
ernestognw Dec 6, 2024
4d03f45
Remove entrypoint
ernestognw Dec 6, 2024
9caded9
Readd entrypoint
ernestognw Dec 6, 2024
f6b4454
Run --ir-minimum in forge coverage
ernestognw Dec 6, 2024
2d2300f
up
ernestognw Dec 7, 2024
d6ba190
Make Accounts initializable
ernestognw Dec 7, 2024
208386f
Finish docs
ernestognw Dec 7, 2024
49fc47d
Merge branch 'master' into aa/accounts
ernestognw Dec 7, 2024
d715e4c
rewrite helpers/signers as alternative to ethers.SigningKey and
Amxx Dec 9, 2024
8ad95a1
Rename _validateNestedEIP712Signature -> _validateSignature
ernestognw Dec 9, 2024
885efdd
Read virtual to ERC7739Signer functions
ernestognw Dec 9, 2024
d5f0dac
lint
ernestognw Dec 9, 2024
130ce04
Implement review recommendations
ernestognw Dec 9, 2024
dcdae8d
Include signer into account factory hash
ernestognw Dec 9, 2024
03d935d
Update Account inheritance order
ernestognw Dec 10, 2024
5456f26
up
ernestognw Dec 10, 2024
9412b65
Merge branch 'master' into aa/accounts
ernestognw Dec 10, 2024
524bf15
Remove ERC1155HolderLean
ernestognw Dec 10, 2024
4718b87
Abstract AccountSignerDomain
ernestognw Dec 10, 2024
c8ad19d
up
ernestognw Dec 10, 2024
ed66cca
Merge branch 'master' into aa/accounts
ernestognw Dec 10, 2024
c41956c
Remove signed hash fn
ernestognw Dec 11, 2024
7e51cd2
Add standalone example of usage
ernestognw Dec 13, 2024
459d594
Merge branch 'master' into aa/accounts
ernestognw Dec 13, 2024
f497fd1
Remove docs
ernestognw Dec 13, 2024
6409cb3
ERC4337 userOp validation should not be 7739 wrapped
Amxx Dec 13, 2024
97b33df
documentation
Amxx Dec 13, 2024
ddd17e9
Rename `_validateSignature` to `_rawSignatureValidation` and remove _…
ernestognw Dec 13, 2024
e8ef6d1
errata
ernestognw Dec 13, 2024
d706876
Default _signableUserOpHash to a typed userop signature
ernestognw Dec 13, 2024
188e71d
Remove docs mocks
ernestognw Dec 13, 2024
6ace1a7
Remove ERC7739 from AccountBase
ernestognw Dec 14, 2024
9793e49
Make ERC7739Signer validations private
ernestognw Dec 14, 2024
9e34432
Move EIP712 userop signing to Accountbase
ernestognw Dec 14, 2024
ae6a665
Split AccountCore / Account
Amxx Dec 16, 2024
07ca067
remove intermediary variable
Amxx Dec 16, 2024
6aa5597
doc
Amxx Dec 16, 2024
0513f3a
spelling
Amxx Dec 16, 2024
e3ce6b5
abstract signer
Amxx Dec 16, 2024
69cc3da
docs
Amxx Dec 16, 2024
d0bd34f
ERC7702 signer
Amxx Dec 16, 2024
3b1c1f4
fix
Amxx Dec 16, 2024
190b5a5
doc example for ERC7739 use signers
Amxx Dec 16, 2024
a6ab43b
Complete minimal documentation
ernestognw Dec 17, 2024
5c210cf
Update CHANGELOG.md
ernestognw Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make Accounts initializable
  • Loading branch information
ernestognw committed Dec 7, 2024
commit d6ba190d3c6d0e7717bcb605df61f4be19ad1eae
13 changes: 10 additions & 3 deletions contracts/account/draft-AccountECDSA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {AccountBase} from "./draft-AccountBase.sol";
import {ERC7739Signer} from "../utils/cryptography/draft-ERC7739Signer.sol";
import {ERC7739Signer, EIP712} from "../utils/cryptography/draft-ERC7739Signer.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";

/**
* @dev Account implementation using {ECDSA} signatures and {ERC7739Signer} for replay protection.
*/
abstract contract AccountECDSA is ERC165, ERC7739Signer, ERC721Holder, ERC1155HolderLean, AccountBase {
using MessageHashUtils for bytes32;

address private immutable _signer;
/**
* @dev The {signer} is already initialized.
*/
error AccountECDSAUninitializedSigner(address signer);

address private _signer;

/**
* @dev Initializes the account with the address of the native signer.
*/
constructor(address signerAddr) {
function _initializeSigner(address signerAddr) internal {
if (_signer != address(0)) revert AccountECDSAUninitializedSigner(signerAddr);
_signer = signerAddr;
}

Expand Down
12 changes: 9 additions & 3 deletions contracts/account/draft-AccountP256.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ import {ERC7739Signer} from "../utils/cryptography/draft-ERC7739Signer.sol";
abstract contract AccountP256 is ERC165, ERC7739Signer, ERC721Holder, ERC1155HolderLean, AccountBase {
using MessageHashUtils for bytes32;

bytes32 private immutable _qx;
bytes32 private immutable _qy;
/**
* @dev The {signer} is already initialized.
*/
error AccountP256UninitializedSigner(bytes32 qx, bytes32 qy);

bytes32 private _qx;
bytes32 private _qy;

/**
* @dev Initializes the account with the P256 public key.
*/
constructor(bytes32 qx, bytes32 qy) {
function _initializeSigner(bytes32 qx, bytes32 qy) internal {
if (_qx != 0 || _qy != 0) revert AccountP256UninitializedSigner(qx, qy);
_qx = qx;
_qy = qy;
}
Expand Down
8 changes: 7 additions & 1 deletion contracts/account/draft-AccountRSA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ import {ERC7739Signer} from "../utils/cryptography/draft-ERC7739Signer.sol";
abstract contract AccountRSA is ERC165, ERC7739Signer, ERC721Holder, ERC1155HolderLean, AccountBase {
using MessageHashUtils for bytes32;

/**
* @dev The {signer} is already initialized.
*/
error AccountP256UninitializedSigner(bytes e, bytes n);

bytes private _e;
bytes private _n;

/**
* @dev Initializes the account with the RSA public key.
*/
constructor(bytes memory e, bytes memory n) {
function _initializeSigner(bytes memory e, bytes memory n) internal {
if (_e.length != 0 || _n.length != 0) revert AccountP256UninitializedSigner(e, n);
_e = e;
_n = n;
}
Expand Down
14 changes: 14 additions & 0 deletions contracts/mocks/account/AccountECDSAMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";
import {ERC4337Utils} from "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {AccountECDSA} from "../../account/draft-AccountECDSA.sol";

contract AccountECDSAMock is AccountECDSA {
constructor(string memory name, string memory version, address signerAddr) EIP712(name, version) {
_initializeSigner(signerAddr);
}
}
14 changes: 14 additions & 0 deletions contracts/mocks/account/AccountP256Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";
import {ERC4337Utils} from "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {AccountP256} from "../../account/draft-AccountP256.sol";

contract AccountP256Mock is AccountP256 {
constructor(string memory name, string memory version, bytes32 qx, bytes32 qy) EIP712(name, version) {
_initializeSigner(qx, qy);
}
}
14 changes: 14 additions & 0 deletions contracts/mocks/account/AccountRSAMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";
import {ERC4337Utils} from "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {AccountRSA} from "../../account/draft-AccountRSA.sol";

contract AccountRSAMock is AccountRSA {
constructor(string memory name, string memory version, bytes memory e, bytes memory n) EIP712(name, version) {
_initializeSigner(e, n);
}
}
2 changes: 1 addition & 1 deletion test/account/draft-AccountECDSA.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function fixture() {
const [beneficiary, other] = await ethers.getSigners();
const target = await ethers.deployContract('CallReceiverMockExtended');
const signer = new ECDSASigner();
const helper = new ERC4337Helper('$AccountECDSA');
const helper = new ERC4337Helper('$AccountECDSAMock');
const smartAccount = await helper.newAccount(['AccountECDSA', '1', signer.EOA.address]);
const domain = {
name: 'AccountECDSA',
Expand Down
2 changes: 1 addition & 1 deletion test/account/draft-AccountP256.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function fixture() {
const [beneficiary, other] = await ethers.getSigners();
const target = await ethers.deployContract('CallReceiverMockExtended');
const signer = new P256Signer();
const helper = new ERC4337Helper('$AccountP256');
const helper = new ERC4337Helper('$AccountP256Mock');
const smartAccount = await helper.newAccount(['AccountP256', '1', signer.publicKey.qx, signer.publicKey.qy]);
const domain = {
name: 'AccountP256',
Expand Down
2 changes: 1 addition & 1 deletion test/account/draft-AccountRSA.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function fixture() {
const [beneficiary, other] = await ethers.getSigners();
const target = await ethers.deployContract('CallReceiverMockExtended');
const signer = new RSASignerSHA256();
const helper = new ERC4337Helper('$AccountRSA');
const helper = new ERC4337Helper('$AccountRSAMock');
const smartAccount = await helper.newAccount(['AccountRSA', '1', signer.publicKey.e, signer.publicKey.n]);
const domain = {
name: 'AccountRSA',
Expand Down
Loading