Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 55ae87b

Browse files
committed
Add batch instruction
1 parent 8df8ddb commit 55ae87b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

interface/src/instruction.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pinocchio::{program_error::ProgramError, pubkey::Pubkey};
55
use crate::error::TokenError;
66

77
/// Instructions supported by the token program.
8-
#[repr(C)]
8+
#[repr(C, u8)]
99
#[derive(Clone, Debug, PartialEq)]
1010
pub enum TokenInstruction<'a> {
1111
/// Initializes a new mint and optionally deposits all the newly minted
@@ -477,6 +477,21 @@ pub enum TokenInstruction<'a> {
477477
/// The ui_amount of tokens to reformat.
478478
ui_amount: &'a str,
479479
},
480+
481+
/// Executes a batch of instructions. The instructions to be executed are specified
482+
/// in sequence on the instruction data. Each instruction provides:
483+
/// - `u8`: number of accounts
484+
/// - `u8`: instruction data length (includes the discriminator)
485+
/// - `u8`: instruction discriminator
486+
/// - `[u8]`: instruction data
487+
///
488+
/// Accounts follow a similar pattern, where accounts for each instruction are
489+
/// specified in sequence. Therefore, the number of accounts expected by this
490+
/// instruction is variable – i.e., it depends on the instructions provided.
491+
///
492+
/// Both the number of accountsa and instruction data length are used to identify
493+
/// the slice of accounts and instruction data for each instruction.
494+
Batch = 255,
480495
// Any new variants also need to be added to program-2022 `TokenInstruction`, so that the
481496
// latter remains a superset of this instruction set. New variants also need to be added to
482497
// token/js/src/instructions/types.ts to maintain @solana/spl-token compatibility

0 commit comments

Comments
 (0)