pub struct TokenBatch<'a, const DATA: usize = 256, const ACCOUNTS: usize = 16> { /* private fields */ }Expand description
A stack-resident batch of token instructions.
DATA bounds the instruction data (one discriminator byte plus the
headers and data of every pushed instruction) and ACCOUNTS bounds
the account list. A push that would overflow either is refused with
InvalidArgument and leaves the batch unchanged.
Implementations§
Source§impl<'a, const DATA: usize, const ACCOUNTS: usize> TokenBatch<'a, DATA, ACCOUNTS>
impl<'a, const DATA: usize, const ACCOUNTS: usize> TokenBatch<'a, DATA, ACCOUNTS>
Sourcepub const fn new() -> TokenBatch<'a, DATA, ACCOUNTS>
pub const fn new() -> TokenBatch<'a, DATA, ACCOUNTS>
An empty batch. DATA must hold at least the discriminator.
Sourcepub fn push(
&mut self,
instruction: &impl TokenInstruction<'a>,
) -> Result<(), ProgramError>
pub fn push( &mut self, instruction: &impl TokenInstruction<'a>, ) -> Result<(), ProgramError>
Append an instruction whose authority signs directly or through PDA seeds given at invoke time.
Sourcepub fn push_multisig(
&mut self,
instruction: &impl TokenInstruction<'a>,
multisig_signers: &[&'a AccountView<'a>],
) -> Result<(), ProgramError>
pub fn push_multisig( &mut self, instruction: &impl TokenInstruction<'a>, multisig_signers: &[&'a AccountView<'a>], ) -> Result<(), ProgramError>
Append an instruction whose authority is a multisig with these signer accounts.
Sourcepub fn data(&self) -> &[u8]
pub fn data(&self) -> &[u8]
The instruction data as it will be sent: [255] then the headers
and inner data.
Sourcepub fn account_metas(&self) -> &[InstructionAccount<'a>]
pub fn account_metas(&self) -> &[InstructionAccount<'a>]
The account metas as they will be sent.
Sourcepub fn account_views(&self) -> &[&'a AccountView<'a>]
pub fn account_views(&self) -> &[&'a AccountView<'a>]
The account views as they will be sent, in meta order.
Sourcepub fn invoke(&self) -> Result<(), ProgramError>
pub fn invoke(&self) -> Result<(), ProgramError>
Send the batch to SPL Token.
Sourcepub fn invoke_signed(
&self,
signers: &[Signer<'_, '_>],
) -> Result<(), ProgramError>
pub fn invoke_signed( &self, signers: &[Signer<'_, '_>], ) -> Result<(), ProgramError>
Send the batch to SPL Token with PDA signers.
Sourcepub fn invoke_on(
&self,
program: TokenProgram,
signers: &[Signer<'_, '_>],
) -> Result<(), ProgramError>
pub fn invoke_on( &self, program: TokenProgram, signers: &[Signer<'_, '_>], ) -> Result<(), ProgramError>
Send the batch to an explicit token program. An empty batch is
refused with InvalidArgument rather than sent.