Skip to content

fix(assets-controller): seed native balances after account refresh#9388

Merged
salimtb merged 5 commits into
mainfrom
fix/seed-native-metadata-new-account
Jul 6, 2026
Merged

fix(assets-controller): seed native balances after account refresh#9388
salimtb merged 5 commits into
mainfrom
fix/seed-native-metadata-new-account

Conversation

@salimtb

@salimtb salimtb commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Zero-balancing for new accounts ran before getAssets on account-tree changes, so assetsBalance was often never populated for the new account. Seed native zero balances using the refreshed account list after the fetch.

  • Fetch balances via RpcDataSource when a user switches EVM accounts, enables RPC-only networks, switches account groups, or adds a new account to the account tree
  • Fixes missing assetsBalance for newly added accounts on custom/RPC networks (e.g. DXC / eip155:50) where assetsInfo was present but balances were not fetched

Explanation

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

Medium Risk
Changes balance refresh timing in AssetsController for account-tree and subscription flows; localized but affects wallet balance display on custom/RPC networks.

Overview
Fixes cases where assetsBalance stayed empty for new or RPC-only-network accounts even when metadata was present, by tightening when AssetsController force-refreshes balances.

On account tree updates, the controller now tracks newly added accounts and, after the usual group-wide getAssets and re-subscribe, runs a second forced fetch scoped to those new accounts so the slow/RPC pipeline can populate balances (e.g. custom chains like eip155:50).

Documents the same class of fix for account group switches and newly enabled RPC-only networks in the changelog. #handleEnabledNetworksChanged only refactors to reuse a local accounts variable when fetching added chains—behavior unchanged.

Reviewed by Cursor Bugbot for commit 8e87933. Bugbot is set up for automated code reviews on this repo. Configure here.

salimtb added 2 commits July 4, 2026 12:57
Zero-balancing for new accounts ran before getAssets on account-tree
changes, so assetsBalance was often never populated for the new account.
Seed native zero balances using the refreshed account list after the fetch.
@salimtb salimtb marked this pull request as ready for review July 4, 2026 11:10
@salimtb salimtb requested review from a team as code owners July 4, 2026 11:10
@salimtb salimtb temporarily deployed to default-branch July 4, 2026 11:10 — with GitHub Actions Inactive
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit d0d117f. Configure here.

Comment thread packages/assets-controller/src/AssetsController.ts
@salimtb salimtb requested a review from Prithpal-Sooriya July 6, 2026 10:23
@salimtb salimtb added this pull request to the merge queue Jul 6, 2026
Merged via the queue into main with commit 7c13b25 Jul 6, 2026
413 of 414 checks passed
@salimtb salimtb deleted the fix/seed-native-metadata-new-account branch July 6, 2026 10:54
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.

2 participants