Skip to content

refactor(solana-wallet-snap): extract SnapAssetsAdapter from existing AssetsService - #121

Merged
ulissesferreira merged 2 commits into
mainfrom
ulissesferreira/wpn-1652-snap-assets-adapter-6620
Aug 18, 2026
Merged

refactor(solana-wallet-snap): extract SnapAssetsAdapter from existing AssetsService#121
ulissesferreira merged 2 commits into
mainfrom
ulissesferreira/wpn-1652-snap-assets-adapter-6620

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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).

  • Move the Snap-owned assets domain (fetch, persist, account-asset reads, metadata, market data) into adapters/SnapAssetsAdapter.ts
  • AssetsService is now a Tron-style thin facade: constructor takes { snapAdapter } and every public method delegates
  • No Core routing yet — Snap adapter remains the sole path (no CoreAssetsAdapter in this PR)
  • Rebased onto latest main and aligned SnapAssetsAdapter with the shared Logger from @metamask/snap-networks-utils/logger (logger.withPrefix(...) instead of the old local createPrefixedLogger / ILogger)

Callers (Keyring, SendService, AccountsSynchronizer, KeyringAccountMonitor, asset handlers) are unchanged and still go through AssetsService.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
Open in Web Open in Cursor 

@ulissesferreira ulissesferreira changed the title refactor(WPN-1652): extract SnapAssetsAdapter for Solana balance reads refactor(solana-wallet-snap): extract SnapAssetsAdapter for Solana balance reads Aug 6, 2026
Base automatically changed from ulissesferreira/wpn-1652-align-assets-service-api-6620 to main August 10, 2026 16:10
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-snap-assets-adapter-6620 branch from 0b8c00f to 013ceaf Compare August 14, 2026 13:38
@cursor cursor Bot changed the title refactor(solana-wallet-snap): extract SnapAssetsAdapter for Solana balance reads refactor(solana-wallet-snap): extract SnapAssetsAdapter for Solana assets domain Aug 14, 2026

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.

I suggest "View file" for an easier review on the end result

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.

For the reviewer, confirm everything was moved here neatly

@ulissesferreira ulissesferreira changed the title refactor(solana-wallet-snap): extract SnapAssetsAdapter for Solana assets domain refactor(solana-wallet-snap): extract SnapAssetsAdapter from existing AssetsService Aug 14, 2026
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-snap-assets-adapter-6620 branch from 7202af0 to c0b1fa8 Compare August 14, 2026 14:40
@ulissesferreira
ulissesferreira marked this pull request as ready for review August 14, 2026 15:00
@ulissesferreira
ulissesferreira requested review from a team as code owners August 14, 2026 15:00
@ulissesferreira
ulissesferreira deployed to default-branch August 14, 2026 15:00 — with GitHub Actions Active
@stanleyyconsensys
stanleyyconsensys requested a lite review from Copilot August 18, 2026 07:03

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

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 SnapAssetsAdapter containing the legacy snap-owned assets logic (fetch, persist, metadata, market data, account-asset reads).
  • Refactors AssetsService into a delegate-only facade and wires the adapter in snapContext.
  • 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-thenable issue as above: this emitSnapKeyringEvent(...) call is awaited in a file that requires an @typescript-eslint/await-thenable suppression. Consider making the awaited expression explicitly thenable (or remove await if 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.

@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-snap-assets-adapter-6620 branch from c0b1fa8 to 0447272 Compare August 18, 2026 13:59
… AssetsService

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-snap-assets-adapter-6620 branch from 0447272 to b946882 Compare August 18, 2026 14:07
…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(() => {

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.

nit: but since we want to avoid using beforeEach in favor of with...() wrapper. up to you

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.

Will change it in follow ups! Since it will bring in a lot

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

LGTM

@ulissesferreira
ulissesferreira added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 03b2801 Aug 18, 2026
49 checks passed
@ulissesferreira
ulissesferreira deleted the ulissesferreira/wpn-1652-snap-assets-adapter-6620 branch August 18, 2026 15:18
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.

4 participants