Skip to content

feat: add EIP-7702 step to money account upgrade controller#8565

Merged
Jwhiles merged 9 commits intomainfrom
MUSD-448
Apr 28, 2026
Merged

feat: add EIP-7702 step to money account upgrade controller#8565
Jwhiles merged 9 commits intomainfrom
MUSD-448

Conversation

@Jwhiles
Copy link
Copy Markdown
Contributor

@Jwhiles Jwhiles commented Apr 23, 2026

Explanation

Adds 'Step 1' to the money account upgrade controller. This step submits EIP-7702 authorization.

The eip-7702-authorization step submits an EIP-7702 delegation-slot authorization to CHOMP so the Money Account is upgraded to a smart account pointed at the configured delegator impl. It first reads the account's on-chain code via eth_getCode: an empty response ('0x') means a plain EOA and the step proceeds; a 0xef0100 delegation that matches delegatorImplAddress short-circuits with 'already-done'; any other delegation address or unexpected bytecode throws, so the step never overwrites an existing delegation or operates on a regular contract.

For a plain EOA, the step fetches the current on-chain nonce via eth_getTransactionCount, signs the authorization { chainId, contractAddress: delegatorImplAddress, nonce } through KeyringController:signEip7702Authorization, splits the resulting 65-byte signature into { r, s, v, yParity }, and submits it to ChompApiService:createUpgrade (chainId and nonce as decimal strings, since that's the API's wire format).

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Touches upgrade orchestration and introduces network RPC + signature handling, so failures could block upgrades or cause incorrect CHOMP submissions if edge cases are missed.

Overview
Adds a new eip-7702-authorization step to MoneyAccountUpgradeController’s upgrade sequence that checks on-chain code/nonce via NetworkController, signs an EIP-7702 authorization via KeyringController, splits the 65-byte signature, and submits it to CHOMP via ChompApiService:createUpgrade (skipping if already delegated and erroring if delegated elsewhere or the address is a contract).

Updates the controller to persist init-time chainId/delegatorImplAddress and pass them through the step context, expands allowed messenger actions, adds @metamask/network-controller as a dependency, and extends unit tests (including a new comprehensive test suite for the EIP-7702 step).

Reviewed by Cursor Bugbot for commit 82b60d8. Bugbot is set up for automated code reviews on this repo. Configure here.

export const eip7702AuthorizationStep: Step = {
name: 'eip-7702-authorization',
async run({ messenger, address, chainId, delegatorImplAddress }) {
const existing = await messenger.call(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think existing might not be the best check. If can exist but be a wrong one (example lower nonce). Maybe checking if account is actually upgraded might be better. You can check how the existing upgrade account works and how it checks / saves the ones that are already upgraded.

Because if its already upgraded this step can be skipped altogether.

@Jwhiles Jwhiles marked this pull request as ready for review April 27, 2026 08:16
@Jwhiles Jwhiles requested review from a team as code owners April 27, 2026 08:16
@Jwhiles Jwhiles requested a review from MoMannn April 27, 2026 08:17
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28b898f. Configure here.

Comment thread packages/money-account-upgrade-controller/tsconfig.build.json
@Jwhiles Jwhiles force-pushed the MUSD-448 branch 2 times, most recently from 8a1c399 to 0e3e0ab Compare April 27, 2026 09:27
@Jwhiles Jwhiles changed the title feat: add step 1 to money account upgrade controller feat: add EIP-7702 step to money account upgrade controller Apr 27, 2026
Matt561
Matt561 previously approved these changes Apr 27, 2026
shane-t
shane-t previously approved these changes Apr 27, 2026
MoMannn
MoMannn previously approved these changes Apr 28, 2026
return 'already-done';
}
throw new Error(
`Account ${address} is already delegated to ${existingDelegation}, which is not the configured delegator impl ${delegatorImplAddress}. Refusing to overwrite an existing EIP-7702 delegation.`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not actually a delegation but the account is already upgraded to another smart account not delegation/metamask smart account.

@Jwhiles Jwhiles added this pull request to the merge queue Apr 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 28, 2026
@Jwhiles Jwhiles added this pull request to the merge queue Apr 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 28, 2026
@Jwhiles Jwhiles dismissed stale reviews from MoMannn, shane-t, and Matt561 via 82b60d8 April 28, 2026 08:40
@Jwhiles Jwhiles added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit 51dd87d Apr 28, 2026
368 of 374 checks passed
@Jwhiles Jwhiles deleted the MUSD-448 branch April 28, 2026 08:58
Sign up for free to 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.

4 participants