Skip to content

feat: reintroduce saved gas settings#43317

Open
pedronfigueiredo wants to merge 1 commit into
mainfrom
pnf/save-custom-gas-settings
Open

feat: reintroduce saved gas settings#43317
pedronfigueiredo wants to merge 1 commit into
mainfrom
pnf/save-custom-gas-settings

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

Re-introduces saved gas fee preferences for confirmations. Users can save low, medium, high, or custom gas settings from the gas edit modal and reuse that preference for future send or dapp transactions on the same account and chain.

Dapp-proposed fees still take precedence when present, and MM Pay/Swaps flows are excluded.

Related PRs:

Changelog

CHANGELOG entry: Added the ability to save gas fee preferences per account and network.

Related issues

Fixes:

Manual testing steps

  1. Start a send transaction on account 1 and network A.
  2. Open the gas edit modal and select low, medium, high, or custom.
  3. Save the preference and open another transaction on account 1 and network A.
  4. Confirm the saved gas preference is presented by default.
  5. Switch to another account or network and confirm the saved preference is not reused.
  6. Open a dapp transaction with proposed gas fees and confirm the dapp-proposed fees take precedence.

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

Medium Risk
Changes persisted preference shape and transaction default gas behavior; migration 214 intentionally clears unmappable legacy chain-scoped gas data, which can reset some users’ saved fees.

Overview
Reintroduces saved gas fee preferences scoped by account and chain, so confirmations can default to the user’s last low/medium/high/custom choice for that sender on that network.

Preferences & persistence: advancedGasFee moves from chain-only to chainId → account → { userFeeLevel, maxBaseFee, priorityFee, gasPrice }. setAdvancedGasFee requires account, normalizes addresses, supports per-account clear without wiping other accounts, and uses shared AdvancedGasFeePreferences types. Migration 214 drops legacy chain-scoped blobs that can’t be mapped to an account, keeps valid account-scoped data, and normalizes account keys to lowercase.

Transaction wiring: getSavedGasFees now takes full TransactionMeta, reads prefs by chainId + txParams.from, maps to SavedGasFees with a validated level, and returns nothing for MetaMask Pay transactions. The extension pins a preview @metamask/transaction-controller build for this API.

Confirmations UI: New usePersistGasFeePreference dispatches setAdvancedGasFee when users pick estimate levels or save advanced/custom gas modals. getAdvancedGasFeeValues reads prefs for the selected account on the current chain.

Metrics: Gas transaction metrics add gas_fee_presented (from default estimates) alongside gas_fee_selected, with dappSuggested normalized to dapp_proposed.

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

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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.

@mm-token-exchange-service

mm-token-exchange-service Bot commented Jun 8, 2026

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (11 files, +296 -19)
  • 📁 app/
    • 📁 scripts/
      • 📁 lib/
        • 📁 transaction/
          • 📁 metrics-builders/
            • 📄 gas.test.ts +18 -0
            • 📄 gas.ts +9 -4
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 components/
          • 📁 modals/
            • 📁 advanced-eip1559-modal/
              • 📄 advanced-eip1559-modal.test.tsx +39 -3
              • 📄 advanced-eip1559-modal.tsx +17 -3
            • 📁 advanced-gas-price-modal/
              • 📄 advanced-gas-price-modal.test.tsx +37 -3
              • 📄 advanced-gas-price-modal.tsx +16 -3
        • 📁 hooks/
          • 📁 gas/
            • 📄 useGasFeeEstimateLevelOptions.test.ts +70 -1
            • 📄 useGasFeeEstimateLevelOptions.ts +6 -1
            • 📄 useGasPriceEstimateOption.test.ts +44 -1
            • 📄 useGasPriceEstimateOption.ts +7 -0
            • 📄 usePersistGasFeePreference.ts +33 -0

👨‍🔧 @MetaMask/extension-platform (1 files, +2 -2)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +2 -2

📜 @MetaMask/policy-reviewers (12 files, +172 -8)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +21 -1
      • 📁 experimental/
        • 📄 policy.json +21 -1
      • 📁 flask/
        • 📄 policy.json +21 -1
      • 📁 main/
        • 📄 policy.json +21 -1
    • 📁 webpack/
      • 📁 mv2/
        • 📁 beta/
          • 📄 policy.json +20 -1
        • 📁 experimental/
          • 📄 policy.json +20 -1
        • 📁 flask/
          • 📄 policy.json +20 -1
        • 📁 main/
          • 📄 policy.json +20 -1
      • 📁 mv3/
        • 📁 beta/
          • 📄 policy.json +2 -0
        • 📁 experimental/
          • 📄 policy.json +2 -0
        • 📁 flask/
          • 📄 policy.json +2 -0
        • 📁 main/
          • 📄 policy.json +2 -0

Tip

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


🧪 @MetaMask/qa (1 files, +2 -2)
  • 📁 test/
    • 📁 e2e/
      • 📁 fixtures/
        • 📄 onboarding-fixture.json +2 -2

@github-actions github-actions Bot added the size-L label Jun 8, 2026
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review June 8, 2026 13:50
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner June 8, 2026 13:50
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from 3fe8c3e to 9cff38d Compare June 8, 2026 13:52
Comment thread ui/pages/confirmations/hooks/gas/usePersistGasFeePreference.ts
@metamaskbotv2

metamaskbotv2 Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
Builds ready [9cff38d]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 20 pass · 🟡 4 warn · 🔴 0 fail)

Baseline (latest main): 51036da | Date: 5/2/2026 | Pipeline: 27142419486 | 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]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: -71%
  • loadNewAccount/total: -71%
  • bridgeUserActions/bridge_load_page: -72%
  • bridgeUserActions/bridge_load_asset_picker: -53%
  • bridgeUserActions/bridge_search_token: -28%
  • bridgeUserActions/total: -40%
  • loadNewAccount/load_new_account: -56%
  • loadNewAccount/total: -56%
  • bridgeUserActions/bridge_load_page: +12%
  • bridgeUserActions/bridge_load_asset_picker: -35%
  • bridgeUserActions/bridge_search_token: -15%
  • bridgeUserActions/total: -11%
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: -26%
  • startupStandardHome/load: -28%
  • startupStandardHome/domContentLoaded: -28%
  • startupStandardHome/domInteractive: -42%
  • startupStandardHome/firstPaint: -10%
  • startupStandardHome/backgroundConnect: -16%
  • startupStandardHome/loadScripts: -28%
  • startupStandardHome/setupStore: -21%
  • startupStandardHome/numNetworkReqs: -67%
  • startupStandardHome/domInteractive: -53%
  • startupStandardHome/backgroundConnect: +12%
  • startupStandardHome/firstReactRender: +39%
  • startupStandardHome/initialActions: +20%
  • startupStandardHome/setupStore: -51%
  • startupStandardHome/numNetworkReqs: -37%
  • startupPowerUserHome/uiStartup: -22%
  • startupPowerUserHome/domInteractive: -73%
  • startupPowerUserHome/backgroundConnect: -59%
  • startupPowerUserHome/firstReactRender: +37%
  • startupPowerUserHome/setupStore: -68%
  • startupPowerUserHome/numNetworkReqs: -75%

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

  • 🟡 startupPowerUserHome/LCP: p75 3.0s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [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: -63%
  • onboardingImportWallet/pwFormToMetricsScreen: +534%
  • onboardingImportWallet/metricsToWalletReadyScreen: -22%
  • onboardingImportWallet/doneButtonToHomeScreen: -69%
  • onboardingImportWallet/total: -47%
  • onboardingNewWallet/srpButtonToPwForm: -76%
  • onboardingNewWallet/createPwToRecoveryScreen: +1176%
  • onboardingNewWallet/skipBackupToMetricsScreen: -66%
  • assetDetails/assetClickToPriceChart: -64%
  • assetDetails/total: -64%
  • solanaAssetDetails/assetClickToPriceChart: -72%
  • solanaAssetDetails/total: -72%
  • importSrpHome/loginToHomeScreen: -29%
  • importSrpHome/openAccountMenuAfterLogin: -74%
  • importSrpHome/homeAfterImportWithNewWallet: -81%
  • importSrpHome/total: -74%

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

  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.8s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: +27%
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2.15 KiB (0.04%)
  • ui: 5.32 KiB (0.05%)
  • common: 121 Bytes (0%)

@socket-security

socket-security Bot commented Jun 11, 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
Updated@​metamask/​transaction-controller@​67.0.0 ⏵ 68.0.0-preview-1a8241c00000
Updated@​metamask/​approval-controller@​9.0.1 ⏵ 9.0.21001007691 +6100
Updated@​metamask/​controller-utils@​12.1.0 ⏵ 12.2.09910077 +198 +4100
Updated@​metamask/​core-backend@​6.3.2 ⏵ 6.3.37810010097 +1100

View full report

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Jun 11, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from a8c28c4 to 5fe4823 Compare June 11, 2026 12:45
Comment thread ui/pages/confirmations/hooks/gas/usePersistGasFeePreference.ts
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from 5fe4823 to c8de7e5 Compare June 11, 2026 13:07
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner June 11, 2026 13:07

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 c8de7e5. Configure here.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from c8de7e5 to 93e2e73 Compare June 11, 2026 13:27
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner June 11, 2026 13:27
@metamaskbotv2

metamaskbotv2 Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
Builds ready [ddcc6f6] [reused from c8de7e5]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 9 warn · 🔴 1 fail)

Baseline (latest main): 697494a | Date: 6/11/2026 | Pipeline: 27350984717 | Baseline logs

Metricschrome-webpackfirefox-webpack
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 1 failure)

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: +28%
  • loadNewAccount/total: +28%
  • loadNewAccount/inp: -18%
  • loadNewAccount/fcp: +16%
  • confirmTx/inp: -18%
  • bridgeUserActions/bridge_load_page: +22%
  • bridgeUserActions/longTaskCount: -29%
  • bridgeUserActions/longTaskMaxDuration: +19%
  • bridgeUserActions/tbt: +54%
  • bridgeUserActions/inp: +53%
  • bridgeUserActions/fcp: +14%
  • bridgeUserActions/lcp: +21%
  • loadNewAccount/load_new_account: +39%
  • loadNewAccount/total: +39%
  • loadNewAccount/inp: -18%
  • loadNewAccount/lcp: +1113%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/inp: -18%
  • confirmTx/lcp: +1138%
  • bridgeUserActions/bridge_load_page: +180%
  • bridgeUserActions/bridge_load_asset_picker: +42%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +19%
  • bridgeUserActions/inp: -19%
  • bridgeUserActions/lcp: +1081%

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

  • 🟡 loadNewAccount/FCP: p75 2.1s
  • 🟡 bridgeUserActions/FCP: p75 1.9s
  • 🟡 loadNewAccount/FCP: p75 1.9s
  • 🟡 confirmTx/FCP: p75 1.8s
Startup Benchmarks · Samples: 100

⚠️ Missing data: firefox/webpack/startupPowerUserHome

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

  • startupPowerUserHome/numNetworkReqs: +50%
  • startupStandardHome/inp: -17%

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

  • 🔴 startupPowerUserHome/INP: p75 504ms
User Journey Benchmarks · Samples: 5 · mock API 🔴 1

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

Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [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]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/doneButtonToHomeScreen: -88%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -98%
  • onboardingImportWallet/longTaskCount: -71%
  • onboardingImportWallet/longTaskTotalDuration: -91%
  • onboardingImportWallet/longTaskMaxDuration: -88%
  • onboardingImportWallet/tbt: -98%
  • onboardingImportWallet/total: -88%
  • onboardingNewWallet/srpButtonToPwForm: +11%
  • onboardingNewWallet/createPwToRecoveryScreen: +12%
  • onboardingNewWallet/doneButtonToAssetList: -19%
  • onboardingNewWallet/longTaskTotalDuration: -27%
  • onboardingNewWallet/tbt: -31%
  • onboardingNewWallet/total: -16%
  • assetDetails/assetClickToPriceChart: +32%
  • assetDetails/longTaskCount: +67%
  • assetDetails/longTaskTotalDuration: +198%
  • assetDetails/longTaskMaxDuration: +334%
  • assetDetails/tbt: +1210%
  • assetDetails/total: +32%
  • assetDetails/inp: -38%
  • assetDetails/cls: -90%
  • solanaAssetDetails/assetClickToPriceChart: -78%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: -78%
  • solanaAssetDetails/cls: -92%
  • importSrpHome/loginToHomeScreen: -15%
  • importSrpHome/openAccountMenuAfterLogin: -23%
  • importSrpHome/homeAfterImportWithNewWallet: -48%
  • importSrpHome/longTaskCount: -11%
  • importSrpHome/longTaskTotalDuration: -26%
  • importSrpHome/tbt: -30%
  • importSrpHome/total: -39%
  • importSrpHome/inp: -33%
  • importSrpHome/lcp: -55%

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

  • 🟡 importSrpHome/FCP: p75 1.8s
  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 importSrpHome/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: 2.26 KiB (0.03%)
  • ui: 6.58 KiB (0.06%)
  • common: 23.65 KiB (0.18%)

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

Labels

risk:high size-L team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant