Skip to content

Signer: Add isDerivable and keyPair to ISigner, align IWalletAccount with signer-backed accounts#52

Open
claudiovb wants to merge 1 commit into
tetherto:mainfrom
claudiovb:fix/universal-signer
Open

Signer: Add isDerivable and keyPair to ISigner, align IWalletAccount with signer-backed accounts#52
claudiovb wants to merge 1 commit into
tetherto:mainfrom
claudiovb:fix/universal-signer

Conversation

@claudiovb

Copy link
Copy Markdown
Contributor

Description

This PR extends the universal signer interface and aligns the wallet account interface with it, following up on the post-merge review of tetherto/wdk-wallet-evm#40:

  • ISigner gains two members:
    • isDerivable (boolean) — whether the signer supports account derivation. Lets users check derivation support without asserting on concrete types or probing whether derive() throws. Wallet managers already branch on this to validate default signers and to decide how to build accounts for registered signers.
    • keyPair (KeyPair | null) — the signer's key pair, or null for signers that cannot expose key material (e.g. hardware signers).
  • IWalletAccount is updated so accounts backed by any ISigner can honestly fulfill the contract:
    • keyPairKeyPair | null (null when the underlying signer doesn't allow retrieving key pairs).
    • indexnumber | undefined and pathstring | undefined (undefined when the signer is not bound to a BIP-44 position, e.g. private-key signers).
  • WalletManager constructor overloads are now annotated with @throws: Error for an invalid seed phrase on the seed overload, and SignerError on the signer overload when the default signer does not support account derivation (enforced by chain-specific subclasses).
  • Type declarations under types/ were hand-edited to match (no build:types run; the generator currently has issues — tracked separately).

No implementation code changes; runtime behavior is unchanged. Verified with the full test suite, standard, and a tsc check over the declaration files, plus end-to-end against wdk-wallet-evm (node and bare runtimes) with this branch as the dependency.

Motivation and Context

Discussed in the post-merge review of tetherto/wdk-wallet-evm#40 (EVM: split signer from account). The EVM package needed isDerivable and keyPair on its ISignerEvm interface, and review concluded these belong on the base ISigner since all signer implementations should support them. Making keyPair nullable (and index/path optional on IWalletAccount) is required for signers that can never expose key material or a derivation position.

Related Issue

No standalone issue — this implements interface changes requested in the post-merge review discussion of tetherto/wdk-wallet-evm#40.

Type of change

  • New feature (non-breaking change which adds functionality)

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.

1 participant