Register all single-shot EVM client schemes (exact, upto, auth-capture) in the scan wallet#941
Closed
A1igator wants to merge 1 commit into
Closed
Conversation
Contributor
|
@A1igator is attempting to deploy a commit to the Merit Systems Team on Vercel. A member of the Team first needs to authorize it. |
Lets the scan wallet pay endpoints advertising any single-shot EVM
scheme the SDK supports — `exact`, `upto`, and `auth-capture` (x402r
refundable / escrow-backed payments) — not just `exact`.
- Add a shared `registerEvmSchemes(client, { signer })` helper in
`wrap-fetch.ts` that registers `exact` (via registerExactEvmScheme),
`UptoEvmScheme`, and `AuthCaptureEvmScheme`. All three are stateless
and take the same `ClientEvmSigner`, so one signer wires up every path.
- Use it at the two EVM payment sites: the server (custodial) wallet
`sendUsdc` flow and the browser wagmi `useEvmPaymentWrapper` hook.
- Bump the `@x402/*` catalog from ^2.11.0 to ^2.14.0; the new client
subpaths ship in @x402/evm@2.14.0.
`batch-settlement` is intentionally omitted: it is stateful (payment
channels, vouchers, on-chain recovery) and needs persistent client
storage that the per-request wallet clients here don't provide.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bd92633 to
3e63c84
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.
At x402r.org, we've been working on refundable payments for x402. This PR wires the scan wallet up to actually pay them — and, while we're here, every other single-shot EVM scheme the SDK supports.
What
Lets the scan wallet pay endpoints advertising any single-shot EVM scheme the SDK supports —
exact,upto, andauth-capture(our escrow-backed / refundable payments) — instead of onlyexact.Today both EVM payment sites register only the exact scheme, so the wallet can't match a non-exact entry in a 402's
accepts:apps/scan/src/trpc/routers/user/server-wallet.ts— the custodial server wallet (sendUsdc)apps/scan/src/app/(app)/_hooks/x402/evm.ts— the browser wagmi wallet hookChanges
apps/scan/src/lib/x402/wrap-fetch.ts— new sharedregisterEvmSchemes(client, { signer })that registers:exact(existingregisterExactEvmScheme)upto(UptoEvmScheme) — variable-amount / meteredauth-capture(AuthCaptureEvmScheme, from@x402/evm/auth-capture/client) — our escrow-backed / refundable schemeAll three are single-shot and take the same
ClientEvmSigner, so one signer wires up every path. Registering a scheme an endpoint doesn't use is harmless — the client routes on eachacceptsentry'sscheme.Both EVM call sites switched from
registerExactEvmScheme(...)toregisterEvmSchemes(...).pnpm-workspace.yaml— bump the shared@x402/*catalog^2.11.0→^2.14.0(theupto/clientandauth-capture/clientsubpaths ship in@x402/evm@2.14.0); lockfile regenerated. All five@x402/*packages publish in lockstep at 2.14.0.registerExactEvmSchemestays exported for compatibility. This is purely additive — endpoints that only advertiseexactbehave exactly as before.Deliberately excluded:
batch-settlementThe SDK also exposes a
batch-settlementclient scheme, but it's intentionally not registered here. Unlike the others it's stateful — per-channel deposits, signed vouchers, on-chain channel recovery — and needs persistent client channel storage. The wallet builds a fresh per-requestx402Client, so the scheme's default in-memory storage would silently lose channel state between requests. Wiring it up correctly (durable channel storage + lifecycle) is separate work.Why now
The
auth-captureclient scheme landed upstream in x402-foundation/x402#2486 and is published in@x402/evm@2.14.0. This is the wallet-side wiring to consume it (andupto, which the SDK already shipped).AuthCaptureEvmSchemeis pure signing — no on-chain reads/calls.Demand: #663 — our x402r escrow endpoints (36 live in production) that the scan wallet currently can't pay.
Notes
main— theAcceptsSchemeenum was dropped in favor of a free-stringscheme(Prismascheme String, zodz.string().min(1), plus a "accepts non-exact x402 schemes" upsert test), so non-exact schemes already index. This PR doesn't touch that path.auth-capture. Endpoints advertising the olderescrowname should move toauth-captureto match.Test plan
pnpm installresolves@x402/evm@2.14.0with theupto/client+auth-capture/clientsubpathsauth-capture(andupto) endpoint end-to-end on Base🤖 Generated with Claude Code