use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct VerifySizedCollectionItem {
pub metadata: solana_program::pubkey::Pubkey,
pub collection_authority: solana_program::pubkey::Pubkey,
pub payer: solana_program::pubkey::Pubkey,
pub collection_mint: solana_program::pubkey::Pubkey,
pub collection: solana_program::pubkey::Pubkey,
pub collection_master_edition_account: solana_program::pubkey::Pubkey,
pub collection_authority_record: Option<solana_program::pubkey::Pubkey>,
}
impl VerifySizedCollectionItem {
pub fn instruction(&self) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(&[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.collection_authority,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.payer, true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.collection_mint,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.collection,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.collection_master_edition_account,
false,
));
if let Some(collection_authority_record) = self.collection_authority_record {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
collection_authority_record,
false,
));
}
accounts.extend_from_slice(remaining_accounts);
let data = VerifySizedCollectionItemInstructionData::new()
.try_to_vec()
.unwrap();
solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
}
}
}
#[derive(BorshDeserialize, BorshSerialize)]
struct VerifySizedCollectionItemInstructionData {
discriminator: u8,
}
impl VerifySizedCollectionItemInstructionData {
fn new() -> Self {
Self { discriminator: 30 }
}
}
#[derive(Default)]
pub struct VerifySizedCollectionItemBuilder {
metadata: Option<solana_program::pubkey::Pubkey>,
collection_authority: Option<solana_program::pubkey::Pubkey>,
payer: Option<solana_program::pubkey::Pubkey>,
collection_mint: Option<solana_program::pubkey::Pubkey>,
collection: Option<solana_program::pubkey::Pubkey>,
collection_master_edition_account: Option<solana_program::pubkey::Pubkey>,
collection_authority_record: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl VerifySizedCollectionItemBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
self.metadata = Some(metadata);
self
}
#[inline(always)]
pub fn collection_authority(
&mut self,
collection_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.collection_authority = Some(collection_authority);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
self.payer = Some(payer);
self
}
#[inline(always)]
pub fn collection_mint(
&mut self,
collection_mint: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.collection_mint = Some(collection_mint);
self
}
#[inline(always)]
pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self {
self.collection = Some(collection);
self
}
#[inline(always)]
pub fn collection_master_edition_account(
&mut self,
collection_master_edition_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.collection_master_edition_account = Some(collection_master_edition_account);
self
}
#[inline(always)]
pub fn collection_authority_record(
&mut self,
collection_authority_record: Option<solana_program::pubkey::Pubkey>,
) -> &mut Self {
self.collection_authority_record = collection_authority_record;
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 = VerifySizedCollectionItem {
metadata: self.metadata.expect("metadata is not set"),
collection_authority: self
.collection_authority
.expect("collection_authority is not set"),
payer: self.payer.expect("payer is not set"),
collection_mint: self.collection_mint.expect("collection_mint is not set"),
collection: self.collection.expect("collection is not set"),
collection_master_edition_account: self
.collection_master_edition_account
.expect("collection_master_edition_account is not set"),
collection_authority_record: self.collection_authority_record,
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct VerifySizedCollectionItemCpiAccounts<'a, 'b> {
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub collection: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
}
pub struct VerifySizedCollectionItemCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub collection: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
}
impl<'a, 'b> VerifySizedCollectionItemCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: VerifySizedCollectionItemCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
metadata: accounts.metadata,
collection_authority: accounts.collection_authority,
payer: accounts.payer,
collection_mint: accounts.collection_mint,
collection: accounts.collection,
collection_master_edition_account: accounts.collection_master_edition_account,
collection_authority_record: accounts.collection_authority_record,
}
}
#[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(7 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.collection_authority.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.payer.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.collection_mint.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.collection.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.collection_master_edition_account.key,
false,
));
if let Some(collection_authority_record) = self.collection_authority_record {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*collection_authority_record.key,
false,
));
}
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let data = VerifySizedCollectionItemInstructionData::new()
.try_to_vec()
.unwrap();
let instruction = solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.metadata.clone());
account_infos.push(self.collection_authority.clone());
account_infos.push(self.payer.clone());
account_infos.push(self.collection_mint.clone());
account_infos.push(self.collection.clone());
account_infos.push(self.collection_master_edition_account.clone());
if let Some(collection_authority_record) = self.collection_authority_record {
account_infos.push(collection_authority_record.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 VerifySizedCollectionItemCpiBuilder<'a, 'b> {
instruction: Box<VerifySizedCollectionItemCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> VerifySizedCollectionItemCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(VerifySizedCollectionItemCpiBuilderInstruction {
__program: program,
metadata: None,
collection_authority: None,
payer: None,
collection_mint: None,
collection: None,
collection_master_edition_account: None,
collection_authority_record: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn metadata(
&mut self,
metadata: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.metadata = Some(metadata);
self
}
#[inline(always)]
pub fn collection_authority(
&mut self,
collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collection_authority = Some(collection_authority);
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 collection_mint(
&mut self,
collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collection_mint = Some(collection_mint);
self
}
#[inline(always)]
pub fn collection(
&mut self,
collection: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collection = Some(collection);
self
}
#[inline(always)]
pub fn collection_master_edition_account(
&mut self,
collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collection_master_edition_account =
Some(collection_master_edition_account);
self
}
#[inline(always)]
pub fn collection_authority_record(
&mut self,
collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.collection_authority_record = collection_authority_record;
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 instruction = VerifySizedCollectionItemCpi {
__program: self.instruction.__program,
metadata: self.instruction.metadata.expect("metadata is not set"),
collection_authority: self
.instruction
.collection_authority
.expect("collection_authority is not set"),
payer: self.instruction.payer.expect("payer is not set"),
collection_mint: self
.instruction
.collection_mint
.expect("collection_mint is not set"),
collection: self.instruction.collection.expect("collection is not set"),
collection_master_edition_account: self
.instruction
.collection_master_edition_account
.expect("collection_master_edition_account is not set"),
collection_authority_record: self.instruction.collection_authority_record,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
struct VerifySizedCollectionItemCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection_master_edition_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}