fix: Managed removed property from MultichainAssetsController:accountAssetListUpdated event body#8461
Merged
gabrieledm merged 32 commits intomainfrom Apr 22, 2026
Conversation
…untAssetListUpdated` event body to manage stale balances
…untAssetListUpdated` event body to manage stale balances
…tps://github.com/MetaMask/core into fix/NEB-892_usdt-balance-not-updating-after-swap
Signed-off-by: gabrieledm <gabriele.delmonte-ext@consensys.net>
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
salimtb
reviewed
Apr 16, 2026
| const newAccountAssets = Object.entries(assets).map( | ||
| ([accountId, { added }]) => ({ | ||
| const updatedAccountAssets = Object.entries(assets).map( | ||
| ([accountId, { added, removed }]) => ({ |
Contributor
There was a problem hiding this comment.
should we have the same fix on the MultichainAssetsRatesController ?
Prithpal-Sooriya
previously approved these changes
Apr 16, 2026
…tps://github.com/MetaMask/core into fix/NEB-892_usdt-balance-not-updating-after-swap
…tps://github.com/MetaMask/core into fix/NEB-892_usdt-balance-not-updating-after-swap
…tps://github.com/MetaMask/core into fix/NEB-892_usdt-balance-not-updating-after-swap
Signed-off-by: gabrieledm <gabriele.delmonte-ext@consensys.net>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 b2adaa5. Configure here.
Signed-off-by: gabrieledm <gabriele.delmonte-ext@consensys.net>
Prithpal-Sooriya
approved these changes
Apr 16, 2026
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
FrederikBolding
approved these changes
Apr 17, 2026
matthewwalsh0
approved these changes
Apr 17, 2026
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 PR fixes stale multichain asset balances in
MultichainBalancesControllerwhenMultichainAssetsController:accountAssetListUpdatedis emitted.Before this change, the controller only used the
addedassets from the event payload and ignoredremoved.As a result, balances for assets that were no longer present in the account asset list could remain cached in controller state and continue to appear as stale balances in the client.
Changes in
MultichainBalancesControlleraccountAssetListUpdatedhandler to use bothaddedandremovedremovedadded{ amount: '0', unit: '' }foraddedassets when the snap does not return a balance for themReferences
Checklist
Note
Medium Risk
Touches core state reconciliation logic for multichain balances and pricing caches; bugs could cause incorrect asset visibility or rate/balance clearing across accounts despite added test coverage.
Overview
Fixes stale multichain cached data by fully handling the
removedportion ofMultichainAssetsController:accountAssetListUpdated.MultichainBalancesControllernow deletes balances for removed assets (and clears an account’s balances when it has no remaining assets), while still fetching/merging balances for newly added assets and inserting explicit zero placeholders when a Snap omits a balance.MultichainAssetsRatesControllernow treats the event as a per-account delta: it fetches rates only foraddedassets, and purges conversion rates and historical prices for removed assets only when the asset is no longer tracked by any account. Tests and the assets-controllers changelog are updated accordingly, andtransaction-pay-controllerfixes aTransactionMetaimport to use the published package path.Reviewed by Cursor Bugbot for commit c9ce3f7. Bugbot is set up for automated code reviews on this repo. Configure here.