@x402r/svm: implement authCapture for SVM (pilot)#46
Open
Conversation
New package mirroring @x402r/evm's shape: authCapture/{client,server,
facilitator,shared}. Faithful port of base/commerce-payments authCapture
primitives to Solana — escrow + token collector.
Client builds partial-signed Solana transactions whose inner instruction
is auth_capture_escrow.{authorize,charge}, encoded as Borsh PaymentInfo +
amount + (optional) splits + collector_data. The escrow internally CPIs
into the configured ITokenCollector for fund movement.
Facilitator decodes the inner instruction, binds every PaymentInfo field
to PaymentRequirements + extra, and runs the same MUST list as exact-svm
plus the operator/expiry/fee-bps bindings.
Auth model: partial-tx + facilitator-cosign (same as @x402/svm exact).
ERC-3009 / Permit2 don't exist on SVM — runtime signature checks ARE the
authorization.
Status: pilot, unaudited. Codama-generated PDA helpers and IDL-derived
discriminators land via a follow-up once `anchor build` runs upstream.
Companion spec: PR #45.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
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.
Summary
New
@x402r/svmpackage mirroring@x402r/evm's shape. Implements the spec from #45 — faithful SVM port ofbase/commerce-paymentsauthCapture primitives.Layout
client/scheme.ts—AuthCaptureSvmSchemebuilds a partial-signed Solana tx whose inner instruction isauth_capture_escrow.{authorize,charge}.facilitator/scheme.ts— decodes the inner ix, binds everyPaymentInfofield toPaymentRequirements+extra, runs the MUST list from the spec.server/scheme.ts—AuthCaptureSvmServerSchemeparses prices and enhances requirements with SVM-specific extras.shared/{types,constants,nonce,pda,utils,limits}.ts— wire types, per-cluster program IDs, Borsh encoder + SHA-256-of-Borshpayment_info_hash, PDA helpers, parsing utils, slot/splits limits.Auth model: partial-tx + facilitator-cosign. ERC-3009 / Permit2 don't exist on SVM — runtime signature checks ARE the authorization. Same pattern as
@x402/svmexact.Status: pilot, unaudited. Per-cluster program-ID placeholders are pinned to the
declare_id!lines in the (separate) contracts repo and resolve at runtime once the contracts deploy. PDA helpers are stubs that throwstub:errors until the Codama-generated client lands; the surrounding code typechecks against the stub signatures so the swap is single-file.Test plan
pnpm buildclean (CJS + ESM + DTS)pnpm testgreen (4 tests, Borsh round-trip + hash determinism + size)target/idl/*.jsonCompanion
Spec: #45.
🤖 Generated with Claude Code