Skip to content

fix(signing): match wallet shape by member presence, not signTypedData arity - #95

Merged
joeblau merged 1 commit into
mainfrom
fix/issue-92
Aug 4, 2026
Merged

fix(signing): match wallet shape by member presence, not signTypedData arity#95
joeblau merged 1 commit into
mainfrom
fix/issue-92

Conversation

@joeblau

@joeblau joeblau commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • isViemJsonRpc / isViemLocal no longer consult Function.length — membership checks only, so wrapped/adapted wallets (signTypedData(...args), defaulted params, Privy-style adapters) adapt and sign
  • Positional ethers-style signTypedData(domain, types, value) (≥3 declared params) is rejected up front with an explanatory error instead of failing cryptically at sign time
  • The fall-through error enumerates, for both supported shapes, every missing member with its found typeof — one iteration is enough to fix an adapter from the message alone
  • docs/signing.md updated; new 7-test suite pins length-0 adapters against absolute signature fixtures via the public signing paths

Verification (3-agent agreement)

  • Claude (Opus/Fable, this session): APPROVE after line-by-line review
  • Kimi K3 Max: APPROVE (verified diagnostics char-for-char, ran signing suite + typecheck, confirmed real viem wallets report length 1 so the ≥3 rejection is safe)
  • Codex gpt-5.6-sol @ xhigh: APPROVE ("guards now accept length-0 adapters, reject 3+ parameter ethers-style signers before adaptation, and report each missing member with its observed type")
  • Integration: all four fix branches merged together pass bun run check + 1965 offline tests, 0 fail

Fixes #92

🤖 Generated with Claude Code

…a arity

isViemJsonRpc/isViemLocal required signTypedData.length to be 1 or 2, but
Function.length counts only parameters declared before the first default or
rest parameter. A wrapped or adapted wallet (Privy-style embedded-wallet
adapter declaring signTypedData(...args) or all-defaulted params) reports
length 0, failed BOTH guards, and died with an opaque "unknown wallet type"
error the moment signing was first needed. This fork supports only
viem-shaped wallets, so the arity probe was a vestigial viem-vs-ethers
discriminator.

- Drop the arity conditions from both guards; membership checks stay
  (jsonrpc = callable signTypedData + getAddresses + getChainId,
  local = callable signTypedData + string address). Length-0 adapters now
  adapt and sign byte-identically to the account they wrap.
- Keep the one protection arity provided: createSigner rejects a callable
  signTypedData declaring >= 3 parameters up front — the positional
  ethers-style signTypedData(domain, types, value) shape that would
  otherwise pass isViemLocal and fail cryptically at sign time — with a
  message pointing at the required viem-style single-params-object shape.
- Make the fall-through diagnostic: the error now enumerates exactly which
  members are missing (no callable signTypedData at all, or which of
  getAddresses/getChainId/string address the wallet lacks), so an
  integrator can fix their adapter from the message alone.
- Update the guard/interface JSDoc, the stale arity comments in tests, and
  the docs/signing.md wallet-compatibility section accordingly.
- New suite tests/signing/_abstractWallet.test.ts pins all of the above
  against the existing signature fixtures.

Fixes #92
@joeblau
joeblau merged commit 34f90b0 into main Aug 4, 2026
6 checks passed
@joeblau joeblau mentioned this pull request Aug 4, 2026
joeblau added a commit that referenced this pull request Aug 4, 2026
Four fixes, each cross-verified to agreement by three independent
reviewers (Claude, Kimi K3 Max, Codex gpt-5.6-sol xhigh):

- #89 subscription failures notify every subscriber + failureSignal (#93)
- #90 WebSocket message pacing on by default, flush charging fixed (#96)
- #91 200-OK { type: "error" } envelopes throw HttpRequestError (#94)
- #92 wallet shape detection by member presence, not arity (#95)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@joeblau
joeblau deleted the fix/issue-92 branch August 4, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

isViemJsonRpc arity guard rejects wrapped/adapted wallets with opaque "unknown wallet type" error

1 participant