Conversation
02904b6 to
5bff3d8
Compare
OttoAllmendinger
requested changes
Jan 28, 2026
Contributor
OttoAllmendinger
left a comment
There was a problem hiding this comment.
make sure we use bigint instead of string when dealing with amounts
Comment on lines
+57
to
+58
| /** Lamports to transfer (as string) */ | ||
| lamports: string; |
Comment on lines
+159
to
+160
| /** Amount in lamports to withdraw (as string) */ | ||
| lamports: string; |
| use solana_system_interface::instruction::{self as system_ix, SystemInstruction}; | ||
| use spl_stake_pool::instruction::StakePoolInstruction; | ||
|
|
||
| /// Well-known program IDs and sysvars |
Contributor
There was a problem hiding this comment.
where are these defined?
6a37e03 to
3ea21e0
Compare
… support This commit adds comprehensive transaction building capabilities to wasm-solana, enabling the construction of both legacy and versioned (MessageV0) Solana transactions without requiring @solana/web3.js dependency. ## Transaction Building ### Core Builder (Rust) - `src/builder/build.rs` - Main transaction building logic from TransactionIntent - `src/builder/types.rs` - Type definitions (TransactionIntent, Instruction, Nonce, etc.) - `src/builder/versioned.rs` - MessageV0/versioned transaction building from raw data ### Supported Instructions - Transfer (SOL and SPL tokens) - CreateAssociatedTokenAccount - StakingActivate, StakingDeactivate, StakingWithdraw - StakingAuthorize, StakingAuthorizeRaw - StakingPartialDeactivate (split + deactivate) - StakingSplit - AdvanceNonceAccount (durable nonce support) - Memo - SetComputeUnitLimit, SetComputeUnitPrice - TokenTransfer (SPL Token Program transfers) - CustomInstruction (raw instruction support) ### TypeScript API (`js/builder.ts`) - `buildTransaction()` - Build transactions from high-level intents - Type definitions for all instruction kinds and nonce sources - Support for Address Lookup Tables in versioned transactions ## Versioned Transaction Support ### Parsing (`js/versioned.ts`, `src/versioned.rs`) - `VersionedTransaction` class for parsing both legacy and MessageV0 transactions - `isVersionedTransaction()` utility to detect transaction format - Extract Address Lookup Tables, static account keys, and instructions - Support for adding signatures to parsed transactions ### Building from Raw Data - `buildFromRawVersionedData()` - Build MessageV0 from pre-compiled instruction data - Preserves account indexes, ALT references, and message header from source - Enables rebuilding transactions with different blockhash/nonce ## WASM Exports ### Constants (`src/wasm/constants.rs`) - Program IDs: systemProgramId, tokenProgramId, token2022ProgramId, etc. - Sysvar addresses: sysvarClockAddress, sysvarRecentBlockhashes, etc. - Well-known addresses: memoV1ProgramId, associatedTokenProgramId, etc. ### Builder Functions (`src/wasm/builder.rs`) - `buildTransaction()` - WASM entry point for transaction building - `buildFromRawVersionedData()` - WASM entry point for versioned building ### Transaction Methods - `serializeMessage()` - Returns message bytes for web3.js API compatibility - Property-based API (feePayer, recentBlockhash, signatures) - `CustomInstruction` type for passing raw instructions to builder ## Additional Changes ### CreateATA Fix - Fixed `programId` return value for CreateAssociatedTokenAccount instructions - Now correctly returns Token Program ID instead of ATA Program ID ### Stake Split Support - Added `StakeSplitIntent` for stake account splitting - Proper handling of split instruction in both building and parsing ### Test Coverage - `test/builder.ts` - Comprehensive builder tests (693 lines) - `test/versioned.ts` - Versioned transaction tests - `test/transaction.ts` - Extended transaction tests with building ## Architecture The builder follows an intent-based architecture: 1. Caller creates a `TransactionIntent` with fee payer, nonce, and instructions 2. Builder converts intents to native Solana instructions 3. Transaction is serialized as legacy or versioned based on ALT presence 4. Returns raw transaction bytes for signing This design eliminates @solana/web3.js dependency while maintaining full compatibility with the Solana transaction format.
OttoAllmendinger
approved these changes
Jan 29, 2026
Contributor
There was a problem hiding this comment.
if we already expose a Transaction type, maybe we should return that here instead of the serialized for of it? The caller can serialize if they need
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.
This commit adds comprehensive transaction building capabilities to wasm-solana,
enabling the construction of both legacy and versioned (MessageV0) Solana
transactions without requiring @solana/web3.js dependency.
Transaction Building
Core Builder (Rust)
src/builder/build.rs- Main transaction building logic from TransactionIntentsrc/builder/types.rs- Type definitions (TransactionIntent, Instruction, Nonce, etc.)src/builder/versioned.rs- MessageV0/versioned transaction building from raw dataSupported Instructions
TypeScript API (
js/builder.ts)buildTransaction()- Build transactions from high-level intentsVersioned Transaction Support
Parsing (
js/versioned.ts,src/versioned.rs)VersionedTransactionclass for parsing both legacy and MessageV0 transactionsisVersionedTransaction()utility to detect transaction formatBuilding from Raw Data
buildFromRawVersionedData()- Build MessageV0 from pre-compiled instruction dataWASM Exports
Constants (
src/wasm/constants.rs)Builder Functions (
src/wasm/builder.rs)buildTransaction()- WASM entry point for transaction buildingbuildFromRawVersionedData()- WASM entry point for versioned buildingTransaction Methods
serializeMessage()- Returns message bytes for web3.js API compatibilityCustomInstructiontype for passing raw instructions to builderAdditional Changes
CreateATA Fix
programIdreturn value for CreateAssociatedTokenAccount instructionsStake Split Support
StakeSplitIntentfor stake account splittingTest Coverage
test/builder.ts- Comprehensive builder tests (693 lines)test/versioned.ts- Versioned transaction teststest/transaction.ts- Extended transaction tests with buildingArchitecture
The builder follows an intent-based architecture:
TransactionIntentwith fee payer, nonce, and instructionsThis design eliminates @solana/web3.js dependency while maintaining full
compatibility with the Solana transaction format.