Skip to content

refactor: construct GasFeeController via @metamask/wallet - #44534

Closed
sirtimid wants to merge 2 commits into
mainfrom
sirtimid/construct-gas-fee-controller-via-wallet
Closed

sirtimid wants to merge 2 commits into
mainfrom
sirtimid/construct-gas-fee-controller-via-wallet

Conversation

@sirtimid

Copy link
Copy Markdown
Contributor

Description

Constructs the extension's GasFeeController through @metamask/wallet instead of the local messenger-client-init wiring, continuing the incremental adoption of the shared controller-integration layer. This integrates MetaMask/core#9527, which wires GasFeeController into @metamask/wallet.

The wallet now owns GasFeeController as an instanceOptions.gasFeeController slot. It builds getProvider and getCurrentNetworkEIP1559Compatibility from NetworkController itself, and lets the controller default onNetworkDidChange and getChainId via its messenger NetworkController:networkDidChange subscription. The extension supplies only the client-specific overrides: the poll interval (10s), the client id (extension), the gas API endpoints, and the BSC legacy gas API compatibility check.

What changed:

  • Added app/scripts/wallet-init/instance-options/gas-fee-controller.ts (+test) building the gasFeeController instance options.
  • Added a minimal app/scripts/wallet-init/messengers/gas-fee-controller-messenger.ts (+test) that delegates only NetworkController:getState and NetworkController:getNetworkClientById, used to read the global chain id for the BSC check.
  • Wired gasFeeController into app/scripts/wallet-init/initialization.ts.
  • Resolved this.gasFeeController via this.wallet.getInstance('GasFeeController') and removed the GasFeeControllerInit import and init-map entry in metamask-controller.js. Consumers such as UserOperationController keep resolving it through getMessengerClient, which falls back to wallet.getInstance(name).
  • Deleted the local messenger-client-init/confirmations/gas-fee-controller-init.ts and messengers/gas-fee-controller-messenger.ts (+tests) and removed their import, re-exports, and MESSENGER_FACTORIES entry from messengers/index.ts. GasFeeController stays in controller-list.ts.

This PR is a draft and preview-pinned. @metamask/wallet and @metamask/gas-fee-controller are pinned to the core#9527 preview builds (7ed2770ae). It stays draft until a real @metamask/wallet release ships core#9527; then the pins are bumped to the release and LavaMoat policies are regenerated via @metamaskbot update-policies.

Changelog

CHANGELOG entry: null

Related issues

Integrates: MetaMask/core#9527

Manual testing steps

  1. Build and run the extension.
  2. Open a confirmation and confirm gas fee estimates load and update (EIP-1559 and legacy networks).
  3. Switch networks and confirm gas estimates refresh for the newly selected network.

Screenshots/Recordings

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.

🤖 Generated with Claude Code

@metamask-ci metamask-ci Bot added the team-ocap-kernel The Ocap Kernel team label Jul 16, 2026
@metamask-ci

metamask-ci Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

🫰 @MetaMask/core-platform (1 files, +1 -3)
  • 📁 app/
    • 📁 scripts/
      • 📄 metamask-controller.js +1 -3

👨‍🔧 @MetaMask/extension-platform (1 files, +1 -3)
  • 📁 app/
    • 📁 scripts/
      • 📄 metamask-controller.js +1 -3

📜 @MetaMask/policy-reviewers (8 files, +256 -24)
  • 📁 lavamoat/
    • 📁 webpack/
      • 📁 mv2/
        • 📁 beta/
          • 📄 policy.json +32 -3
        • 📁 experimental/
          • 📄 policy.json +32 -3
        • 📁 flask/
          • 📄 policy.json +32 -3
        • 📁 main/
          • 📄 policy.json +32 -3
      • 📁 mv3/
        • 📁 beta/
          • 📄 policy.json +32 -3
        • 📁 experimental/
          • 📄 policy.json +32 -3
        • 📁 flask/
          • 📄 policy.json +32 -3
        • 📁 main/
          • 📄 policy.json +32 -3

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.

@socket-security

socket-security Bot commented Jul 16, 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
Added@​metamask-previews/​wallet@​7.0.1-preview-7ed2770ae751007698100
Added@​metamask-previews/​gas-fee-controller@​26.2.4-preview-7ed2770ae821007598100

View full report

@sirtimid

Copy link
Copy Markdown
Contributor Author

@metamaskbot update-policies

@metamask-ci

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

LavaMoat validation was skipped in CI. Policies were not checked for this commit.

@metamask-ci

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Builds ready [ca525f6] [reused from 16ab47a]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 0 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 8b84374 | Date: 7/16/2026 | Pipeline: 29510180914 | Baseline logs

Interaction Benchmarks · Samples: 5

⚠️ Missing data: chrome/webpack/interactionUserActions, firefox/webpack/interactionUserActions

✅ No regressions detected

User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/webpack/userJourneyOnboardingImport, chrome/webpack/userJourneyOnboardingNew, chrome/webpack/userJourneyAssets, chrome/webpack/userJourneyAccountManagement, chrome/webpack/userJourneyTransactions, firefox/webpack/userJourneyOnboardingImport, firefox/webpack/userJourneyOnboardingNew, firefox/webpack/userJourneyAssets, firefox/webpack/userJourneyAccountManagement, firefox/webpack/userJourneyTransactions

