refactor(solana-wallet-snap): extract SnapAssetsAdapter from existing AssetsService - #121
Conversation
0b8c00f to
013ceaf
Compare
There was a problem hiding this comment.
I suggest "View file" for an easier review on the end result
There was a problem hiding this comment.
For the reviewer, confirm everything was moved here neatly
7202af0 to
c0b1fa8
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the Solana snap’s assets domain by extracting the snap-owned implementation into a dedicated SnapAssetsAdapter, turning AssetsService into a thin facade that delegates all behavior to the adapter (as part of the staged assets-controller migration).
Changes:
- Introduces
SnapAssetsAdaptercontaining the legacy snap-owned assets logic (fetch, persist, metadata, market data, account-asset reads). - Refactors
AssetsServiceinto a delegate-only facade and wires the adapter insnapContext. - Updates/extends unit tests and changelog; adjusts ESLint suppressions and manifest shasum.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/solana-wallet-snap/src/snapContext.ts | Constructs SnapAssetsAdapter and injects it into the AssetsService facade. |
| packages/solana-wallet-snap/src/core/services/assets/index.ts | Exposes the new adapter from the assets service module. |
| packages/solana-wallet-snap/src/core/services/assets/AssetsService.ts | Replaces inlined assets logic with delegation to SnapAssetsAdapter. |
| packages/solana-wallet-snap/src/core/services/assets/AssetsService.test.ts | Updates tests to instantiate the adapter and adds delegation coverage for metadata/market data. |
| packages/solana-wallet-snap/src/core/services/assets/adapters/SnapAssetsAdapter.ts | New adapter containing the extracted legacy assets domain logic. |
| packages/solana-wallet-snap/src/core/services/assets/adapters/SnapAssetsAdapter.test.ts | Adds initial unit tests for the adapter (constructor + hasChanged). |
| packages/solana-wallet-snap/snap.manifest.json | Updates bundle shasum for the new build output. |
| packages/solana-wallet-snap/CHANGELOG.md | Documents the adapter extraction and facade refactor. |
| eslint-suppressions.json | Moves existing suppressions from AssetsService to SnapAssetsAdapter. |
Suppressed comments (1)
packages/solana-wallet-snap/src/core/services/assets/adapters/SnapAssetsAdapter.ts:624
- Same
await-thenableissue as above: thisemitSnapKeyringEvent(...)call is awaited in a file that requires an@typescript-eslint/await-thenablesuppression. Consider making the awaited expression explicitly thenable (or removeawaitif appropriate) so the suppression can be dropped.
await emitSnapKeyringEvent(snap, KeyringEvent.AccountBalancesUpdated, {
balances: balancesUpdatedPayload,
});
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
c0b1fa8 to
0447272
Compare
… AssetsService Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
0447272 to
b946882
Compare
…er extract The SnapAssetsAdapter extraction changed the bundle, so CI's mm-snap build rewrote the shasum and failed the dirty-tree check. Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
| let mockNftApiClient: NftApiClient; | ||
| let mockCache: ICache<Serializable>; | ||
|
|
||
| beforeEach(() => { |
There was a problem hiding this comment.
nit: but since we want to avoid using beforeEach in favor of with...() wrapper. up to you
There was a problem hiding this comment.
Will change it in follow ups! Since it will bring in a lot
Explanation
Part of migrating the Solana assets-controller staged migration from snap-solana-wallet#636 into this monorepo (PR 2 of 6, Lane A / feature-flag path only).
adapters/SnapAssetsAdapter.tsAssetsServiceis now a Tron-style thin facade: constructor takes{ snapAdapter }and every public method delegatesCoreAssetsAdapterin this PR)mainand alignedSnapAssetsAdapterwith the sharedLoggerfrom@metamask/snap-networks-utils/logger(logger.withPrefix(...)instead of the old localcreatePrefixedLogger/ILogger)Callers (
Keyring,SendService,AccountsSynchronizer,KeyringAccountMonitor, asset handlers) are unchanged and still go throughAssetsService.References
AssetsProviderwiring (Tron-style, not literalCoreAssetsAdapter)Checklist