Repository navigation
chore(solana): add return types across the Solana platform modules - #635
Open
ulissesferreira wants to merge 2 commits into
Open
ulissesferreira wants to merge 2 commits into
ulissesferreira wants to merge 2 commits into
Conversation
ulissesferreira
temporarily deployed
to
default-branch
November 17, 2026 02:16 — with
GitHub Actions
Inactive
The SonarCloud new-code coverage gate was failing at 76% because two polyfill lines changed in this PR had no tests. - Add tests for the queue-microtask polyfill: it installs a global `queueMicrotask`, defines it as writable/configurable/enumerable, and runs its callback asynchronously. - Move the queue-microtask implementation from `index.ts` to `install.ts`, matching the `ed25519` polyfill layout. Vitest excludes `src/**/index.ts` from coverage (the old Jest `coveragePathIgnorePatterns`), so the implementation could never be measured there and SonarCloud reported it as 0% covered. `index.ts` is now a re-export. - Add a JWK import test for the Ed25519 polyfill, covering the `hasProperty(jwk, 'd')` branch this PR introduced.
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Clears the Oxlint suppressions for the Solana Snap's core platform modules: the polyfill shims, the instruction parsers, the SDK extensions and the event emitter. 36 of the 37 suppressed violations in these files are gone; the rules cleared are
typescript/explicit-function-return-type(20),typescript/no-explicit-any(2 of 3),typescript/no-unsafe-assignment(3),typescript/no-unsafe-return,typescript/no-unsafe-argument,internal-snaps/no-in-operator(2),vitest/no-conditional-in-test(4),no-unused-vars,no-shadowandpromise/no-callback-in-promise.The change is behaviour-neutral: return types are the ones TypeScript already inferred, the two
inoperators were replaced withhasProperty()from@metamask/utils(an own-property check with the same narrowing, on plain decoded objects),catch (error)becamecatchwhere the binding was unused (a@ts-expect-erroron a branded-address lookup became a typed accessor), and the conditional test setup was turned intoit.eachdata. The polyfill signatures match the DOM/Node signatures they polyfill (Promise<ArrayBuffer | JsonWebKey>,Promise<CryptoKey>,void,string,Uint8Array).Changes
packages/solana-wallet-snap/src/core/components/Domain/Domain.tsx— returns aSnapElement<DomainProps>from the component (the Snaps SDK leaves JSX expressions untyped in this repo, so the element is labelled with the typeSnapComponentalready declares) (typescript/no-unsafe-return)packages/solana-wallet-snap/src/core/sdk-extensions/codecs.ts— the signer pairs are mapped as tuples beforeObject.fromEntries, so the signatures map stops falling through theanyoverload (typescript/no-unsafe-assignment)packages/solana-wallet-snap/src/core/sdk-extensions/codecs.test.ts— the fixture transaction is labelledTransactionat the call site, sinceMockExecutionScenario.signedTransactionis typedany(typescript/no-unsafe-argument)packages/solana-wallet-snap/src/core/sdk-extensions/transaction-messages.ts— explicit lifetime-setter return type,booleanpredicates, andcatchwithout the unused binding (typescript/explicit-function-return-type,no-unused-vars)packages/solana-wallet-snap/src/entities/instructions/instructions.ts—stringreturn types,booleanpredicate,hasProperty()instead ofin, and agetParsingConfig()accessor that replaces the@ts-expect-erroron the branded-address lookup (typescript/explicit-function-return-type,typescript/no-unsafe-assignment,internal-snaps/no-in-operator)packages/solana-wallet-snap/src/entities/instructions/instructions.test.ts— per-version fixture data viait.each, a module-level lookup-table predicate, andassert()for the fixture invariants instead ofif/throwand?? {}defaults (vitest/no-conditional-in-test)packages/solana-wallet-snap/src/entities/instructions/programs/secp256k1-secp256r1.ts— return types for the identifier, the twoisSecp256*Instructionpredicates and the verify parser (typescript/explicit-function-return-type)packages/solana-wallet-snap/src/infrastructure/event-emitter/EventEmitter.ts—voidreturn types, and aListener<Data>payload type (defaultunknown) instead ofany, erased when the listener is stored because listeners are keyed by event name only (typescript/explicit-function-return-type,typescript/no-explicit-any)packages/solana-wallet-snap/src/polyfills/ed25519/polyfill.ts— DOM-matching return types ontoBase64,toBuffer,exportKeyandimportKey, andhasProperty()for the JWKdcheck (typescript/explicit-function-return-type,internal-snaps/no-in-operator)packages/solana-wallet-snap/src/polyfills/dom-exception/index.ts,packages/solana-wallet-snap/src/polyfills/index.ts—voidreturn types (typescript/explicit-function-return-type)packages/solana-wallet-snap/src/polyfills/queue-microtask/index.ts—Promise<void>return type, a non-shadowing local name for the shim, and the microtask deferral expressed asawaitinstead of passing the callback to.then()(typescript/explicit-function-return-type,no-shadow,promise/no-callback-in-promise)oxlint-suppressions.json— regenerated with--prune-suppressionsQuality gates
yarn lint:oxlint packages/solana-wallet-snap— clean, 36 suppression entries removed (2069 → 2033 for the repo; the 12 files in this unit go 37 → 1)tsc --noEmit— cleanvitest run— 88 files, 1124 passed | 4 skipped | 1 todo, same asorigin/mainoxfmt --check— cleanLeft behind
One violation stays suppressed:
typescript/no-explicit-anyonParsedInstruction.datainentities/instructions/instructions.ts. The value is the untyped parse output of every instruction parser, and tightening it toJson/unknownbreaks the consumers that read it as a scalar —TransactionMapper(BigNumber(rawAmount)),analyzeFeePaymentandfeatures/confirmation/components/Instruction— so it needs its own change across those call sites rather than a type swap here.