Skip to content

fix: preserve staked balances on Accounts API updates - #9753

Open
salimtb wants to merge 3 commits into
mainfrom
fix/preserve-staked-balance-accounts-api
Open

fix: preserve staked balances on Accounts API updates#9753
salimtb wants to merge 3 commits into
mainfrom
fix/preserve-staked-balance-accounts-api

Conversation

@salimtb

@salimtb salimtb commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Exclude staking vault asset IDs from Accounts API v5/v6 balance processing and keep prior staked amounts when replaceCoveredChainBalances would drop them, so network switches no longer reset pooled staking to missing/0.

UI PR: MetaMask/metamask-mobile#34178

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 merge behavior for staking vault asset IDs during Accounts API updates; scope is narrow but incorrect logic could still show wrong staked ETH balances.

Overview
Fixes pooled staking balances disappearing when Accounts API refreshes balances on network switch or other chain-slice updates (replaceCoveredChainBalances).

AccountsApiDataSource now skips staking vault contract asset IDs when mapping v5/v6 balance rows, so the API cannot treat the vault share token as a normal ERC-20 and overwrite or zero out amounts owned by StakedBalanceDataSource.

AssetsController merge logic for covered-chain replacement now carries forward any prior staking-contract balances that the incoming slice omits, instead of clearing them.

Tests cover v5/v6 API filtering and preservation during AccountsApiDataSource merge replaces; changelog documents the fix.

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

salimtb added a commit that referenced this pull request Aug 3, 2026
…eased

The entry was mistakenly placed in the released 11.3.0 section; move it
under Unreleased and add the PR link (#9753).

Co-authored-by: Cursor <cursoragent@cursor.com>
salimtb and others added 2 commits August 3, 2026 10:12
Exclude staking vault asset IDs from Accounts API v5/v6 balance processing
and keep prior staked amounts when replaceCoveredChainBalances would drop
them, so network switches no longer reset pooled staking to missing/0.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eased

The entry was mistakenly placed in the released 11.3.0 section; move it
under Unreleased and add the PR link (#9753).

Co-authored-by: Cursor <cursoragent@cursor.com>
@salimtb
salimtb force-pushed the fix/preserve-staked-balance-accounts-api branch from 866dfb4 to 6a9595c Compare August 3, 2026 08:14
…ource test

Co-authored-by: Cursor <cursoragent@cursor.com>
@salimtb
salimtb marked this pull request as ready for review August 5, 2026 17:10
@salimtb
salimtb requested review from a team as code owners August 5, 2026 17:10
@salimtb
salimtb temporarily deployed to default-branch August 5, 2026 17:10 — with GitHub Actions Inactive
@salimtb
salimtb added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 5, 2026
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