fix: AccountsApiBalanceFetcher stricter zero out conditions#8044
Merged
Prithpal-Sooriya merged 2 commits intomainfrom Feb 25, 2026
Merged
fix: AccountsApiBalanceFetcher stricter zero out conditions#8044Prithpal-Sooriya merged 2 commits intomainfrom
Prithpal-Sooriya merged 2 commits intomainfrom
Conversation
… tests - Introduced a helper function to streamline balance fetcher setup in tests. - Updated test cases to ensure ERC20 token entries are included even when API returns no balance. - Added a new test to verify that unsupported chains do not include ERC20 token entries, ensuring accurate balance reporting. This refactor improves test clarity and maintainability while ensuring comprehensive coverage of balance fetching scenarios.
Contributor
Author
|
@cursor READ AND FOLLOW THESE MEMORY FILES: Please update the assets-controllers changelog. Make it a 1 bullet entry. This is a fix to ensure that when we have much stricter zero out conditions. |
|
Done! I've updated the ### Fixed
- Fix `AccountsApiBalanceFetcher` to apply stricter conditions when zeroing out token balances ([#8044](https://github.com/MetaMask/core/pull/8044))
Reflection Statement: No memory update required - the task was completed successfully following the existing playbook rules for changelog updates ([shr-004], [ts-002]). |
…ut fix Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
salimtb
approved these changes
Feb 25, 2026
github-merge-queue bot
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
…3.20.0 (#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 ## **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 - [x] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Prithpal-Sooriya
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Feb 25, 2026
#40411) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> Patch for the core fix: MetaMask/core#8044 [](https://codespaces.new/MetaMask/metamask-extension/pull/40411?quickstart=1) <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions Fixes: #40324 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 <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <!-- [screenshots/recordings] --> Core fix: https://www.loom.com/share/0cd294c9f2bb4732a7ec9ad56d9dbd4a Extension Demo: https://www.loom.com/share/5bfe5543fc6c4e3db819c3586ffad297 - [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 - [x] 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. - [ ] 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** > 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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f277a1c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
7 tasks
github-merge-queue bot
pushed a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Feb 26, 2026
…#26590) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 https://consensyssoftware.atlassian.net/browse/ASSETS-2796 ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions ## **Related issues** Fixes: MetaMask/metamask-extension#40324 (this issue also happens on mobile!) #26618 ## **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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://www.loom.com/share/d6e472d2ab444205acdad64507f43eed ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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 - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/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** > Touches cross-chain balance fetching behavior via a patched dependency; incorrect gating could still cause missing/incorrect displayed balances for some network selections. Dependency patching adds some upgrade/maintenance risk but is scoped to a small conditional change. > > **Overview** > Updates `@metamask/assets-controllers` via a Yarn patch to tighten when missing balances are backfilled as zero in `AccountsApiBalanceFetcher`. > > Zero-value native and ERC-20 balances are now only synthesized when the chain was *explicitly requested* (`chainIds.includes(chainId)`) and is *supported* (`supports(chainId)`), avoiding unintended zeroing for other chains. The app’s dependency wiring is updated (`package.json` + `yarn.lock`) to use the patched `@metamask/assets-controllers@100.0.3`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c3c5058. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github bot
added a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Feb 26, 2026
….67.0 (#26590) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 https://consensyssoftware.atlassian.net/browse/ASSETS-2796 ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions ## **Related issues** Fixes: MetaMask/metamask-extension#40324 (this issue also happens on mobile!) #26618 ## **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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://www.loom.com/share/d6e472d2ab444205acdad64507f43eed ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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 - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/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** > Touches cross-chain balance fetching behavior via a patched dependency; incorrect gating could still cause missing/incorrect displayed balances for some network selections. Dependency patching adds some upgrade/maintenance risk but is scoped to a small conditional change. > > **Overview** > Updates `@metamask/assets-controllers` via a Yarn patch to tighten when missing balances are backfilled as zero in `AccountsApiBalanceFetcher`. > > Zero-value native and ERC-20 balances are now only synthesized when the chain was *explicitly requested* (`chainIds.includes(chainId)`) and is *supported* (`supports(chainId)`), avoiding unintended zeroing for other chains. The app’s dependency wiring is updated (`package.json` + `yarn.lock`) to use the patched `@metamask/assets-controllers@100.0.3`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c3c5058. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Prithpal-Sooriya
added a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Feb 26, 2026
…#26590) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> Patch for the core fix: MetaMask/core#8044 https://consensyssoftware.atlassian.net/browse/ASSETS-2796 <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions Fixes: MetaMask/metamask-extension#40324 (this issue also happens on mobile!) #26618 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 <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <!-- [screenshots/recordings] --> https://www.loom.com/share/d6e472d2ab444205acdad64507f43eed - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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 - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] 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** > Touches cross-chain balance fetching behavior via a patched dependency; incorrect gating could still cause missing/incorrect displayed balances for some network selections. Dependency patching adds some upgrade/maintenance risk but is scoped to a small conditional change. > > **Overview** > Updates `@metamask/assets-controllers` via a Yarn patch to tighten when missing balances are backfilled as zero in `AccountsApiBalanceFetcher`. > > Zero-value native and ERC-20 balances are now only synthesized when the chain was *explicitly requested* (`chainIds.includes(chainId)`) and is *supported* (`supports(chainId)`), avoiding unintended zeroing for other chains. The app’s dependency wiring is updated (`package.json` + `yarn.lock`) to use the patched `@metamask/assets-controllers@100.0.3`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c3c5058. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
7 tasks
joaoloureirop
pushed a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Feb 26, 2026
…ro out conditions (#26642) - fix: AccountsApiBalanceFetcher stricter zero out conditions cp-7.67.0 (#26590) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Patch for the core fix: MetaMask/core#8044 https://consensyssoftware.atlassian.net/browse/ASSETS-2796 ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fix: AccountsApiBalanceFetcher stricter zero out conditions ## **Related issues** Fixes: MetaMask/metamask-extension#40324 (this issue also happens on mobile!) #26618 ## **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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://www.loom.com/share/d6e472d2ab444205acdad64507f43eed ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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 - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/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** > Touches balance-fetching logic (via a Yarn patch to `@metamask/assets-controllers`), which can affect displayed native/ERC-20 balances across networks if the new gating conditions are wrong. Scope is small and isolated to when missing API results are backfilled with zeroes. > > **Overview** > Applies a Yarn patch to `@metamask/assets-controllers@99.4.0` that tightens `AccountsApiBalanceFetcher` “zero-out” behavior: missing native and ERC-20 balances are only backfilled with `0` when the `chainId` was included in the original request and `supports(chainId)` is true. > > Updates `package.json` and `yarn.lock` to consume the patched dependency via `.yarn/patches/...`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 28f899b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [ed2fb6c](ed2fb6c) Co-authored-by: Prithpal Sooriya <prithpal.sooriya@consensys.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Explanation
This refactor improves test clarity and maintainability while ensuring comprehensive coverage of balance fetching scenarios.
Fixes: MetaMask/metamask-extension#40324
References
Checklist
Note
Low Risk
Small, well-scoped logic change gated by
supports()with added test coverage; risk is limited to balance backfill behavior on edge-case chains.Overview
Fixes
AccountsApiBalanceFetcherso it only synthesizes zero native/ERC-20 balances when the chain was explicitly requested and is supported by the Accounts API, preventing unsupported networks from having token balances incorrectly zeroed out.Updates/extends the unit tests around the ERC-20 “zero balance guarantee” (including a new unsupported-chain case) and documents the fix in the
assets-controllerschangelog.Written by Cursor Bugbot for commit 580c79e. This will update automatically on new commits. Configure here.