use crate::generated::types::PrintArgs;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};
pub struct Print {
pub edition_metadata: solana_program::pubkey::Pubkey,
pub edition: solana_program::pubkey::Pubkey,
pub edition_mint: (solana_program::pubkey::Pubkey, bool),
pub edition_token_account_owner: solana_program::pubkey::Pubkey,
pub edition_token_account: solana_program::pubkey::Pubkey,
pub edition_mint_authority: solana_program::pubkey::Pubkey,
pub edition_token_record: Option<solana_program::pubkey::Pubkey>,
pub master_edition: solana_program::pubkey::Pubkey,
pub edition_marker_pda: solana_program::pubkey::Pubkey,
pub payer: solana_program::pubkey::Pubkey,
pub master_token_account_owner: (solana_program::pubkey::Pubkey, bool),
pub master_token_account: solana_program::pubkey::Pubkey,
pub master_metadata: solana_program::pubkey::Pubkey,
pub update_authority: solana_program::pubkey::Pubkey,
pub spl_token_program: solana_program::pubkey::Pubkey,
pub spl_ata_program: solana_program::pubkey::Pubkey,
pub sysvar_instructions: solana_program::pubkey::Pubkey,
pub system_program: solana_program::pubkey::Pubkey,
}
impl Print {
pub fn instruction(
&self,
args: PrintInstructionArgs,
) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: PrintInstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(18 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.edition_metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.edition,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.edition_mint.0,
self.edition_mint.1,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.edition_token_account_owner,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.edition_token_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.edition_mint_authority,
true,
));
if let Some(edition_token_record) = self.edition_token_record {
accounts.push(solana_program::instruction::AccountMeta::new(
edition_token_record,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::MPL_TOKEN_METADATA_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new(
self.master_edition,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.edition_marker_pda,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer, true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.master_token_account_owner.0,
self.master_token_account_owner.1,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.master_token_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.master_metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.update_authority,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.spl_token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.spl_ata_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.sysvar_instructions,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&(PrintInstructionData::new())).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
}
}
}
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct PrintInstructionData {
discriminator: u8,
}
impl PrintInstructionData {
pub fn new() -> Self {
Self { discriminator: 55 }
}
}
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PrintInstructionArgs {
pub print_args: PrintArgs,
}
#[derive(Default)]
pub struct PrintBuilder {
edition_metadata: Option<solana_program::pubkey::Pubkey>,
edition: Option<solana_program::pubkey::Pubkey>,
edition_mint: Option<(solana_program::pubkey::Pubkey, bool)>,
edition_token_account_owner: Option<solana_program::pubkey::Pubkey>,
edition_token_account: Option<solana_program::pubkey::Pubkey>,
edition_mint_authority: Option<solana_program::pubkey::Pubkey>,
edition_token_record: Option<solana_program::pubkey::Pubkey>,
master_edition: Option<solana_program::pubkey::Pubkey>,
edition_marker_pda: Option<solana_program::pubkey::Pubkey>,
payer: Option<solana_program::pubkey::Pubkey>,
master_token_account_owner: Option<(solana_program::pubkey::Pubkey, bool)>,
master_token_account: Option<solana_program::pubkey::Pubkey>,
master_metadata: Option<solana_program::pubkey::Pubkey>,
update_authority: Option<solana_program::pubkey::Pubkey>,
spl_token_program: Option<solana_program::pubkey::Pubkey>,
spl_ata_program: Option<solana_program::pubkey::Pubkey>,
sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
print_args: Option<PrintArgs>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl PrintBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn edition_metadata(
&mut self,
edition_metadata: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.edition_metadata = Some(edition_metadata);
self
}
#[inline(always)]
pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
self.edition = Some(edition);
self
}
#[inline(always)]
pub fn edition_mint(
&mut self,
edition_mint: solana_program::pubkey::Pubkey,
as_signer: bool,
) -> &mut Self {
self.edition_mint = Some((edition_mint, as_signer));
self
}
#[inline(always)]
pub fn edition_token_account_owner(
&mut self,
edition_token_account_owner: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.edition_token_account_owner = Some(edition_token_account_owner);
self
}
#[inline(always)]
pub fn edition_token_account(
&mut self,
edition_token_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.edition_token_account = Some(edition_token_account);
self
}
#[inline(always)]
pub fn edition_mint_authority(
&mut self,
edition_mint_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.edition_mint_authority = Some(edition_mint_authority);
self
}
#[inline(always)]
pub fn edition_token_record(
&mut self,
edition_token_record: Option<solana_program::pubkey::Pubkey>,
) -> &mut Self {
self.edition_token_record = edition_token_record;
self
}
#[inline(always)]
pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self {
self.master_edition = Some(master_edition);
self
}
#[inline(always)]
pub fn edition_marker_pda(
&mut self,
edition_marker_pda: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.edition_marker_pda = Some(edition_marker_pda);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer = Some(payer);
self
}
#[inline(always)]
pub fn master_token_account_owner(
&mut self,
master_token_account_owner: solana_program::pubkey::Pubkey,
as_signer: bool,
) -> &mut Self {
self.master_token_account_owner = Some((master_token_account_owner, as_signer));
self
}
#[inline(always)]
pub fn master_token_account(
&mut self,
master_token_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.master_token_account = Some(master_token_account);
self
}
#[inline(always)]
pub fn master_metadata(
&mut self,
master_metadata: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.master_metadata = Some(master_metadata);
self
}
#[inline(always)]
pub fn update_authority(
&mut self,
update_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.update_authority = Some(update_authority);
self
}
#[inline(always)]
pub fn spl_token_program(
&mut self,
spl_token_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.spl_token_program = Some(spl_token_program);
self
}
#[inline(always)]
pub fn spl_ata_program(
&mut self,
spl_ata_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.spl_ata_program = Some(spl_ata_program);
self
}
#[inline(always)]
pub fn sysvar_instructions(
&mut self,
sysvar_instructions: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.sysvar_instructions = Some(sysvar_instructions);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn print_args(&mut self, print_args: PrintArgs) -> &mut Self {
self.print_args = Some(print_args);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: solana_program::instruction::AccountMeta,
) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[solana_program::instruction::AccountMeta],
) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = Print {
edition_metadata: self.edition_metadata.expect("edition_metadata is not set"),
edition: self.edition.expect("edition is not set"),
edition_mint: self.edition_mint.expect("edition_mint is not set"),
edition_token_account_owner: self
.edition_token_account_owner
.expect("edition_token_account_owner is not set"),
edition_token_account: self
.edition_token_account
.expect("edition_token_account is not set"),
edition_mint_authority: self
.edition_mint_authority
.expect("edition_mint_authority is not set"),
edition_token_record: self.edition_token_record,
master_edition: self.master_edition.expect("master_edition is not set"),
edition_marker_pda: self
.edition_marker_pda
.expect("edition_marker_pda is not set"),
payer: self.payer.expect("payer is not set"),
master_token_account_owner: self
.master_token_account_owner
.expect("master_token_account_owner is not set"),
master_token_account: self
.master_token_account
.expect("master_token_account is not set"),
master_metadata: self.master_metadata.expect("master_metadata is not set"),
update_authority: self.update_authority.expect("update_authority is not set"),
spl_token_program: self.spl_token_program.unwrap_or(solana_program::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
spl_ata_program: self.spl_ata_program.unwrap_or(solana_program::pubkey!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
)),
sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
"Sysvar1nstructions1111111111111111111111111"
)),
system_program: self
.system_program
.unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
};
let args = PrintInstructionArgs {
print_args: self.print_args.clone().expect("print_args is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct PrintCpiAccounts<'a, 'b> {
pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub edition: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct PrintCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub edition: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub __args: PrintInstructionArgs,
}
impl<'a, 'b> PrintCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: PrintCpiAccounts<'a, 'b>,
args: PrintInstructionArgs,
) -> Self {
Self {
__program: program,
edition_metadata: accounts.edition_metadata,
edition: accounts.edition,
edition_mint: accounts.edition_mint,
edition_token_account_owner: accounts.edition_token_account_owner,
edition_token_account: accounts.edition_token_account,
edition_mint_authority: accounts.edition_mint_authority,
edition_token_record: accounts.edition_token_record,
master_edition: accounts.master_edition,
edition_marker_pda: accounts.edition_marker_pda,
payer: accounts.payer,
master_token_account_owner: accounts.master_token_account_owner,
master_token_account: accounts.master_token_account,
master_metadata: accounts.master_metadata,
update_authority: accounts.update_authority,
spl_token_program: accounts.spl_token_program,
spl_ata_program: accounts.spl_ata_program,
sysvar_instructions: accounts.sysvar_instructions,
system_program: accounts.system_program,
__args: args,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(18 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.edition_metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.edition.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.edition_mint.0.key,
self.edition_mint.1,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.edition_token_account_owner.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.edition_token_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.edition_mint_authority.key,
true,
));
if let Some(edition_token_record) = self.edition_token_record {
accounts.push(solana_program::instruction::AccountMeta::new(
*edition_token_record.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::MPL_TOKEN_METADATA_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new(
*self.master_edition.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.edition_marker_pda.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.master_token_account_owner.0.key,
self.master_token_account_owner.1,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.master_token_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.master_metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.update_authority.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.spl_token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.spl_ata_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.sysvar_instructions.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_writable: remaining_account.1,
is_signer: remaining_account.2,
})
});
let mut data = borsh::to_vec(&(PrintInstructionData::new())).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(18 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.edition_metadata.clone());
account_infos.push(self.edition.clone());
account_infos.push(self.edition_mint.0.clone());
account_infos.push(self.edition_token_account_owner.clone());
account_infos.push(self.edition_token_account.clone());
account_infos.push(self.edition_mint_authority.clone());
if let Some(edition_token_record) = self.edition_token_record {
account_infos.push(edition_token_record.clone());
}
account_infos.push(self.master_edition.clone());
account_infos.push(self.edition_marker_pda.clone());
account_infos.push(self.payer.clone());
account_infos.push(self.master_token_account_owner.0.clone());
account_infos.push(self.master_token_account.clone());
account_infos.push(self.master_metadata.clone());
account_infos.push(self.update_authority.clone());
account_infos.push(self.spl_token_program.clone());
account_infos.push(self.spl_ata_program.clone());
account_infos.push(self.sysvar_instructions.clone());
account_infos.push(self.system_program.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_program::program::invoke(&instruction, &account_infos)
} else {
solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
pub struct PrintCpiBuilder<'a, 'b> {
instruction: Box<PrintCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> PrintCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(PrintCpiBuilderInstruction {
__program: program,
edition_metadata: None,
edition: None,
edition_mint: None,
edition_token_account_owner: None,
edition_token_account: None,
edition_mint_authority: None,
edition_token_record: None,
master_edition: None,
edition_marker_pda: None,
payer: None,
master_token_account_owner: None,
master_token_account: None,
master_metadata: None,
update_authority: None,
spl_token_program: None,
spl_ata_program: None,
sysvar_instructions: None,
system_program: None,
print_args: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn edition_metadata(
&mut self,
edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition_metadata = Some(edition_metadata);
self
}
#[inline(always)]
pub fn edition(
&mut self,
edition: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition = Some(edition);
self
}
#[inline(always)]
pub fn edition_mint(
&mut self,
edition_mint: &'b solana_program::account_info::AccountInfo<'a>,
as_signer: bool,
) -> &mut Self {
self.instruction.edition_mint = Some((edition_mint, as_signer));
self
}
#[inline(always)]
pub fn edition_token_account_owner(
&mut self,
edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition_token_account_owner = Some(edition_token_account_owner);
self
}
#[inline(always)]
pub fn edition_token_account(
&mut self,
edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition_token_account = Some(edition_token_account);
self
}
#[inline(always)]
pub fn edition_mint_authority(
&mut self,
edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition_mint_authority = Some(edition_mint_authority);
self
}
#[inline(always)]
pub fn edition_token_record(
&mut self,
edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.edition_token_record = edition_token_record;
self
}
#[inline(always)]
pub fn master_edition(
&mut self,
master_edition: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.master_edition = Some(master_edition);
self
}
#[inline(always)]
pub fn edition_marker_pda(
&mut self,
edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.edition_marker_pda = Some(edition_marker_pda);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.payer = Some(payer);
self
}
#[inline(always)]
pub fn master_token_account_owner(
&mut self,
master_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
as_signer: bool,
) -> &mut Self {
self.instruction.master_token_account_owner = Some((master_token_account_owner, as_signer));
self
}
#[inline(always)]
pub fn master_token_account(
&mut self,
master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.master_token_account = Some(master_token_account);
self
}
#[inline(always)]
pub fn master_metadata(
&mut self,
master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.master_metadata = Some(master_metadata);
self
}
#[inline(always)]
pub fn update_authority(
&mut self,
update_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.update_authority = Some(update_authority);
self
}
#[inline(always)]
pub fn spl_token_program(
&mut self,
spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.spl_token_program = Some(spl_token_program);
self
}
#[inline(always)]
pub fn spl_ata_program(
&mut self,
spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.spl_ata_program = Some(spl_ata_program);
self
}
#[inline(always)]
pub fn sysvar_instructions(
&mut self,
sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.sysvar_instructions = Some(sysvar_instructions);
self
}
#[inline(always)]
pub fn system_program(
&mut self,
system_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn print_args(&mut self, print_args: PrintArgs) -> &mut Self {
self.instruction.print_args = Some(print_args);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: &'b solana_program::account_info::AccountInfo<'a>,
is_writable: bool,
is_signer: bool,
) -> &mut Self {
self.instruction
.__remaining_accounts
.push((account, is_writable, is_signer));
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> &mut Self {
self.instruction
.__remaining_accounts
.extend_from_slice(accounts);
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = PrintInstructionArgs {
print_args: self
.instruction
.print_args
.clone()
.expect("print_args is not set"),
};
let instruction = PrintCpi {
__program: self.instruction.__program,
edition_metadata: self
.instruction
.edition_metadata
.expect("edition_metadata is not set"),
edition: self.instruction.edition.expect("edition is not set"),
edition_mint: self
.instruction
.edition_mint
.expect("edition_mint is not set"),
edition_token_account_owner: self
.instruction
.edition_token_account_owner
.expect("edition_token_account_owner is not set"),
edition_token_account: self
.instruction
.edition_token_account
.expect("edition_token_account is not set"),
edition_mint_authority: self
.instruction
.edition_mint_authority
.expect("edition_mint_authority is not set"),
edition_token_record: self.instruction.edition_token_record,
master_edition: self
.instruction
.master_edition
.expect("master_edition is not set"),
edition_marker_pda: self
.instruction
.edition_marker_pda
.expect("edition_marker_pda is not set"),
payer: self.instruction.payer.expect("payer is not set"),
master_token_account_owner: self
.instruction
.master_token_account_owner
.expect("master_token_account_owner is not set"),
master_token_account: self
.instruction
.master_token_account
.expect("master_token_account is not set"),
master_metadata: self
.instruction
.master_metadata
.expect("master_metadata is not set"),
update_authority: self
.instruction
.update_authority
.expect("update_authority is not set"),
spl_token_program: self
.instruction
.spl_token_program
.expect("spl_token_program is not set"),
spl_ata_program: self
.instruction
.spl_ata_program
.expect("spl_ata_program is not set"),
sysvar_instructions: self
.instruction
.sysvar_instructions
.expect("sysvar_instructions is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
struct PrintCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
edition_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition_mint: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
edition_token_account_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition_mint_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition_marker_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
master_token_account_owner: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
master_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
master_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
print_args: Option<PrintArgs>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}