use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct SetTokenStandard {
pub metadata: solana_program::pubkey::Pubkey,
pub update_authority: solana_program::pubkey::Pubkey,
pub mint: solana_program::pubkey::Pubkey,
pub edition: Option<solana_program::pubkey::Pubkey>,
}
impl SetTokenStandard {
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(4 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.update_authority,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.mint, false,
));
if let Some(edition) = self.edition {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
edition, false,
));
}
accounts.extend_from_slice(remaining_accounts);
let data = SetTokenStandardInstructionData::new().try_to_vec().unwrap();
solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
}
}
}
#[derive(BorshDeserialize, BorshSerialize)]
struct SetTokenStandardInstructionData {
discriminator: u8,
}
impl SetTokenStandardInstructionData {
fn new() -> Self {
Self { discriminator: 35 }
}
}
#[derive(Default)]
pub struct SetTokenStandardBuilder {
metadata: Option<solana_program::pubkey::Pubkey>,
update_authority: Option<solana_program::pubkey::Pubkey>,
mint: Option<solana_program::pubkey::Pubkey>,
edition: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl SetTokenStandardBuilder {
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 update_authority(
&mut self,
update_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.update_authority = Some(update_authority);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.mint = Some(mint);
self
}
#[inline(always)]
pub fn edition(&mut self, edition: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
self.edition = edition;
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 = SetTokenStandard {
metadata: self.metadata.expect("metadata is not set"),
update_authority: self.update_authority.expect("update_authority is not set"),
mint: self.mint.expect("mint is not set"),
edition: self.edition,
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct SetTokenStandardCpiAccounts<'a, 'b> {
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
}
pub struct SetTokenStandardCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
}
impl<'a, 'b> SetTokenStandardCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: SetTokenStandardCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
metadata: accounts.metadata,
update_authority: accounts.update_authority,
mint: accounts.mint,
edition: accounts.edition,
}
}
#[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(4 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.update_authority.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.mint.key,
false,
));
if let Some(edition) = self.edition {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*edition.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 = SetTokenStandardInstructionData::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(4 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.metadata.clone());
account_infos.push(self.update_authority.clone());
account_infos.push(self.mint.clone());
if let Some(edition) = self.edition {
account_infos.push(edition.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 SetTokenStandardCpiBuilder<'a, 'b> {
instruction: Box<SetTokenStandardCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> SetTokenStandardCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(SetTokenStandardCpiBuilderInstruction {
__program: program,
metadata: None,
update_authority: None,
mint: None,
edition: 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 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 mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.mint = Some(mint);
self
}
#[inline(always)]
pub fn edition(
&mut self,
edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.edition = edition;
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 = SetTokenStandardCpi {
__program: self.instruction.__program,
metadata: self.instruction.metadata.expect("metadata is not set"),
update_authority: self
.instruction
.update_authority
.expect("update_authority is not set"),
mint: self.instruction.mint.expect("mint is not set"),
edition: self.instruction.edition,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
struct SetTokenStandardCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}