Skip to content

feat: SUBS-814 - optimize gas fees for Shield crypto subscription#39931

Merged
chaitanyapotti merged 12 commits intomainfrom
feat/SUBS-814-improve-gas-fee-subscription
Feb 13, 2026
Merged

feat: SUBS-814 - optimize gas fees for Shield crypto subscription#39931
chaitanyapotti merged 12 commits intomainfrom
feat/SUBS-814-improve-gas-fee-subscription

Conversation

@tanguyenvn
Copy link
Copy Markdown
Contributor

@tanguyenvn tanguyenvn commented Feb 10, 2026

Description

Optimize gas fees for Shield crypto subscription approval transactions to reduce over-funding during gas sponsorship.

Changes:

  1. Implement gas fee optimization formula: min(2 * low, medium) for priority fees on EIP-1559 networks
  2. Use useGasFeeEstimates hook to get real-time gas estimates for the target chain
  3. Set disableGasBuffer: true to prevent automatic gas limit buffering by TransactionController
  4. Remove redundant manual estimateGas call (TransactionController handles this internally)

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Optimized gas fees for Shield crypto subscription transactions to reduce sponsorship costs

Related issues

Fixes: SUBS-814

Manual testing steps

  1. Go to Settings > Shield > Subscribe with Crypto
  2. Select a token on an EIP-1559 network (e.g., Ethereum mainnet)
  3. Initiate a subscription approval transaction
  4. Verify in the confirmation screen that maxPriorityFeePerGas uses the optimized formula
  5. Complete the transaction and verify it succeeds with lower gas costs

Screenshots/Recordings

Before

N/A - Internal gas fee changes, no UI changes

After

N/A - Internal gas fee changes, no UI changes

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.

Made with Cursor


Note

Medium Risk
Touches transaction-parameter construction for subscription approval flows; mistakes could lead to underpriced transactions or failures on EIP-1559 networks, though guarded by estimate-type checks and tests.

Overview
Reduces over-funding of Shield crypto subscription approval transactions by overriding the EIP-1559 maxPriorityFeePerGas on shieldSubscriptionApprove transactions using min(2 × low, medium) from live useGasFeeEstimates for the token’s chain.

Adds a focused unit test suite for useSubscriptionCryptoApprovalTransaction covering fee-market vs legacy networks and missing/invalid estimates, and updates the Jest console baseline to allow the new test’s Router warnings.

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

tanguyenvn and others added 2 commits February 10, 2026 10:33
…sactions

use min(2 * low, medium) formula to reduce over-funding in gas sponsorship

Co-authored-by: Cursor <cursoragent@cursor.com>
disableGasBuffer: true already ensures raw gas estimate is used
Co-authored-by: Cursor <cursoragent@cursor.com>
@tanguyenvn tanguyenvn requested a review from a team as a code owner February 10, 2026 05:36
@tanguyenvn tanguyenvn self-assigned this Feb 10, 2026
@github-actions
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.

@metamaskbot metamaskbot added the team-shield Shield team label Feb 10, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 10, 2026

✨ Files requiring CODEOWNER review ✨

🔐 @MetaMask/web3auth (2 files, +354 -9)
  • 📁 ui/
    • 📁 hooks/
      • 📁 subscription/
        • 📄 useSubscription.test.ts +283 -0
        • 📄 useSubscription.ts +71 -9

@tanguyenvn tanguyenvn marked this pull request as draft February 10, 2026 05:37
decGWEIToHexWEI returns hex strings without 0x prefix. Following
codebase convention (toHexWei in metamask.js), wrap with addHexPrefix
to ensure proper hex format for maxPriorityFeePerGas and maxFeePerGas.

Co-authored-by: Cursor <cursoragent@cursor.com>
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 10, 2026

