Skip to content

fix: AccountsApiBalanceFetcher stricter zero out conditions#8044

Merged
Prithpal-Sooriya merged 2 commits intomainfrom
fix-stricter-balance-zero-out
Feb 25, 2026
Merged

fix: AccountsApiBalanceFetcher stricter zero out conditions#8044
Prithpal-Sooriya merged 2 commits intomainfrom
fix-stricter-balance-zero-out

Conversation

@Prithpal-Sooriya
Copy link
Copy Markdown
Contributor

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

Explanation

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

Fixes: MetaMask/metamask-extension#40324

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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 AccountsApiBalanceFetcher so 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-controllers changelog.

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

… 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.
@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review February 25, 2026 17:11
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner February 25, 2026 17:11
@Prithpal-Sooriya
Copy link
Copy Markdown
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.

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 25, 2026

Done! I've updated the packages/assets-controllers/CHANGELOG.md with a single bullet entry under the Fixed section:

### Fixed

- Fix `AccountsApiBalanceFetcher` to apply stricter conditions when zeroing out token balances ([#8044](https://github.com/MetaMask/core/pull/8044))
  • Followed the memory file instructions (including using the correct commit author)
  • Validated the changelog passes the changelog:validate check
  • Committed and pushed to branch fix-stricter-balance-zero-out

Reflection Statement: No memory update required - the task was completed successfully following the existing playbook rules for changelog updates ([shr-004], [ts-002]).

Open in Web Open in Cursor 

…ut fix

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@cursor cursor bot requested a review from a team as a code owner February 25, 2026 17:14
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit 2fefc95 Feb 25, 2026
314 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the fix-stricter-balance-zero-out branch February 25, 2026 18:15
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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](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 -->
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 -->
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants