Skip to content

feat(tron-wallet-snap): route asset reads through Core when migration is on - #145

Open
ulissesferreira wants to merge 1 commit into
mainfrom
WPN-1497-route-assets-logic-based-on-feature-flag
Open

feat(tron-wallet-snap): route asset reads through Core when migration is on#145
ulissesferreira wants to merge 1 commit into
mainfrom
WPN-1497-route-assets-logic-based-on-feature-flag

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pass RemoteFeatureFlagsProvider into AssetsService and resolve the Tron assets migration flag via #shouldReturnAssetsFromCore
  • Route getAccountAssetByID, getAccountAssetsByIDs, getAccountAssets, fetchAssetsAndBalancesForAccount, and saveMany through Core when migration is active
  • When migration is on, fetch returns only snap-owned assets; save publishes them via keyring events without local persistence

Part of WPN-1497. Stack:

  1. refactor(tron-wallet-snap): extract shared asset utils and inject SnapAssetsAdapter #143
  2. feat(tron-wallet-snap): add CoreAssetsAdapter and mapControllerAsset #144
  3. feat(tron-wallet-snap): route asset reads through Core when migration is on #145 (this PR)

Replaces outdated #127 / #141.

Test plan

  • yarn workspace @metamask/tron-wallet-snap run build
  • yarn workspace @metamask/tron-wallet-snap run jest --no-coverage src/services/assets/AssetsService.test.ts
  • With migration flag off: asset reads/writes/fetch behave as Snap-only
  • With migration flag on: fungible reads come from AssetsController; fetch returns only snap-owned assets; saveMany emits only snap-owned assets and does not persist fungibles locally

@ulissesferreira
ulissesferreira requested a review from a team as a code owner August 10, 2026 14:13
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-implement-core-assets-adapter branch from 714b17d to 3550d24 Compare August 10, 2026 14:13
@ulissesferreira
ulissesferreira requested a review from a team as a code owner August 10, 2026 14:13
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from ba86a26 to 25080b8 Compare August 10, 2026 14:14
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-implement-core-assets-adapter branch from 3550d24 to a42b752 Compare August 10, 2026 15:07
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from 46681f7 to e73dd2e Compare August 10, 2026 15:35
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-implement-core-assets-adapter branch 4 times, most recently from 69e150f to cc94a88 Compare August 14, 2026 12:49
@ulissesferreira
ulissesferreira marked this pull request as draft August 14, 2026 13:29
Base automatically changed from WPN-1497-implement-core-assets-adapter to main August 14, 2026 13:50
@cursor
cursor Bot force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from c0bae22 to 084b8c7 Compare August 18, 2026 10:00
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch 2 times, most recently from e5c9702 to 6aa1f0a Compare August 25, 2026 17:52
@ulissesferreira
ulissesferreira changed the base branch from main to fix/map-controller-asset-display-balance August 25, 2026 17:52
@ulissesferreira
ulissesferreira force-pushed the fix/map-controller-asset-display-balance branch 2 times, most recently from 818a716 to 4be4426 Compare August 26, 2026 12:56
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from 6aa1f0a to 32c46a3 Compare August 26, 2026 13:07
@ulissesferreira
ulissesferreira force-pushed the fix/map-controller-asset-display-balance branch from 8bfe50d to 681e0cb Compare August 26, 2026 13:13
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from 5a9e4a0 to 4641aa1 Compare August 26, 2026 13:27
Base automatically changed from fix/map-controller-asset-display-balance to main August 26, 2026 13:55
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from 4641aa1 to ccfc1c6 Compare August 26, 2026 13:58
@ulissesferreira
ulissesferreira marked this pull request as ready for review August 26, 2026 14:23
@ulissesferreira
ulissesferreira deployed to default-branch August 26, 2026 14:23 — with GitHub Actions Active
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch 3 times, most recently from a5cd442 to 89b4f7e Compare August 27, 2026 11:45
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Reopening to re-trigger CI after amend

@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch 4 times, most recently from 783bc2f to 396c3af Compare August 28, 2026 10:41
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-route-assets-logic-based-on-feature-flag branch from 396c3af to 05bd174 Compare August 28, 2026 10:46
@Battambang

Copy link
Copy Markdown
Contributor

nit: the Changelog file is updated so seems to me that the PR label should not have the no-changelog label

Copilot AI left a comment

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.

Pull request overview

Adds feature-flagged routing between Snap-managed assets and Core’s AssetsController.

Changes:

  • Adds migration-aware asset read, fetch, and save routing.
  • Injects the remote feature-flags provider.
  • Adds migration tests and release metadata updates.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AssetsService.ts Implements feature-flagged adapter routing.
AssetsService.test.ts Adds migration routing tests.
context.ts Injects the feature-flags provider.
snap.manifest.json Updates the bundle checksum.
CHANGELOG.md Documents the migration behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +56 to +58
const result =
parseSnapsAssetsMigrationStage(flagValue) !==
SnapsAssetsMigrationStage.Off;

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.

This is by design. We decided against having the extra fallback complexity so we just have a on or off type of situation


describe('facade delegation', () => {
it('delegates repository reads and market helpers to SnapAssetsAdapter', async () => {
it('delegates static helpers and empty batch reads to SnapAssetsAdapter', async () => {
Comment thread packages/tron-wallet-snap/CHANGELOG.md
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.

3 participants