Skip to content

chore(solana): type the Solana asset services - #632

Open
ulissesferreira wants to merge 2 commits into
mainfrom
chore/solana-lint-suppressions-assets
Open

ulissesferreira wants to merge 2 commits into
mainfrom
chore/solana-lint-suppressions-assets

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Description

Removes every Oxlint suppression in the Solana snap's asset services. The bulk of the diff is typing, not refactoring: TokenHelper now narrows the token-2022 mint extension union with type predicates instead of handling any extension objects, the asset service tests describe their mocked RPC/client shapes with real types (and assert for fixture narrowing) instead of as any, and three conditionals in test setup became mockResolvedValueOnce / mockRejectedValueOnce chains. Two dead private members in SnapAssetsAdapter were removed: #getNftsMetadata and #fetchNftAssets were only ever referenced from commented-out NFT call sites, so their callers, helper types and imports went with them. Behaviour is unchanged: the removed code was unreachable, isIncremental still short-circuits the same way, and the assertions removed were no-ops at the type level.

Changes

  • packages/solana-wallet-snap/src/core/services/assets/TokenHelper.ts — type the token-2022 Extension union with Extract<…> predicates instead of any; import BigNumber as a named export; drop the unused caught error bindings; Number() the bigint effective-timestamp before comparing with the epoch-seconds number (no-explicit-any, no-unsafe-member-access, no-unsafe-argument, no-unsafe-assignment, no-unused-vars, no-named-as-default)
  • packages/solana-wallet-snap/src/core/services/assets/TokenHelper.test.ts — type the interest-bearing extension fixture as the real extension variant (no-explicit-any)
  • packages/solana-wallet-snap/src/core/services/assets/AssetsService.ts — drop the redundant as Record<…> on Object.fromEntries (no-unnecessary-type-assertion)
  • packages/solana-wallet-snap/src/core/services/assets/AssetsService.test.ts — type the globalThis.snap stub and the mocked getRpc() return values with unknown + ReturnType<SolanaConnection['getRpc']>; delete the two it.skip blocks that asserted the removed non-incremental event behaviour (no-explicit-any, no-unsafe-member-access, no-unsafe-argument, no-disabled-tests)
  • packages/solana-wallet-snap/src/core/services/assets/adapters/SnapAssetsAdapter.ts — remove the dead #getNftsMetadata/#fetchNftAssets and the commented-out call sites that referenced them; run the sync metadata call outside Promise.all; drop two redundant casts (no-unused-private-class-members, await-thenable, no-unnecessary-type-assertion)
  • packages/solana-wallet-snap/src/core/services/assets/adapters/SnapAssetsAdapter.test.ts — narrow the fixture token account with assert from @metamask/utils (no-conditional-in-test)
  • packages/solana-wallet-snap/src/core/services/assets/adapters/CoreAssetsAdapter.test.ts — drop the redundant as Asset; replace scope-branching mock implementations with mockResolvedValueOnce/mockRejectedValueOnce chains (no-unnecessary-type-assertion, no-conditional-in-test)
  • packages/solana-wallet-snap/src/core/services/assets/utils/mapControllerAsset.ts — drop the redundant as TokenAsset (no-unnecessary-type-assertion)
  • oxlint-suppressions.json — regenerated with --prune-suppressions (45 violations removed across the 8 files above)

The NFT client is no longer stored on SnapAssetsAdapter; the constructor option stays in the contract because snapContext.ts still builds and passes it (removing the option is a follow-up that touches that caller).

Quality gates

  • yarn lint:oxlint packages/solana-wallet-snap — clean, 45 suppressions entries removed
  • tsc --noEmit — clean
  • vitest run — 88 files, 1124 passed | 2 skipped | 1 todo (the 2 skips deleted here were the no-disabled-tests blocks)
  • oxfmt --check — clean
  • yarn lint:misc:check — clean

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive (outdated) deployment
default-branch — e870cb07 Deployed Nov 17, 2026 by ulissesferreira via Determine whether this PR is a release PR #2404
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