Skip to content

feat(wasm-solana): add Create-ATA support for consolidateToken - #360

Merged
MohammedRyaan786 merged 1 commit into
masterfrom
CHALO-1260
Aug 14, 2026
Merged

feat(wasm-solana): add Create-ATA support for consolidateToken#360
MohammedRyaan786 merged 1 commit into
masterfrom
CHALO-1260

Conversation

@MohammedRyaan786

@MohammedRyaan786 MohammedRyaan786 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added createAssociatedTokenAccount (boolean) and ataOwnerAddress (string) fields to the ConsolidateIntent TypeScript and Rust types, allowing callers to request automatic ATA creation for recipients. [1] [2]

Builder Logic Updates:

  • Updated build_consolidate to:
    • Parse the new fields from the intent.
    • When createAssociatedTokenAccount is true, validate ataOwnerAddress and emit a CreateAssociatedTokenAccount instruction before each token transfer.
    • Ensure the provided recipient ATA matches the derived address for the owner and mint, raising errors otherwise. [1] [2] [3]

Testing Improvements:

  • Added tests to verify:
    • CreateAssociatedTokenAccount is emitted before TokenTransfer when requested.
    • Backward compatibility when the flag is omitted or false.
    • Error handling when required fields are missing or mismatched.
    • Correct behavior with multiple token recipients and mixed native/token recipients.

Test Utilities:

  • Imported and used getAssociatedTokenAddress in tests to ensure recipient addresses match derived ATAs.

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
@linear-code

linear-code Bot commented Aug 14, 2026

Copy link
Copy Markdown

CHALO-1260

@MohammedRyaan786

Copy link
Copy Markdown
Contributor Author

@claude please review this PR and provide a verdict

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 createAssociatedTokenAccount and ataOwnerAddress fields to the consolidate intent (TypeScript + Rust) to request/parameterize ATA creation.
  • Updated the Rust build_consolidate builder 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
MohammedRyaan786 marked this pull request as ready for review August 14, 2026 10:36
@MohammedRyaan786
MohammedRyaan786 requested a review from a team as a code owner August 14, 2026 10:36
@MohammedRyaan786
MohammedRyaan786 merged commit bda3472 into master Aug 14, 2026
14 checks passed
@MohammedRyaan786
MohammedRyaan786 deleted the CHALO-1260 branch August 14, 2026 13:57
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.

3 participants