fix(types): widen constructor to accept ISigner (parent's contract)#88
Merged
Conversation
The abstract WalletManager (in @tetherto/wdk-wallet) accepts
`string | Uint8Array | ISigner`. WalletManagerEvm's
constructor accepts `string | Uint8Array | ISignerEvm` —
stricter than the parent's contract, since ISignerEvm
extends ISigner with extra required members (isDerivable,
index, path, address, …).
That is a TypeScript subtyping violation: `typeof
WalletManagerEvm` is not assignable to `typeof
WalletManager`, which breaks
`wdk.registerWallet('ethereum', WalletManagerEvm, ...)`
under strict TS in consumers like @tetherto/wdk.
Widen the JSDoc @param to ISigner. Runtime behavior is
unchanged: any signer whose `isDerivable` is falsy (which
includes any plain ISigner without the EVM extension) is
already rejected by the existing `if (!signer.isDerivable)`
guard, so the widened type space does not admit any new
successfully-constructed instances at runtime.
Closes tetherto/wdk#72.
claudiovb
marked this pull request as ready for review
July 2, 2026 12:49
claudiovb
approved these changes
Jul 2, 2026
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.
Summary
The abstract
WalletManager(in@tetherto/wdk-wallet) acceptsstring | Uint8Array | ISigner.WalletManagerEvm's constructor acceptsstring | Uint8Array | ISignerEvm— stricter than the parent's contract, sinceISignerEvmextendsISignerwith extra required members (isDerivable,index,path,address, …).That is a TypeScript subtyping violation:
which breaks
wdk.registerWallet('ethereum', WalletManagerEvm, ...)(the standard consumer entry-point in@tetherto/wdk) under strict TypeScript. This is the second half of tetherto/wdk#72 — thegetAccounthalf was already resolved by #40.Fix
Widen the JSDoc
@paramtype on the constructor fromISignerEvmtoISigner:Runtime behavior is unchanged: any signer whose
isDerivableis falsy — which includes any plainISignerwithout the EVM-specific extension — is already rejected by the existingif (!signer.isDerivable)guard. The widened type space does not admit any new successfully-constructed instances at runtime.Scope
src/wallet-manager-evm.js:@typedefimport +@paramchangetypes/src/wallet-manager-evm.d.ts: surgically edited to mirror the source change; the rest oftypes/is left as-is to avoid unrelated regeneration drifttests/wallet-manager-evm.test.js: 1 new test asserting a bareISigner(noisDerivable) is rejected at constructionTest plan
npm run lint— cleannpm test— 111/111 (was 110; +1 for the new rejection test)npm run build:types— emitsconstructor(seedOrSigner: string | Uint8Array | ISigner, config?: EvmWalletConfig)wdk-core's docs TypeScript snippet: the constructor subtyping error is resolvedMarked as draft
Opening as draft since Issue #72 has an established history and I want to leave room for feedback on the description text and the additional test before it goes to review.