feat(wasm-solana): add Create-ATA support for consolidateToken - #360
Merged
Conversation
Add createAssociatedTokenAccount and ataOwnerAddress fields to the ConsolidateIntent so the WASM builder can emit idempotent CreateAssociatedTokenAccount instructions before token transfers. This removes the need for the wallet-platform needsCreateAta guard that forces consolidateToken to the legacy account-lib path. When createAssociatedTokenAccount is true, the builder derives the destination ATA from ataOwnerAddress + mint + tokenProgram, validates it matches the caller-provided recipient address, and prepends a CreateIdempotent ATA instruction before each TransferChecked. Native SOL recipients are unaffected. All fields are optional with serde defaults for full backwards compatibility. Ticket: CHALO-1260
Contributor
Author
|
@claude please review this PR and provide a verdict |
There was a problem hiding this comment.
Pull request overview
This PR extends the Solana intent builder’s consolidate flow to optionally create destination Associated Token Accounts (ATAs) (via idempotent CreateAssociatedTokenAccount instructions) before performing SPL token transfers, enabling smoother “consolidate” intents when recipient ATAs may not yet exist.
Changes:
- Added
createAssociatedTokenAccountandataOwnerAddressfields to the consolidate intent (TypeScript + Rust) to request/parameterize ATA creation. - Updated the Rust
build_consolidatebuilder to validate the ATA owner, verify the provided recipient ATA matches the derived ATA, and emit Create-ATA (idempotent) prior to each token transfer when enabled. - Added comprehensive tests to cover emission order, backward compatibility, and error cases (missing owner / mismatched ATA), including multi-recipient scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/wasm-solana/test/intentBuilder.ts | Adds tests validating Create-ATA emission behavior and error handling for consolidate intents. |
| packages/wasm-solana/src/intent/types.rs | Extends ConsolidateIntent with optional fields for requesting ATA creation and specifying the ATA owner. |
| packages/wasm-solana/src/intent/build.rs | Implements conditional idempotent Create-ATA emission and derived-ATA validation within build_consolidate. |
| packages/wasm-solana/js/intentBuilder.ts | Updates TypeScript ConsolidateIntent interface to expose the new consolidate options to callers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
MohammedRyaan786
marked this pull request as ready for review
August 14, 2026 10:36
MohammedRyaan786
enabled auto-merge
August 14, 2026 10:36
davidkaplanbitgo
approved these changes
Aug 14, 2026
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.
Ticket: CHALO-1260
This pull request adds support for automatically creating associated token accounts (ATAs) during "consolidate" intents in the Solana intent builder. It introduces new fields to the consolidate intent, updates the builder logic to optionally emit idempotent CreateAssociatedTokenAccount instructions before token transfers, and adds comprehensive tests covering these scenarios.
Enhancements to Consolidate Intent:
createAssociatedTokenAccount(boolean) andataOwnerAddress(string) fields to theConsolidateIntentTypeScript and Rust types, allowing callers to request automatic ATA creation for recipients. [1] [2]Builder Logic Updates:
build_consolidateto:createAssociatedTokenAccountis true, validateataOwnerAddressand emit a CreateAssociatedTokenAccount instruction before each token transfer.Testing Improvements:
Test Utilities:
getAssociatedTokenAddressin tests to ensure recipient addresses match derived ATAs.