This repository was archived by the owner on Oct 7, 2024. It is now read-only.
generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add support for ERC-4337 accounts #213
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6d15382
docs: add EIP-4337 UserOp support
danroc 85f1b56
wip: support 4337 accounts
danroc 70161e2
chore: simplify regex
danroc ebe91f5
feat: add `definePattern` helper function
danroc 2fe4186
chore: move types to `eth` directory
danroc 346ab7d
chore: use `definePattern` to define `UuidV4` type
danroc 3febcb6
chore: move user operation sequence diagram
danroc 3fbdab2
docs: add `eth_signUserOperation`
danroc 1c38555
feat: add `BasicTransaction` type
danroc cad2173
fix: add index files
danroc 5c8ba83
feat: add `PreparedUserOperation` type
danroc b8c556d
fix: make `gasLimits` optional
danroc 7513850
feat: add `EthUserOperationPatch` type
danroc 1a7f356
feat: export base ETH types
danroc 67ffc9a
feat: add `EthKeyring` type
danroc 29fcb5e
fix: add UserOperation methods to support methods enum
danroc 6741d22
docs: add link to ERC-4337 spec
danroc 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| @startuml "ERC-4337 Account Support" | ||
| autonumber | ||
| skinparam fontname Arial | ||
|
|
||
| title "ERC-4337 UserOperation Signing" | ||
|
|
||
| participant Dapp | ||
| participant MetaMask | ||
| participant Snap | ||
|
|
||
| Dapp -> MetaMask ++: ""{""\n\ | ||
| "" chainId, // Ignored by MetaMask""\n\ | ||
| "" from,""\n\ | ||
| "" to,""\n\ | ||
| "" value,""\n\ | ||
| "" data,""\n\ | ||
| } | ||
|
|
||
| note over MetaMask | ||
| Currently, only one transaction | ||
| per UserOp will be supported | ||
| end note | ||
|
|
||
| MetaMask -> Snap ++: ""prepareUserOperation({""\n\ | ||
| "" account: account.id,""\n\ | ||
| "" scope: `eip155:${chainId}`,""\n\ | ||
| "" transactions: [ // List of transactions""\n\ | ||
| "" {""\n\ | ||
| "" to,""\n\ | ||
| "" value,""\n\ | ||
| "" data,""\n\ | ||
| "" },""\n\ | ||
| "" ]""\n\ | ||
| }) | ||
|
|
||
| Snap --> MetaMask --: ""{""\n\ | ||
| "" callData,""\n\ | ||
| "" initCode?,""\n\ | ||
| "" nonce,""\n\ | ||
| "" gasLimits?: {""\n\ | ||
| "" callGasLimit,""\n\ | ||
| "" verificationGasLimit,""\n\ | ||
| "" preVerificationGas,""\n\ | ||
| "" },""\n\ | ||
| "" dummySignature?,""\n\ | ||
| "" dummyPaymasterAndData?,""\n\ | ||
| "" bundler?,""\n\ | ||
| ""}"" | ||
|
|
||
| MetaMask -> MetaMask: Check if the account is already deployed | ||
|
|
||
| alt The account is already deployed | ||
| MetaMask -> MetaMask: Remove the ""initCode"" if set | ||
| else The account is not deployed and the ""initCode"" isn't present | ||
| MetaMask -> Dapp: Throw an error (without the exact reason) | ||
| end | ||
|
|
||
| alt The ""gas"" isn't set | ||
| MetaMask -> MetaMask: Estimate and set gas values | ||
| end | ||
|
|
||
| MetaMask -> MetaMask: Estimate and set gas fees | ||
|
|
||
| MetaMask -> Snap ++: ""patchUserOperation({""\n\ | ||
| "" sender,""\n\ | ||
| "" nonce,""\n\ | ||
| "" initCode,""\n\ | ||
| "" callData,""\n\ | ||
| "" callGasLimit,""\n\ | ||
| "" verificationGasLimit,""\n\ | ||
| "" preVerificationGas,""\n\ | ||
| "" maxFeePerGas,""\n\ | ||
| "" maxPriorityFeePerGas,""\n\ | ||
| "" paymasterAndData, // Dummy value or empty""\n\ | ||
| "" signature, // Dummy value or empty""\n\ | ||
| ""})"" | ||
|
|
||
| Snap --> MetaMask --: ""{""\n\ | ||
| "" paymasterAndData?,""\n\ | ||
| ""}"" | ||
|
|
||
| MetaMask -> MetaMask: Update ""paymasterAndData"" and\n\ | ||
| remove the dummy signature | ||
|
|
||
| MetaMask -> MetaMask: Display approval UI | ||
|
|
||
| MetaMask -> Snap ++: ""signUserOperation([""\n\ | ||
| "" {""\n\ | ||
| "" sender,""\n\ | ||
| "" nonce,""\n\ | ||
| "" initCode,""\n\ | ||
| "" callData,""\n\ | ||
| "" callGasLimit,""\n\ | ||
| "" verificationGasLimit,""\n\ | ||
| "" preVerificationGas,""\n\ | ||
| "" maxFeePerGas,""\n\ | ||
| "" maxPriorityFeePerGas,""\n\ | ||
| "" paymasterAndData,""\n\ | ||
| "" signature, // Empty""\n\ | ||
| "" },""\n\ | ||
| "" entrypoint, // Entrypoint deployed by""\n\ | ||
| "" // the Ethereum Foundation""\n\ | ||
| ""])"" | ||
|
|
||
| Snap --> MetaMask --: ""{""\n\ | ||
| "" signature,""\n\ | ||
| ""}"" | ||
|
|
||
| MetaMask -> MetaMask: Update UserOp's ""signature"" | ||
|
|
||
| MetaMask -> MetaMask: Submit UserOp to bundler and\n\ | ||
| wait for transaction hash | ||
|
|
||
| MetaMask --> Dapp --: ""txHash"" | ||
| @enduml |
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
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.
Uh oh!
There was an error while loading. Please reload this page.