1use crate::generated::types::AuthorizationDataLocal;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub struct WithdrawNft {
14 pub owner: solana_program::pubkey::Pubkey,
16 pub pool: solana_program::pubkey::Pubkey,
18 pub whitelist: Option<solana_program::pubkey::Pubkey>,
21 pub mint_proof: Option<solana_program::pubkey::Pubkey>,
24 pub mint: solana_program::pubkey::Pubkey,
26 pub metadata: solana_program::pubkey::Pubkey,
28 pub edition: solana_program::pubkey::Pubkey,
30 pub user_token_record: Option<solana_program::pubkey::Pubkey>,
32 pub pool_token_record: Option<solana_program::pubkey::Pubkey>,
34 pub token_metadata_program: Option<solana_program::pubkey::Pubkey>,
36 pub sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
38 pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
40 pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
42 pub nft_receipt: solana_program::pubkey::Pubkey,
44 pub owner_ta: solana_program::pubkey::Pubkey,
46 pub pool_ta: solana_program::pubkey::Pubkey,
48 pub token_program: solana_program::pubkey::Pubkey,
50 pub associated_token_program: solana_program::pubkey::Pubkey,
52 pub system_program: solana_program::pubkey::Pubkey,
54}
55
56impl WithdrawNft {
57 pub fn instruction(
58 &self,
59 args: WithdrawNftInstructionArgs,
60 ) -> solana_program::instruction::Instruction {
61 self.instruction_with_remaining_accounts(args, &[])
62 }
63 #[allow(clippy::vec_init_then_push)]
64 pub fn instruction_with_remaining_accounts(
65 &self,
66 args: WithdrawNftInstructionArgs,
67 remaining_accounts: &[solana_program::instruction::AccountMeta],
68 ) -> solana_program::instruction::Instruction {
69 let mut accounts = Vec::with_capacity(19 + remaining_accounts.len());
70 accounts.push(solana_program::instruction::AccountMeta::new(
71 self.owner, true,
72 ));
73 accounts.push(solana_program::instruction::AccountMeta::new(
74 self.pool, false,
75 ));
76 if let Some(whitelist) = self.whitelist {
77 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
78 whitelist, false,
79 ));
80 } else {
81 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82 crate::TENSOR_AMM_ID,
83 false,
84 ));
85 }
86 if let Some(mint_proof) = self.mint_proof {
87 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
88 mint_proof, false,
89 ));
90 } else {
91 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
92 crate::TENSOR_AMM_ID,
93 false,
94 ));
95 }
96 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
97 self.mint, false,
98 ));
99 accounts.push(solana_program::instruction::AccountMeta::new(
100 self.metadata,
101 false,
102 ));
103 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
104 self.edition,
105 false,
106 ));
107 if let Some(user_token_record) = self.user_token_record {
108 accounts.push(solana_program::instruction::AccountMeta::new(
109 user_token_record,
110 false,
111 ));
112 } else {
113 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
114 crate::TENSOR_AMM_ID,
115 false,
116 ));
117 }
118 if let Some(pool_token_record) = self.pool_token_record {
119 accounts.push(solana_program::instruction::AccountMeta::new(
120 pool_token_record,
121 false,
122 ));
123 } else {
124 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
125 crate::TENSOR_AMM_ID,
126 false,
127 ));
128 }
129 if let Some(token_metadata_program) = self.token_metadata_program {
130 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
131 token_metadata_program,
132 false,
133 ));
134 } else {
135 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
136 crate::TENSOR_AMM_ID,
137 false,
138 ));
139 }
140 if let Some(sysvar_instructions) = self.sysvar_instructions {
141 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
142 sysvar_instructions,
143 false,
144 ));
145 } else {
146 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
147 crate::TENSOR_AMM_ID,
148 false,
149 ));
150 }
151 if let Some(authorization_rules) = self.authorization_rules {
152 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
153 authorization_rules,
154 false,
155 ));
156 } else {
157 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
158 crate::TENSOR_AMM_ID,
159 false,
160 ));
161 }
162 if let Some(authorization_rules_program) = self.authorization_rules_program {
163 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
164 authorization_rules_program,
165 false,
166 ));
167 } else {
168 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
169 crate::TENSOR_AMM_ID,
170 false,
171 ));
172 }
173 accounts.push(solana_program::instruction::AccountMeta::new(
174 self.nft_receipt,
175 false,
176 ));
177 accounts.push(solana_program::instruction::AccountMeta::new(
178 self.owner_ta,
179 false,
180 ));
181 accounts.push(solana_program::instruction::AccountMeta::new(
182 self.pool_ta,
183 false,
184 ));
185 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
186 self.token_program,
187 false,
188 ));
189 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
190 self.associated_token_program,
191 false,
192 ));
193 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
194 self.system_program,
195 false,
196 ));
197 accounts.extend_from_slice(remaining_accounts);
198 let mut data = WithdrawNftInstructionData::new().try_to_vec().unwrap();
199 let mut args = args.try_to_vec().unwrap();
200 data.append(&mut args);
201
202 solana_program::instruction::Instruction {
203 program_id: crate::TENSOR_AMM_ID,
204 accounts,
205 data,
206 }
207 }
208}
209
210#[derive(BorshDeserialize, BorshSerialize)]
211pub struct WithdrawNftInstructionData {
212 discriminator: [u8; 8],
213}
214
215impl WithdrawNftInstructionData {
216 pub fn new() -> Self {
217 Self {
218 discriminator: [142, 181, 191, 149, 82, 175, 216, 100],
219 }
220 }
221}
222
223impl Default for WithdrawNftInstructionData {
224 fn default() -> Self {
225 Self::new()
226 }
227}
228
229#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
230#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
231pub struct WithdrawNftInstructionArgs {
232 pub authorization_data: Option<AuthorizationDataLocal>,
233}
234
235#[derive(Clone, Debug, Default)]
259pub struct WithdrawNftBuilder {
260 owner: Option<solana_program::pubkey::Pubkey>,
261 pool: Option<solana_program::pubkey::Pubkey>,
262 whitelist: Option<solana_program::pubkey::Pubkey>,
263 mint_proof: Option<solana_program::pubkey::Pubkey>,
264 mint: Option<solana_program::pubkey::Pubkey>,
265 metadata: Option<solana_program::pubkey::Pubkey>,
266 edition: Option<solana_program::pubkey::Pubkey>,
267 user_token_record: Option<solana_program::pubkey::Pubkey>,
268 pool_token_record: Option<solana_program::pubkey::Pubkey>,
269 token_metadata_program: Option<solana_program::pubkey::Pubkey>,
270 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
271 authorization_rules: Option<solana_program::pubkey::Pubkey>,
272 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
273 nft_receipt: Option<solana_program::pubkey::Pubkey>,
274 owner_ta: Option<solana_program::pubkey::Pubkey>,
275 pool_ta: Option<solana_program::pubkey::Pubkey>,
276 token_program: Option<solana_program::pubkey::Pubkey>,
277 associated_token_program: Option<solana_program::pubkey::Pubkey>,
278 system_program: Option<solana_program::pubkey::Pubkey>,
279 authorization_data: Option<AuthorizationDataLocal>,
280 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
281}
282
283impl WithdrawNftBuilder {
284 pub fn new() -> Self {
285 Self::default()
286 }
287 #[inline(always)]
289 pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
290 self.owner = Some(owner);
291 self
292 }
293 #[inline(always)]
295 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
296 self.pool = Some(pool);
297 self
298 }
299 #[inline(always)]
303 pub fn whitelist(&mut self, whitelist: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
304 self.whitelist = whitelist;
305 self
306 }
307 #[inline(always)]
311 pub fn mint_proof(&mut self, mint_proof: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
312 self.mint_proof = mint_proof;
313 self
314 }
315 #[inline(always)]
317 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
318 self.mint = Some(mint);
319 self
320 }
321 #[inline(always)]
323 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
324 self.metadata = Some(metadata);
325 self
326 }
327 #[inline(always)]
329 pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
330 self.edition = Some(edition);
331 self
332 }
333 #[inline(always)]
336 pub fn user_token_record(
337 &mut self,
338 user_token_record: Option<solana_program::pubkey::Pubkey>,
339 ) -> &mut Self {
340 self.user_token_record = user_token_record;
341 self
342 }
343 #[inline(always)]
346 pub fn pool_token_record(
347 &mut self,
348 pool_token_record: Option<solana_program::pubkey::Pubkey>,
349 ) -> &mut Self {
350 self.pool_token_record = pool_token_record;
351 self
352 }
353 #[inline(always)]
356 pub fn token_metadata_program(
357 &mut self,
358 token_metadata_program: Option<solana_program::pubkey::Pubkey>,
359 ) -> &mut Self {
360 self.token_metadata_program = token_metadata_program;
361 self
362 }
363 #[inline(always)]
366 pub fn sysvar_instructions(
367 &mut self,
368 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
369 ) -> &mut Self {
370 self.sysvar_instructions = sysvar_instructions;
371 self
372 }
373 #[inline(always)]
376 pub fn authorization_rules(
377 &mut self,
378 authorization_rules: Option<solana_program::pubkey::Pubkey>,
379 ) -> &mut Self {
380 self.authorization_rules = authorization_rules;
381 self
382 }
383 #[inline(always)]
386 pub fn authorization_rules_program(
387 &mut self,
388 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
389 ) -> &mut Self {
390 self.authorization_rules_program = authorization_rules_program;
391 self
392 }
393 #[inline(always)]
395 pub fn nft_receipt(&mut self, nft_receipt: solana_program::pubkey::Pubkey) -> &mut Self {
396 self.nft_receipt = Some(nft_receipt);
397 self
398 }
399 #[inline(always)]
401 pub fn owner_ta(&mut self, owner_ta: solana_program::pubkey::Pubkey) -> &mut Self {
402 self.owner_ta = Some(owner_ta);
403 self
404 }
405 #[inline(always)]
407 pub fn pool_ta(&mut self, pool_ta: solana_program::pubkey::Pubkey) -> &mut Self {
408 self.pool_ta = Some(pool_ta);
409 self
410 }
411 #[inline(always)]
414 pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
415 self.token_program = Some(token_program);
416 self
417 }
418 #[inline(always)]
421 pub fn associated_token_program(
422 &mut self,
423 associated_token_program: solana_program::pubkey::Pubkey,
424 ) -> &mut Self {
425 self.associated_token_program = Some(associated_token_program);
426 self
427 }
428 #[inline(always)]
431 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
432 self.system_program = Some(system_program);
433 self
434 }
435 #[inline(always)]
437 pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
438 self.authorization_data = Some(authorization_data);
439 self
440 }
441 #[inline(always)]
443 pub fn add_remaining_account(
444 &mut self,
445 account: solana_program::instruction::AccountMeta,
446 ) -> &mut Self {
447 self.__remaining_accounts.push(account);
448 self
449 }
450 #[inline(always)]
452 pub fn add_remaining_accounts(
453 &mut self,
454 accounts: &[solana_program::instruction::AccountMeta],
455 ) -> &mut Self {
456 self.__remaining_accounts.extend_from_slice(accounts);
457 self
458 }
459 #[allow(clippy::clone_on_copy)]
460 pub fn instruction(&self) -> solana_program::instruction::Instruction {
461 let accounts = WithdrawNft {
462 owner: self.owner.expect("owner is not set"),
463 pool: self.pool.expect("pool is not set"),
464 whitelist: self.whitelist,
465 mint_proof: self.mint_proof,
466 mint: self.mint.expect("mint is not set"),
467 metadata: self.metadata.expect("metadata is not set"),
468 edition: self.edition.expect("edition is not set"),
469 user_token_record: self.user_token_record,
470 pool_token_record: self.pool_token_record,
471 token_metadata_program: self.token_metadata_program,
472 sysvar_instructions: self.sysvar_instructions,
473 authorization_rules: self.authorization_rules,
474 authorization_rules_program: self.authorization_rules_program,
475 nft_receipt: self.nft_receipt.expect("nft_receipt is not set"),
476 owner_ta: self.owner_ta.expect("owner_ta is not set"),
477 pool_ta: self.pool_ta.expect("pool_ta is not set"),
478 token_program: self.token_program.unwrap_or(solana_program::pubkey!(
479 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
480 )),
481 associated_token_program: self.associated_token_program.unwrap_or(
482 solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
483 ),
484 system_program: self
485 .system_program
486 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
487 };
488 let args = WithdrawNftInstructionArgs {
489 authorization_data: self.authorization_data.clone(),
490 };
491
492 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
493 }
494}
495
496pub struct WithdrawNftCpiAccounts<'a, 'b> {
498 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
500 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
502 pub whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
505 pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
508 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
510 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
512 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
514 pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
516 pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
518 pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
520 pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
522 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
524 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
526 pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
528 pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
530 pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
532 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
534 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
536 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
538}
539
540pub struct WithdrawNftCpi<'a, 'b> {
542 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
544 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
546 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
548 pub whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
551 pub mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
554 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
556 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
558 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
560 pub user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
562 pub pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
564 pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
566 pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
568 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
570 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
572 pub nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
574 pub owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
576 pub pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
578 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
580 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
582 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
584 pub __args: WithdrawNftInstructionArgs,
586}
587
588impl<'a, 'b> WithdrawNftCpi<'a, 'b> {
589 pub fn new(
590 program: &'b solana_program::account_info::AccountInfo<'a>,
591 accounts: WithdrawNftCpiAccounts<'a, 'b>,
592 args: WithdrawNftInstructionArgs,
593 ) -> Self {
594 Self {
595 __program: program,
596 owner: accounts.owner,
597 pool: accounts.pool,
598 whitelist: accounts.whitelist,
599 mint_proof: accounts.mint_proof,
600 mint: accounts.mint,
601 metadata: accounts.metadata,
602 edition: accounts.edition,
603 user_token_record: accounts.user_token_record,
604 pool_token_record: accounts.pool_token_record,
605 token_metadata_program: accounts.token_metadata_program,
606 sysvar_instructions: accounts.sysvar_instructions,
607 authorization_rules: accounts.authorization_rules,
608 authorization_rules_program: accounts.authorization_rules_program,
609 nft_receipt: accounts.nft_receipt,
610 owner_ta: accounts.owner_ta,
611 pool_ta: accounts.pool_ta,
612 token_program: accounts.token_program,
613 associated_token_program: accounts.associated_token_program,
614 system_program: accounts.system_program,
615 __args: args,
616 }
617 }
618 #[inline(always)]
619 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
620 self.invoke_signed_with_remaining_accounts(&[], &[])
621 }
622 #[inline(always)]
623 pub fn invoke_with_remaining_accounts(
624 &self,
625 remaining_accounts: &[(
626 &'b solana_program::account_info::AccountInfo<'a>,
627 bool,
628 bool,
629 )],
630 ) -> solana_program::entrypoint::ProgramResult {
631 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
632 }
633 #[inline(always)]
634 pub fn invoke_signed(
635 &self,
636 signers_seeds: &[&[&[u8]]],
637 ) -> solana_program::entrypoint::ProgramResult {
638 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
639 }
640 #[allow(clippy::clone_on_copy)]
641 #[allow(clippy::vec_init_then_push)]
642 pub fn invoke_signed_with_remaining_accounts(
643 &self,
644 signers_seeds: &[&[&[u8]]],
645 remaining_accounts: &[(
646 &'b solana_program::account_info::AccountInfo<'a>,
647 bool,
648 bool,
649 )],
650 ) -> solana_program::entrypoint::ProgramResult {
651 let mut accounts = Vec::with_capacity(19 + remaining_accounts.len());
652 accounts.push(solana_program::instruction::AccountMeta::new(
653 *self.owner.key,
654 true,
655 ));
656 accounts.push(solana_program::instruction::AccountMeta::new(
657 *self.pool.key,
658 false,
659 ));
660 if let Some(whitelist) = self.whitelist {
661 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
662 *whitelist.key,
663 false,
664 ));
665 } else {
666 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
667 crate::TENSOR_AMM_ID,
668 false,
669 ));
670 }
671 if let Some(mint_proof) = self.mint_proof {
672 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
673 *mint_proof.key,
674 false,
675 ));
676 } else {
677 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
678 crate::TENSOR_AMM_ID,
679 false,
680 ));
681 }
682 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
683 *self.mint.key,
684 false,
685 ));
686 accounts.push(solana_program::instruction::AccountMeta::new(
687 *self.metadata.key,
688 false,
689 ));
690 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
691 *self.edition.key,
692 false,
693 ));
694 if let Some(user_token_record) = self.user_token_record {
695 accounts.push(solana_program::instruction::AccountMeta::new(
696 *user_token_record.key,
697 false,
698 ));
699 } else {
700 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
701 crate::TENSOR_AMM_ID,
702 false,
703 ));
704 }
705 if let Some(pool_token_record) = self.pool_token_record {
706 accounts.push(solana_program::instruction::AccountMeta::new(
707 *pool_token_record.key,
708 false,
709 ));
710 } else {
711 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
712 crate::TENSOR_AMM_ID,
713 false,
714 ));
715 }
716 if let Some(token_metadata_program) = self.token_metadata_program {
717 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
718 *token_metadata_program.key,
719 false,
720 ));
721 } else {
722 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
723 crate::TENSOR_AMM_ID,
724 false,
725 ));
726 }
727 if let Some(sysvar_instructions) = self.sysvar_instructions {
728 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
729 *sysvar_instructions.key,
730 false,
731 ));
732 } else {
733 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
734 crate::TENSOR_AMM_ID,
735 false,
736 ));
737 }
738 if let Some(authorization_rules) = self.authorization_rules {
739 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
740 *authorization_rules.key,
741 false,
742 ));
743 } else {
744 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
745 crate::TENSOR_AMM_ID,
746 false,
747 ));
748 }
749 if let Some(authorization_rules_program) = self.authorization_rules_program {
750 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
751 *authorization_rules_program.key,
752 false,
753 ));
754 } else {
755 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
756 crate::TENSOR_AMM_ID,
757 false,
758 ));
759 }
760 accounts.push(solana_program::instruction::AccountMeta::new(
761 *self.nft_receipt.key,
762 false,
763 ));
764 accounts.push(solana_program::instruction::AccountMeta::new(
765 *self.owner_ta.key,
766 false,
767 ));
768 accounts.push(solana_program::instruction::AccountMeta::new(
769 *self.pool_ta.key,
770 false,
771 ));
772 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
773 *self.token_program.key,
774 false,
775 ));
776 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
777 *self.associated_token_program.key,
778 false,
779 ));
780 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
781 *self.system_program.key,
782 false,
783 ));
784 remaining_accounts.iter().for_each(|remaining_account| {
785 accounts.push(solana_program::instruction::AccountMeta {
786 pubkey: *remaining_account.0.key,
787 is_signer: remaining_account.1,
788 is_writable: remaining_account.2,
789 })
790 });
791 let mut data = WithdrawNftInstructionData::new().try_to_vec().unwrap();
792 let mut args = self.__args.try_to_vec().unwrap();
793 data.append(&mut args);
794
795 let instruction = solana_program::instruction::Instruction {
796 program_id: crate::TENSOR_AMM_ID,
797 accounts,
798 data,
799 };
800 let mut account_infos = Vec::with_capacity(20 + remaining_accounts.len());
801 account_infos.push(self.__program.clone());
802 account_infos.push(self.owner.clone());
803 account_infos.push(self.pool.clone());
804 if let Some(whitelist) = self.whitelist {
805 account_infos.push(whitelist.clone());
806 }
807 if let Some(mint_proof) = self.mint_proof {
808 account_infos.push(mint_proof.clone());
809 }
810 account_infos.push(self.mint.clone());
811 account_infos.push(self.metadata.clone());
812 account_infos.push(self.edition.clone());
813 if let Some(user_token_record) = self.user_token_record {
814 account_infos.push(user_token_record.clone());
815 }
816 if let Some(pool_token_record) = self.pool_token_record {
817 account_infos.push(pool_token_record.clone());
818 }
819 if let Some(token_metadata_program) = self.token_metadata_program {
820 account_infos.push(token_metadata_program.clone());
821 }
822 if let Some(sysvar_instructions) = self.sysvar_instructions {
823 account_infos.push(sysvar_instructions.clone());
824 }
825 if let Some(authorization_rules) = self.authorization_rules {
826 account_infos.push(authorization_rules.clone());
827 }
828 if let Some(authorization_rules_program) = self.authorization_rules_program {
829 account_infos.push(authorization_rules_program.clone());
830 }
831 account_infos.push(self.nft_receipt.clone());
832 account_infos.push(self.owner_ta.clone());
833 account_infos.push(self.pool_ta.clone());
834 account_infos.push(self.token_program.clone());
835 account_infos.push(self.associated_token_program.clone());
836 account_infos.push(self.system_program.clone());
837 remaining_accounts
838 .iter()
839 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
840
841 if signers_seeds.is_empty() {
842 solana_program::program::invoke(&instruction, &account_infos)
843 } else {
844 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
845 }
846 }
847}
848
849#[derive(Clone, Debug)]
873pub struct WithdrawNftCpiBuilder<'a, 'b> {
874 instruction: Box<WithdrawNftCpiBuilderInstruction<'a, 'b>>,
875}
876
877impl<'a, 'b> WithdrawNftCpiBuilder<'a, 'b> {
878 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
879 let instruction = Box::new(WithdrawNftCpiBuilderInstruction {
880 __program: program,
881 owner: None,
882 pool: None,
883 whitelist: None,
884 mint_proof: None,
885 mint: None,
886 metadata: None,
887 edition: None,
888 user_token_record: None,
889 pool_token_record: None,
890 token_metadata_program: None,
891 sysvar_instructions: None,
892 authorization_rules: None,
893 authorization_rules_program: None,
894 nft_receipt: None,
895 owner_ta: None,
896 pool_ta: None,
897 token_program: None,
898 associated_token_program: None,
899 system_program: None,
900 authorization_data: None,
901 __remaining_accounts: Vec::new(),
902 });
903 Self { instruction }
904 }
905 #[inline(always)]
907 pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
908 self.instruction.owner = Some(owner);
909 self
910 }
911 #[inline(always)]
913 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
914 self.instruction.pool = Some(pool);
915 self
916 }
917 #[inline(always)]
921 pub fn whitelist(
922 &mut self,
923 whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
924 ) -> &mut Self {
925 self.instruction.whitelist = whitelist;
926 self
927 }
928 #[inline(always)]
932 pub fn mint_proof(
933 &mut self,
934 mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
935 ) -> &mut Self {
936 self.instruction.mint_proof = mint_proof;
937 self
938 }
939 #[inline(always)]
941 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
942 self.instruction.mint = Some(mint);
943 self
944 }
945 #[inline(always)]
947 pub fn metadata(
948 &mut self,
949 metadata: &'b solana_program::account_info::AccountInfo<'a>,
950 ) -> &mut Self {
951 self.instruction.metadata = Some(metadata);
952 self
953 }
954 #[inline(always)]
956 pub fn edition(
957 &mut self,
958 edition: &'b solana_program::account_info::AccountInfo<'a>,
959 ) -> &mut Self {
960 self.instruction.edition = Some(edition);
961 self
962 }
963 #[inline(always)]
966 pub fn user_token_record(
967 &mut self,
968 user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
969 ) -> &mut Self {
970 self.instruction.user_token_record = user_token_record;
971 self
972 }
973 #[inline(always)]
976 pub fn pool_token_record(
977 &mut self,
978 pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
979 ) -> &mut Self {
980 self.instruction.pool_token_record = pool_token_record;
981 self
982 }
983 #[inline(always)]
986 pub fn token_metadata_program(
987 &mut self,
988 token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
989 ) -> &mut Self {
990 self.instruction.token_metadata_program = token_metadata_program;
991 self
992 }
993 #[inline(always)]
996 pub fn sysvar_instructions(
997 &mut self,
998 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
999 ) -> &mut Self {
1000 self.instruction.sysvar_instructions = sysvar_instructions;
1001 self
1002 }
1003 #[inline(always)]
1006 pub fn authorization_rules(
1007 &mut self,
1008 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1009 ) -> &mut Self {
1010 self.instruction.authorization_rules = authorization_rules;
1011 self
1012 }
1013 #[inline(always)]
1016 pub fn authorization_rules_program(
1017 &mut self,
1018 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1019 ) -> &mut Self {
1020 self.instruction.authorization_rules_program = authorization_rules_program;
1021 self
1022 }
1023 #[inline(always)]
1025 pub fn nft_receipt(
1026 &mut self,
1027 nft_receipt: &'b solana_program::account_info::AccountInfo<'a>,
1028 ) -> &mut Self {
1029 self.instruction.nft_receipt = Some(nft_receipt);
1030 self
1031 }
1032 #[inline(always)]
1034 pub fn owner_ta(
1035 &mut self,
1036 owner_ta: &'b solana_program::account_info::AccountInfo<'a>,
1037 ) -> &mut Self {
1038 self.instruction.owner_ta = Some(owner_ta);
1039 self
1040 }
1041 #[inline(always)]
1043 pub fn pool_ta(
1044 &mut self,
1045 pool_ta: &'b solana_program::account_info::AccountInfo<'a>,
1046 ) -> &mut Self {
1047 self.instruction.pool_ta = Some(pool_ta);
1048 self
1049 }
1050 #[inline(always)]
1052 pub fn token_program(
1053 &mut self,
1054 token_program: &'b solana_program::account_info::AccountInfo<'a>,
1055 ) -> &mut Self {
1056 self.instruction.token_program = Some(token_program);
1057 self
1058 }
1059 #[inline(always)]
1061 pub fn associated_token_program(
1062 &mut self,
1063 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1064 ) -> &mut Self {
1065 self.instruction.associated_token_program = Some(associated_token_program);
1066 self
1067 }
1068 #[inline(always)]
1070 pub fn system_program(
1071 &mut self,
1072 system_program: &'b solana_program::account_info::AccountInfo<'a>,
1073 ) -> &mut Self {
1074 self.instruction.system_program = Some(system_program);
1075 self
1076 }
1077 #[inline(always)]
1079 pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
1080 self.instruction.authorization_data = Some(authorization_data);
1081 self
1082 }
1083 #[inline(always)]
1085 pub fn add_remaining_account(
1086 &mut self,
1087 account: &'b solana_program::account_info::AccountInfo<'a>,
1088 is_writable: bool,
1089 is_signer: bool,
1090 ) -> &mut Self {
1091 self.instruction
1092 .__remaining_accounts
1093 .push((account, is_writable, is_signer));
1094 self
1095 }
1096 #[inline(always)]
1101 pub fn add_remaining_accounts(
1102 &mut self,
1103 accounts: &[(
1104 &'b solana_program::account_info::AccountInfo<'a>,
1105 bool,
1106 bool,
1107 )],
1108 ) -> &mut Self {
1109 self.instruction
1110 .__remaining_accounts
1111 .extend_from_slice(accounts);
1112 self
1113 }
1114 #[inline(always)]
1115 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1116 self.invoke_signed(&[])
1117 }
1118 #[allow(clippy::clone_on_copy)]
1119 #[allow(clippy::vec_init_then_push)]
1120 pub fn invoke_signed(
1121 &self,
1122 signers_seeds: &[&[&[u8]]],
1123 ) -> solana_program::entrypoint::ProgramResult {
1124 let args = WithdrawNftInstructionArgs {
1125 authorization_data: self.instruction.authorization_data.clone(),
1126 };
1127 let instruction = WithdrawNftCpi {
1128 __program: self.instruction.__program,
1129
1130 owner: self.instruction.owner.expect("owner is not set"),
1131
1132 pool: self.instruction.pool.expect("pool is not set"),
1133
1134 whitelist: self.instruction.whitelist,
1135
1136 mint_proof: self.instruction.mint_proof,
1137
1138 mint: self.instruction.mint.expect("mint is not set"),
1139
1140 metadata: self.instruction.metadata.expect("metadata is not set"),
1141
1142 edition: self.instruction.edition.expect("edition is not set"),
1143
1144 user_token_record: self.instruction.user_token_record,
1145
1146 pool_token_record: self.instruction.pool_token_record,
1147
1148 token_metadata_program: self.instruction.token_metadata_program,
1149
1150 sysvar_instructions: self.instruction.sysvar_instructions,
1151
1152 authorization_rules: self.instruction.authorization_rules,
1153
1154 authorization_rules_program: self.instruction.authorization_rules_program,
1155
1156 nft_receipt: self
1157 .instruction
1158 .nft_receipt
1159 .expect("nft_receipt is not set"),
1160
1161 owner_ta: self.instruction.owner_ta.expect("owner_ta is not set"),
1162
1163 pool_ta: self.instruction.pool_ta.expect("pool_ta is not set"),
1164
1165 token_program: self
1166 .instruction
1167 .token_program
1168 .expect("token_program is not set"),
1169
1170 associated_token_program: self
1171 .instruction
1172 .associated_token_program
1173 .expect("associated_token_program is not set"),
1174
1175 system_program: self
1176 .instruction
1177 .system_program
1178 .expect("system_program is not set"),
1179 __args: args,
1180 };
1181 instruction.invoke_signed_with_remaining_accounts(
1182 signers_seeds,
1183 &self.instruction.__remaining_accounts,
1184 )
1185 }
1186}
1187
1188#[derive(Clone, Debug)]
1189struct WithdrawNftCpiBuilderInstruction<'a, 'b> {
1190 __program: &'b solana_program::account_info::AccountInfo<'a>,
1191 owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1192 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1193 whitelist: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1194 mint_proof: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1195 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1196 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1197 edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1198 user_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1199 pool_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1200 token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1201 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1202 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1203 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1204 nft_receipt: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1205 owner_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1206 pool_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1207 token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1208 associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1209 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1210 authorization_data: Option<AuthorizationDataLocal>,
1211 __remaining_accounts: Vec<(
1213 &'b solana_program::account_info::AccountInfo<'a>,
1214 bool,
1215 bool,
1216 )>,
1217}