#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};
pub struct RevokeCollectionAuthority {
pub collection_authority_record: solana_program::pubkey::Pubkey,
pub delegate_authority: solana_program::pubkey::Pubkey,
pub revoke_authority: solana_program::pubkey::Pubkey,
pub metadata: solana_program::pubkey::Pubkey,
pub mint: solana_program::pubkey::Pubkey,
}
impl RevokeCollectionAuthority {
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(5 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.collection_authority_record,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.delegate_authority,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.revoke_authority,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.metadata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.mint, false,
));
accounts.extend_from_slice(remaining_accounts);
let data = borsh::to_vec(&(RevokeCollectionAuthorityInstructionData::new())).unwrap();
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 RevokeCollectionAuthorityInstructionData {
discriminator: u8,
}
impl RevokeCollectionAuthorityInstructionData {
pub fn new() -> Self {
Self { discriminator: 24 }
}
}
#[derive(Default)]
pub struct RevokeCollectionAuthorityBuilder {
collection_authority_record: Option<solana_program::pubkey::Pubkey>,
delegate_authority: Option<solana_program::pubkey::Pubkey>,
revoke_authority: Option<solana_program::pubkey::Pubkey>,
metadata: Option<solana_program::pubkey::Pubkey>,
mint: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl RevokeCollectionAuthorityBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn collection_authority_record(
&mut self,
collection_authority_record: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.collection_authority_record = Some(collection_authority_record);
self
}
#[inline(always)]
pub fn delegate_authority(
&mut self,
delegate_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.delegate_authority = Some(delegate_authority);
self
}
#[inline(always)]
pub fn revoke_authority(
&mut self,
revoke_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.revoke_authority = Some(revoke_authority);
self
}
#[inline(always)]
pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
self.metadata = Some(metadata);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.mint = Some(mint);
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 = RevokeCollectionAuthority {
collection_authority_record: self
.collection_authority_record
.expect("collection_authority_record is not set"),
delegate_authority: self
.delegate_authority
.expect("delegate_authority is not set"),
revoke_authority: self.revoke_authority.expect("revoke_authority is not set"),
metadata: self.metadata.expect("metadata is not set"),
mint: self.mint.expect("mint is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct RevokeCollectionAuthorityCpiAccounts<'a, 'b> {
pub collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
pub delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct RevokeCollectionAuthorityCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
pub delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
}
impl<'a, 'b> RevokeCollectionAuthorityCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: RevokeCollectionAuthorityCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
collection_authority_record: accounts.collection_authority_record,
delegate_authority: accounts.delegate_authority,
revoke_authority: accounts.revoke_authority,
metadata: accounts.metadata,
mint: accounts.mint,
}
}
#[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(5 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.collection_authority_record.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.delegate_authority.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.revoke_authority.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.metadata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.mint.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 data = borsh::to_vec(&(RevokeCollectionAuthorityInstructionData::new())).unwrap();
let instruction = solana_program::instruction::Instruction {
program_id: crate::MPL_TOKEN_METADATA_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.collection_authority_record.clone());
account_infos.push(self.delegate_authority.clone());
account_infos.push(self.revoke_authority.clone());
account_infos.push(self.metadata.clone());
account_infos.push(self.mint.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 RevokeCollectionAuthorityCpiBuilder<'a, 'b> {
instruction: Box<RevokeCollectionAuthorityCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> RevokeCollectionAuthorityCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(RevokeCollectionAuthorityCpiBuilderInstruction {
__program: program,
collection_authority_record: None,
delegate_authority: None,
revoke_authority: None,
metadata: None,
mint: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn collection_authority_record(
&mut self,
collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collection_authority_record = Some(collection_authority_record);
self
}
#[inline(always)]
pub fn delegate_authority(
&mut self,
delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.delegate_authority = Some(delegate_authority);
self
}
#[inline(always)]
pub fn revoke_authority(
&mut self,
revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.revoke_authority = Some(revoke_authority);
self
}
#[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 mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.mint = Some(mint);
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 = RevokeCollectionAuthorityCpi {
__program: self.instruction.__program,
collection_authority_record: self
.instruction
.collection_authority_record
.expect("collection_authority_record is not set"),
delegate_authority: self
.instruction
.delegate_authority
.expect("delegate_authority is not set"),
revoke_authority: self
.instruction
.revoke_authority
.expect("revoke_authority is not set"),
metadata: self.instruction.metadata.expect("metadata is not set"),
mint: self.instruction.mint.expect("mint is not set"),
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
struct RevokeCollectionAuthorityCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
delegate_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
revoke_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}