x402: structural signer type (drop viem from public .d.ts) - #20
Merged
Merged
Conversation
…viem Replace viem's LocalAccount in X402FetchOptions.account with a new structural X402SignerAccount interface. signTypedData uses `unknown` (method syntax keeps viem accounts assignable, and unlike `never` the exported interface stays callable for custom signers/test doubles). Removes the viem type import from the shipped x402 .d.ts (both CJS and ESM), clearing TS1541 + ~12 transitive errors for consumers on moduleResolution node16 with skipLibCheck:false. Add a CI regression guard (typecheck/x402-node16/) that type-checks a node16 consumer of glassnode-api/x402 with skipLibCheck:false — the leak attw cannot detect (it runs with skipLibCheck on). Verified: reintroducing the viem import makes the fixture fail with 13 errors. A viem privateKeyToAccount() stays assignable (type-checked integration test). attw/publint green across all module modes; 53 tests pass. Bump 0.11.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P91z58rNwevTzvgcrzzeFV
planadecu
force-pushed
the
fix/x402-structural-account
branch
from
September 22, 2026 11:32
9afa718 to
65ffdf6
Compare
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.
Makes
glassnode-api/x402's public types independent ofviem(an optional peer), fixing theTS1541the quality review flagged (§3.6.4) for consumers onmoduleResolution: node16withskipLibCheck: false.Change
viem'sLocalAccountinX402FetchOptions.accountwith a new structuralX402SignerAccountinterface ({ address: 0x…, signTypedData(...): Promise<0x…> }).signTypedDatakeeps a real viem account assignable.import type { LocalAccount } from 'viem'from the shippedx402.d.ts(both CJSand ESM), so consumers no longer need
viem's types to type-check the public API.Why it's safe
viem'sprivateKeyToAccount(pk)is still assignable toaccount— proven by the type-checkedintegration test (
test/x402.integration.spec.tspasses a real viem account and is compiled bythe
tsc -p tsconfig.test.json --noEmitCI gate).@x402/evm'sExactEvmScheme.Verification
arethetypeswrong --pack .: 🟢 acrossnode10/node16 (CJS)/node16 (ESM)/bundlerfor.,./x402,./package.json.publint: clean. Noviemimport remains indist/**/x402.d.ts.Minor bump (
0.11.0) — adds theX402SignerAccountexport; viem accounts remain compatible.