-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: add support to automatically upgrade account #37571
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
base: main
Are you sure you want to change the base?
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (5 files, +41 -89)
|
Builds ready [a7fe899]
UI Startup Metrics (1285 ± 92 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| const { from, nonce: txNonce } = txParams; | ||
| const nextNonce = await this.#getNextNonce(from, networkClientId); | ||
|
|
||
| const nonce = txNonce ?? nextNonce; |
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.
In what scenario is the nonce from the transaction missing?
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.
We don't have the nonce because we set isExternalSign to true which skips it, but in the scenario where we are upgrading the account we need to pass to Sentinel the nonce.
| #decodeAuthorizationSignature(signature: Hex) { | ||
| const r = signature.slice(0, 66) as Hex; | ||
| const s = `0x${signature.slice(66, 130)}` as Hex; | ||
| const r = stripSingleLeadingZero(signature.slice(0, 66)) as Hex; |
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.
Why is this required?
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.
Here, Nick mentioned that Go doesn't handle cases properly when the underlying type is an integer, and suggested using a function to strip the leading zero. It’s a bit odd, though, because we have similar logic in the Transaction Controller — it retrieves the signature from the Keyring Controller, splits it into r, s, and v, and that flow works without issues.
| (result) => result.chainId.toLowerCase() === chainId.toLowerCase(), | ||
| ); | ||
|
|
||
| // Currently requires upgraded account, can also support no `delegationAddress` in future. |
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.
We can remove this now 😄
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.
Done
Builds ready [b330b88]
UI Startup Metrics (1165 ± 108 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [a380b69]
UI Startup Metrics (1153 ± 93 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
This PR enables automatic account upgrades when Smart Transactions (STX) are turned off.
It removes the UI condition that previously blocked the flow from initiating and refines the EIP-7702 authorization handling, signature normalization, and gasless eligibility logic.
Changelog
CHANGELOG entry: Added automatic account upgrade support
Related issues
Fixes: #35590
Manual testing steps
Screenshots/Recordings
arbitrum.auto.upgrade.webm
bnb_aut.upgrade.webm
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Improves 7702 publish flow with nonce locking and signature normalization, simplifies gasless eligibility to relay-based check, adds hex normalization util, and updates tests.
getNextNonceusingTransactionController.getNonceLock(address, networkClientId)and pass intoDelegation7702PublishHook.toHex/NetworkClientIdin init; wire hook viapublishHook.delegation-7702-publish.ts):getNextNonceand usetransactionMeta.networkClientId; derive authorization nonce fromtxParams.nonceor next nonce.r/s, computeyParitywithtoHex.stripSingleLeadingZero.useIsGaslessSupported: remove atomic-batch checks; gate 7702 byisRelaySupported(chainId)and non-deploy tx; retain smart-transaction + sendBundle path.stripSingleLeadingZero(hex)helper.delegation-7702-publishto mockgetNextNonce; assert auth list/relay behavior.stripSingleLeadingZero.useIsGaslessSupportedtests to reflect relay-only 7702 gating.Written by Cursor Bugbot for commit a380b69. This will update automatically on new commits. Configure here.