use borsh::{BorshDeserialize, BorshSerialize};
#[cfg(feature = "serde-feature")]
use serde::{Deserialize, Serialize};
use solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
use super::InstructionBuilder;
use crate::instruction::MetadataInstruction;
pub fn burn_edition_nft(
program_id: Pubkey,
metadata: Pubkey,
owner: Pubkey,
print_edition_mint: Pubkey,
master_edition_mint: Pubkey,
print_edition_token: Pubkey,
master_edition_token: Pubkey,
master_edition: Pubkey,
print_edition: Pubkey,
edition_marker: Pubkey,
spl_token: Pubkey,
) -> Instruction {
let accounts = vec![
AccountMeta::new(metadata, false),
AccountMeta::new(owner, true),
AccountMeta::new(print_edition_mint, false),
AccountMeta::new_readonly(master_edition_mint, false),
AccountMeta::new(print_edition_token, false),
AccountMeta::new_readonly(master_edition_token, false),
AccountMeta::new(master_edition, false),
AccountMeta::new(print_edition, false),
AccountMeta::new(edition_marker, false),
AccountMeta::new_readonly(spl_token, false),
];
Instruction {
program_id,
accounts,
data: MetadataInstruction::BurnEditionNft.try_to_vec().unwrap(),
}
}
pub fn burn_nft(
program_id: Pubkey,
metadata: Pubkey,
owner: Pubkey,
mint: Pubkey,
token: Pubkey,
edition: Pubkey,
spl_token: Pubkey,
collection_metadata: Option<Pubkey>,
) -> Instruction {
let mut accounts = vec![
AccountMeta::new(metadata, false),
AccountMeta::new(owner, true),
AccountMeta::new(mint, false),
AccountMeta::new(token, false),
AccountMeta::new(edition, false),
AccountMeta::new_readonly(spl_token, false),
];
if let Some(collection_metadata) = collection_metadata {
accounts.push(AccountMeta::new(collection_metadata, false));
}
Instruction {
program_id,
accounts,
data: MetadataInstruction::BurnNft.try_to_vec().unwrap(),
}
}
#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub enum BurnArgs {
V1 {
amount: u64,
},
}
impl InstructionBuilder for super::builders::Burn {
fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = vec![
AccountMeta::new(self.authority, true),
if let Some(collection_metadata) = self.collection_metadata {
AccountMeta::new(collection_metadata, false)
} else {
AccountMeta::new_readonly(crate::ID, false)
},
AccountMeta::new(self.metadata, false),
if let Some(edition) = self.edition {
AccountMeta::new(edition, false)
} else {
AccountMeta::new_readonly(crate::ID, false)
},
AccountMeta::new(self.mint, false),
AccountMeta::new(self.token, false),
if let Some(master_edition) = self.master_edition {
AccountMeta::new(master_edition, false)
} else {
AccountMeta::new_readonly(crate::ID, false)
},
AccountMeta::new_readonly(self.master_edition_mint.unwrap_or(crate::ID), false),
AccountMeta::new_readonly(self.master_edition_token.unwrap_or(crate::ID), false),
if let Some(edition_marker) = self.edition_marker {
AccountMeta::new(edition_marker, false)
} else {
AccountMeta::new_readonly(crate::ID, false)
},
if let Some(token_record) = self.token_record {
AccountMeta::new(token_record, false)
} else {
AccountMeta::new_readonly(crate::ID, false)
},
AccountMeta::new_readonly(self.system_program, false),
AccountMeta::new_readonly(self.sysvar_instructions, false),
AccountMeta::new_readonly(self.spl_token_program, false),
];
Instruction {
program_id: crate::ID,
accounts,
data: MetadataInstruction::Burn(self.args.clone())
.try_to_vec()
.unwrap(),
}
}
}