Skip to content

refactor(engine): wire TransactionController into @metamask/wallet init#32937

Merged
matthewwalsh0 merged 16 commits into
mainfrom
feat/wallet-wire-transaction-controller
Jul 15, 2026
Merged

refactor(engine): wire TransactionController into @metamask/wallet init#32937
matthewwalsh0 merged 16 commits into
mainfrom
feat/wallet-wire-transaction-controller

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Description

Moves TransactionController construction from the legacy Engine init registry into the @metamask/wallet-owned wallet-init flow, mirroring extension PR #43182.

  • @metamask/wallet now owns the TC's controller messenger and persisted state
  • Mobile supplies the client-specific instance options + event listeners
  • Access via wallet.getInstance('TransactionController') instead of the legacy messengerClientsByName registry
  • Mobile-specific behaviour preserved: getState() + selectShouldUseSmartTransaction, isAutomaticGasFeeUpdateEnabled, metrics / notification / money-account event handlers
  • Bumps @metamask/wallet 6→7, @metamask/transaction-controller to 68.4.0, @metamask/messenger to 2.0.0

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Transaction submission after wallet-init refactor

  Scenario: user sends a transaction
    Given a wallet with funds on a supported network
    When user creates and confirms a send transaction
    Then the transaction is submitted and reaches a confirmed state

  Scenario: user submits a smart transaction
    Given smart transactions are enabled for the current chain
    When user confirms a transaction
    Then the transaction is submitted via the smart transaction path

Screenshots/Recordings

N/A

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

High Risk
This changes how the transaction lifecycle controller is constructed and accessed on the critical send/confirm/publish path; regressions could break submission, smart transactions, or metrics without obvious UI failures.

Overview
TransactionController is no longer created through the Engine’s MessengerClientInit registry. Construction and persisted state move to @metamask/wallet, with mobile supplying transactionController instance options and setupTransactionControllerListeners during initializeWallet.

Engine drops TransactionController from the init map and messenger registry; it resolves the controller via this.#wallet.getInstance('TransactionController') instead of messengerClientsByName. The old TransactionControllerInit module and its large init test file are removed in favor of wallet-init/instance-options/transaction-controller and focused unit tests.

Mobile-specific behavior is preserved in the new builders: publish hooks (via a messenger-backed getTransactionController proxy), gas-fee helpers, EIP-7702 token gating, and metrics / notification / money-account event subscriptions. The init messenger lives under wallet-init/messengers (controller messenger wiring removed from Engine messengers index), with extra delegated actions for nonce lock and atomic batch support.

Dependencies: @metamask/wallet ^6^7.0.1, @metamask/connectivity-controller ^0.3.0.

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

@metamask-ci metamask-ci Bot added the team-confirmations Push issues to confirmations team label Jul 8, 2026
@socket-security

socket-security Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​connectivity-controller@​0.3.0981007392100
Updatednpm/​@​metamask/​wallet@​6.0.0 ⏵ 7.0.175 +110076 +197 +1100

View full report

@socket-security

socket-security Bot commented Jul 8, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@metamask-ci

metamask-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Related issues section is empty. Add Fixes: #123 / Closes: <URL> / Refs: <Jira key>, or write a short rationale after the colon.
  • Pre-merge author checklist has only 5 of the required 8 items. Every checklist row must be present and consciously checked — do not delete rows.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@matthewwalsh0 matthewwalsh0 force-pushed the feat/wallet-wire-transaction-controller branch from e9bb5ba to 359a528 Compare July 9, 2026 10:33
@matthewwalsh0 matthewwalsh0 force-pushed the feat/wallet-wire-transaction-controller branch from f6d80b9 to 8fc03e3 Compare July 13, 2026 11:06
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review July 13, 2026 12:44
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners July 13, 2026 12:44
@github-actions github-actions Bot added the risk:high AI analysis: high risk label Jul 13, 2026
@matthewwalsh0 matthewwalsh0 added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jul 13, 2026
@matthewwalsh0 matthewwalsh0 force-pushed the feat/wallet-wire-transaction-controller branch from d8fdad5 to 114da02 Compare July 14, 2026 11:52
…tState arg

Remove the `getState` parameter from `getTransactionControllerInstanceOptions`,
`setupTransactionControllerListeners`, and `initializeWallet` — and from
`isEIP7702GasFeeTokensEnabled`'s private parameter bag. All call sites were
already passing `() => store.getState()`; import `store` directly instead.

Aligns with the pattern used by the other wallet-init instance-option helpers
(e.g. `remote-feature-flag-controller`).
…C 69.0.0)

Forward-port the getSavedGasFees hook added to transaction-controller-init.ts
on main (TC 69.0.0) into our wallet-init instance-options equivalent.

Reads advancedGasFee preferences from PreferencesController state and returns
the saved fee tier/values for the transaction account + chain, allowing TC to
apply user-saved gas fee preferences to non-internal transactions.
Comment thread package.json Outdated
"@metamask/superstruct": "^3.2.1",
"@metamask/swappable-obj-proxy": "^2.1.0",
"@metamask/transaction-controller": "^69.0.0",
"@metamask/transaction-controller": "^68.4.0",

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.

Is this downgrade intentional?

- Bump @metamask/wallet ^7.0.0 → ^7.0.1
  wallet@7.0.1 natively requires @metamask/transaction-controller@^69.0.0
  so the resolution override is no longer needed.
- Remove @metamask/transaction-controller resolution pin (69.0.0)
  TC version is managed by main/wallet; not ours to override.
- Bump @metamask/transaction-controller direct dep ^68.4.0 → ^69.0.0
  Aligns our declaration with what main already has.
- Bump @metamask/connectivity-controller ^0.2.0 → ^0.3.0
  wallet@7.0.1 requires ^0.3.0; deduplicated the nested copy.

@cursor cursor Bot 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.

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 3e739cb. Configure here.

Comment thread package.json
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: @PerformanceSwaps
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/connectivity-controller. Running all tests.

Performance Test Selection:
The TransactionController architectural refactoring (moved to @metamask/wallet Wallet-managed initialization, major version bump ^6→^7) could affect transaction execution timing and performance. The @PerformanceSwaps tag is most relevant as swap flows are the most performance-sensitive transaction flows. Other performance tags like @PerformanceLaunch and @PerformanceLogin could also be affected by the wallet initialization change, but the primary concern is transaction execution performance. Selecting @PerformanceSwaps as the most directly impacted performance scenario.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
53.8% Coverage on New Code (required ≥ 80%)
14.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.37%. Comparing base (65eb9a3) to head (6067326).
⚠️ Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
...et-init/instance-options/transaction-controller.ts 80.48% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32937      +/-   ##
==========================================
+ Coverage   84.34%   84.37%   +0.03%     
==========================================
  Files        6115     6132      +17     
  Lines      163209   163725     +516     
  Branches    39822    39924     +102     
==========================================
+ Hits       137651   138143     +492     
- Misses      16047    16070      +23     
- Partials     9511     9512       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

1 test failed · 2 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

❌ Failed Tests (1)

@swap-bridge-dev-team

Test Platform Device Reason Recording
Cross-chain swap flow - ETH to SOL - 50+ accounts, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) Test error 📹 Watch
✅ Passed Tests (1)
Test Platform Device Duration Team Recording
Swap flow - ETH to LINK, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 2.55s @swap-bridge-dev-team 📹 Watch

Branch: feat/wallet-wire-transaction-controller · Build: Normal · Commit: 5d82359 · View full run

@matthewwalsh0 matthewwalsh0 requested a review from OGPoyraz July 15, 2026 12:33
@matthewwalsh0 matthewwalsh0 added this pull request to the merge queue Jul 15, 2026
Merged via the queue into main with commit c59a71b Jul 15, 2026
448 of 455 checks passed
@matthewwalsh0 matthewwalsh0 deleted the feat/wallet-wire-transaction-controller branch July 15, 2026 14:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
@metamask-ci metamask-ci Bot added the release-8.4.0 Issue or pull request that will be included in release 8.4.0 label Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.4.0 Issue or pull request that will be included in release 8.4.0 risk:high AI analysis: high risk size-XL skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants