Skip to content

refactor(tron-wallet-snap): extract shared asset utils and inject SnapAssetsAdapter - #143

Merged
ulissesferreira merged 5 commits into
mainfrom
WPN-1497-extract-shared-asset-util-functions
Aug 10, 2026
Merged

refactor(tron-wallet-snap): extract shared asset utils and inject SnapAssetsAdapter#143
ulissesferreira merged 5 commits into
mainfrom
WPN-1497-extract-shared-asset-util-functions

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract snap-owned asset helpers (build*, extract*, isSnapOwnedAsset) into shared services/assets/utils and teach SnapAssetsAdapter to use them
  • Initialize SnapAssetsAdapter in context.ts and inject it into AssetsService
  • Rename getByKeyringAccountIdgetAccountAssets (essential-asset synthesis included) and update keyring callers

Part of WPN-1497. Stack:

  1. refactor(tron-wallet-snap): extract shared asset utils and inject SnapAssetsAdapter #143 (this PR)
  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

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 src/services/assets/utils/isSnapOwnedAsset.test.ts src/handlers/keyring/keyring.test.ts
  • Confirm runtime still reads/writes only via Snap adapter (no Core routing yet)

…pAssetsAdapter

Move snap-owned extraction helpers into shared utils, wire SnapAssetsAdapter from
context into AssetsService, and rename getByKeyringAccountId to getAccountAssets.

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.

Simple rename, will come in handy

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.

Simple rename, will come in handy

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 functions will be reused in the future so let's extract them to a utils

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.

Adapters should not be initialized in the service but rather passed in

…om CI

Apply oxfmt to extracted asset utils and set snap.manifest.json shasum to
the Linux CI build output so the build job's clean-working-tree check passes.
Satisfy import-x/consistent-type-specifier-style for CI eslint.
Comment thread packages/tron-wallet-snap/src/services/assets/utils/isSnapOwnedAsset.ts Outdated
Comment thread packages/tron-wallet-snap/src/services/assets/utils/isSnapOwnedAsset.ts Outdated

@taran-a taran-a 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.

GG. LGTM, just a couple of comment regarding types

Use CaipAssetType for the snap-owned asset set and lookup parameter
per review feedback.
@ulissesferreira
ulissesferreira added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 5d6e0d6 Aug 10, 2026
49 checks passed
@ulissesferreira
ulissesferreira deleted the WPN-1497-extract-shared-asset-util-functions branch August 10, 2026 16:21
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