Skip to content

feat: add SPL token transfer support to wasm-solana payment intent#208

Merged
lcovar merged 1 commit intomasterfrom
BTC-3149-sol-token-transfer-intent
Mar 13, 2026
Merged

feat: add SPL token transfer support to wasm-solana payment intent#208
lcovar merged 1 commit intomasterfrom
BTC-3149-sol-token-transfer-intent

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Mar 13, 2026

The payment intent builder only supported native SOL transfers. This adds SPL token transfer support so bgms can route all payments through WASM without falling back to the legacy TypeScript path.

  • Added token_address, token_program_id, decimal_places fields to Recipient (all #[serde(default)], no breakage for existing callers)
  • Extracted derive_ata() and create_ata_idempotent_ix() helpers
  • build_payment() detects token recipients via token_address field or symbol containing ':' (bgms format: "USDC:EPjFWaYHrt...")
  • For token recipients: emits CreateIdempotent ATA + TransferChecked
  • For native SOL: unchanged system_ix::transfer path
  • Updated PaymentIntent TS type with tokenAddress, tokenProgramId, decimalPlaces optional fields
  • 6 new tests: explicit tokenAddress, symbol:mint extraction, SOL regression, missing decimalPlaces error, mixed recipients, round-trip

BTC-3149

The payment intent builder only supported native SOL transfers. This
adds SPL token transfer support so bgms can route all payments through
WASM without falling back to the legacy TypeScript path.

- Added token_address, token_program_id, decimal_places fields to
  Recipient (all #[serde(default)], no breakage for existing callers)
- Extracted derive_ata() and create_ata_idempotent_ix() helpers
- build_payment() detects token recipients via token_address field or
  symbol containing ':' (bgms format: "USDC:EPjFWaYHrt...")
- For token recipients: emits CreateIdempotent ATA + TransferChecked
- For native SOL: unchanged system_ix::transfer path
- Updated PaymentIntent TS type with tokenAddress, tokenProgramId,
  decimalPlaces optional fields
- 6 new tests: explicit tokenAddress, symbol:mint extraction, SOL
  regression, missing decimalPlaces error, mixed recipients, round-trip

BTC-3149
@lcovar lcovar force-pushed the BTC-3149-sol-token-transfer-intent branch from 2f97a73 to f124b6b Compare March 13, 2026 00:58
@lcovar lcovar marked this pull request as ready for review March 13, 2026 01:31
@lcovar lcovar requested a review from a team as a code owner March 13, 2026 01:31
Comment on lines 91 to +99
recipients?: Array<{
address?: { address: string };
amount?: { value: bigint; symbol?: string };
/** Mint address (base58) — if set, this is an SPL token transfer */
tokenAddress?: string;
/** Token program ID (defaults to SPL Token Program) */
tokenProgramId?: string;
/** Decimal places for the token (required for transfer_checked) */
decimalPlaces?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably could use a Recipient type here

@lcovar lcovar merged commit b0d1ced into master Mar 13, 2026
13 checks passed
@lcovar lcovar deleted the BTC-3149-sol-token-transfer-intent branch March 13, 2026 16:07
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.

2 participants