Skip to content

chore(solana): replace in in the Solana transaction and fee code - #633

Open
ulissesferreira wants to merge 1 commit into
mainfrom
chore/solana-lint-suppressions-transactions-fees
Open

ulissesferreira wants to merge 1 commit into
mainfrom
chore/solana-lint-suppressions-transactions-fees

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Description

Removes the 37 Oxlint suppressions covering the Solana fee calculator and the transaction services. The internal-snaps/no-in-operator violations are replaced with hasProperty() from @metamask/utils (a drop-in own-property check with the same narrowing behaviour), and the remaining families are type-level or test-hygiene fixes: the named BigNumber export, missing return types, real types instead of any, and argument-dependent test setup that no longer needs conditionals.

This is behaviour-neutral. hasProperty() and the in operator agree for every value these guards actually receive; the only difference is that hasProperty() returns false for null instead of throwing, which the pre-existing typeof x === 'object' checks now cover explicitly where a nested value can be null. The single || → ?? switch is equivalent because TransactionError is a union of non-empty string literals and an object type, so meta.err is never a falsy non-nullish value.

Changes

  • packages/solana-wallet-snap/src/core/fees/FeeCalculator.ts — hasProperty() in the four input type guards, named BigNumber export, dropped the two unused catch bindings (no-in-operator, import/no-named-as-default, no-unused-vars)
  • packages/solana-wallet-snap/src/core/fees/normalizers/types.ts — ed25519Signatures: readonly any[] → readonly (SignatureBytes | string | null)[], the exact union the three normalizers produce (no-explicit-any)
  • packages/solana-wallet-snap/src/core/fees/FeeCalculator.test.ts — the invalid-input fixture is typed as NormalizableInput instead of any (no-explicit-any, no-unsafe-argument)
  • packages/solana-wallet-snap/src/core/fees/normalizers/normalizeKitTransaction.test.ts — the mock scenario's signedTransaction is typed as a kit Transaction (no-unsafe-argument)
  • packages/solana-wallet-snap/src/core/services/transactions/TransactionMapper.ts — hasProperty() for the Err status check, ?? for meta.err, BigNumber.Value narrowing for the parsed transfer amount, and return types on #aggregateSameAssetMovements / #decodeOpcode (no-in-operator, prefer-nullish-coalescing, no-unsafe-assignment, no-unsafe-argument, explicit-function-return-type, import/no-named-as-default)
  • packages/solana-wallet-snap/src/core/services/transactions/TransactionMapper.test.ts — the two disabled maps swaps - #6 SOL -> USDC / #7 SOL -> OBRIC cases assert mapping the code does not implement (their own comment says so), so they are now it.todo carrying the same explanation and Solscan links, instead of .skip (no-disabled-tests)
  • packages/solana-wallet-snap/src/core/services/transactions/TransactionsRepository.test.ts — return type on createMockTransaction (explicit-function-return-type)
  • packages/solana-wallet-snap/src/core/services/transactions/TransactionsService.ts — hasProperty() for the two 'mint' in asset checks, reading the narrowed mint with String() (no-in-operator)
  • packages/solana-wallet-snap/src/core/services/transactions/TransactionsService.test.ts — typed globalThis.snap assignment, and the four argument-dependent ternary mocks became total lookup tables keyed by account/program (no-explicit-any, no-unsafe-member-access, no-conditional-in-test)
  • packages/solana-wallet-snap/src/core/services/transactions/utils/isSpam.ts — named BigNumber export (import/no-named-as-default)
  • packages/solana-wallet-snap/src/core/services/transactions/utils/isSpam.test.ts — module-level assertDefined() helper replaces the per-test if (!transaction) throw (no-conditional-in-test)

Quality gates

  • yarn lint:oxlint packages/solana-wallet-snap — clean, 37 suppressions entries removed (repository total 2069 → 2032)
  • tsc --noEmit — clean
  • vitest run — 88 files, 1124 passed, 2 skipped (was 4), 3 todo (was 1)
  • oxfmt --check — clean

Two disabled tests were converted to it.todo rather than deleted: they document an edge case the mapper does not handle (a swap that looks like a receive), and the file already uses it.todo for the same reason.

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
default-branch — 8415a2ac Deployed Nov 17, 2026 by ulissesferreira via Determine whether this PR is a release PR #2405
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