Repository navigation
fix(x402): skip an option whose chain has no wallet key with a clear reason - #708
Conversation
…reason exportWallet returns a null key for a chain the wallet file doesn't hold. Such a wallet reaching a Solana (or EVM) option failed inside the payload builder, and the fallback loop's skip line showed a raw TypeError. Check for the key first, log which key is missing and how to get a wallet with both, and skip without fetching a blockhash. Also reword the self-sponsored feePayer error to "pay on another network" rather than naming Base, since X Layer is a supported rail too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pr-reviewer Summary for #1a300a9✅ No issues found The code review completed successfully with no findings. Review effort: 2/5 (Simple) SummaryThis PR is a clean, well-scoped bug fix. The core change — a missing-key guard in The new test (12d) is well-structured: it overrides the wallet mock inline, verifies the SVM builder is never reached, and checks the exact skip-line format. The outer The changeset is correctly typed ( Token usage: 3,549 input, 3,319 output, 321,330 cache read, 34,948 cache write | Usage Guide New pushes are reviewed automatically with a 10-minute cooldown between reviews. To request a review at any time, comment |
There was a problem hiding this comment.
Auto-approved
This PR was automatically approved because:
- Claude recommends approval
- Claude assessed this as a moderate effort change
- The effort level is within the auto-approval threshold of 2
- No high or critical issues were detected
If you have any concerns, please request a manual review.
Summary
Follow-up to #686, which made the x402 fallback loop log why it skipped a payment option.
exportWalletreturns a null key (andundefinedaddress) for a chain the wallet file doesn't hold. A Solana option reached with such a wallet failed inside the SVM payload builder, so the new skip line printed a raw JavaScript error.buildPaymentForRequirementnow checks for the rail's key first and logs:nulllike the existing permit2 skip, and no longer fetches a blockhash for an option it cannot sign. The same check covers a wallet without an EVM key.feePayererror now says "pay on another network" instead of "pay on Base", since X Layer (USDT0) is also a supported rail.Tests
12dinsrc/__tests__/x402.test.js: a wallet with no Solana key, a cheaper Solana option and an EVM option. It checks that the EVM option is signed, the SVM builder is never called, and the skip line names the missing key. Fails onmain.x402-svm.test.jsasserts the reworded message.npm testpassesnpm run lintpasses🤖 Generated with Claude Code