Skip to content

fix: AccountsApiBalanceFetcher stricter zero out conditions cp-13.20.0#40411

Merged
Prithpal-Sooriya merged 1 commit intomainfrom
fix/patch-asset-zero-out-strictness-check
Feb 25, 2026
Merged

fix: AccountsApiBalanceFetcher stricter zero out conditions cp-13.20.0#40411
Prithpal-Sooriya merged 1 commit intomainfrom
fix/patch-asset-zero-out-strictness-check

Conversation

@Prithpal-Sooriya
Copy link
Copy Markdown
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Feb 25, 2026

Description

Patch for the core fix: MetaMask/core#8044

Open in GitHub Codespaces

Changelog

CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions

Related issues

Fixes: #40324

Manual testing steps

  1. Add avalanche and have avalanche tokens
  2. Select avalanche only in the network picker - EXPECTED: see avalanche erc-20 balances
  3. Select popular networks in the network picket - EXPECTED: see avalanche erc-20 balances

Screenshots/Recordings

Before

After

Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a

Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297

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
Touches balance calculation logic (risk of missing/incorrect balance display) and changes dependency resolution via Yarn patching, but the code change is small and tightly scoped.

Overview
Fixes a balance-fetching edge case in @metamask/assets-controllers by only synthesizing zero native/ERC-20 balances when the chain was explicitly requested (chainIds.includes(chainId)) and is supported, avoiding unintended zeroing for other chains.

Wires the extension to consume this fix via a Yarn patch for @metamask/assets-controllers@100.0.2, updating package.json resolutions and yarn.lock to ensure the patched package is used across multiple semver ranges.

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

@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.

