Skip to content

refactor(tron-wallet-snap): aggressive AssetsService cleanup — handlers in service, snap-owned sync only - #98

Closed
ulissesferreira wants to merge 5 commits into
WPN-1497-snap-adapterfrom
ulissesferreira/aggressive-assets-cleanup-4b9e
Closed

refactor(tron-wallet-snap): aggressive AssetsService cleanup — handlers in service, snap-owned sync only#98
ulissesferreira wants to merge 5 commits into
WPN-1497-snap-adapterfrom
ulissesferreira/aggressive-assets-cleanup-4b9e

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up cleanup on top of the SnapAssetsAdapter extraction (WPN-1497-snap-adapter):

  • Move asset-handler logic (getAssetsMetadata, conversions, market data, historical prices) back into AssetsService so it no longer relies on SnapAssetsAdapter for those paths
  • Replace broad asset fetch/save with AssetsService.syncSnapOwnedAssets, which only syncs Snap-managed protocol assets (staking, resources, rewards)
  • Slim SnapAssetsAdapter to snap-owned fetch + persistence/events (fungibles are left alone during reconcile)
  • Wire AccountsService.synchronizeAssets / cron path through syncSnapOwnedAssets
  • Remove unused AssetsService APIs (getAccountAssets, getAll, hasChanged, fetchAssetsAndBalancesForAccount, public saveMany)
  • Add SNAP_OWNED_ASSETS / isSnapOwnedAsset helpers

Test plan

  • yarn workspace @metamask/tron-wallet-snap run jest --no-coverage src/services/assets/AssetsService.test.ts src/services/accounts/AccountsService.test.ts src/services/assets/snapOwnedAssets.test.ts (97 passed)
  • yarn workspace @metamask/tron-wallet-snap run build
  • yarn lint
  • yarn workspace @metamask/tron-wallet-snap run changelog:validate

Stacks on WPN-1497-snap-adapter.

Open in Web Open in Cursor 

ulissesferreira and others added 5 commits August 3, 2026 12:33
Co-authored-by: Cursor <cursoragent@cursor.com>
Align test file formatting with lint:misc:check expectations.
…s for snap-owned sync

- AccountsService: mock syncSnapOwnedAssets instead of fetch/saveMany
- AssetsService: rewrite tests for syncSnapOwnedAssets end-to-end flow
- Remove native TRX/TRC20 fetch and enrichment test cases
- Keep snap-owned extraction, persistence, and event emission coverage
- Update facade delegation test (remove hasChanged, getAccountAssets)
- Add CHANGELOG entry for AssetsService snap-owned sync refactor

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
…ync snap-owned only

AssetsService now owns metadata/conversion/market/historical-price logic.
SnapAssetsAdapter fetches and persists only snap-owned assets.
AccountsService.synchronizeAssets calls syncSnapOwnedAssets.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Move extraneous-dependency suppressions with relocated imports, fix
id-length and class-member spacing, and format updated tests.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
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