feat(assets-controller): add snaps migration FF#9534
Conversation
2f2753c to
355b70c
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
355b70c to
44376e0
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
Preview build PR MetaMask/metamask-extension#44601 |
44376e0 to
d7c747d
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| try { | ||
| return this.#messenger.call('RemoteFeatureFlagController:getState') | ||
| .remoteFeatureFlags; | ||
| } catch { |
There was a problem hiding this comment.
i don't think this try/catch here is needed
There was a problem hiding this comment.
Thanks. I just removed it
| - `#getNativeAssetMap` returns a stable empty object when uncached so memoized formatters are not busted by `?? {}` identity churn | ||
| - `TokenDataSource` EVM spam filtering now uses per-chain floors from Token API `GET /v1/suggestedOccurrenceFloors` (`queryApiClient.token.fetchV1SuggestedOccurrenceFloors`) instead of a hardcoded minimum of 3 occurrences. Chains missing from the response (or a failed floors fetch) still fall back to 3 ([#9537](https://github.com/MetaMask/core/pull/9537)) | ||
| - `TokensApiClient` (used by `RpcDataSource` / `TokenDetector`) now sets the token-list `occurrenceFloor` query param from the same Token API `GET /v1/suggestedOccurrenceFloors` endpoint (cached 1h), replacing the hardcoded Linea/MegaETH/Tempo special cases. Missing chains or failed fetches fall back to 3 ([#9537](https://github.com/MetaMask/core/pull/9537)) | ||
| - Add `@metamask/remote-feature-flag-controller` as a dependency ([#9534](https://github.com/MetaMask/core/pull/9534)) |
There was a problem hiding this comment.
this should be a breaking change as we're adding new event to the messenger now
There was a problem hiding this comment.
Good catch. In the end, I removed it because the controller was already importing the controller.
821143d to
f0616d5
Compare
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 f0616d5. Configure here.
f0616d5 to
602a1f3
Compare
602a1f3 to
87ff788
Compare

Explanation
The
AssetsControllerneeds to take over assets ingestion (balances, metadata,prices) for the non-EVM networks currently owned by their Snaps — Solana,
Stellar, and Tron — but this has to happen gradually and be reversible per
network. Previously the
AssetsController/AccountsApiDataSourcehad no notionof a per-network migration state: the Accounts API data source hardcoded an
eip155-only filter for the chains it surfaced as active, so there was no safeway to stage the rollout or roll it back without a code change.
This PR adds stage-gated ingestion driven by the
RemoteFeatureFlagController, so the migration for each network can be advancedand rolled back independently via LaunchDarkly:
snaps-assets-migrationutil module defines the per-network rolloutmodel: the
SnapsAssetsMigrationStageenum (Off→ReadAssetsControllerWithFallback→
ReadAssetsControllerWithoutFallback→ReadAssetsControllerOnly), theper-network flag keys (
networkAssetsSnapsMigrationSolana,networkAssetsSnapsMigrationStellar,networkAssetsSnapsMigrationTron), andhelpers to resolve and evaluate a stage from remote feature flag state
(
parseSnapsAssetsMigrationStage,isMigrationStageActive,getSnapsAssetsMigrationNamespace,getMigrationStages,shouldSupportChain).AssetsControllerresolves each network's stage fromRemoteFeatureFlagControllerstate (read via theRemoteFeatureFlagController:getStatemessenger action). Migration networksare ingested (Account Activity WebSocket + Accounts API) only from
ReadAssetsControllerWithFallbackonward and left to the Snap when the stageis
Off— which is also the fail-safe when the flag is missing or thecontroller is unavailable. Non-migration namespaces (e.g.
eip155) are nevergated.
AccountsApiDataSourcenow gates the networks it surfaces as activechains on the same per-network stage (replacing the hardcoded
eip155-onlyfilter). It also subscribes to
RemoteFeatureFlagController:stateChange(mirroring
core-backend'sAccountActivityService) so newly-enablednetworks are picked up — and disabled ones dropped — without waiting for the
periodic refresh. A selector reduces the flags to a primitive migration-stage
signature so the handler only fires when a stage actually changes.
References
Checklist
Note
Medium Risk
Changes which non-EVM chains the Accounts API data source treats as active and can shift balance/subscription behavior at runtime when flags flip; rollout is flag-gated with
Offas the safe default.Overview
Adds per-network, LaunchDarkly-driven rollout for moving Solana, Stellar, and Tron asset ingestion from Snaps into
AssetsController, replacing the hardcodedeip155-only active-chain filter onAccountsApiDataSource.A new
snaps-assets-migrationmodule definesSnapsAssetsMigrationStage(OffthroughReadAssetsControllerOnly), flag keys (networkAssetsSnapsMigrationSolana/Stellar/Tron), and helpers such asshouldSupportChainandparseSnapsAssetsMigrationStage(missing or invalid flags default toOff). EVM chains stay ungated; migration namespaces only become active chains once stage ≥ReadAssetsControllerWithFallback.AccountsApiDataSourcefilters supported networks withshouldSupportChain, subscribes toRemoteFeatureFlagController:stateChangewith a migration-stage signature selector, and refreshes active chains when a stage changes.AssetsControllermessenger types now allow that event; migration helpers are re-exported from the package entrypoint. Tests always registerRemoteFeatureFlagController:getState(default{}).Reviewed by Cursor Bugbot for commit 87ff788. Bugbot is set up for automated code reviews on this repo. Configure here.