Builds ready [9491f11]
UI Startup Metrics (1300 ± 97 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1300111715809713551468
load112295413618811641280
domContentLoaded111594913488811581268
domInteractive251486172167
firstPaint190581176193191314
backgroundConnect21419326612215242
firstReactRender1693751725
initialActions105113
loadScripts9157421156889601066
setupStore1262651523
numNetworkReqs231598221587
BrowserifyPower User HomeuiStartup17711393240418418262229
load11791042182116811611674
domContentLoaded11611030176915811411579
domInteractive3518149243584
firstPaint229741735262260321
backgroundConnect32629139723334373
firstReactRender22164562335
initialActions105112
loadScripts91478614901538981324
setupStore1654771830
numNetworkReqs1194825444144207
WebpackStandard HomeuiStartup796677129193826970
load695600102882744841
domContentLoaded690596102482739835
domInteractive2616104192281
firstPaint1176162376141211
backgroundConnect25175682641
firstReactRender14103341620
initialActions103112
loadScripts688594101681737833
setupStore1153751219
numNetworkReqs221585201580
WebpackPower User HomeuiStartup1222897193916713011563
load71060913231266921049
domContentLoaded70060213181256821038
domInteractive37182203832126
firstPaint1426547690167305
backgroundConnect16513234348160277
firstReactRender21173532328
initialActions104111
loadScripts69860013061226801029
setupStore1143841317
numNetworkReqs1194728753145246
FirefoxBrowserifyStandard HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
initialActions------
loadScripts------
setupStore------
numNetworkReqs------
BrowserifyPower User HomeuiStartup27361970365835129313492
load15551291232824716072182
domContentLoaded15541290232724716062181
domInteractive11935734134105444
firstPaint------
backgroundConnect251118999211244898
firstReactRender20156572126
initialActions203122
loadScripts15161261230323815292134
setupStore1498751192192572
numNetworkReqs67381653490129
WebpackStandard HomeuiStartup15391320198312115811800
load1331119715617913801481
domContentLoaded1331119615607913781481
domInteractive812814535113133
firstPaint------
backgroundConnect52212123055104
firstReactRender1410116101418
initialActions1037412
loadScripts1304117814887313541426
setupStore156160211250
numNetworkReqs231392181878
WebpackPower User HomeuiStartup26811992389344427653642
load15271259260829516672201
domContentLoaded15271259260329516662201
domInteractive12432742140107561
firstPaint------
backgroundConnect271111949198268832
firstReactRender22156462430
initialActions203123
loadScripts14851208258627916082000
setupStore1739824224227647
numNetworkReqs65351553295123
📊 Page Load Benchmark Results

Current Commit: 9491f11 | Date: 2/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±111ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 736ms (±137ms) 🟢 | historical mean value: 717ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 89ms (±119ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 111ms 1.01s 2.12s 1.07s 2.12s
domContentLoaded 736ms 137ms 704ms 2.08s 755ms 2.08s
firstPaint 89ms 119ms 60ms 1.28s 88ms 1.28s
firstContentfulPaint 89ms 119ms 60ms 1.28s 88ms 1.28s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 985 Bytes (0.01%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 10, 2026

Builds ready [9491f11]
UI Startup Metrics (1300 ± 97 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1300111715809713551468
load112295413618811641280
domContentLoaded111594913488811581268
domInteractive251486172167
firstPaint190581176193191314
backgroundConnect21419326612215242
firstReactRender1693751725
initialActions105113
loadScripts9157421156889601066
setupStore1262651523
numNetworkReqs231598221587
BrowserifyPower User HomeuiStartup17711393240418418262229
load11791042182116811611674
domContentLoaded11611030176915811411579
domInteractive3518149243584
firstPaint229741735262260321
backgroundConnect32629139723334373
firstReactRender22164562335
initialActions105112
loadScripts91478614901538981324
setupStore1654771830
numNetworkReqs1194825444144207
WebpackStandard HomeuiStartup796677129193826970
load695600102882744841
domContentLoaded690596102482739835
domInteractive2616104192281
firstPaint1176162376141211
backgroundConnect25175682641
firstReactRender14103341620
initialActions103112
loadScripts688594101681737833
setupStore1153751219
numNetworkReqs221585201580
WebpackPower User HomeuiStartup1222897193916713011563
load71060913231266921049
domContentLoaded70060213181256821038
domInteractive37182203832126
firstPaint1426547690167305
backgroundConnect16513234348160277
firstReactRender21173532328
initialActions104111
loadScripts69860013061226801029
setupStore1143841317
numNetworkReqs1194728753145246
FirefoxBrowserifyStandard HomeuiStartup15281313222518715461941
load13201135199315713481668
domContentLoaded13191135198815613481668
domInteractive62332373585120
firstPaint------
backgroundConnect54281382254102
firstReactRender1192221213
initialActions102112
loadScripts12941119196714913201591
setupStore156159231238
numNetworkReqs241397201784
BrowserifyPower User HomeuiStartup27361970365835129313492
load15551291232824716072182
domContentLoaded15541290232724716062181
domInteractive11935734134105444
firstPaint------
backgroundConnect251118999211244898
firstReactRender20156572126
initialActions203122
loadScripts15161261230323815292134
setupStore1498751192192572
numNetworkReqs67381653490129
WebpackStandard HomeuiStartup15391320198312115811800
load1331119715617913801481
domContentLoaded1331119615607913781481
domInteractive812814535113133
firstPaint------
backgroundConnect52212123055104
firstReactRender1410116101418
initialActions1037412
loadScripts1304117814887313541426
setupStore156160211250
numNetworkReqs231392181878
WebpackPower User HomeuiStartup26811992389344427653642
load15271259260829516672201
domContentLoaded15271259260329516662201
domInteractive12432742140107561
firstPaint------
backgroundConnect271111949198268832
firstReactRender22156462430
initialActions203123
loadScripts14851208258627916082000
setupStore1739824224227647
numNetworkReqs65351553295123
📊 Page Load Benchmark Results

Current Commit: 9491f11 | Date: 2/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±111ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 736ms (±137ms) 🟢 | historical mean value: 717ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 89ms (±119ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 111ms 1.01s 2.12s 1.07s 2.12s
domContentLoaded 736ms 137ms 704ms 2.08s 755ms 2.08s
firstPaint 89ms 119ms 60ms 1.28s 88ms 1.28s
firstContentfulPaint 89ms 119ms 60ms 1.28s 88ms 1.28s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 985 Bytes (0.01%)
  • common: 20 Bytes (0%)

@tanguyenvn
Copy link
Copy Markdown
Contributor Author

@cursor review

Add disableGasBuffer to addTransaction options type definition to
properly support TransactionController's gas buffer disable feature.
This ensures TypeScript recognizes the option and it's passed through
to the background controller.

Co-authored-by: Cursor <cursoragent@cursor.com>
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 10, 2026

Builds ready [2332c81]
UI Startup Metrics (1342 ± 95 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1342119916289513771560
load115697814148811861347
domContentLoaded115197314088711761337
domInteractive2616103182374
firstPaint158641316162201247
backgroundConnect23321628813235256
firstReactRender16104551723
initialActions105113
loadScripts9327571184879591115
setupStore1162341318
numNetworkReqs231587201583
BrowserifyPower User HomeuiStartup16751349301820417282019
load1119994224918810951578
domContentLoaded1106984222618610801567
domInteractive34171712632102
firstPaint229622245237244387
backgroundConnect31127449132317364
firstReactRender21154662232
initialActions102111
loadScripts87776418771728561302
setupStore1483941522
numNetworkReqs1104826247135187
WebpackStandard HomeuiStartup810664107491856987
load70559492082758853
domContentLoaded70059091682753847
domInteractive241585172175
firstPaint1106036960136204
backgroundConnect24164872639
firstReactRender14103551625
initialActions104112
loadScripts69758791481751841
setupStore1153241120
numNetworkReqs2315101211584
WebpackPower User HomeuiStartup1200858203820312771629
load68158415261426681028
domContentLoaded67357915191426581019
domInteractive34161853329102
firstPaint1415953588166300
backgroundConnect17013840648165251
firstReactRender21163532326
initialActions101011
loadScripts67057715121406561012
setupStore1144141216
numNetworkReqs1214530057146275
FirefoxBrowserifyStandard HomeuiStartup16161407228716716581968
load13921205206214214471666
domContentLoaded13911200205714214411666
domInteractive83323585099138
firstPaint------
backgroundConnect5729157206491
firstReactRender12102621314
initialActions103122
loadScripts13661179203414014201645
setupStore177187241446
numNetworkReqs241392211783
BrowserifyPower User HomeuiStartup27872266413938428903623
load16051297244224016592153
domContentLoaded16041296244224016592153
domInteractive12837513103127421
firstPaint------
backgroundConnect272112984218260869
firstReactRender20156582027
initialActions214122
loadScripts15581269242322916112113
setupStore1609781212175658
numNetworkReqs663614731100125
WebpackStandard HomeuiStartup15861332235916316271940
load1357118418029614191522
domContentLoaded1357118318019714191522
domInteractive74292074096141
firstPaint------
backgroundConnect60262333962137
firstReactRender14115751420
initialActions104112
loadScripts1328114016269113941473
setupStore216230361160
numNetworkReqs2412100211784
WebpackPower User HomeuiStartup26981956371342127883595
load15531261245129416492196
domContentLoaded15531260245129516492195
domInteractive12428847163102663
firstPaint------
backgroundConnect260115993202240888
firstReactRender22167572428
initialActions213123
loadScripts15161238243228816262129
setupStore22661256273379721
numNetworkReqs65341403199120
📊 Page Load Benchmark Results

Current Commit: 2332c81 | Date: 2/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 728ms (±38ms) 🟢 | historical mean value: 717ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±12ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.02s 1.36s 1.07s 1.36s
domContentLoaded 728ms 38ms 708ms 1.03s 751ms 1.03s
firstPaint 77ms 12ms 60ms 184ms 88ms 184ms
firstContentfulPaint 77ms 12ms 60ms 184ms 88ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 985 Bytes (0.01%)
  • common: 20 Bytes (0%)

Revert disableGasBuffer approach and use explicit estimateGas call
for gas limit estimation. This reduces PR complexity while still
achieving gas fee optimization via min(2 * low, medium) formula.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tanguyenvn
Copy link
Copy Markdown
Contributor Author

@cursor review

tuna1207
tuna1207 previously approved these changes Feb 11, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 12, 2026

Builds ready [ac032b2]
UI Startup Metrics (1380 ± 112 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13801157178911214581564
load1190983153810312421366
domContentLoaded1182980153210312371358
domInteractive281599192481
firstPaint150671188124196258
backgroundConnect23721729515242264
firstReactRender16113141723
initialActions109113
loadScripts957764130010310091132
setupStore1263661423
numNetworkReqs231589201580
BrowserifyPower User HomeuiStartup1930141310472105917673440
load1137997208818311111623
domContentLoaded1121988206317511001592
domInteractive35181702833104
firstPaint182731749178228308
backgroundConnect45527979858143261255
firstReactRender23155082640
initialActions105113
loadScripts88876918001678641326
setupStore1665581731
numNetworkReqs1134925047137208
WebpackStandard HomeuiStartup83368411381099191028
load721606101598799890
domContentLoaded716602101197794885
domInteractive2615102192278
firstPaint1046234045129185
backgroundConnect26185593142
firstReactRender14103941622
initialActions104112
loadScripts714600100996785883
setupStore1264971224
numNetworkReqs231597211584
WebpackPower User HomeuiStartup1246923230519313581544
load73163315051337271053
domContentLoaded72162714921327151032
domInteractive40193584334122
firstPaint14466705101158341
backgroundConnect16813443649165275
firstReactRender23174342529
initialActions101011
loadScripts71862514821307131024
setupStore1344871420
numNetworkReqs1234627549146202
FirefoxBrowserifyStandard HomeuiStartup16161384217516116651974
load13981215184313214461690
domContentLoaded13971214184313214411689
domInteractive79342254499153
firstPaint------
backgroundConnect5827189236093
firstReactRender12101711314
initialActions102122
loadScripts13691196174112214211640
setupStore146116141238
numNetworkReqs241592201681
BrowserifyPower User HomeuiStartup27582038745963128333523
load15701259613750015981916
domContentLoaded15691259613750015971916
domInteractive12034634105117364
firstPaint------
backgroundConnect2641161197234236929
firstReactRender191472101823
initialActions103122
loadScripts15361238610049715531885
setupStore1507906217132661
numNetworkReqs71361523293136
WebpackStandard HomeuiStartup15741315301420616191852
load13691180279418214031572
domContentLoaded13681180279418314031572
domInteractive822828847127147
firstPaint------
backgroundConnect5222174255597
firstReactRender14115651417
initialActions102012
loadScripts13401159276518113771522
setupStore12658101127
numNetworkReqs231293191875
WebpackPower User HomeuiStartup27171941823671027723529
load15691247694561016212235
domContentLoaded15681247694561016212235
domInteractive13132883152111535
firstPaint------
backgroundConnect2801131149231268902
firstReactRender22156972328
initialActions204122
loadScripts15281225691260515662187
setupStore1518714189196575
numNetworkReqs66371833392129
📊 Page Load Benchmark Results

Current Commit: ac032b2 | Date: 2/12/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±36ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 723ms (±34ms) 🟢 | historical mean value: 730ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±12ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 36ms 1.02s 1.31s 1.05s 1.31s
domContentLoaded 723ms 34ms 705ms 977ms 737ms 977ms
firstPaint 77ms 12ms 60ms 188ms 84ms 188ms
firstContentfulPaint 77ms 12ms 60ms 188ms 84ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 297.69 KiB (7.43%)
  • ui: 9.63 KiB (0.12%)
  • common: 4.12 KiB (0.04%)

…ation

Only set maxPriorityFeePerGas; let the transaction controller derive
maxFeePerGas from suggestedGasFees.medium as its default.

Co-authored-by: Cursor <cursoragent@cursor.com>
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 12, 2026

Builds ready [1cb26ea]
UI Startup Metrics (1350 ± 101 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13501150170510114101534
load116097814439712171345
domContentLoaded115397514409612091340
domInteractive271588182473
firstPaint1376431364196228
backgroundConnect23521343727234259
firstReactRender1592831621
initialActions106113
loadScripts9367611213969821109
setupStore1162141418
numNetworkReqs221585201580
BrowserifyPower User HomeuiStartup19001360974188018612310
load11761059210717711611604
domContentLoaded11611046209117211441578
domInteractive37171943530126
firstPaint215682110257258335
backgroundConnect4392828094816338497
firstReactRender22155072335
initialActions104112
loadScripts92179917901619011300
setupStore1473861526
numNetworkReqs1164626548142218
WebpackStandard HomeuiStartup8416861109999201029
load73461495489810888
domContentLoaded72960994688805881
domInteractive261690182378
firstPaint1156266876123217
backgroundConnect24175062641
firstReactRender14103141623
initialActions104111
loadScripts72660794388803878
setupStore1163141120
numNetworkReqs231586201584
WebpackPower User HomeuiStartup1226956208417212821529
load71863012901187101047
domContentLoaded70962312771186981037
domInteractive38172083335115
firstPaint1326654882131284
backgroundConnect16413332043162265
firstReactRender23163952433
initialActions103111
loadScripts70662112651166961023
setupStore1254551418
numNetworkReqs1204528852147241
FirefoxBrowserifyStandard HomeuiStartup15271305226918215611941
load13191130188514613691599
domContentLoaded13181130187914513691598
domInteractive67322634587141
firstPaint------
backgroundConnect5326177205388
firstReactRender11101811213
initialActions102012
loadScripts12941109186014113431563
setupStore13668111236
numNetworkReqs241291201782
BrowserifyPower User HomeuiStartup26692068379635528493351
load15211326233621216201933
domContentLoaded15211325233321216201932
domInteractive13234719120132360
firstPaint------
backgroundConnect308114987242363899
firstReactRender201466101932
initialActions103122
loadScripts14851288230920315731870
setupStore1488742203160640
numNetworkReqs73351653392133
WebpackStandard HomeuiStartup15901286345722516321836
load1372116216189414181527
domContentLoaded1371116216189414181527
domInteractive882920143129159
firstPaint------
backgroundConnect5127128215896
firstReactRender14105151419
initialActions103112
loadScripts1346114815518913881502
setupStore31616411631342
numNetworkReqs231288171674
WebpackPower User HomeuiStartup25821931346736426693369
load15001246226924016102075
domContentLoaded14991245226924016102075
domInteractive13132634129116478
firstPaint------
backgroundConnect257107816168285656
firstReactRender21156072329
initialActions213123
loadScripts14561201222922615641976
setupStore1848904231241694
numNetworkReqs68341703486132
📊 Page Load Benchmark Results

Current Commit: 1cb26ea | Date: 2/12/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±53ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 725ms (±50ms) 🟢 | historical mean value: 733ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±12ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 53ms 1.01s 1.32s 1.09s 1.32s
domContentLoaded 725ms 50ms 696ms 996ms 762ms 996ms
firstPaint 76ms 12ms 60ms 184ms 88ms 184ms
firstContentfulPaint 76ms 12ms 60ms 184ms 88ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 297.69 KiB (7.43%)
  • ui: 9.49 KiB (0.11%)
  • common: 9.34 KiB (0.09%)

Copy link
Copy Markdown

@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 4 potential issues.

data: approvalData,
};
transactionParams.gas = await estimateGas(transactionParams);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing validation for null internal account

High Severity

The code uses evmInternalAccount?.address as Hex without validating that evmInternalAccount exists. The selector getInternalAccountBySelectedAccountGroupAndCaip can return null, which causes evmInternalAccount?.address to evaluate to undefined. This undefined value is then cast to Hex and passed as the from parameter to addTransaction, which will fail at runtime.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we don't change evmInternalAccount in this PR, can skip this issue now

const { gasFeeEstimates, gasEstimateType } = useGasFeeEstimates(
networkClientId,
Boolean(networkClientId),
) as unknown as { gasFeeEstimates: GasFeeEstimates; gasEstimateType: string };
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type cast bypasses TypeScript safety

Low Severity

The code uses as unknown as to force type cast the return value from useGasFeeEstimates, completely bypassing TypeScript's type checking. This pattern prevents compile-time detection of type mismatches and could cause runtime errors if the actual return type differs from the assumed type, making the code more fragile to upstream changes.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

useGasFeeEstimates is not ts file, so there are no types

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 12, 2026

Builds ready [e1d6549]
UI Startup Metrics (1358 ± 102 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13581176181210214281516
load116898216199612001316
domContentLoaded116197716119511951307
domInteractive2715150212371
firstPaint181661319193201285
backgroundConnect23722032415241261
firstReactRender16104041825
initialActions201421413
loadScripts9397611338929691084
setupStore1263551421
numNetworkReqs231591211584
BrowserifyPower User HomeuiStartup2268150910602156721364011
load12471062199519213001677
domContentLoaded12261051189117912741591
domInteractive40202193835141
firstPaint210781900245245344
backgroundConnect645292831513383662060
firstReactRender22154042430
initialActions105111
loadScripts981820161017210231308
setupStore1574261826
numNetworkReqs1224422447150218
WebpackStandard HomeuiStartup8196751164978761008
load711604103491765854
domContentLoaded706600102691760849
domInteractive261795182381
firstPaint1166273386119266
backgroundConnect24185872639
firstReactRender14102941720
initialActions104112
loadScripts703598101790758847
setupStore1152941120
numNetworkReqs231589211584
WebpackPower User HomeuiStartup1218869170915312991502
load7186271121108707994
domContentLoaded7086201109107697985
domInteractive38191472937116
firstPaint1396947186142330
backgroundConnect16213034142161259
firstReactRender22173232427
initialActions102111
loadScripts7056181099105695973
setupStore1144151318
numNetworkReqs1354526949162224
FirefoxBrowserifyStandard HomeuiStartup15351331203313915801829
load13221149165710613771536
domContentLoaded13211148165710713761536
domInteractive69332353989136
firstPaint------
backgroundConnect5429151166075
firstReactRender1291611214
initialActions102012
loadScripts12971126162610413521499
setupStore176193301240
numNetworkReqs241290201782
BrowserifyPower User HomeuiStartup26891943412437228723422
load15861357248324116242112
domContentLoaded15851357248324116242112
domInteractive139381057139139319
firstPaint------
backgroundConnect283106930210348736
firstReactRender18156861924
initialActions203122
loadScripts15361330244822515842060
setupStore1258800171113507
numNetworkReqs773717037107143
WebpackStandard HomeuiStartup15531287205215015841886
load13481165163910614011561
domContentLoaded13471165163810614001560
domInteractive73282464897144
firstPaint------
backgroundConnect53262553351113
firstReactRender13102121318
initialActions102012
loadScripts13241152158110013841502
setupStore156115201248
numNetworkReqs241297211681
WebpackPower User HomeuiStartup28152007950983229543828
load16111315683960216222133
domContentLoaded16101313683960216222133
domInteractive14433694149126547
firstPaint------
backgroundConnect3271101436267363922
firstReactRender22163242430
initialActions203122
loadScripts15781291680760015952031
setupStore17081121225183631
numNetworkReqs75361943698145
📊 Page Load Benchmark Results

Current Commit: e1d6549 | Date: 2/12/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±42ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±40ms) 🟢 | historical mean value: 728ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±9ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.02s 1.34s 1.07s 1.34s
domContentLoaded 732ms 40ms 710ms 1.01s 747ms 1.01s
firstPaint 78ms 9ms 64ms 156ms 84ms 156ms
firstContentfulPaint 78ms 9ms 64ms 156ms 84ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.1 KiB (0.01%)
  • common: 20 Bytes (0%)

@chaitanyapotti chaitanyapotti added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 83bee6c Feb 13, 2026
184 checks passed
@chaitanyapotti chaitanyapotti deleted the feat/SUBS-814-improve-gas-fee-subscription branch February 13, 2026 05:08
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
@metamaskbot metamaskbot added the release-13.20.0 Issue or pull request that will be included in release 13.20.0 label Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.20.0 Issue or pull request that will be included in release 13.20.0 size-M team-shield Shield team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants