Repository navigation
feat(assets-controller): add balance state in snaps request - #10819
Merged
Merged
Conversation
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Kriys94
force-pushed
the
feature/SmoothSnapsMigration
branch
from
October 15, 2026 14:08
842ddd8 to
34f990b
Compare
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
juanmigdr
approved these changes
Oct 16, 2026
This branch was successfully deployed
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
v6
SnapDataSourcefetches request the snap's listed holdings plus visible assets (native, pin, and default tracked). Accounts API and the websocket already return a wider token set than the snap lists. If a chain rolls back to the snap, those extra tokens would stop refreshing.This adds a temporary, deletable block so the v6 request is the union of:
Hidden assets stay out, and tokens stored for other chains stay out. A visible token with no balance entry is still requested. If the snap omits a balance-state token it was asked for, that token stays out of the snapshot.
Delete
#includeSnapRollbackBalanceStateTokensand its call in#fetchV6once balance reads fully move to Accounts API. The visible-asset path is unchanged.Unsubscribing from account activity now releases every tracked chain the same way a WebSocket disconnect does.
#unsubscribeFromAllAccountActivitypublishes oneAccountActivityService:statusChangedevent with statusdownfor every tracked chain, including any status still buffered, and then clears that set. A snaps-migration flag change and an account switch both go through this unsubscribe before resubscribing. The next system notification marks the chains that are still up, so chains whose flag turned off can be subscribed through snaps.References
packages/assets-controller/docs/decisions/2026-09-23-accounts-api-v6-integration.mdChecklist
Note
Medium Risk
Changes v6 snap balance fetch scope and when AssetsController sees chains as down during migration flag toggles; incorrect signaling could mis-route balance sources until the next system notification.
Overview
Snap v6 balance requests temporarily include every token already in balance state for the requested chains (plus listed holdings and visible assets), in a marked-for-deletion block, so a rollback to Snaps still refreshes tokens Accounts API / websocket already track. Snap-omitted balance-state tokens are not zero-filled or backfilled from state.
Account activity chain status is refactored:
#publishTrackedChainsDowncentralizes publishingdownfor all tracked chains (including debounced pending). WebSocket disconnect and snaps-migration feature-flag resubscribe use it; account switches only unsubscribe/resubscribe and do not publish chains down.Docs, changelogs, and tests (
SnapDataSource,AccountActivityService) are updated for the new request union and status semantics.Reviewed by Cursor Bugbot for commit c18f4a6. Bugbot is set up for automated code reviews on this repo. Configure here.