✅ No regressions detected

Dapp Page Load Benchmarks · Samples: 100

⚠️ Missing data: chrome/webpack/pageLoadBenchmark

✅ No regressions detected

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 11.58 KiB (0.08%)
  • ui: -3.13 KiB (-0.02%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: -124 Bytes (-0.01%)
  • zip: 1.95 KiB (0.01%)

@sirtimid

Copy link
Copy Markdown
Contributor Author

@metamaskbot update-policies

@sirtimid
sirtimid force-pushed the sirtimid/construct-gas-fee-controller-via-wallet branch from ca525f6 to 60bd82e Compare July 16, 2026 16:39
@metamask-ci

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

LavaMoat validation was skipped in CI. Policies were not checked for this commit.

@metamask-ci

metamask-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Builds ready [60bd82e]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 2ba6714 | Date: 7/16/2026 | Pipeline: 29516488169 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/webpack/userJourneyAssets, chrome/webpack/userJourneyTransactions

Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
assetDetails
[Sentry log · main/release]
–🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
–🟢 [CI log]
sendTransactions
[Sentry log · main/release]
–🟢 [CI log]
swap
[Sentry log · main/release]
–🟢 [CI log]
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 11.08 KiB (0.08%)
  • ui: 91 Bytes (0%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: -110 Bytes (-0.01%)
  • zip: 2.93 KiB (0.01%)

sirtimid and others added 2 commits July 20, 2026 16:51
Construct the extension's GasFeeController through @metamask/wallet
instead of the local messenger-client-init wiring, integrating
MetaMask/core#9527.

The wallet now owns GasFeeController as an instanceOptions.gasFeeController
slot: it builds getProvider and getCurrentNetworkEIP1559Compatibility from
NetworkController itself and lets the controller default onNetworkDidChange
and getChainId via its messenger subscription. The extension supplies only
the client-specific overrides (interval, clientId, gas API endpoints, and
the BSC legacy gas API compatibility check).

- Add wallet-init/instance-options/gas-fee-controller.ts and a minimal
  wallet-init/messengers/gas-fee-controller-messenger.ts (delegates only
  NetworkController:getState + getNetworkClientById for the chain-id read).
- Wire gasFeeController into wallet-init/initialization.ts.
- Resolve this.gasFeeController via this.wallet.getInstance('GasFeeController')
  and drop the GasFeeControllerInit import + init-map entry.
- Delete the local confirmations/gas-fee-controller-init and
  messengers/gas-fee-controller-messenger (+tests) and their entries in
  messenger-client-init/messengers/index.ts. GasFeeController stays in
  controller-list.ts.

Preview-pin @metamask/wallet and @metamask/gas-fee-controller to the
core#9527 preview builds (7ed2770ae) until a wallet release ships it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sirtimid
sirtimid force-pushed the sirtimid/construct-gas-fee-controller-via-wallet branch from 60bd82e to f1627c1 Compare July 20, 2026 13:58
@sonarqubecloud

Copy link
Copy Markdown

@metamask-ci

metamask-ci Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
Builds ready [f1627c1]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 12 warn · 🔴 3 fail)

Baseline (latest main): abc8a82 | Date: 7/20/2026 | Pipeline: 29748579180 | Baseline logs

Metricschrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🔴 srpButtonToSrpForm(p95) [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🔴 createPwToRecoveryScreen(p95) [CI log]🔴 [CI log]

Regressions (🔴 3 failures)

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ loadNewAccount/load_new_account: +63%
  • ↑ loadNewAccount/total: +63%
  • ↑ confirmTx/longTaskTotalDuration: +24%
  • ↑ confirmTx/longTaskMaxDuration: +20%
  • ↑ confirmTx/tbt: +43%
  • ↑ confirmTx/inp: +30%
  • ↑ confirmTx/fcp: +11%
  • ↑ confirmTx/lcp: +13%
  • ↑ bridgeUserActions/bridge_load_page: +94%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +34%
  • ↑ bridgeUserActions/longTaskCount: +11%
  • ↑ bridgeUserActions/longTaskTotalDuration: +33%
  • ↑ bridgeUserActions/longTaskMaxDuration: +11%
  • ↑ bridgeUserActions/tbt: +78%
  • ↑ bridgeUserActions/total: +12%
  • ↑ bridgeUserActions/inp: +64%
  • ↑ bridgeUserActions/lcp: +16%
  • ↑ loadNewAccount/load_new_account: +45%
  • ↑ loadNewAccount/total: +45%
  • ↓ loadNewAccount/inp: -23%
  • ↓ loadNewAccount/fcp: -46%
  • ↑ loadNewAccount/lcp: +1234%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↓ confirmTx/inp: -20%
  • ↑ confirmTx/fcp: +10%
  • ↑ confirmTx/lcp: +1340%
  • ↑ bridgeUserActions/bridge_load_page: +313%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +141%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +37%
  • ↓ bridgeUserActions/inp: -18%
  • ↑ bridgeUserActions/lcp: +1219%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 1.9s
  • 🟡 confirmTx/FCP: p75 1.9s
  • 🟡 bridgeUserActions/FCP: p75 1.9s
  • 🟡 confirmTx/FCP: p75 1.9s
  • 🟡 bridgeUserActions/FCP: p75 1.9s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
–🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↓ startupStandardHome/uiStartup: -19%
  • ↓ startupStandardHome/load: -19%
  • ↓ startupStandardHome/domContentLoaded: -19%
  • ↓ startupStandardHome/domInteractive: -41%
  • ↓ startupStandardHome/backgroundConnect: -15%
  • ↓ startupStandardHome/firstReactRender: -16%
  • ↓ startupStandardHome/initialActions: -44%
  • ↓ startupStandardHome/loadScripts: -19%
  • ↓ startupStandardHome/setupStore: -16%
  • ↓ startupStandardHome/fcp: -31%
  • ↓ startupStandardHome/lcp: -19%
  • ↓ startupPowerUserHome/uiStartup: -13%
  • ↑ startupPowerUserHome/domInteractive: +11%
  • ↓ startupPowerUserHome/backgroundConnect: -25%
  • ↓ startupPowerUserHome/inp: -17%
  • ↓ startupPowerUserHome/lcp: -11%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/LCP: p75 3.1s
User Journey Benchmarks · Samples: 5 · mock API 🔴 3
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🔴 [CI log]
🔴 total
🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🔴 [CI log]
🔴 total
🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
importSrpHome
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
sendTransactions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/srpButtonToSrpForm: +10%
  • ↓ onboardingImportWallet/metricsToWalletReadyScreen: -19%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -91%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -32%
  • ↓ onboardingImportWallet/longTaskCount: -92%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -97%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -93%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -75%
  • ↑ onboardingNewWallet/createPwToRecoveryScreen: +12%
  • ↓ onboardingNewWallet/longTaskCount: -72%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -81%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -49%
  • ↓ onboardingNewWallet/tbt: -98%
  • ↓ solanaAssetDetails/assetClickToPriceChart: -68%
  • ↓ solanaAssetDetails/longTaskCount: -100%
  • ↓ solanaAssetDetails/longTaskTotalDuration: -100%
  • ↓ solanaAssetDetails/longTaskMaxDuration: -100%
  • ↓ solanaAssetDetails/total: -68%
  • ↑ solanaAssetDetails/fcp: +15%
  • ↓ solanaAssetDetails/cls: -86%
  • ↓ importSrpHome/loginToHomeScreen: -28%
  • ↓ importSrpHome/openAccountMenuAfterLogin: -62%
  • ↓ importSrpHome/homeAfterImportWithNewWallet: -58%
  • ↓ importSrpHome/longTaskCount: -48%
  • ↓ importSrpHome/longTaskTotalDuration: -55%
  • ↓ importSrpHome/longTaskMaxDuration: -14%
  • ↓ importSrpHome/tbt: -54%
  • ↓ importSrpHome/total: -56%
  • ↓ importSrpHome/inp: -17%
  • ↓ importSrpHome/cls: -17%
  • ↓ sendTransactions/openSendPageFromHome: -29%
  • ↓ sendTransactions/selectTokenToSendFormLoaded: -20%
  • ↓ sendTransactions/reviewTransactionToConfirmationPage: -97%
  • ↓ sendTransactions/longTaskCount: -100%
  • ↓ sendTransactions/longTaskTotalDuration: -100%
  • ↓ sendTransactions/longTaskMaxDuration: -100%
  • ↓ sendTransactions/tbt: -100%
  • ↓ sendTransactions/total: -94%
  • ↓ sendTransactions/inp: -33%
  • ↓ sendTransactions/cls: -53%
  • ↓ swap/openSwapPageFromHome: -54%
  • ↑ swap/fetchAndDisplaySwapQuotes: +111%
  • ↓ swap/longTaskCount: -17%
  • ↓ swap/longTaskTotalDuration: -38%
  • ↓ swap/longTaskMaxDuration: -27%
  • ↓ swap/tbt: -95%
  • ↑ swap/total: +107%
  • ↓ swap/cls: -86%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 solanaAssetDetails/FCP: p75 1.8s
  • 🟡 importSrpHome/INP: p75 288ms
  • 🟡 assetDetails/FCP: p75 2.0s
  • 🟡 solanaAssetDetails/FCP: p75 2.0s
  • 🟡 sendTransactions/FCP: p75 1.9s
  • 🟡 swap/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 12.03 KiB (0.08%)
  • ui: 1.05 KiB (0.01%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 1.81 KiB (0.09%)
  • zip: 3.24 KiB (0.01%)

@sirtimid

sirtimid commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing in favor of #44527 which will bump the wallet and contain this work as well

@sirtimid sirtimid closed this Jul 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 23, 2026

This branch was previously deployed

1 inactive deployment
pr-comment — f1627c1e Deployed Jul 20, 2026 by sirtimid via Publish prerelease / Publish prerelease #153089
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-M team-ocap-kernel The Ocap Kernel team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant