Skip to content

fix(x402): skip an option whose chain has no wallet key with a clear reason - #708

Merged
gulshngill merged 1 commit into
mainfrom
fix/x402-svm-missing-solana-key
Sep 24, 2026
Merged

gulshngill merged 1 commit into
mainfrom
fix/x402-svm-missing-solana-key

Conversation

@gulshngill

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #686, which made the x402 fallback loop log why it skipped a payment option.

  • Missing wallet key. exportWallet returns a null key (and undefined address) 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. buildPaymentForRequirement now checks for the rail's key first and logs:
    [x402] Skipping solana:5eykt… option: wallet "test" has no Solana key. Create a wallet with both keys (nansen wallet create) and make it the default (nansen wallet default <name>).
    
    It returns null like 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.
  • Error wording. The self-sponsored feePayer error now says "pay on another network" instead of "pay on Base", since X Layer (USDT0) is also a supported rail.

Tests

  • New 12d in src/__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 on main.
  • x402-svm.test.js asserts the reworded message.
npm test      → Test Files 107 passed · Tests 4324 passed | 2 skipped
npm run lint  → clean
  • npm test passes
  • npm run lint passes
  • Changeset added (patch)
  • Schema unchanged

🤖 Generated with Claude Code

…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>
@nansen-pr-reviewer

Copy link
Copy Markdown

pr-reviewer Summary for #1a300a9

✅ No issues found

The code review completed successfully with no findings.

Review effort: 2/5 (Simple)

Summary

This PR is a clean, well-scoped bug fix. The core change — a missing-key guard in buildPaymentForRequirement — is correct, minimal, and consistent with the existing permit2-exact skip pattern immediately below it. The exportWallet contract always returns both evm and solana sub-objects (even for a wallet that lacks a chain), so exported[rail]?.privateKey handles all real and mocked shapes safely.

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 beforeEach/afterEach on the describe block handles module reset and unmocking, so the temporary wallet mock doesn't leak into test 13. The solanaOption amount (5000) is correctly cheaper than the EVM option (10000), satisfying the "tried first" comment.

The changeset is correctly typed (patch), targets the right package, and the error reword in x402-svm.js ("pay on another network" rather than "pay on Base") is accurate given X Layer support. No issues found.


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 @nansen-pr-reviewer re-review.

@nansen-pr-reviewer nansen-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gulshngill
gulshngill merged commit 59ebd64 into main Sep 24, 2026
13 checks passed
@gulshngill
gulshngill deleted the fix/x402-svm-missing-solana-key branch September 24, 2026 16:32
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