Skip to content

Support smart-wallet Solana payments in exact SVM (SWIG first)#1964

Open
romeo4934 wants to merge 2 commits intox402-foundation:mainfrom
romeo4934:codex/svm-exact-transfer-extractors
Open

Support smart-wallet Solana payments in exact SVM (SWIG first)#1964
romeo4934 wants to merge 2 commits intox402-foundation:mainfrom
romeo4934:codex/svm-exact-transfer-extractors

Conversation

@romeo4934
Copy link
Copy Markdown

@romeo4934 romeo4934 commented Apr 8, 2026

Summary

  • enable smart-wallet Solana payments in exact SVM, starting with SWIG wallets
  • keep direct top-level SPL TransferChecked support as the default exact SVM payment path
  • add built-in support for SWIG-wrapped exact payments in the Go, TypeScript, and Python SVM facilitators
  • verify SWIG SignV2 and SubAccountSignV1 by decoding them into the same canonical transfer details used for direct payments
  • update the SVM README and exact SVM spec to document smart-wallet compatibility through known wrapped payment programs

Why

Today the stock exact SVM facilitator only accepts transactions whose third top-level instruction is a direct SPL Token or Token-2022 TransferChecked. That blocks smart-wallet Solana payment flows where the exact same SPL payment is wrapped inside a higher-level wallet instruction.

This shows up in practice with wallets such as SWIG: the payment is still an exact SPL token transfer, but it is expressed through a smart-wallet instruction rather than a direct top-level TransferChecked.

This PR keeps the existing exact-scheme safety checks on:

  • token program
  • source token account
  • mint
  • destination ATA
  • authority
  • exact amount
  • fee-payer safety

The change is that facilitators now recognize a small set of known wrapped payment programs in addition to the direct transfer shape. SWIG is the first built-in smart-wallet integration. Future wrappers such as Squads can be added explicitly using the same pattern.

Implementation

Go

  • add built-in canonical transfer decoding for direct SPL transfers and SWIG-wrapped smart-wallet transfers
  • update both V1 and V2 exact facilitators to use the same built-in transfer decoding path
  • add real SWIG serialized transaction fixtures for SignV2 and SubAccountSignV1

TypeScript

  • add the same built-in transfer decoding logic to the SVM exact facilitators
  • update V1 and V2 facilitators to verify canonical transfer details from either direct or SWIG-wrapped payments
  • add fixture-driven unit coverage for both SWIG transaction shapes

Python

  • add the same built-in transfer decoding logic to the SVM exact facilitators
  • update V1 and V2 facilitators to verify canonical transfer details from either direct or SWIG-wrapped payments
  • add fixture-driven unit coverage for both SWIG transaction shapes

Tests

Added unit coverage in all three language implementations for:

  • direct exact SVM payment verification still working as before
  • SWIG SignV2 wrapped payments
  • SWIG SubAccountSignV1 wrapped payments

Validation run locally:

  • cd go && go test ./mechanisms/svm/... && go test ./...
  • cd typescript/packages/mechanisms/svm && npm exec --yes pnpm@10.12.1 -- format && npm exec --yes pnpm@10.12.1 -- lint && npm exec --yes pnpm@10.12.1 -- test
  • cd python && /opt/homebrew/bin/python3.11 -m black x402/mechanisms/svm/constants.py x402/mechanisms/svm/types.py x402/mechanisms/svm/utils.py x402/mechanisms/svm/exact/facilitator.py x402/mechanisms/svm/exact/v1/facilitator.py x402/tests/unit/mechanisms/svm/test_facilitator.py && /opt/homebrew/bin/python3.11 -m ruff check x402/mechanisms/svm/constants.py x402/mechanisms/svm/types.py x402/mechanisms/svm/utils.py x402/mechanisms/svm/exact/facilitator.py x402/mechanisms/svm/exact/v1/facilitator.py x402/tests/unit/mechanisms/svm/test_facilitator.py && /opt/homebrew/bin/python3.11 -m pytest x402/tests/unit/mechanisms/svm/test_facilitator.py

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge)
  • I added a changelog fragment for user-facing changes

@github-actions github-actions bot added specs Spec changes or additions go sdk Changes to core v2 packages labels Apr 8, 2026
@romeo4934 romeo4934 changed the title Allow exact SVM facilitators to decode wrapped payment instructions Support built-in SWIG wrapped exact SVM payments Apr 8, 2026
@romeo4934 romeo4934 changed the title Support built-in SWIG wrapped exact SVM payments Enable smart-wallet Solana payments in exact SVM (SWIG first) Apr 8, 2026
@romeo4934 romeo4934 changed the title Enable smart-wallet Solana payments in exact SVM (SWIG first) Support smart-wallet Solana payments in exact SVM (SWIG first) Apr 8, 2026
@romeo4934 romeo4934 force-pushed the codex/svm-exact-transfer-extractors branch 2 times, most recently from 32e8b1d to b7ce934 Compare April 8, 2026 18:03
@romeo4934 romeo4934 force-pushed the codex/svm-exact-transfer-extractors branch from b7ce934 to 99bb53a Compare April 8, 2026 18:05
@romeo4934 romeo4934 marked this pull request as ready for review April 8, 2026 18:06
@romeo4934
Copy link
Copy Markdown
Author

A bit of reviewer context: this PR intentionally takes a “known wrapped payment programs” approach rather than a generic extension hook.

The goal is to keep the exact SVM facilitator simple and predictable while unlocking smart-wallet payment flows that still resolve to the same canonical SPL transfer. SWIG is the first built-in case because it is already used in production-like flows and maps cleanly to the exact-scheme safety checks.

This means exact SVM now supports:

  • direct top-level TransferChecked
  • vetted wrapped payment programs that deterministically decode to the same canonical transfer intent

If other smart-wallet wrappers such as Squads need support later, they can be added explicitly following the same pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go python sdk Changes to core v2 packages specs Spec changes or additions typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant