fix: Managed removed property from MultichainAssetsController:accountAssetListUpdated event body#8461
Open
gabrieledm wants to merge 24 commits intomainfrom
Open
fix: Managed removed property from MultichainAssetsController:accountAssetListUpdated event body#8461gabrieledm wants to merge 24 commits intomainfrom
removed property from MultichainAssetsController:accountAssetListUpdated event body#8461gabrieledm wants to merge 24 commits intomainfrom
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>
| TransactionPaymentToken, | ||
| } from '..'; | ||
| import { TransactionPayStrategy } from '..'; | ||
| import type { TransactionMeta } from '../../../transaction-controller/src'; |
Contributor
There was a problem hiding this comment.
(optional) We can remove this change to minimise CO
Prithpal-Sooriya
approved these changes
Apr 16, 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 multichain balance/rate caching logic and deletion semantics; mistakes could drop valid cached data or cause UI inconsistencies across accounts, though changes are scoped and covered by new tests.
Overview
Ensures multichain cached data is reconciled when
MultichainAssetsController:accountAssetListUpdatedincludesremovedassets, preventing stale balances/rates from lingering after assets are no longer tracked.MultichainBalancesControllernow treats the event payload as a per-account delta: it deletes balances forremovedassets, fetches/merges balances foraddedassets, and fills missing Snap responses with explicit zero balances; new tests cover stale-balance removal and clearing when an account has no remaining assets.MultichainAssetsRatesControllersimilarly cleans up cachedconversionRatesandhistoricalPricesfor removed assets that are no longer tracked by any account (while keeping shared assets), and updates tests to validate both purge and retention behavior. Also fixes atransaction-pay-controllertype import to use@metamask/transaction-controllerdirectly and updates related ESLint suppression entries.Reviewed by Cursor Bugbot for commit 891fa43. Bugbot is set up for automated code reviews on this repo. Configure here.