Skip to content

feat(tron-wallet-snap): route fungible reads through Core AssetsController - #96

Draft
ulissesferreira wants to merge 4 commits into
WPN-1497-messenger-plumbingfrom
WPN-1497-core-adapter-routing
Draft

feat(tron-wallet-snap): route fungible reads through Core AssetsController#96
ulissesferreira wants to merge 4 commits into
WPN-1497-messenger-plumbingfrom
WPN-1497-core-adapter-routing

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Summary

  • Introduce CoreAssetsAdapter and mapControllerAsset for Core AssetsController reads
  • Route fungible asset reads (TRX, TRC10, TRC20) based on resolved migration stage (Off / ReadWithFallback / Read)
  • Snap-owned assets always use SnapAssetsAdapter; narrow sync/saveMany to snap-owned when Core stage is active
  • Manifest endows AssetsController:getAsset and AssetsController:getAssets

Part 2 of 2 split from #94. Part 1: WPN-1497-messenger-plumbing.

Jira

Test plan

  • yarn workspace @metamask/tron-wallet-snap build
  • yarn workspace @metamask/tron-wallet-snap run jest --no-coverage (898 tests)

Stacks on PR 1 (WPN-1497-messenger-plumbing), which stacks on #92.

Supersedes #94.

@socket-security

socket-security Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask-previews/​snap-networks-utils@​0.0.0-preview-a0892371 ⏵ 0.0.0-preview-8589132721008887 -3100
Updatednpm/​@​metamask/​assets-controller@​13.0.0 ⏵ 13.1.076 +110080 +1100 +1100

View full report

): Promise<AssetEntity | null> {
if (isSnapOwnedAsset(assetId)) {
return this.#snapAdapter.getAccountAssetByID(accountId, assetId);
}

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 shouldn't exist

return ASSETS_MIGRATION_STAGE;
}

async #getProviderAccountAssetByID(

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.

Unnecessary indirection

return mapControllerAsset(accountId, asset);
}

async #getProviderAccountAssetsByIDs(

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.

Unnecessary indirection

);
}

async #getProviderAccountAssetsByScope(

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.

Unnecessary indirection

}

return this.#getProviderAccountAssetByID(accountId, assetId);
}

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.

We don't need the fallback thing. Just an if with an early return and everything else

@cursor
cursor Bot force-pushed the WPN-1497-messenger-plumbing branch from f5bde1f to f53d7bf Compare August 4, 2026 11:09
ulissesferreira and others added 4 commits August 4, 2026 14:43
Bump devDependency to match snap-networks-utils baseline. Update
AssetsService test mocks for v13 SnapsAssetsMigrationStage enum names
and RemoteFeatureFlagController:getState return shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
…vider

Adopt @metamask/snap-networks-utils AssetsProvider from day one for
account-scoped AssetsController reads (getAccountAssetByID,
getAccountAssetsByIDs, getAccountAssetsByScope) behind migration-stage
routing in AssetsService. Map controller Asset shapes to private
AssetEntity via mapControllerAsset; protocol assets remain Snap-owned
through SnapAssetsAdapter. CoreAssetsAdapter is not used.

Co-authored-by: Cursor <cursoragent@cursor.com>
…red AssetsProvider

Wire @metamask/tron-wallet-snap to @metamask-previews/snap-networks-utils@0.0.0-preview-8589132
(published from PR #82) via npm alias, replacing workspace:^ to satisfy yarn constraints.
Allow the preview dependency range in yarn.config.cjs until PR #82 merges.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from f53d7bf to c9d4f0c Compare August 4, 2026 13:45
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from 1a63feb to 3dc547d Compare August 4, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant