Skip to content

refactor(snap-solana-wallet): align Solana AssetsService read API with snap-networks-utils - #120

Open
ulissesferreira wants to merge 3 commits into
mainfrom
ulissesferreira/wpn-1652-align-assets-service-api-6620
Open

refactor(snap-solana-wallet): align Solana AssetsService read API with snap-networks-utils#120
ulissesferreira wants to merge 3 commits into
mainfrom
ulissesferreira/wpn-1652-align-assets-service-api-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#635 into this monorepo (PR 1 of 6, Lane A / feature-flag path only).

  • Add shared read API methods on AssetsService: getAccountAssetByID, getAccountAssetsByIDs, getAccountAssetsByScope, getAccountAssets
  • Wire accountsService into AssetsService (needed for account lookup by ID)
  • Update Keyring and Send to use the new API
  • No behavior change — still reads from Snap-owned assetEntities via AssetsRepository
  • Rebased onto latest main (includes chore(solana-wallet-snap): deprecate pre-Unified Send Flow code #130 removal of legacy send UI / refreshSend cron — those paths are no longer updated here)

Read API surface

Migration call sites use only these four methods, with return shapes aligned to AssetsProvider / AssetsController patterns (single element, map-by-ID, scoped array, full array):

Method Return type
getAccountAssetByID AssetEntity | null
getAccountAssetsByIDs Record<string, AssetEntity | null>
getAccountAssetsByScope AssetEntity[]
getAccountAssets AssetEntity[]

CI babysit fixes

  • Fix unused-vars eslint failures in SendService and prune the stale suppression
  • Remove unused Keyring fields (configProvider, traceName) and prune stale eslint suppressions
  • Simplify read helpers: getAccountAssets fetches once and filters by active networks; getAccountAssetsByIDs uses a Map for lookups
  • Rebased onto latest main (Release/6.0.0 + chore(solana-wallet-snap): deprecate pre-Unified Send Flow code #130 send-flow deprecation)
  • Synced snap.manifest.json shasum with the CI production build after rebase

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 

cursor Bot pushed a commit that referenced this pull request Aug 5, 2026
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@ulissesferreira
ulissesferreira marked this pull request as ready for review August 5, 2026 18:06
@ulissesferreira
ulissesferreira requested review from a team as code owners August 5, 2026 18:06
cursor Bot pushed a commit that referenced this pull request Aug 5, 2026
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-align-assets-service-api-6620 branch from f5ec399 to ed3340c Compare August 5, 2026 18:09
@MetaMask MetaMask deleted a comment from cursor Bot Aug 5, 2026
@ulissesferreira ulissesferreira changed the title chore(WPN-1652): align Solana AssetsService read API with snap-networks-utils refactor: align Solana AssetsService read API with snap-networks-utils Aug 5, 2026
@ulissesferreira ulissesferreira changed the title refactor: align Solana AssetsService read API with snap-networks-utils refactor(snap-solana-wallet): align Solana AssetsService read API with snap-networks-utils Aug 5, 2026
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-align-assets-service-api-6620 branch 2 times, most recently from 515bebf to 0f8d17f Compare August 6, 2026 11:47
@MetaMask MetaMask deleted a comment from cursor Bot Aug 6, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Aug 6, 2026
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent rebase latest main and make sure the CI is green

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Taking a look!

Open in Web Open in Cursor 

@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-align-assets-service-api-6620 branch from 11fe525 to eef1038 Compare August 6, 2026 15:18
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent in this migration make sure the calls to the AssetsService are all one of the following method names:

getAccountAssetByID, getAccountAssetsByIDs, getAccountAssetsByScope, getAccountAssets

where the return types follow a similar logic to the AssetsProvider first 3 methods. Not the same return type, but similar takes on single element, map, array and array

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Aligned the migration with the four-method read API you specified.

Changes

  1. Added getAccountAssets to AssetsService — returns AssetEntity[] across all active networks (replaces the inlined getAccountAssetsByScope loop in Keyring).

  2. Updated Keyring.getAccountAssets — now calls this.#assetsService.getAccountAssets(accountId) instead of fanning out per scope.

  3. Read API surface — migration call sites now use only these four methods with return shapes matching AssetsProvider patterns:

Method Return type Used by
getAccountAssetByID AssetEntity | null (service layer)
getAccountAssetsByIDs Record<string, AssetEntity | null> Keyring balances, Send
getAccountAssetsByScope AssetEntity[] (service layer)
getAccountAssets AssetEntity[] Keyring asset listing
  1. Tests updatedAssetsService.test.ts, Keyring.test.ts; all 95 tests in the affected suites pass.

The previous getAccountAssetsForAllActiveScopes name is gone; getAccountAssets is the canonical fourth method, consistent with the Tron snap pattern.

Open in Web Open in Cursor 

let mockKeyringAccountMonitor: KeyringAccountMonitor;
let mockConfigProvider: ConfigProvider;

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.

This, in the future, will probably be removed in favour of a setup function

@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent The changes here are missing a lint run + fix and also have disorganized commits which are hard to review. Fix lint problems and suggest a possible list of commits that make sense for this. Make sure the read assets methods are lean and as logically simple as possible

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Fixed lint failures, simplified the read API, and pushed commit 541bae11.

Lint fixes

yarn lint was failing on two unused private fields in Keyring.ts:

  • #configProvider — added during migration but never used (account/config lookup belongs on AssetsService, not Keyring). Removed from Keyring, snapContext, and tests.
  • #traceName — dead code; only #traceNameBatch is used in createAccounts.

Also ran yarn lint:fix, which pruned 3 stale entries from eslint-suppressions.json. Lint now passes cleanly.

Read API simplification

The four read methods are now leaner:

Method Approach
getAccountAssetsByScope Core primitive: account lookup → findByAccount → filter by scope
getAccountAssetByID Delegates to getAccountAssetsByScope + find
getAccountAssetsByIDs Groups by scope, builds a Map for O(1) lookups (no repeated .find())
getAccountAssets Single account fetch + findByAccount, then filters by active networks (avoids N redundant account lookups)

All 95 tests in the affected suites pass.

Suggested commit structure

The current history has noise (chore: retrigger CI, duplicate manifest shasum commits, SendService lint fix split out). For review, I'd squash/rebase onto latest main into 3 focused commits:

  1. refactor(solana-wallet-snap): add AssetsService read API aligned with snap-networks-utils

    • AssetsService.ts — four read methods + accountsService dependency
    • AssetsService.test.ts
    • snapContext.ts — wire accountsService into AssetsService
    • CHANGELOG.md
  2. refactor(solana-wallet-snap): route Keyring and Send through AssetsService read API

    • Keyring.ts / Keyring.test.ts
    • SendService.ts / SendService.test.ts
  3. chore(solana-wallet-snap): sync snap.manifest.json shasum after build

    • snap.manifest.json only (auto-generated by production build)

The lint cleanup and read-API simplification from this turn fold into commits 1–2 above. Drop chore: retrigger CI after rebase onto main entirely.

To apply: git fetch origin main && git rebase -i origin/main, then squash/reorder into the three commits above.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 7, 2026 12:12
… snap-networks-utils

Add getAccountAssetByID, getAccountAssetsByIDs, getAccountAssetsByScope,
and getAccountAssets on AssetsService, wire accountsService for account
lookup, and cover the read helpers with unit tests.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
…rvice read API

Switch Keyring asset listing/balances and Send balance lookups to the new
read methods, remove unused SendService variables, and prune stale eslint
suppressions.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-align-assets-service-api-6620 branch from 541bae1 to 7a154fb Compare August 7, 2026 12:13
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor
cursor Bot force-pushed the ulissesferreira/wpn-1652-align-assets-service-api-6620 branch from 7a154fb to 5d407ac Compare August 7, 2026 12:25
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.

3 participants