Skip to content

feat: source GasFeeController from @metamask/wallet#33430

Draft
sirtimid wants to merge 3 commits into
mainfrom
sirtimid/adopt-wallet-gas-fee-controller
Draft

feat: source GasFeeController from @metamask/wallet#33430
sirtimid wants to merge 3 commits into
mainfrom
sirtimid/adopt-wallet-gas-fee-controller

Conversation

@sirtimid

Copy link
Copy Markdown
Member

Description

Sources mobile's GasFeeController from @metamask/wallet instead of the local controller-init wiring, continuing the shared controller-integration migration (@metamask/wallet is the layer that extension, mobile, and wallet-cli all adopt).

This integrates MetaMask/core#9527, which wires GasFeeController into the default Wallet initialization set. Because that PR is still a draft, the wallet and its sibling packages are pinned to preview builds (core commit 7ed2770ae) in a separate, revert-before-ready chore: commit.

What changed:

  • Adds wallet-init/instance-options/gas-fee-controller.ts (+ test) supplying only the mobile-specific options: clientId, the EIP-1559/legacy gas API endpoints, and getCurrentNetworkLegacyGasAPICompatibility (mainnet ‖ BSC ‖ Polygon). The wallet now builds getProvider and getCurrentNetworkEIP1559Compatibility from NetworkController itself and constructs GasFeeController after NetworkController via core#9527's new dependency ordering.
  • Deletes the local gas-fee-controller-init and gas-fee-controller-messenger (+ tests + barrels).
  • Resolves the controller through this.#wallet.getInstance('GasFeeController') in Engine.ts and drops it from the init registry, MESSENGER_FACTORIES, and the MessengerClientsToInitialize union (it remains in MessengerClients / EngineState / actions / events / BACKGROUND_STATE_CHANGE_EVENT_NAMES, matching the already-migrated NetworkController/TransactionController).

The chosen preview (7ed2770ae) wires exactly mobile's already-adopted controller set plus GasFeeController — it does not wire any controller mobile still inits locally, so there is no double-registration at boot.

Changelog

CHANGELOG entry: null

Related issues

Refs: MetaMask/core#9527

Manual testing steps

  1. Build and launch the app on iOS or Android and confirm it boots with no A handler for GasFeeController:* has already been registered error.
  2. Open the send/confirmation flow on an EIP-1559 network (e.g. Ethereum mainnet) and confirm the gas fee estimates (low / market / aggressive) load and update over time.
  3. Repeat on a legacy-gas network (e.g. BSC or Polygon) and confirm gas prices load.
  4. Submit a transaction and confirm gas estimation drives the fee correctly.

Screenshots/Recordings

N/A — no UI changes; this is an internal controller-wiring refactor.

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

🤖 Generated with Claude Code

sirtimid and others added 2 commits July 16, 2026 18:46
TEMP: pins the core#9527 (draft) preview builds so mobile can source
GasFeeController from @metamask/wallet before a real release ships.
Revert before marking the PR ready.

- @metamask/wallet -> @metamask-previews/wallet@7.0.1-preview-7ed2770ae
- @metamask/gas-fee-controller -> @metamask-previews/gas-fee-controller@26.2.4-preview-7ed2770ae
- @metamask/account-tree-controller -> @metamask-previews/account-tree-controller@7.5.5-preview-7ed2770ae
- @metamask/accounts-controller -> ^39.0.5 (required by the wallet preview)

Preview aliases are added to both dependencies and resolutions so the
wallet's real-range transitive deps collapse onto the single preview copy
(keeps `yarn dedupe --check` clean).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adopt the wallet-owned GasFeeController (core#9527) in place of mobile's
local controller-init wiring, mirroring the previous controller adoptions.

- Add wallet-init/instance-options/gas-fee-controller.ts (+ test) supplying
  the mobile client options (clientId, API endpoints, legacy-gas API
  compatibility). The wallet builds getProvider and the EIP-1559 callback
  from NetworkController and constructs GasFeeController after it.
- Wire it into wallet-init/initialization.ts.
- Delete the local gas-fee-controller-init and messenger (+ tests + barrels).
- Resolve GasFeeController via this.#wallet.getInstance in Engine.ts; drop it
  from the init registry, MESSENGER_FACTORIES, and the
  MessengerClientsToInitialize union (kept in MessengerClients / EngineState /
  actions / events / BACKGROUND_STATE_CHANGE_EVENT_NAMES).
- Update CODEOWNERS and remove the stale eslint burndown entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@metamask-ci metamask-ci Bot added the team-ocap-kernel Ocap Kernel team label Jul 16, 2026
@github-actions github-actions Bot added pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-M labels Jul 16, 2026
@socket-security

socket-security Bot commented Jul 16, 2026

Copy link
Copy Markdown

@sirtimid sirtimid removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jul 16, 2026
The initializeWallet test asserted an exact instanceOptions object that
omitted gasFeeController, so the newly wired builder output failed the
toHaveBeenCalledWith match. Mock the builder to a sentinel and assert
its slot, matching the sibling builders.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@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/accounts-controller, @metamask/account-tree-controller, @metamask/gas-fee-controller. Running all tests.

Performance Test Selection:
The GasFeeController is directly involved in gas fee estimation for swap transactions. The refactoring changes how GasFeeController is initialized (from MessengerClientInitFunction to Wallet instance options pattern) and uses a preview version of @metamask/gas-fee-controller. If the new initialization path introduces any latency in gas fee fetching or estimation, it could impact swap flow performance. @PerformanceSwaps covers quote fetching and swap execution times which depend on gas fee estimation. Other performance tags (Launch, Login, Onboarding, AccountList, AssetLoading) are not directly affected by GasFeeController changes.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@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.03s @swap-bridge-dev-team 📹 Watch

Branch: sirtimid/adopt-wallet-gas-fee-controller · Build: Normal · Commit: 2a87660 · View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant