Skip to content

feat(transaction-controller): support saved gas fee levels - #8993

Merged
pedronfigueiredo merged 5 commits into
mainfrom
pnf/save-custom-gas-settings
Jul 10, 2026
Merged

feat(transaction-controller): support saved gas fee levels#8993
pedronfigueiredo merged 5 commits into
mainfrom
pnf/save-custom-gas-settings

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Explanation

This expands transaction-controller saved gas fee handling so clients can resolve saved preferences with full transaction metadata instead of only a chain ID. That lets consumers key saved gas settings by both chain and account while keeping the controller API responsible for applying saved fees.

The saved gas payload now supports gas fee estimate levels (low, medium, high) and legacy custom gasPrice values in addition to EIP-1559 custom fee values. Saved estimate levels reuse the current gas fee flow estimate for the saved level; custom values override only the specific saved fields.

Transactions that already include gas fee params continue to use those initial params, so dapp-proposed fees keep precedence over saved preferences. Swap transaction types continue to skip saved gas fees.

References

Related PRs:

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 client adoption work to resolve them

Note

Medium Risk
Breaking callback signature and changed gas-fee precedence logic can misprice dApp txs or break extension/mobile until consumers update; changes are confined to gas fee application paths with substantial test coverage.

Overview
Breaking change: getSavedGasFees now receives full TransactionMeta instead of chain ID so clients can key saved preferences by chain and account. The SavedGasFees shape adds optional estimate level, legacy gasPrice, and makes EIP-1559 fields optional.

Gas fee application in updateGasFees now skips saved lookup when the tx already has initial gas params (dapp fees win), still skips internal txs, and can pick low/medium/high from the current gas fee flow when only a level is saved. Custom maxBaseFee / priorityFee / gasPrice override specific fields; userFeeLevel stays on the saved level only when pricing is truly level-derived (otherwise custom).

Deprecated incoming transaction constructor options and restored no-op startIncomingTransactionPolling / stopIncomingTransactionPolling for backward compatibility, with tests.

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

@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch 2 times, most recently from 83cc6ba to ba63c2b Compare June 3, 2026 16:45
@pedronfigueiredo
pedronfigueiredo marked this pull request as ready for review June 8, 2026 13:23
@pedronfigueiredo
pedronfigueiredo requested review from a team as code owners June 8, 2026 13:23
vinistevam
vinistevam previously approved these changes Jun 9, 2026
@pedronfigueiredo
pedronfigueiredo added this pull request to the merge queue Jun 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 9, 2026
@pedronfigueiredo
pedronfigueiredo added this pull request to the merge queue Jun 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 11, 2026
@pedronfigueiredo
pedronfigueiredo added this pull request to the merge queue Jun 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 11, 2026
@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from ba63c2b to b620f8f Compare June 11, 2026 09:11
@pedronfigueiredo

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.2-preview-b620f8fc6
@metamask-previews/accounts-controller@39.0.1-preview-b620f8fc6
@metamask-previews/address-book-controller@7.1.2-preview-b620f8fc6
@metamask-previews/ai-controllers@0.7.0-preview-b620f8fc6
@metamask-previews/analytics-controller@1.1.1-preview-b620f8fc6
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-b620f8fc6
@metamask-previews/announcement-controller@8.1.0-preview-b620f8fc6
@metamask-previews/app-metadata-controller@2.0.1-preview-b620f8fc6
@metamask-previews/approval-controller@9.0.2-preview-b620f8fc6
@metamask-previews/assets-controller@9.0.1-preview-b620f8fc6
@metamask-previews/assets-controllers@109.0.0-preview-b620f8fc6
@metamask-previews/authenticated-user-storage@2.0.0-preview-b620f8fc6
@metamask-previews/base-controller@9.1.0-preview-b620f8fc6
@metamask-previews/base-data-service@0.1.3-preview-b620f8fc6
@metamask-previews/bridge-controller@75.1.1-preview-b620f8fc6
@metamask-previews/bridge-status-controller@72.1.0-preview-b620f8fc6
@metamask-previews/build-utils@3.0.4-preview-b620f8fc6
@metamask-previews/chain-agnostic-permission@1.6.1-preview-b620f8fc6
@metamask-previews/chomp-api-service@3.1.0-preview-b620f8fc6
@metamask-previews/claims-controller@0.5.3-preview-b620f8fc6
@metamask-previews/client-controller@1.0.1-preview-b620f8fc6
@metamask-previews/compliance-controller@2.1.0-preview-b620f8fc6
@metamask-previews/composable-controller@12.0.1-preview-b620f8fc6
@metamask-previews/config-registry-controller@0.4.1-preview-b620f8fc6
@metamask-previews/connectivity-controller@0.2.0-preview-b620f8fc6
@metamask-previews/controller-utils@12.2.0-preview-b620f8fc6
@metamask-previews/core-backend@6.3.3-preview-b620f8fc6
@metamask-previews/delegation-controller@3.0.2-preview-b620f8fc6
@metamask-previews/earn-controller@12.2.0-preview-b620f8fc6
@metamask-previews/eip-5792-middleware@3.0.4-preview-b620f8fc6
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-b620f8fc6
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-b620f8fc6
@metamask-previews/ens-controller@19.1.3-preview-b620f8fc6
@metamask-previews/eth-block-tracker@15.0.1-preview-b620f8fc6
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-b620f8fc6
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-b620f8fc6
@metamask-previews/foundryup@1.0.1-preview-b620f8fc6
@metamask-previews/gas-fee-controller@26.2.2-preview-b620f8fc6
@metamask-previews/gator-permissions-controller@4.2.0-preview-b620f8fc6
@metamask-previews/geolocation-controller@0.1.3-preview-b620f8fc6
@metamask-previews/json-rpc-engine@10.5.0-preview-b620f8fc6
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-b620f8fc6
@metamask-previews/keyring-controller@27.0.0-preview-b620f8fc6
@metamask-previews/logging-controller@8.0.2-preview-b620f8fc6
@metamask-previews/message-manager@14.1.2-preview-b620f8fc6
@metamask-previews/messenger@1.2.0-preview-b620f8fc6
@metamask-previews/messenger-cli@0.2.0-preview-b620f8fc6
@metamask-previews/money-account-balance-service@1.0.2-preview-b620f8fc6
@metamask-previews/money-account-controller@0.3.3-preview-b620f8fc6
@metamask-previews/money-account-upgrade-controller@2.0.4-preview-b620f8fc6
@metamask-previews/multichain-account-service@10.0.3-preview-b620f8fc6
@metamask-previews/multichain-api-middleware@3.1.3-preview-b620f8fc6
@metamask-previews/multichain-network-controller@3.1.3-preview-b620f8fc6
@metamask-previews/multichain-transactions-controller@7.1.1-preview-b620f8fc6
@metamask-previews/name-controller@9.1.2-preview-b620f8fc6
@metamask-previews/network-controller@32.0.0-preview-b620f8fc6
@metamask-previews/network-enablement-controller@5.3.0-preview-b620f8fc6
@metamask-previews/notification-services-controller@24.1.3-preview-b620f8fc6
@metamask-previews/passkey-controller@2.0.1-preview-b620f8fc6
@metamask-previews/permission-controller@13.1.1-preview-b620f8fc6
@metamask-previews/permission-log-controller@5.1.0-preview-b620f8fc6
@metamask-previews/perps-controller@8.1.0-preview-b620f8fc6
@metamask-previews/phishing-controller@17.2.0-preview-b620f8fc6
@metamask-previews/polling-controller@16.0.6-preview-b620f8fc6
@metamask-previews/preferences-controller@23.1.0-preview-b620f8fc6
@metamask-previews/profile-metrics-controller@3.2.0-preview-b620f8fc6
@metamask-previews/profile-sync-controller@28.1.1-preview-b620f8fc6
@metamask-previews/ramps-controller@14.1.1-preview-b620f8fc6
@metamask-previews/rate-limit-controller@7.0.1-preview-b620f8fc6
@metamask-previews/react-data-query@0.2.1-preview-b620f8fc6
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-b620f8fc6
@metamask-previews/sample-controllers@5.0.1-preview-b620f8fc6
@metamask-previews/seedless-onboarding-controller@10.0.2-preview-b620f8fc6
@metamask-previews/selected-network-controller@26.1.3-preview-b620f8fc6
@metamask-previews/shield-controller@5.1.2-preview-b620f8fc6
@metamask-previews/signature-controller@39.2.5-preview-b620f8fc6
@metamask-previews/snap-account-service@0.3.1-preview-b620f8fc6
@metamask-previews/social-controllers@2.2.1-preview-b620f8fc6
@metamask-previews/storage-service@1.0.2-preview-b620f8fc6
@metamask-previews/subscription-controller@6.1.3-preview-b620f8fc6
@metamask-previews/transaction-controller@67.1.0-preview-b620f8fc6
@metamask-previews/transaction-pay-controller@23.5.1-preview-b620f8fc6
@metamask-previews/user-operation-controller@41.2.4-preview-b620f8fc6
@metamask-previews/wallet@3.0.0-preview-b620f8fc6

