use crate::generated::types::MetadataArgs;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};
pub struct DecompressV1 {
pub voucher: solana_program::pubkey::Pubkey,
pub leaf_owner: solana_program::pubkey::Pubkey,
pub token_account: solana_program::pubkey::Pubkey,
pub mint: solana_program::pubkey::Pubkey,
pub mint_authority: solana_program::pubkey::Pubkey,
pub metadata_account: solana_program::pubkey::Pubkey,
pub master_edition: solana_program::pubkey::Pubkey,
pub system_program: solana_program::pubkey::Pubkey,
pub sysvar_rent: solana_program::pubkey::Pubkey,
pub token_metadata_program: solana_program::pubkey::Pubkey,
pub token_program: solana_program::pubkey::Pubkey,
pub associated_token_program: solana_program::pubkey::Pubkey,
pub log_wrapper: solana_program::pubkey::Pubkey,
}
impl DecompressV1 {
pub fn instruction(
&self,
args: DecompressV1InstructionArgs,
) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: DecompressV1InstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(13 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.voucher,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.leaf_owner,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.token_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.mint, false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.mint_authority,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.metadata_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.master_edition,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.sysvar_rent,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_metadata_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.log_wrapper,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&(DecompressV1InstructionData::new())).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_program::instruction::Instruction {
program_id: crate::MPL_BUBBLEGUM_ID,
accounts,
data,
}
}
}
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct DecompressV1InstructionData {
discriminator: [u8; 8],
}
impl DecompressV1InstructionData {
pub fn new() -> Self {
Self {
discriminator: [54, 85, 76, 70, 228, 250, 164, 81],
}
}
}
#[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 DecompressV1InstructionArgs {
pub metadata: MetadataArgs,
}
#[derive(Default)]
pub struct DecompressV1Builder {
voucher: Option<solana_program::pubkey::Pubkey>,
leaf_owner: Option<solana_program::pubkey::Pubkey>,
token_account: Option<solana_program::pubkey::Pubkey>,
mint: Option<solana_program::pubkey::Pubkey>,
mint_authority: Option<solana_program::pubkey::Pubkey>,
metadata_account: Option<solana_program::pubkey::Pubkey>,
master_edition: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
sysvar_rent: Option<solana_program::pubkey::Pubkey>,
token_metadata_program: Option<solana_program::pubkey::Pubkey>,
token_program: Option<solana_program::pubkey::Pubkey>,
associated_token_program: Option<solana_program::pubkey::Pubkey>,
log_wrapper: Option<solana_program::pubkey::Pubkey>,
metadata: Option<MetadataArgs>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl DecompressV1Builder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn voucher(&mut self, voucher: solana_program::pubkey::Pubkey) -> &mut Self {
self.voucher = Some(voucher);
self
}
#[inline(always)]
pub fn leaf_owner(&mut self, leaf_owner: solana_program::pubkey::Pubkey) -> &mut Self {
self.leaf_owner = Some(leaf_owner);
self
}
#[inline(always)]
pub fn token_account(&mut self, token_account: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_account = Some(token_account);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.mint = Some(mint);
self
}
#[inline(always)]
pub fn mint_authority(&mut self, mint_authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.mint_authority = Some(mint_authority);
self
}
#[inline(always)]
pub fn metadata_account(
&mut self,
metadata_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.metadata_account = Some(metadata_account);
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 system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn sysvar_rent(&mut self, sysvar_rent: solana_program::pubkey::Pubkey) -> &mut Self {
self.sysvar_rent = Some(sysvar_rent);
self
}
#[inline(always)]
pub fn token_metadata_program(
&mut self,
token_metadata_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.token_metadata_program = Some(token_metadata_program);
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn log_wrapper(&mut self, log_wrapper: solana_program::pubkey::Pubkey) -> &mut Self {
self.log_wrapper = Some(log_wrapper);
self
}
#[inline(always)]
pub fn metadata(&mut self, metadata: MetadataArgs) -> &mut Self {
self.metadata = Some(metadata);
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 =
DecompressV1 {
voucher: self.voucher.expect("voucher is not set"),
leaf_owner: self.leaf_owner.expect("leaf_owner is not set"),
token_account: self.token_account.expect("token_account is not set"),
mint: self.mint.expect("mint is not set"),
mint_authority: self.mint_authority.expect("mint_authority is not set"),
metadata_account: self.metadata_account.expect("metadata_account is not set"),
master_edition: self.master_edition.expect("master_edition is not set"),
system_program: self
.system_program
.unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
sysvar_rent: self.sysvar_rent.unwrap_or(solana_program::pubkey!(
"SysvarRent111111111111111111111111111111111"
)),
token_metadata_program: self.token_metadata_program.unwrap_or(
solana_program::pubkey!("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
),
token_program: self.token_program.unwrap_or(solana_program::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
associated_token_program: self.associated_token_program.unwrap_or(
solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
),
log_wrapper: self.log_wrapper.unwrap_or(solana_program::pubkey!(
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"
)),
};
let args = DecompressV1InstructionArgs {
metadata: self.metadata.clone().expect("metadata is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct DecompressV1CpiAccounts<'a, 'b> {
pub voucher: &'b solana_program::account_info::AccountInfo<'a>,
pub leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub sysvar_rent: &'b solana_program::account_info::AccountInfo<'a>,
pub token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct DecompressV1Cpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub voucher: &'b solana_program::account_info::AccountInfo<'a>,
pub leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
pub token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub sysvar_rent: &'b solana_program::account_info::AccountInfo<'a>,
pub token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
pub __args: DecompressV1InstructionArgs,
}
impl<'a, 'b> DecompressV1Cpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: DecompressV1CpiAccounts<'a, 'b>,
args: DecompressV1InstructionArgs,
) -> Self {
Self {
__program: program,
voucher: accounts.voucher,
leaf_owner: accounts.leaf_owner,
token_account: accounts.token_account,
mint: accounts.mint,
mint_authority: accounts.mint_authority,
metadata_account: accounts.metadata_account,
master_edition: accounts.master_edition,
system_program: accounts.system_program,
sysvar_rent: accounts.sysvar_rent,
token_metadata_program: accounts.token_metadata_program,
token_program: accounts.token_program,
associated_token_program: accounts.associated_token_program,
log_wrapper: accounts.log_wrapper,
__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(13 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.voucher.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.leaf_owner.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.token_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.mint_authority.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.metadata_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.master_edition.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.sysvar_rent.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_metadata_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.log_wrapper.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(&(DecompressV1InstructionData::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_BUBBLEGUM_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(13 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.voucher.clone());
account_infos.push(self.leaf_owner.clone());
account_infos.push(self.token_account.clone());
account_infos.push(self.mint.clone());
account_infos.push(self.mint_authority.clone());
account_infos.push(self.metadata_account.clone());
account_infos.push(self.master_edition.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.sysvar_rent.clone());
account_infos.push(self.token_metadata_program.clone());
account_infos.push(self.token_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.log_wrapper.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 DecompressV1CpiBuilder<'a, 'b> {
instruction: Box<DecompressV1CpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> DecompressV1CpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(DecompressV1CpiBuilderInstruction {
__program: program,
voucher: None,
leaf_owner: None,
token_account: None,
mint: None,
mint_authority: None,
metadata_account: None,
master_edition: None,
system_program: None,
sysvar_rent: None,
token_metadata_program: None,
token_program: None,
associated_token_program: None,
log_wrapper: None,
metadata: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn voucher(
&mut self,
voucher: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.voucher = Some(voucher);
self
}
#[inline(always)]
pub fn leaf_owner(
&mut self,
leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.leaf_owner = Some(leaf_owner);
self
}
#[inline(always)]
pub fn token_account(
&mut self,
token_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_account = Some(token_account);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.mint = Some(mint);
self
}
#[inline(always)]
pub fn mint_authority(
&mut self,
mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.mint_authority = Some(mint_authority);
self
}
#[inline(always)]
pub fn metadata_account(
&mut self,
metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.metadata_account = Some(metadata_account);
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 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 sysvar_rent(
&mut self,
sysvar_rent: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.sysvar_rent = Some(sysvar_rent);
self
}
#[inline(always)]
pub fn token_metadata_program(
&mut self,
token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_metadata_program = Some(token_metadata_program);
self
}
#[inline(always)]
pub fn token_program(
&mut self,
token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn log_wrapper(
&mut self,
log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.log_wrapper = Some(log_wrapper);
self
}
#[inline(always)]
pub fn metadata(&mut self, metadata: MetadataArgs) -> &mut Self {
self.instruction.metadata = Some(metadata);
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 = DecompressV1InstructionArgs {
metadata: self
.instruction
.metadata
.clone()
.expect("metadata is not set"),
};
let instruction = DecompressV1Cpi {
__program: self.instruction.__program,
voucher: self.instruction.voucher.expect("voucher is not set"),
leaf_owner: self.instruction.leaf_owner.expect("leaf_owner is not set"),
token_account: self
.instruction
.token_account
.expect("token_account is not set"),
mint: self.instruction.mint.expect("mint is not set"),
mint_authority: self
.instruction
.mint_authority
.expect("mint_authority is not set"),
metadata_account: self
.instruction
.metadata_account
.expect("metadata_account is not set"),
master_edition: self
.instruction
.master_edition
.expect("master_edition is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
sysvar_rent: self
.instruction
.sysvar_rent
.expect("sysvar_rent is not set"),
token_metadata_program: self
.instruction
.token_metadata_program
.expect("token_metadata_program is not set"),
token_program: self
.instruction
.token_program
.expect("token_program is not set"),
associated_token_program: self
.instruction
.associated_token_program
.expect("associated_token_program is not set"),
log_wrapper: self
.instruction
.log_wrapper
.expect("log_wrapper is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
struct DecompressV1CpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
voucher: Option<&'b solana_program::account_info::AccountInfo<'a>>,
leaf_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
metadata_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
sysvar_rent: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
metadata: Option<MetadataArgs>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}