Skip to content

@x402r/svm: implement authCapture for SVM (pilot)#46

Open
A1igator wants to merge 1 commit intomainfrom
aliabdoli/authcapture-svm-impl
Open

@x402r/svm: implement authCapture for SVM (pilot)#46
A1igator wants to merge 1 commit intomainfrom
aliabdoli/authcapture-svm-impl

Conversation

@A1igator
Copy link
Copy Markdown
Contributor

@A1igator A1igator commented May 9, 2026

Summary

New @x402r/svm package mirroring @x402r/evm's shape. Implements the spec from #45 — faithful SVM port of base/commerce-payments authCapture primitives.

Layout

packages/svm/src/authCapture/{client,server,facilitator,shared}
  • client/scheme.tsAuthCaptureSvmScheme builds a partial-signed Solana tx whose inner instruction is auth_capture_escrow.{authorize,charge}.
  • facilitator/scheme.ts — decodes the inner ix, binds every PaymentInfo field to PaymentRequirements + extra, runs the MUST list from the spec.
  • server/scheme.tsAuthCaptureSvmServerScheme parses 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-Borsh payment_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/svm exact.

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 throw stub: errors until the Codama-generated client lands; the surrounding code typechecks against the stub signatures so the swap is single-file.

Test plan

  • pnpm build clean (CJS + ESM + DTS)
  • pnpm test green (4 tests, Borsh round-trip + hash determinism + size)
  • Stub PDA helpers swapped for Codama-generated ones once the contracts repo's IDL lands
  • Anchor instruction discriminator placeholders replaced with values from target/idl/*.json

Companion

Spec: #45.

🤖 Generated with Claude Code

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>
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