Skip to content

Add EIP-712 support for Account v2 - #21

Open
0xyanc wants to merge 9 commits into
tokenbound:jw/account-v2from
0xyanc:account-v2-eip712
Open

Add EIP-712 support for Account v2#21
0xyanc wants to merge 9 commits into
tokenbound:jw/account-v2from
0xyanc:account-v2-eip712

Conversation

@0xyanc

Copy link
Copy Markdown

No description provided.

@jaydenwindlejaydenwindle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff @0xyanc! A few small change requests for you, then would love to merge this in

Comment threadsrc/Account.sol Outdated
Comment threadsrc/Account.sol Outdated
constructor(address _guardian, address entryPoint_) {
if (_guardian == address(0) || entryPoint_ == address(0))
constructor(address _guardian, address entryPoint_, string memory _name, string memory _version)
EIP712(_name, _version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the name and version fields constant instead of passed as constructor arguments? Makes it easier to reason about when deploying :)

Comment threadsrc/Account.sol Outdated
userOp.preVerificationGas,
userOp.maxFeePerGas,
userOp.maxPriorityFeePerGas,
userOp.paymasterAndData

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include userOpHash in the typed data fields?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This userOpHash would be the hash returned by the EntryPoint?

@jaydenwindlejaydenwindleMay 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Also passed into the _validateSignature function as a parameter

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to copy the UserOperation in memory as I get "Stack too deep" error otherwise

Comment threadtest/AccountERC4337.t.sol Outdated
assertEq(accountAddress.balance, 1 ether);
}

function _buildOpHash(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expose this as a public getter on the account contract? So that it can be accessed easily by clients.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposed buildUserOp712Hash(UserOperation memory op, bytes32 opHash) in Account.sol

Comment threadsrc/Account.sol Outdated
) == IERC1271.isValidSignature.selector;
bytes32 hashStruct = keccak256(
abi.encode(
keccak256(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the hash of this typed data a public constant?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an immutable variable so the hash is not computed each time

@0xyanc
0xyanc requested a review from jaydenwindleMay 20, 2023 15:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@0xyanc@jaydenwindle