refactor(snap-solana-wallet): align Solana AssetsService read API with snap-networks-utils - #120
Conversation
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
f5ec399 to
ed3340c
Compare
515bebf to
0f8d17f
Compare
|
@cursoragent rebase latest main and make sure the CI is green |
11fe525 to
eef1038
Compare
|
@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 |
|
Aligned the migration with the four-method read API you specified. Changes
The previous |
|
@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 |
|
Fixed lint failures, simplified the read API, and pushed commit Lint fixes
Also ran Read API simplificationThe four read methods are now leaner:
All 95 tests in the affected suites pass. Suggested commit structureThe current history has noise (
The lint cleanup and read-API simplification from this turn fold into commits 1–2 above. Drop To apply: |
7a154fb to
5d407ac
Compare
|
@cursoragent rebase with latest main |
|
Rebased onto latest Rebase summaryBase: Conflicts resolved:
Commit history (3 commits, unchanged structure):
Verification:
Branch force-pushed to |
… 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>
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
5d407ac to
5cd2400
Compare
… typecheck - Add AssetsRepository.findByKeyringAccountIdAndAssetType for direct lookups - getAccountAssetByID: repository lookup + native placeholder only when needed - getAccountAssetsByIDs: single repository read, no Promise.all scope fan-out - Extract #createNativePlaceholder shared with findByAccount - Pin @solana/addresses to 2.1.0 to fix Address brand mismatches - Build snap-networks-utils before typecheck (dist required by tron-wallet-snap) - Remove @jest/globals expect import from index.test.ts (use snaps-jest types) - Sync snap.manifest.json shasum after build Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
| "test:scripts": "NODE_OPTIONS=--experimental-vm-modules yarn jest --config ./jest.config.scripts.js --silent", | ||
| "test:verbose": "yarn workspaces foreach --all --exclude @metamask/sample-snap --parallel --verbose run test:verbose", | ||
| "typecheck": "yarn workspaces foreach --all --parallel --verbose exec tsc --noEmit", | ||
| "typecheck": "yarn workspace @metamask/snap-networks-utils run build && yarn workspaces foreach --all --parallel --verbose exec tsc --noEmit", |
There was a problem hiding this comment.
This will be removed when we coordinate how we want typescript to work across the repo. For now, we need it.
…tsService read API Remove findByKeyringAccountIdAndAssetType from AssetsRepository. Read paths stay on AssetsService (getAccountAssetByID, getAccountAssetsByIDs, getAccountAssetsByScope, getAccountAssets) using findByAccount and in-memory filtering. Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
…ByAccount Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
… path Route getAccountAssetByID through getAccountAssetsByIDs instead of getAccountAssetsByScope, and extract #getAccountAssetsOrEmpty so the read API shares one account lookup + findByAccount path. Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Apply the production bundle shasum computed by CI and fix oxfmt formatting in AssetsService.test.ts.
Remove suppressions that no longer apply after the AssetsService refactor.
| */ | ||
| async getAccountAssetByID( | ||
| accountId: string, | ||
| assetId: string, |
| */ | ||
| async getAccountAssetsByIDs( | ||
| accountId: string, | ||
| assetIds: string[], |
There was a problem hiding this comment.
should be CaipAssetType[] ?
| async getAccountAssetsByIDs( | ||
| accountId: string, | ||
| assetIds: string[], | ||
| ): Promise<Record<string, AssetEntity | null>> { |
taran-a
left a comment
There was a problem hiding this comment.
LGTM, just same questions//comments regarding types.
…setType Use CaipAssetType for asset ID parameters and return keys in getAccountAssetByID and getAccountAssetsByIDs per review feedback.
The previous commit used a test-environment shasum; CI builds with ENVIRONMENT=production and requires a clean working tree.


Summary
Align Solana
AssetsServiceread API withsnap-networks-utils/ AssetsController shapes, and route Keyring + Send through those helpers while keeping Snap-owned storage.Follow-up simplification
getAccountAssetByIDnow goes throughgetAccountAssetsByIDsinstead ofgetAccountAssetsByScope(avoids an unnecessary scope filter).#getAccountAssetsOrEmptyso the read API shares one account lookup +findByAccountpath.Test plan
ENVIRONMENT=test yarn workspace @metamask/solana-wallet-snap run buildyarn workspace @metamask/solana-wallet-snap run jest --no-coverage src/core/services/assets/AssetsService.test.tsgetAccountAssets/getAccountBalancesstill resolve via AssetsServicegetAccountAssetsByIDs