use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct WithdrawNftCore {
pub owner: solana_program::pubkey::Pubkey,
pub pool: solana_program::pubkey::Pubkey,
pub whitelist: Option<solana_program::pubkey::Pubkey>,
pub mint_proof: Option<solana_program::pubkey::Pubkey>,
pub asset: solana_program::pubkey::Pubkey,
pub collection: Option<solana_program::pubkey::Pubkey>,
pub mpl_core_program: solana_program::pubkey::Pubkey,
pub nft_receipt: solana_program::pubkey::Pubkey,
}
impl WithdrawNftCore {
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(8 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.owner, true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.pool, false,
));
if let Some(whitelist) = self.whitelist {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
whitelist, false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
if let Some(mint_proof) = self.mint_proof {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
mint_proof, false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new(
self.asset, false,
));
if let Some(collection) = self.collection {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
collection, false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.mpl_core_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.nft_receipt,
false,
));
accounts.extend_from_slice(remaining_accounts);
let data = WithdrawNftCoreInstructionData::new().try_to_vec().unwrap();
solana_program::instruction::Instruction {
program_id: crate::TENSOR_AMM_ID,
accounts,
data,
}
}
}
#[derive(BorshDeserialize, BorshSerialize)]
pub struct WithdrawNftCoreInstructionData {
discriminator: [u8; 8],
}
impl WithdrawNftCoreInstructionData {
pub fn new() -> Self {
Self {
discriminator: [112, 131, 239, 116, 187, 149, 114, 145],
}
}
}
impl Default for WithdrawNftCoreInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct WithdrawNftCoreBuilder {
owner: Option<solana_program::pubkey::Pubkey>,
pool: Option<solana_program::pubkey::Pubkey>,
whitelist: Option<solana_program::pubkey::Pubkey>,
mint_proof: Option<solana_program::pubkey::Pubkey>,
asset: Option<solana_program::pubkey::Pubkey>,
collection: Option<solana_program::pubkey::Pubkey>,
mpl_core_program: Option<solana_program::pubkey::Pubkey>,
nft_receipt: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl WithdrawNftCoreBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
self.owner = Some(owner);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
self.pool = Some(pool);
self
}
#[inline(always)]
pub fn whitelist(&mut self, whitelist: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
self.whitelist = whitelist;
self
}
#[inline(always)]
pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
self.mint_proof = mint_proof;
self
}
#[inline(always)]
pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self {
self.asset = Some(asset);
self
}
#[inline(always)]
pub fn collection(&mut self, collection: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
self.collection = collection;
self
}
#[inline(always)]
pub fn mpl_core_program(
&mut self,
mpl_core_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.mpl_core_program = Some(mpl_core_program);
self
}
#[inline(always)]
pub fn nft_receipt(&mut self, nft_receipt: solana_program::pubkey::Pubkey) -> &mut Self {
self.nft_receipt = Some(nft_receipt);
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 = WithdrawNftCore {
owner: self.owner.expect("owner is not set"),
pool: self.pool.expect("pool is not set"),
whitelist: self.whitelist,
mint_proof: self.mint_proof,
asset: self.asset.expect("asset is not set"),
collection: self.collection,
mpl_core_program: self.mpl_core_program.unwrap_or(solana_program::pubkey!(
"CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
)),
nft_receipt: self.nft_receipt.expect("nft_receipt is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct WithdrawNftCoreCpiAccounts<'a, 'b> {
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub asset: &'b solana_program::account_info::AccountInfo<'a>,
pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub mpl_core_program: &'b solana_program::account_info::AccountInfo<'a>,
pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct WithdrawNftCoreCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub asset: &'b solana_program::account_info::AccountInfo<'a>,
pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub mpl_core_program: &'b solana_program::account_info::AccountInfo<'a>,
pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
}
impl<'a, 'b> WithdrawNftCoreCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: WithdrawNftCoreCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
owner: accounts.owner,
pool: accounts.pool,
whitelist: accounts.whitelist,
mint_proof: accounts.mint_proof,
asset: accounts.asset,
collection: accounts.collection,
mpl_core_program: accounts.mpl_core_program,
nft_receipt: accounts.nft_receipt,
}
}
#[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(8 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.owner.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.pool.key,
false,
));
if let Some(whitelist) = self.whitelist {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*whitelist.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
if let Some(mint_proof) = self.mint_proof {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*mint_proof.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new(
*self.asset.key,
false,
));
if let Some(collection) = self.collection {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*collection.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::TENSOR_AMM_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.mpl_core_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.nft_receipt.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 = WithdrawNftCoreInstructionData::new().try_to_vec().unwrap();
let instruction = solana_program::instruction::Instruction {
program_id: crate::TENSOR_AMM_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.owner.clone());
account_infos.push(self.pool.clone());
if let Some(whitelist) = self.whitelist {
account_infos.push(whitelist.clone());
}
if let Some(mint_proof) = self.mint_proof {
account_infos.push(mint_proof.clone());
}
account_infos.push(self.asset.clone());
if let Some(collection) = self.collection {
account_infos.push(collection.clone());
}
account_infos.push(self.mpl_core_program.clone());
account_infos.push(self.nft_receipt.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)
}
}
}
#[derive(Clone, Debug)]
pub struct WithdrawNftCoreCpiBuilder<'a, 'b> {
instruction: Box<WithdrawNftCoreCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> WithdrawNftCoreCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(WithdrawNftCoreCpiBuilderInstruction {
__program: program,
owner: None,
pool: None,
whitelist: None,
mint_proof: None,
asset: None,
collection: None,
mpl_core_program: None,
nft_receipt: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.owner = Some(owner);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.pool = Some(pool);
self
}
#[inline(always)]
pub fn whitelist(
&mut self,
whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.whitelist = whitelist;
self
}
#[inline(always)]
pub fn mint_proof(
&mut self,
mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.mint_proof = mint_proof;
self
}
#[inline(always)]
pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.asset = Some(asset);
self
}
#[inline(always)]
pub fn collection(
&mut self,
collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.collection = collection;
self
}
#[inline(always)]
pub fn mpl_core_program(
&mut self,
mpl_core_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.mpl_core_program = Some(mpl_core_program);
self
}
#[inline(always)]
pub fn nft_receipt(
&mut self,
nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.nft_receipt = Some(nft_receipt);
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 = WithdrawNftCoreCpi {
__program: self.instruction.__program,
owner: self.instruction.owner.expect("owner is not set"),
pool: self.instruction.pool.expect("pool is not set"),
whitelist: self.instruction.whitelist,
mint_proof: self.instruction.mint_proof,
asset: self.instruction.asset.expect("asset is not set"),
collection: self.instruction.collection,
mpl_core_program: self
.instruction
.mpl_core_program
.expect("mpl_core_program is not set"),
nft_receipt: self
.instruction
.nft_receipt
.expect("nft_receipt is not set"),
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct WithdrawNftCoreCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
asset: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mpl_core_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}