@Prithpal-Sooriya Prithpal-Sooriya changed the title fix: AccountsApiBalanceFetcher stricter zero out conditions fix: AccountsApiBalanceFetcher stricter zero out conditions cp-13.20.0 Feb 25, 2026
Comment on lines +10 to +13
+ const isChainIncludedInRequest = chainIds.includes(chainId);
+ const isChainSupported = this.supports(chainId);
+ const shouldZeroOutBalance = !existingBalance && isChainIncludedInRequest && isChainSupported;
+ if (shouldZeroOutBalance) {
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.

Same as proposed fix in core:
MetaMask/core#8044

Comment on lines +22 to +25
+ const isChainIncludedInRequest = chainIds.includes(chainId);
+ const isChainSupported = this.supports(chainId);
+ const shouldZeroOutBalance = !existingBalance && isChainIncludedInRequest && isChainSupported;
+ if (isERC && shouldZeroOutBalance) {
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.

Same as proposed fix in core:
MetaMask/core#8044

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 1 potential issue.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 25, 2026

Builds ready [f277a1c]
⚡ Performance Benchmarks (1476 ± 127 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account31436342350
total31436342350
Confirm Txconfirm_tx60972961196143
total60972961196143
Bridge User Actionsbridge_load_page21321219250
bridge_load_asset_picker25838272322
bridge_search_token74415755758
total12156512641295
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14761219213312715131678
load12491036178611312871455
domContentLoaded12421032177111112821445
domInteractive2817114202479
firstPaint189691381182246385
backgroundConnect22020032218222254
firstReactRender2111263252030
initialActions106113
loadScripts1040826154911010811244
setupStore1374151622
numNetworkReqs312292192282
Chrome Browserify Startup Power User HomeuiStartup3269155410938220940689340
load13121121190315613631595
domContentLoaded12901099184914713311564
domInteractive3720176253582
firstPaint228911831182276347
backgroundConnect13642749044207416017592
firstReactRender26185272839
initialActions104113
loadScripts1061886158714110881347
setupStore1674872026
numNetworkReqs82331332297115
Chrome Webpack Startup Standard HomeuiStartup8857171266999351094
load757630100196820920
domContentLoaded75162599595812908
domInteractive3016104212590
firstPaint1176233556140221
backgroundConnect29195583447
firstReactRender19123662332
initialActions105112
loadScripts74862398594809904
setupStore1363961524
numNetworkReqs312296202588
Chrome Webpack Startup Power User HomeuiStartup1302918280632613432007
load76265711731187591056
domContentLoaded75065111491177431046
domInteractive43202093540130
firstPaint1557340982195347
backgroundConnect2051351316158174362
firstReactRender23183632429
initialActions103111
loadScripts74764911401157411038
setupStore1357981420
numNetworkReqs994821331113155
Firefox Browserify Startup Standard HomeuiStartup17391462288124217472200
load14491220236318414651772
domContentLoaded14481214236318414641772
domInteractive84363264599151
firstPaint------
backgroundConnect7635112611264135
firstReactRender14124131519
initialActions103122
loadScripts14171193233117614371659
setupStore248169301878
numNetworkReqs312096192783
Firefox Browserify Startup Power User HomeuiStartup28912199638150930683517
load15961318487340916021968
domContentLoaded15951318487341016011968
domInteractive174491674210147476
firstPaint------
backgroundConnect47812214913276801129
firstReactRender18136771921
initialActions207122
loadScripts15481287481340615711919
setupStore14716723178175603
numNetworkReqs85381973599166
Firefox Webpack Startup Standard HomeuiStartup17371398341436317502289
load14491181289930214541665
domContentLoaded14481181289930214541665
domInteractive104301553156131232
firstPaint------
backgroundConnect7726171716966118
firstReactRender16123541624
initialActions106122
loadScripts14241166288530214271622
setupStore18772151754
numNetworkReqs311996172771
Firefox Webpack Startup Power User HomeuiStartup27181919406938929403367
load15211272217818615921890
domContentLoaded15201271217718615921890
domInteractive16150851161147526
firstPaint------
backgroundConnect3781131641285478841
firstReactRender22168092329
initialActions203122
loadScripts14831248211117915691783
setupStore15815765190172573
numNetworkReqs82352043592156
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2201219221
srpButtonToSrpForm9519597
confirmSrpToPwForm2202222
pwFormToMetricsScreen1501515
metricsToWalletReadyScreen1701717
doneButtonToHomeScreen12582612751289
openAccountMenuToAccountListLoaded716510872447244
total88118588538894
Onboarding New WalletcreateWalletToSocialScreen2202220223
srpButtonToPwForm1064110110
createPwToRecoveryScreen911010
skipBackupToMetricsScreen3834243
agreeButtonToOnboardingSuccess1601616
doneButtonToAssetList81933311131297
total121232914951680
Asset DetailsassetClickToPriceChart3913940
total3913940
Solana Asset DetailsassetClickToPriceChart4714849
total4714849
Import Srp HomeloginToHomeScreen20016920692070
openAccountMenuAfterLogin4374750
homeAfterImportWithNewWallet247916526112626
total459325847244997
Send TransactionsopenSendPageFromHome29113348
selectTokenToSendFormLoaded2412426
reviewTransactionToConfirmationPage103915210981305
total109514511621346
SwapopenSwapPageFromHome12210130133
fetchAndDisplaySwapQuotes564882362816416
total578584264776549
🌐 Dapp Page Load Benchmarks

Current Commit: f277a1c | Date: 2/25/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±71ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 736ms (±69ms) 🟢 | historical mean value: 734ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±12ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 71ms 1.01s 1.34s 1.26s 1.34s
domContentLoaded 736ms 69ms 698ms 1.01s 933ms 1.01s
firstPaint 78ms 12ms 60ms 164ms 88ms 164ms
firstContentfulPaint 78ms 12ms 60ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 727 Bytes (0.01%)

@sonarqubecloud
Copy link
Copy Markdown

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit 299601b Feb 25, 2026
354 of 360 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the fix/patch-asset-zero-out-strictness-check branch February 25, 2026 18:53
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
@metamaskbot metamaskbot added the release-13.21.0 Issue or pull request that will be included in release 13.21.0 label Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.21.0 Issue or pull request that will be included in release 13.21.0 size-S team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Native token balances for all popular networks displayed as 0 in the token list

4 participants