Skip to content

fix(sdk): replace any with typed generics in unified scanner adapter API - #227

Open
Jerryvic911 wants to merge 2 commits into
wraith-protocol:developfrom
Jerryvic911:fix/201-typed-scanner-adapters
Open

Jerryvic911 wants to merge 2 commits into
wraith-protocol:developfrom
Jerryvic911:fix/201-typed-scanner-adapters

Conversation

@Jerryvic911

Copy link
Copy Markdown
Contributor

Replace any defaults on ChainScannerAdapter and CustomChainInput with unknown, so the public adapter API carries real generic constraints instead of an escape hatch that defeated type checking entirely. encodeMetaAddress params are explicitly unknown since key material differs per chain. ScanAllInput.adapters now accepts a heterogeneous array of CustomChainInput without any, relying on bivariant method checking for soundness. The custom-adapter arm of MatchedAnnouncement now carries unknown instead of any, completing the discriminated union. Drops two undocumented, untyped fallback shapes in the scanAll() custom-adapter loop (bare adapter object, { input: {...} }) that were never used in tests, docs, or examples and made real generic constraints impossible.

Adds test/scanner/unified.test-d.ts, a new compile-time usage test file run via vitest's --typecheck.only mode (wired up as pnpm run test:types), verifying adapter generics narrow correctly, mismatched CustomChainInput generics are rejected at compile time, and the discriminated union holds.

Closes #201

Replace any defaults on ChainScannerAdapter and CustomChainInput with
unknown, so the public adapter API carries real generic constraints
instead of an escape hatch that defeated type checking entirely.
encodeMetaAddress params are explicitly unknown since key material
differs per chain. ScanAllInput.adapters now accepts a heterogeneous
array of CustomChainInput without any, relying on bivariant method
checking for soundness. The custom-adapter arm of MatchedAnnouncement
now carries unknown instead of any, completing the discriminated
union. Drops two undocumented, untyped fallback shapes in the
scanAll() custom-adapter loop (bare adapter object, { input: {...} })
that were never used in tests, docs, or examples and made real
generic constraints impossible.

Adds test/scanner/unified.test-d.ts, a new compile-time usage test
file run via vitest's --typecheck.only mode (wired up as pnpm run
test:types), verifying adapter generics narrow correctly, mismatched
CustomChainInput generics are rejected at compile time, and the
discriminated union holds.

Closes wraith-protocol#201
@drips-wave

drips-wave Bot commented Sep 25, 2026

Copy link
Copy Markdown

@Jerryvic911 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify

truthixify commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The custom arm is not discriminated yet. chain: string overlaps the built-in chain names, so announcement stays unknown even after checking for evm. Please fix that narrowing and run test:types in CI.

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.

[Wave 9] Remove any from the unified scanner adapter API

2 participants