feat: add SPL token transfer support to wasm-solana payment intent#208
Merged
feat: add SPL token transfer support to wasm-solana payment intent#208
Conversation
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
2f97a73 to
f124b6b
Compare
OttoAllmendinger
approved these changes
Mar 13, 2026
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; |
Contributor
There was a problem hiding this comment.
we probably could use a Recipient type here
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.
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.
BTC-3149