@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from b620f8f to a8ca11c Compare June 11, 2026 11:50
@pedronfigueiredo

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.2-preview-a8ca11c
@metamask-previews/accounts-controller@39.0.1-preview-a8ca11c
@metamask-previews/address-book-controller@7.1.2-preview-a8ca11c
@metamask-previews/ai-controllers@0.7.0-preview-a8ca11c
@metamask-previews/analytics-controller@1.1.1-preview-a8ca11c
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-a8ca11c
@metamask-previews/announcement-controller@8.1.0-preview-a8ca11c
@metamask-previews/app-metadata-controller@2.0.1-preview-a8ca11c
@metamask-previews/approval-controller@9.0.2-preview-a8ca11c
@metamask-previews/assets-controller@9.0.1-preview-a8ca11c
@metamask-previews/assets-controllers@109.0.0-preview-a8ca11c
@metamask-previews/authenticated-user-storage@2.0.0-preview-a8ca11c
@metamask-previews/base-controller@9.1.0-preview-a8ca11c
@metamask-previews/base-data-service@0.1.3-preview-a8ca11c
@metamask-previews/bridge-controller@75.1.1-preview-a8ca11c
@metamask-previews/bridge-status-controller@72.1.0-preview-a8ca11c
@metamask-previews/build-utils@3.0.4-preview-a8ca11c
@metamask-previews/chain-agnostic-permission@1.6.1-preview-a8ca11c
@metamask-previews/chomp-api-service@3.1.0-preview-a8ca11c
@metamask-previews/claims-controller@0.5.3-preview-a8ca11c
@metamask-previews/client-controller@1.0.1-preview-a8ca11c
@metamask-previews/compliance-controller@2.1.0-preview-a8ca11c
@metamask-previews/composable-controller@12.0.1-preview-a8ca11c
@metamask-previews/config-registry-controller@0.4.1-preview-a8ca11c
@metamask-previews/connectivity-controller@0.2.0-preview-a8ca11c
@metamask-previews/controller-utils@12.2.0-preview-a8ca11c
@metamask-previews/core-backend@6.3.3-preview-a8ca11c
@metamask-previews/delegation-controller@3.0.2-preview-a8ca11c
@metamask-previews/earn-controller@12.2.0-preview-a8ca11c
@metamask-previews/eip-5792-middleware@3.0.4-preview-a8ca11c
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-a8ca11c
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-a8ca11c
@metamask-previews/ens-controller@19.1.3-preview-a8ca11c
@metamask-previews/eth-block-tracker@15.0.1-preview-a8ca11c
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-a8ca11c
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-a8ca11c
@metamask-previews/foundryup@1.0.1-preview-a8ca11c
@metamask-previews/gas-fee-controller@26.2.2-preview-a8ca11c
@metamask-previews/gator-permissions-controller@4.2.0-preview-a8ca11c
@metamask-previews/geolocation-controller@0.1.3-preview-a8ca11c
@metamask-previews/json-rpc-engine@10.5.0-preview-a8ca11c
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-a8ca11c
@metamask-previews/keyring-controller@27.0.0-preview-a8ca11c
@metamask-previews/logging-controller@8.0.2-preview-a8ca11c
@metamask-previews/message-manager@14.1.2-preview-a8ca11c
@metamask-previews/messenger@1.2.0-preview-a8ca11c
@metamask-previews/messenger-cli@0.2.0-preview-a8ca11c
@metamask-previews/money-account-balance-service@1.0.2-preview-a8ca11c
@metamask-previews/money-account-controller@0.3.3-preview-a8ca11c
@metamask-previews/money-account-upgrade-controller@2.0.5-preview-a8ca11c
@metamask-previews/multichain-account-service@10.0.3-preview-a8ca11c
@metamask-previews/multichain-api-middleware@3.1.3-preview-a8ca11c
@metamask-previews/multichain-network-controller@3.1.3-preview-a8ca11c
@metamask-previews/multichain-transactions-controller@7.1.1-preview-a8ca11c
@metamask-previews/name-controller@9.1.2-preview-a8ca11c
@metamask-previews/network-controller@32.0.0-preview-a8ca11c
@metamask-previews/network-enablement-controller@5.3.0-preview-a8ca11c
@metamask-previews/notification-services-controller@24.1.3-preview-a8ca11c
@metamask-previews/passkey-controller@2.0.1-preview-a8ca11c
@metamask-previews/permission-controller@13.1.1-preview-a8ca11c
@metamask-previews/permission-log-controller@5.1.0-preview-a8ca11c
@metamask-previews/perps-controller@8.1.0-preview-a8ca11c
@metamask-previews/phishing-controller@17.2.0-preview-a8ca11c
@metamask-previews/polling-controller@16.0.6-preview-a8ca11c
@metamask-previews/preferences-controller@23.1.0-preview-a8ca11c
@metamask-previews/profile-metrics-controller@3.2.0-preview-a8ca11c
@metamask-previews/profile-sync-controller@28.1.1-preview-a8ca11c
@metamask-previews/ramps-controller@14.1.1-preview-a8ca11c
@metamask-previews/rate-limit-controller@7.0.1-preview-a8ca11c
@metamask-previews/react-data-query@0.2.1-preview-a8ca11c
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-a8ca11c
@metamask-previews/sample-controllers@5.0.1-preview-a8ca11c
@metamask-previews/seedless-onboarding-controller@10.0.2-preview-a8ca11c
@metamask-previews/selected-network-controller@26.1.3-preview-a8ca11c
@metamask-previews/shield-controller@5.1.2-preview-a8ca11c
@metamask-previews/signature-controller@39.2.5-preview-a8ca11c
@metamask-previews/snap-account-service@0.3.1-preview-a8ca11c
@metamask-previews/social-controllers@2.2.1-preview-a8ca11c
@metamask-previews/storage-service@1.0.2-preview-a8ca11c
@metamask-previews/subscription-controller@6.2.0-preview-a8ca11c
@metamask-previews/transaction-controller@68.0.0-preview-a8ca11c
@metamask-previews/transaction-pay-controller@23.5.1-preview-a8ca11c
@metamask-previews/user-operation-controller@41.2.4-preview-a8ca11c
@metamask-previews/wallet@3.0.0-preview-a8ca11c

@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from a8ca11c to 1a8241c Compare June 11, 2026 12:12
@pedronfigueiredo

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.2-preview-1a8241c
@metamask-previews/accounts-controller@39.0.1-preview-1a8241c
@metamask-previews/address-book-controller@7.1.2-preview-1a8241c
@metamask-previews/ai-controllers@0.7.0-preview-1a8241c
@metamask-previews/analytics-controller@1.1.1-preview-1a8241c
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-1a8241c
@metamask-previews/announcement-controller@8.1.0-preview-1a8241c
@metamask-previews/app-metadata-controller@2.0.1-preview-1a8241c
@metamask-previews/approval-controller@9.0.2-preview-1a8241c
@metamask-previews/assets-controller@9.0.1-preview-1a8241c
@metamask-previews/assets-controllers@109.0.0-preview-1a8241c
@metamask-previews/authenticated-user-storage@2.0.0-preview-1a8241c
@metamask-previews/base-controller@9.1.0-preview-1a8241c
@metamask-previews/base-data-service@0.1.3-preview-1a8241c
@metamask-previews/bridge-controller@75.1.1-preview-1a8241c
@metamask-previews/bridge-status-controller@72.1.0-preview-1a8241c
@metamask-previews/build-utils@3.0.4-preview-1a8241c
@metamask-previews/chain-agnostic-permission@1.6.1-preview-1a8241c
@metamask-previews/chomp-api-service@3.1.0-preview-1a8241c
@metamask-previews/claims-controller@0.5.3-preview-1a8241c
@metamask-previews/client-controller@1.0.1-preview-1a8241c
@metamask-previews/compliance-controller@2.1.0-preview-1a8241c
@metamask-previews/composable-controller@12.0.1-preview-1a8241c
@metamask-previews/config-registry-controller@0.4.1-preview-1a8241c
@metamask-previews/connectivity-controller@0.2.0-preview-1a8241c
@metamask-previews/controller-utils@12.2.0-preview-1a8241c
@metamask-previews/core-backend@6.3.3-preview-1a8241c
@metamask-previews/delegation-controller@3.0.2-preview-1a8241c
@metamask-previews/earn-controller@12.2.0-preview-1a8241c
@metamask-previews/eip-5792-middleware@3.0.4-preview-1a8241c
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-1a8241c
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-1a8241c
@metamask-previews/ens-controller@19.1.3-preview-1a8241c
@metamask-previews/eth-block-tracker@15.0.1-preview-1a8241c
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-1a8241c
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-1a8241c
@metamask-previews/foundryup@1.0.1-preview-1a8241c
@metamask-previews/gas-fee-controller@26.2.2-preview-1a8241c
@metamask-previews/gator-permissions-controller@4.2.0-preview-1a8241c
@metamask-previews/geolocation-controller@0.1.3-preview-1a8241c
@metamask-previews/json-rpc-engine@10.5.0-preview-1a8241c
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-1a8241c
@metamask-previews/keyring-controller@27.0.0-preview-1a8241c
@metamask-previews/logging-controller@8.0.2-preview-1a8241c
@metamask-previews/message-manager@14.1.2-preview-1a8241c
@metamask-previews/messenger@1.2.0-preview-1a8241c
@metamask-previews/messenger-cli@0.2.0-preview-1a8241c
@metamask-previews/money-account-balance-service@1.0.2-preview-1a8241c
@metamask-previews/money-account-controller@0.3.3-preview-1a8241c
@metamask-previews/money-account-upgrade-controller@2.0.5-preview-1a8241c
@metamask-previews/multichain-account-service@10.0.3-preview-1a8241c
@metamask-previews/multichain-api-middleware@3.1.3-preview-1a8241c
@metamask-previews/multichain-network-controller@3.1.3-preview-1a8241c
@metamask-previews/multichain-transactions-controller@7.1.1-preview-1a8241c
@metamask-previews/name-controller@9.1.2-preview-1a8241c
@metamask-previews/network-controller@32.0.0-preview-1a8241c
@metamask-previews/network-enablement-controller@5.3.0-preview-1a8241c
@metamask-previews/notification-services-controller@24.1.3-preview-1a8241c
@metamask-previews/passkey-controller@2.0.1-preview-1a8241c
@metamask-previews/permission-controller@13.1.1-preview-1a8241c
@metamask-previews/permission-log-controller@5.1.0-preview-1a8241c
@metamask-previews/perps-controller@8.1.0-preview-1a8241c
@metamask-previews/phishing-controller@17.2.0-preview-1a8241c
@metamask-previews/polling-controller@16.0.6-preview-1a8241c
@metamask-previews/preferences-controller@23.1.0-preview-1a8241c
@metamask-previews/profile-metrics-controller@3.2.0-preview-1a8241c
@metamask-previews/profile-sync-controller@28.1.1-preview-1a8241c
@metamask-previews/ramps-controller@14.1.1-preview-1a8241c
@metamask-previews/rate-limit-controller@7.0.1-preview-1a8241c
@metamask-previews/react-data-query@0.2.1-preview-1a8241c
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-1a8241c
@metamask-previews/sample-controllers@5.0.1-preview-1a8241c
@metamask-previews/seedless-onboarding-controller@10.0.2-preview-1a8241c
@metamask-previews/selected-network-controller@26.1.3-preview-1a8241c
@metamask-previews/shield-controller@5.1.2-preview-1a8241c
@metamask-previews/signature-controller@39.2.5-preview-1a8241c
@metamask-previews/snap-account-service@0.3.1-preview-1a8241c
@metamask-previews/social-controllers@2.2.1-preview-1a8241c
@metamask-previews/storage-service@1.0.2-preview-1a8241c
@metamask-previews/subscription-controller@6.2.0-preview-1a8241c
@metamask-previews/transaction-controller@68.0.0-preview-1a8241c
@metamask-previews/transaction-pay-controller@23.5.1-preview-1a8241c
@metamask-previews/user-operation-controller@41.2.4-preview-1a8241c
@metamask-previews/wallet@3.0.0-preview-1a8241c

dan437
dan437 previously approved these changes Jun 15, 2026
Comment thread packages/transaction-controller/CHANGELOG.md Outdated
@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from 69d8cef to 2ecedf3 Compare July 3, 2026 10:49
Comment thread packages/transaction-controller/src/utils/gas-fees.ts Outdated
@pedronfigueiredo
pedronfigueiredo force-pushed the pnf/save-custom-gas-settings branch from 7c33a6f to 0d8540e Compare July 7, 2026 12:49

@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 0d8540e. Configure here.

Comment thread packages/transaction-controller/src/utils/gas-fees.ts
dan437
dan437 previously approved these changes Jul 9, 2026
pedronfigueiredo and others added 4 commits July 10, 2026 13:49
…even when a level is set

Revert an unrelated edit to the already-released 68.0.0 changelog entry
that crept in from a prior rebase, and fix getUserFeeLevel to return
CUSTOM whenever savedGasFees includes an explicit maxBaseFee,
priorityFee, or gasPrice override, even if a level is also present.
Without this, GasFeePoller would treat the transaction as fully
level-tracked and silently overwrite the custom override on the next
automatic gas fee update.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…eeLevel when actually applied

Cursor Bugbot flagged that a saved gas fee level (e.g. 'high') could be
reflected in txMeta.userFeeLevel even when the resolved fee wasn't
actually derived from that level - specifically when the gas fee flow
returns a flat eth_gasPrice-type estimate, or when the flow throws and
a raw eth_gasPrice RPC fallback is used. In both cases there are no
per-level values to select from, so labelling userFeeLevel with the
saved level was misleading.

Track whether the suggested fee was actually derived from a per-level
lookup and only preserve the saved level in userFeeLevel when it was;
otherwise fall back to CUSTOM.
dan437
dan437 previously approved these changes Jul 10, 2026
…eased 68.3.0 section to Unreleased

The rebase auto-merge placed our saved-gas-fee-levels changelog entry
under the already-released [68.3.0] section instead of [Unreleased],
since that's where the surrounding context lines used to live before
68.3.0 was cut. Move it back to [Unreleased].
@pedronfigueiredo
pedronfigueiredo added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit 54be8f0 Jul 10, 2026
421 checks passed
@pedronfigueiredo
pedronfigueiredo deleted the pnf/save-custom-gas-settings branch July 10, 2026 13:11
@pedronfigueiredo pedronfigueiredo mentioned this pull request Jul 10, 2026
2 tasks
DDDDDanica pushed a commit to MetaMask/metamask-extension that referenced this pull request Jul 14, 2026
## **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:
- MetaMask/core#8993
- MetaMask/metamask-mobile#31649

## **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.

<!--
## **Screenshots/Recordings**

### **Before**

### **After**
-->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes persisted preference shape and transaction default gas
behavior; migration clears legacy chain-scoped fees, which can reset
saved settings for some users.
> 
> **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 and persistence:** `advancedGasFee` moves from
chain-only to **chain → account →** `AdvancedGasFeePreferences`
(including `userFeeLevel`). `setAdvancedGasFee` requires `account`,
normalizes addresses, supports per-account clear when
`gasFeePreferences` is omitted, and typed prefs replace loose string
maps. UI adds `usePersistGasFeePreference` and wires save/select paths
in gas modals and estimate hooks; `getAdvancedGasFeeValues` reads the
**selected account** on the current chain.
> 
> **Transaction wiring:** `getSavedGasFees` takes full
`TransactionMeta`, looks up prefs by `from` + `chainId`, maps to
`SavedGasFees`, and returns nothing for **MetaMask Pay** transactions.
Bumps `@metamask/transaction-controller` to **^69.0.0** and
`@metamask/wallet` to **^7.0.1**.
> 
> **Migration 218:** Converts or drops legacy chain-scoped fee blobs;
keeps valid account-scoped data (lowercase keys); clears unmigratable
legacy/malformed entries. Fixtures and mock state move to version
**218**.
> 
> **Metrics:** Gas metrics add `gas_fee_presented` from default
estimates and share `dappSuggested` → `dapp_proposed` normalization for
selected vs presented levels.
> 
> LavaMoat policy updates are dependency graph alignment for nested
`transaction-controller` copies.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9310301. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
pull Bot pushed a commit to Reality2byte/metamask-extension that referenced this pull request Jul 14, 2026
## **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:
- MetaMask/core#8993
- MetaMask/metamask-mobile#31649

## **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.

<!--
## **Screenshots/Recordings**

### **Before**

### **After**
-->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes persisted preference shape and transaction default gas
behavior; migration clears legacy chain-scoped fees, which can reset
saved settings for some users.
> 
> **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 and persistence:** `advancedGasFee` moves from
chain-only to **chain → account →** `AdvancedGasFeePreferences`
(including `userFeeLevel`). `setAdvancedGasFee` requires `account`,
normalizes addresses, supports per-account clear when
`gasFeePreferences` is omitted, and typed prefs replace loose string
maps. UI adds `usePersistGasFeePreference` and wires save/select paths
in gas modals and estimate hooks; `getAdvancedGasFeeValues` reads the
**selected account** on the current chain.
> 
> **Transaction wiring:** `getSavedGasFees` takes full
`TransactionMeta`, looks up prefs by `from` + `chainId`, maps to
`SavedGasFees`, and returns nothing for **MetaMask Pay** transactions.
Bumps `@metamask/transaction-controller` to **^69.0.0** and
`@metamask/wallet` to **^7.0.1**.
> 
> **Migration 218:** Converts or drops legacy chain-scoped fee blobs;
keeps valid account-scoped data (lowercase keys); clears unmigratable
legacy/malformed entries. Fixtures and mock state move to version
**218**.
> 
> **Metrics:** Gas metrics add `gas_fee_presented` from default
estimates and share `dappSuggested` → `dapp_proposed` normalization for
selected vs presented levels.
> 
> LavaMoat policy updates are dependency graph alignment for nested
`transaction-controller` copies.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9310301. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
pull Bot pushed a commit to Reality2byte/metamask-mobile that referenced this pull request Jul 14, 2026
## Summary
- Persist custom gas fee settings from the advanced gas modals.
- Read saved gas preferences when building fee options for send
confirmations.
- Wire mobile PreferencesController and TransactionController
integration for saved gas fee preferences.

## Related PRs
- MetaMask/metamask-extension#43317
- MetaMask/core#8993

## Testing
- `yarn jest
app/components/Views/confirmations/components/modals/advanced-eip1559-modal/advanced-eip1559-modal.test.tsx
app/components/Views/confirmations/components/modals/advanced-gas-price-modal/advanced-gas-price-modal.test.tsx
app/components/Views/confirmations/hooks/gas/useGasFeeEstimateLevelOptions.test.ts
app/components/Views/confirmations/hooks/gas/useGasPriceEstimateOption.test.ts
app/components/Views/confirmations/hooks/gas/usePersistGasFeePreference.test.ts
app/core/Engine/controllers/preferences-controller-init.test.ts
app/core/Engine/controllers/transaction-controller/metrics_properties/gas.test.ts
app/core/Engine/controllers/transaction-controller/transaction-controller-init.test.ts`
(8 suites, 78 tests).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes how default and custom gas fees are stored and applied for
sends; incorrect lookup or validation could affect fee defaults, though
saves are gated on complete custom values and covered by new tests.
> 
> **Overview**
> Adds **per-account, per-chain persistence** for gas choices so
confirmations can reuse the user’s last fee level or custom values.
> 
> On save, confirmation gas flows call **`usePersistGasFeePreference`**,
which writes to **`PreferencesController.setAdvancedGasFee`**
(`advancedGasFee` is persisted state). Advanced EIP-1559 and legacy gas
price modals share **`useAdvancedGasFeeModal`**, which blocks save when
custom fees are incomplete and persists mapped preferences (e.g. max
base / priority fee). Preset estimate levels and gas-price estimate
options persist the selected **`userFeeLevel`** as well.
> 
> **`TransactionController`** is upgraded to **69.0.0** and receives a
**`getSavedGasFees`** hook that reads those preferences for the
transaction’s `from` address and chain. Gas metrics now report
**`dapp_proposed`** when **`UserFeeLevel.DAPP_SUGGESTED`** is selected.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3041ea6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
pull Bot pushed a commit to dmrazzy/core that referenced this pull request Aug 4, 2026
…sted estimates (MetaMask#9704)

## Explanation

Underpriced gas fees — a `maxFeePerGas` below (or barely above) the
current base fee — produce transactions that are very unlikely to be
included before fee conditions change further. They typically end up
stuck as pending until eventually marked as failed (e.g. `Transaction
not found on network after timeout`), with no actionable feedback to the
user. Telemetry shows this is a meaningful contributor to
dropped/timed-out transactions.

Two fee sources can produce such values, and nothing in the client
validates either against current network conditions. This PR adds a
feature-flag-gated staleness gate for both, at transaction creation time
— the last point where fees can still be changed before signing.

### 1. Dapp-suggested fees (`replaceUnderpricedDappGasFees` flag)

Currently:

- `updateGasFees` uses `initialParams.maxFeePerGas` as-is.
- Gas estimation deliberately strips fee fields before calling the RPC
node, so the node's own fee-cap validation never runs.
- `GasFeePoller` only refreshes fees for preset levels, so
`dappSuggested` fees stay frozen while the confirmation is open.

A dapp that computes fees from stale data can therefore produce a signed
transaction that cannot mine. With the flag enabled:

- A new `shouldIgnoreDappGasFees` check fires when the dapp-suggested
`maxFeePerGas` (or a legacy `gasPrice` used as `maxFeePerGas` on
EIP-1559 networks) is below the current **low** estimate. The low
estimate is the floor rather than the raw base fee, since fees between
the base fee and the low estimate have near-zero effective priority fee
and no headroom for base fee movement, so they share the same failure
mode.
- When it fires, the transaction falls through to the existing suggested
(medium) fee logic for both `maxFeePerGas` and `maxPriorityFeePerGas`.
- `userFeeLevel` is set to `medium` instead of `dappSuggested`, which
also opts the transaction into `GasFeePoller` refresh while unapproved.
- The original values remain available via `dappSuggestedGasFees` on the
transaction metadata, so UIs can still display the site suggestion and
users can revert via the edit modal.

Note: for transactions with complete dapp-suggested fees,
`getSuggestedGasFees` previously skipped fetching estimates entirely.
When the flag is enabled, estimates are now fetched for these
transactions so the comparison can run — one additional gas fee estimate
call per dapp transaction on enabled chains.

### 2. Saved (advanced) gas fee preferences
(`replaceUnderpricedSavedGasFees` flag)

A saved *custom* preference is a static `maxBaseFee` captured at some
point in the past; once the base fee rises past it, every transaction
priced from it strands. Nothing else guards this source: the dapp gate
deliberately excludes `savedGasFees`, and `hasInitialGasFeeParams` only
protects transactions carrying explicit fee params — saved fees apply
precisely when they don't. This is increasingly relevant as clients
expand saved-preference usage (per-account custom gas settings persisted
from the confirmation flow, and MetaMask#9682 extending saved fees to
wallet-initiated transfers).

With the flag enabled:

- After suggested fees are fetched, if the saved preference has a custom
`maxBaseFee` below the current low estimate, the saved preference is
ignored for this transaction and the suggested (medium) values are used
instead.
- **Level-based saved preferences (`low`/`medium`/`high`) are never
touched** — they track current estimates by construction.
- `userFeeLevel` becomes `medium` instead of `custom`, with the same
`GasFeePoller` refresh benefit.
- No fetch-path changes needed: transactions eligible for saved fees
carry no fee params, so estimates are already fetched.

### Guards / fail-open behavior (both gates)

Fees are kept unchanged when: the respective feature flag is not enabled
for the chain (both default to disabled; per-chain rollout via
`perChainConfig` with `default` fallback, mirroring `timeoutAttempts`);
the transaction is internal (dapp gate; swaps/bridges are priced by the
aggregator/relay); the fee is at or above the low estimate; or estimates
are unavailable / not fee-market type.

### The product decision (saved-fees gate)

Overriding a value the *user* saved is a stronger intervention than
overriding a dapp's computed value. Three defensible behaviors when the
saved-fees gate fires: (1) silently use suggested fees (this PR's
behavior), (2) use suggested fees + surface an alert ("your saved gas
setting is below current network fees"), (3) keep the saved value + warn
only. The flag ships disabled, so this can be settled before enablement.

An argument for intervening (1 or 2) rather than deferring entirely to
the saved value: **saved preferences already do not grant full
autonomy.** The controller already ignores them for swaps and bridges
(`SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES`, MetaMask#9401/MetaMask#9682) — explicitly
because a saved fee could underprice aggregator-priced transactions —
and already yields them to explicit fee params
(`hasInitialGasFeeParams`, MetaMask#8993). The established principle is that
saved preferences apply *where they can work* and yield *where they
would predictably break the transaction*. A custom `maxBaseFee` below
the current low estimate is the clearest instance of the latter — this
extends existing precedent rather than setting new one.

## References

- Prior art for saved-fee exclusions: MetaMask#9401, MetaMask#9682, MetaMask#8993
- Known edge case (fee bump vs. dapp max-spend arithmetic) and proposed
balance-clamp refinement: see PR comment below — it applies to both
gates.

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes pre-sign gas selection for dapp and saved-fee paths when flags
are enabled; behavior is gated and fail-open, but wrong thresholds or
rollout could surprise users or sites.
> 
> **Overview**
> Adds **opt-in, per-chain** gates in `updateGasFees` so transactions
are less likely to be priced below current network conditions before
approval.
> 
> When **`replaceUnderpricedDappGasFees`** is enabled, dapp-suggested
EIP-1559 fees whose effective `maxFeePerGas` (including legacy
`gasPrice` used as max fee) is **below the wallet’s low estimate** are
replaced with **suggested medium** `maxFeePerGas` /
`maxPriorityFeePerGas`. **`userFeeLevel`** becomes **`medium`** instead
of **`dappSuggested`**, so fees can keep updating while unapproved;
originals stay on **`dappSuggestedGasFees`**. Complete dapp fee params
no longer skip estimate fetch when this flag is on (needed for the
comparison; fail-open if estimates are missing).
> 
> When **`replaceUnderpricedSavedGasFees`** is enabled, saved **custom**
`maxBaseFee` below the low estimate is **dropped** for that tx so medium
suggestions apply; **level-based** saved prefs are unchanged.
**`userFeeLevel`** becomes **`medium`** instead of **`custom`**.
> 
> New remote feature-flag helpers and types mirror existing per-chain
`default` / `perChainConfig` patterns; both flags default to
**disabled**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
95e622d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

3 participants