Skip to content

feat(tron): stop syncing and emitting assets while the assets migration is active - #424

Open
ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2054-skip-asset-sync-when-migration-active
Open

ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2054-skip-asset-sync-when-migration-active

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

While the assets migration feature flag is off, the snap owns asset synchronization: it fetches assets and balances from the chain, persists them to snap state, and publishes updates to the extension by emitting AccountAssetListUpdated and AccountBalancesUpdated.

Once the migration is active, the AssetsController owns asset syncing, so the snap must stay out of the way. Until now, the snap's asset sync kept running while the flag was on: every sync trigger (the 60s cronjob, the background event scheduled by setSelectedAccounts, and post-transaction refreshes) still fetched assets and emitted keyring events for snap-owned assets.

This PR changes the last behaviours missing for the AssetsController migration to happen:

  • When the migration is on, the snap's asset sync becomes a no-op. AccountsService.synchronizeAssets now consults AssetsService.isAssetsMigrationEnabled (true only when the migration stage is Off) and returns early, so the snap neither fetches nor emits assets. Transaction synchronization is unaffected, and the cronjob itself keeps running so it still handles transaction syncing and resumes asset syncing as soon as the flag is turned off.
  • When the live assets and balances are fetched by getAccountAssets and getAccountBalances, they are persisted to the snap's local state without emitting AccountAssetListUpdated and AccountBalancesUpdated events. This keeps snap state warm for the AssetsController to take over, while Core owns publishing updates once the migration is active.

References

Ticket: WPN-2054

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

@ulissesferreira
ulissesferreira force-pushed the WPN-2054-skip-asset-sync-when-migration-active branch 8 times, most recently from cbfbe94 to 08f7b77 Compare October 9, 2026 12:41
@ulissesferreira
ulissesferreira marked this pull request as ready for review October 9, 2026 13:29
@ulissesferreira
ulissesferreira requested a review from a team as a code owner October 9, 2026 13:29
@ulissesferreira
ulissesferreira deployed to default-branch October 9, 2026 13:29 — with GitHub Actions Active
Comment thread packages/tron-wallet-snap/CHANGELOG.md Outdated
Comment on lines +16 to +17
- Stop fetching, persisting, and publishing assets from the snap while the assets migration feature flag is active: the periodic sync cronjob and the synchronization triggered by selected account changes no longer touch assets or emit `AccountAssetListUpdated` and `AccountBalancesUpdated` events, leaving asset syncing to the `AssetsController` ([#424](https://github.com/MetaMask/internal-snaps/pull/424))
- Persist the live assets and balances fetched by `getAccountAssets` and `getAccountBalances` to local state without emitting `AccountAssetListUpdated` and `AccountBalancesUpdated` events ([#424](https://github.com/MetaMask/internal-snaps/pull/424))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we regroup this one into one entry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed!

Comment on lines +521 to +527
if (await this.#assetsService.isAssetsMigrationEnabled()) {
/**
* No-op when AssetsController is already handling assets
*/
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are fine here that nothing is done at the moment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed! If the AssetsMigration is on we are not supposed to do anything

@ulissesferreira
ulissesferreira force-pushed the WPN-2054-skip-asset-sync-when-migration-active branch from 08f7b77 to 7bbd68d Compare October 9, 2026 17:00
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

This branch was successfully deployed

1 active (outdated) deployment
default-branch — 08f7b778 Deployed Oct 9, 2026 by ulissesferreira via Determine whether this PR is a release PR #1577
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