Skip to content

chore: add auth header to bridge-api token calls + use chain-agnostic gas fee estimates#40172

Merged
micaelae merged 53 commits intomainfrom
swaps3986-auth-header
Mar 4, 2026
Merged

chore: add auth header to bridge-api token calls + use chain-agnostic gas fee estimates#40172
micaelae merged 53 commits intomainfrom
swaps3986-auth-header

Conversation

@micaelae
Copy link
Member

@micaelae micaelae commented Feb 17, 2026

Description

Changes

  • Bumps the bridge-controller and bridge-status-controller versions
  • Use the gasFeeEstimatesByChainId state to calculate network fees instead of gasFeeEstimates
  • Add the Authorization header to bridge-api calls

Open in GitHub Codespaces

Changelog

CHANGELOG entry: chore: add auth header to bridge-api token calls, chore: use chain-agnostic gas fee estimates for calculating swap and bridge network fees

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3986

Manual testing steps

  1. No user facing changes

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.

Note

Medium Risk
Updates bridge controllers and request plumbing to include bearer authentication and to rely on chain-specific gas fee estimates, which can impact quote fetching and fee calculations across networks. Changes span background messaging, UI hooks, tests, and dependency/policy updates, increasing integration risk.

Overview
Bumps @metamask/bridge-controller/@metamask/bridge-status-controller (and removes the local Yarn patch) and adjusts controller init to pass clientId.

Adds bearer-token support for bridge API calls: introduces getBearerToken() (background request), allows AuthenticationController:getBearerToken through bridge-related messengers, and updates token-list fetchers (fetchPopularTokens/fetchTokensBySearchQuery) plus bridge hooks (usePopularTokens, useTokenSearchResults, useTokensWithFiltering) to fetch and forward a JWT via getClientHeaders.

Updates test fixtures/mocks to the new gas fee shape (gasFeeEstimatesByChainId) and to expect Authorization: Bearer ... headers; refreshes unit/e2e tests and LavaMoat policies accordingly.

Written by Cursor Bugbot for commit 07b4729. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Feb 17, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 17, 2026

✨ Files requiring CODEOWNER review ✨

📜 @MetaMask/policy-reviewers (8 files, +40 -72)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +5 -4
      • 📁 experimental/
        • 📄 policy.json +5 -4
      • 📁 flask/
        • 📄 policy.json +5 -4
      • 📁 main/
        • 📄 policy.json +5 -4
    • 📁 webpack/
      • 📁 mv2/
        • 📁 beta/
          • 📄 policy.json +5 -14
        • 📁 experimental/
          • 📄 policy.json +5 -14
        • 📁 flask/
          • 📄 policy.json +5 -14
        • 📁 main/
          • 📄 policy.json +5 -14

Tip

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


🔄 @MetaMask/swaps-engineers (11 files, +184 -208)
  • 📁 test/
    • 📁 data/
      • 📁 bridge/
        • 📄 mock-bridge-store.ts +25 -8
    • 📁 e2e/
      • 📁 tests/
        • 📁 bridge/
          • 📄 bridge-test-utils.ts +55 -38
  • 📁 ui/
    • 📁 ducks/
      • 📁 bridge/
        • 📄 selectors.test.ts +2 -2
    • 📁 hooks/
      • 📁 bridge/
        • 📄 usePopularTokens.ts +8 -2
        • 📄 useTokenSearchResults.ts +14 -5
        • 📄 useTokensWithFiltering.test.ts +13 -3
        • 📄 useTokensWithFiltering.ts +7 -1
    • 📁 pages/
      • 📁 bridge/
        • 📁 prepare/
          • 📁 __snapshots__/
            • 📄 bridge-input-group.test.tsx.snap +2 -108
            • 📄 bridge-input-group.test.tsx +36 -27
            • 📄 bridge-transaction-settings-modal.test.tsx +7 -4
        • 📁 utils/
          • 📄 tokens.ts +15 -10

@micaelae
Copy link
Member Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policy update failed. You can review the logs or retry the policy update here

1 similar comment
@metamaskbot
Copy link
Collaborator

Policy update failed. You can review the logs or retry the policy update here

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 18, 2026

Builds ready [6a3ab05]
📊 Page Load Benchmark Results

Current Commit: 6a3ab05 | Date: 2/18/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±82ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 749ms (±80ms) 🟢 | historical mean value: 741ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±13ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 82ms 1.01s 1.34s 1.32s 1.34s
domContentLoaded 749ms 80ms 706ms 1.03s 997ms 1.03s
firstPaint 81ms 13ms 60ms 188ms 92ms 188ms
firstContentfulPaint 81ms 13ms 60ms 188ms 92ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 71.4 KiB (1.66%)
  • ui: 620 Bytes (0.01%)
  • common: 123.64 KiB (1.13%)

@micaelae
Copy link
Member Author

@metamaskbot update-policies

@micaelae
Copy link
Member Author

micaelae commented Mar 3, 2026

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

No policy changes

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 3, 2026

Builds ready [c9ec827]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account30127132720306327
total30127132720306327
Confirm Txconfirm_tx6050601060742660706074
total6050601060742660706074
Bridge User Actionsbridge_load_page26825028615282286
bridge_load_asset_picker27021636654282366
bridge_search_token7327297342733734
total1264123413173212831317
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14281184170010414791617
load120499814309112591360
domContentLoaded119799314079012541354
domInteractive2917144212582
firstPaint166671177128218288
backgroundConnect21419525914219246
firstReactRender20125162133
initialActions105124
loadScripts99980512198910511160
setupStore1363861624
numNetworkReqs312289192282
Power User HomeuiStartup284515639638158932925233
load12321070170612412641506
domContentLoaded12151055160211812391498
domInteractive3421172183754
firstPaint1938442083269326
backgroundConnect880271506894012002762
firstReactRender25176482644
initialActions104112
loadScripts999848139111610281286
setupStore177195201736
numNetworkReqs75371462493113
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2232162285228228
srpButtonToSrpForm94949409494
confirmSrpToPwForm22222202222
pwFormToMetricsScreen15151601516
metricsToWalletReadyScreen16161601616
doneButtonToHomeScreen673595850101723850
openAccountMenuToAccountListLoaded295529452965829652965
total40253857418411841174184
Onboarding New WalletcreateWalletToSocialScreen2202202210221221
srpButtonToPwForm1111081142110114
createPwToRecoveryScreen999099
skipBackupToMetricsScreen38354023840
agreeButtonToOnboardingSuccess17161711717
doneButtonToAssetList63761767426674674
total1030100810652510651065
Asset DetailsassetClickToPriceChart48435655156
total48435655156
Solana Asset DetailsassetClickToPriceChart68667126871
total68667126871
Import Srp HomeloginToHomeScreen2037200220843520572084
openAccountMenuAfterLogin554181156481
homeAfterImportWithNewWallet2495243725775825222577
total4586452847026945704702
Send TransactionsopenSendPageFromHome21122762627
selectTokenToSendFormLoaded19182111921
reviewTransactionToConfirmationPage87884692834891928
total96188810988110061098
SwapopenSwapPageFromHome1078712415122124
fetchAndDisplaySwapQuotes269826932705427002705
total2806278028291828202829
🌐 Dapp Page Load Benchmarks

Current Commit: c9ec827 | Date: 3/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±76ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 743ms (±73ms) 🟢 | historical mean value: 740ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±11ms) 🟢 | historical mean value: 87ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 76ms 1.01s 1.35s 1.28s 1.35s
domContentLoaded 743ms 73ms 703ms 1.03s 956ms 1.03s
firstPaint 80ms 11ms 64ms 164ms 88ms 164ms
firstContentfulPaint 80ms 11ms 64ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -73.33 KiB (-1.37%)
  • ui: 744 Bytes (0.01%)
  • common: 91.55 KiB (0.82%)

Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 3, 2026

Builds ready [e95fbd0]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29127032922302329
total29127032922302329
Confirm Txconfirm_tx6069603961032460846103
total6069603961032460846103
Bridge User Actionsbridge_load_page28322235846297358
bridge_load_asset_picker23714628054280280
bridge_search_token71370172910711729
total1244113413398613061339
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup15111261201212215811694
load12751056165210613341449
domContentLoaded12681052164510613291441
domInteractive2916115222589
firstPaint180701442151241328
backgroundConnect22620146930225261
firstReactRender20124362131
initialActions107113
loadScripts1062839143210511141235
setupStore1386171420
numNetworkReqs312293202287
Power User HomeuiStartup17861444254419118342205
load12041088182716811861641
domContentLoaded11871065180615911701607
domInteractive3920197283789
firstPaint1928152197250356
backgroundConnect31326545235324391
firstReactRender24174872538
initialActions106113
loadScripts96384915451519481369
setupStore1784672028
numNetworkReqs58351722855144
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2182162201219220
srpButtonToSrpForm94939519595
confirmSrpToPwForm21212202122
pwFormToMetricsScreen16151911619
metricsToWalletReadyScreen16151601616
doneButtonToHomeScreen63360170741651707
openAccountMenuToAccountListLoaded2909289129241229212924
total3922385639945039633994
Onboarding New WalletcreateWalletToSocialScreen2202172242222224
srpButtonToPwForm1051041071105107
createPwToRecoveryScreen889099
skipBackupToMetricsScreen36353813738
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList51649854819515548
total90788493819906938
Asset DetailsassetClickToPriceChart42384534545
total42384534545
Solana Asset DetailsassetClickToPriceChart76688667886
total76688667886
Import Srp HomeloginToHomeScreen22721978256819823442568
openAccountMenuAfterLogin37294663846
homeAfterImportWithNewWallet2556252325963225792596
total49064609514021451165140
Send TransactionsopenSendPageFromHome23193252532
selectTokenToSendFormLoaded19172112021
reviewTransactionToConfirmationPage8508488521850852
total8938879015896901
SwapopenSwapPageFromHome1151101214116121
fetchAndDisplaySwapQuotes268926862691226902691
total2804279028171028122817
🌐 Dapp Page Load Benchmarks

Current Commit: e95fbd0 | Date: 3/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±41ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 735ms (±38ms) 🟢 | historical mean value: 738ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±12ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 41ms 1.02s 1.36s 1.09s 1.36s
domContentLoaded 735ms 38ms 708ms 1.03s 770ms 1.03s
firstPaint 81ms 12ms 64ms 184ms 92ms 184ms
firstContentfulPaint 81ms 12ms 64ms 184ms 92ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 5.17 MiB (100%)
  • ui: 8.15 MiB (100%)
  • common: 10.98 MiB (100%)

ghgoodreau
ghgoodreau previously approved these changes Mar 3, 2026
Copy link
Contributor

@MajorLift MajorLift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Policy changes LGTM

  • All changes are to internal packages
  • No changes to webpack/mv3 policies

Comment on lines -970 to -972
"globals": {
"Buffer.from": true
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global access removed

@socket-security
Copy link

socket-security bot commented Mar 4, 2026

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​bridge-status-controller@​68.0.0 ⏵ 67.0.198 +11007899 +1100
Updated@​metamask/​bridge-controller@​68.0.0 ⏵ 67.4.0100 +5100100 +22100 +2100

View full report

MajorLift
MajorLift previously approved these changes Mar 4, 2026
ghgoodreau
ghgoodreau previously approved these changes Mar 4, 2026
@micaelae
Copy link
Member Author

micaelae commented Mar 4, 2026

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

No policy changes

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 4, 2026

Builds ready [07b4729]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2752752760276276
total2752752760276276
Confirm Txconfirm_tx603560246044860406044
total603560246044860406044
Bridge User Actionsbridge_load_page2632602673267267
bridge_load_asset_picker20715824330226243
bridge_search_token71870274016726740
total1207109813759812281375
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14881264175610715431690
load1243105115169713021431
domContentLoaded1236104715019612981412
domInteractive291798192584
firstPaint170791444144218295
backgroundConnect22820328916235259
firstReactRender21125782335
initialActions109124
loadScripts102583312779310821211
setupStore1464181732
numNetworkReqs312285183178
Power User HomeuiStartup2201140810289143619904250
load12451065225318512461616
domContentLoaded12281060222617712331562
domInteractive4019204313797
firstPaint241711507192287400
backgroundConnect658266844713043352704
firstReactRender24156482636
initialActions105113
loadScripts997839191016510091321
setupStore1674571727
numNetworkReqs67321552676124
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212192232222223
srpButtonToSrpForm9590101498101
confirmSrpToPwForm21212202122
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151711617
doneButtonToHomeScreen727597963143817963
openAccountMenuToAccountListLoaded27952485312425629373124
total38883673409213839524092
Onboarding New WalletcreateWalletToSocialScreen2192172222221222
srpButtonToPwForm1081071091108109
createPwToRecoveryScreen989099
skipBackupToMetricsScreen35353613536
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList5024945126506512
total8888819018885901
Asset DetailsassetClickToPriceChart46395565255
total46395565255
Solana Asset DetailsassetClickToPriceChart71637657676
total71637657676
Import Srp HomeloginToHomeScreen191119021921719111921
openAccountMenuAfterLogin544166106566
homeAfterImportWithNewWallet27562523313624729633136
total46274491492317245624923
Send TransactionsopenSendPageFromHome19172322023
selectTokenToSendFormLoaded17161811818
reviewTransactionToConfirmationPage85784687913858879
total89388291312892913
SwapopenSwapPageFromHome9588102598102
fetchAndDisplaySwapQuotes268326812685126842685
total278027722783427832783
🌐 Dapp Page Load Benchmarks

Current Commit: 07b4729 | Date: 3/4/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.08s (±79ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 764ms (±76ms) 🟢 | historical mean value: 742ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±15ms) 🟢 | historical mean value: 82ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.08s 79ms 1.03s 1.38s 1.35s 1.38s
domContentLoaded 764ms 76ms 721ms 1.06s 1.02s 1.06s
firstPaint 83ms 15ms 64ms 220ms 92ms 220ms
firstContentfulPaint 83ms 15ms 64ms 220ms 92ms 220ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -73.33 KiB (-1.37%)
  • ui: 742 Bytes (0.01%)
  • common: 91.55 KiB (0.82%)

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

Labels

release-13.22.0 Issue or pull request that will be included in release 13.22.0 size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.