Skip to content

contracts: base commerce-payments port (escrow + spl-token-collector)#2

Open
A1igator wants to merge 1 commit into
mainfrom
aliabdoli/svm-base-port
Open

contracts: base commerce-payments port (escrow + spl-token-collector)#2
A1igator wants to merge 1 commit into
mainfrom
aliabdoli/svm-base-port

Conversation

@A1igator
Copy link
Copy Markdown
Contributor

Summary

SVM port of base/commerce-payments' authCapture primitives. First half of a two-PR split of #1 — this PR isolates the commerce-payments-analog code so it can be reviewed against the EVM original without the x402r-specific layer mixed in.

Program Role
auth-capture-escrow Pure escrow primitive (AuthCaptureEscrow analog). 6 lifecycle ixs (authorize/charge/capture/void/refund/reclaim) + 1 admin (initialize_protocol_fee_config). CPIs into ITokenCollector for fund movement; knows nothing about plugins / arbitration.
spl-token-collector The pilot's only ITokenCollector impl (EIP3009TokenCollector / Permit2TokenCollector analog). SPL Token transfers for collect_authorize (payer ATA → vault) and collect_refund (treasury → payer). Future Token-2022 / bridge collectors slot in via the same interface.

Also adds:

  • Workspace plumbing: Anchor.toml, Cargo workspace, Vitest + Codama generator wiring, deploy/pin-program-ids migration scripts.
  • Trident fuzz harness for the splits math (fuzz_splits).
  • Test scaffolding under tests/ (Vitest, bodies are expect.fail("TODO") stubs).

Stacked follow-up

The x402r-specific layer (payment-operator factory + static-address-condition / receiver-condition / payer-condition plugins + slot-dispatch fuzz scaffold) ships in a stacked PR targeting this branch.

Licensing

  • Every Rust source file carries SPDX-License-Identifier: BUSL-1.1 and // CONTRACTS UNAUDITED: USE AT YOUR OWN RISK.
  • Every Cargo.toml declares license = "BUSL-1.1".
  • Same BUSL parameters as x402r-contracts: Change Date 2029-12-09, Change License MIT, Hackathon Promotional Rights grant retained.

Status

Pilot, unaudited. Mainnet usage is at users' own risk.

Pre-merge follow-ups (apply to both PRs in the split, tracked here for visibility):

  • anchor build to produce IDLs (toolchain not installed locally)
  • pnpm codama:generate to swap stubs in the @x402r/svm SDK
  • Replace placeholder Anchor instruction discriminators with values from target/idl/*.json
  • Fill out the Vitest test bodies (currently expect.fail("TODO") scaffolding)
  • Devnet + mainnet-beta deploy via migrations/deploy.ts + migrations/pin-program-ids.ts

🤖 Generated with Claude Code

Adds the SVM port of base/commerce-payments' authCapture primitives:

- auth-capture-escrow: pure escrow primitive. 6 lifecycle ixs
  (authorize/charge/capture/void/refund/reclaim) + 1 admin
  (initialize_protocol_fee_config). CPIs into ITokenCollector for fund
  movement; knows nothing about plugins / arbitration.
- spl-token-collector: the pilot's only ITokenCollector impl. SPL Token
  transfers for collect_authorize (payer ATA -> vault) and collect_refund
  (treasury -> payer). Future Token-2022 / bridge collectors slot in via
  the same interface.

Also adds workspace plumbing (Anchor.toml, Cargo workspace, Vitest +
Codama generator wiring), a Trident fuzz harness for the splits math,
and migration scripts for protocol-fee-config init + post-deploy
program-ID pinning.

x402r-specific extensions (payment-operator factory, condition plugins,
slot-dispatch fuzz) ship in a follow-up PR that stacks on top of this
one.

Status: pilot, unaudited. Mainnet usage is at users' own risk.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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