1use crate::generated::types::AuthorizationData;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub struct UseV1 {
14 pub authority: solana_program::pubkey::Pubkey,
16 pub delegate_record: Option<solana_program::pubkey::Pubkey>,
18 pub token: Option<solana_program::pubkey::Pubkey>,
20 pub mint: solana_program::pubkey::Pubkey,
22 pub metadata: solana_program::pubkey::Pubkey,
24 pub edition: Option<solana_program::pubkey::Pubkey>,
26 pub payer: solana_program::pubkey::Pubkey,
28 pub system_program: solana_program::pubkey::Pubkey,
30 pub sysvar_instructions: solana_program::pubkey::Pubkey,
32 pub spl_token_program: Option<solana_program::pubkey::Pubkey>,
34 pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
36 pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
38}
39
40impl UseV1 {
41 pub fn instruction(
42 &self,
43 args: UseV1InstructionArgs,
44 ) -> solana_program::instruction::Instruction {
45 self.instruction_with_remaining_accounts(args, &[])
46 }
47 #[allow(clippy::vec_init_then_push)]
48 pub fn instruction_with_remaining_accounts(
49 &self,
50 args: UseV1InstructionArgs,
51 remaining_accounts: &[solana_program::instruction::AccountMeta],
52 ) -> solana_program::instruction::Instruction {
53 let mut accounts = Vec::with_capacity(12 + remaining_accounts.len());
54 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
55 self.authority,
56 true,
57 ));
58 if let Some(delegate_record) = self.delegate_record {
59 accounts.push(solana_program::instruction::AccountMeta::new(
60 delegate_record,
61 false,
62 ));
63 } else {
64 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65 crate::MPL_TOKEN_METADATA_ID,
66 false,
67 ));
68 }
69 if let Some(token) = self.token {
70 accounts.push(solana_program::instruction::AccountMeta::new(token, false));
71 } else {
72 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
73 crate::MPL_TOKEN_METADATA_ID,
74 false,
75 ));
76 }
77 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
78 self.mint, false,
79 ));
80 accounts.push(solana_program::instruction::AccountMeta::new(
81 self.metadata,
82 false,
83 ));
84 if let Some(edition) = self.edition {
85 accounts.push(solana_program::instruction::AccountMeta::new(
86 edition, false,
87 ));
88 } else {
89 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
90 crate::MPL_TOKEN_METADATA_ID,
91 false,
92 ));
93 }
94 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95 self.payer, true,
96 ));
97 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
98 self.system_program,
99 false,
100 ));
101 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
102 self.sysvar_instructions,
103 false,
104 ));
105 if let Some(spl_token_program) = self.spl_token_program {
106 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
107 spl_token_program,
108 false,
109 ));
110 } else {
111 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
112 crate::MPL_TOKEN_METADATA_ID,
113 false,
114 ));
115 }
116 if let Some(authorization_rules_program) = self.authorization_rules_program {
117 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
118 authorization_rules_program,
119 false,
120 ));
121 } else {
122 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
123 crate::MPL_TOKEN_METADATA_ID,
124 false,
125 ));
126 }
127 if let Some(authorization_rules) = self.authorization_rules {
128 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
129 authorization_rules,
130 false,
131 ));
132 } else {
133 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
134 crate::MPL_TOKEN_METADATA_ID,
135 false,
136 ));
137 }
138 accounts.extend_from_slice(remaining_accounts);
139 let mut data = UseV1InstructionData::new().try_to_vec().unwrap();
140 let mut args = args.try_to_vec().unwrap();
141 data.append(&mut args);
142
143 solana_program::instruction::Instruction {
144 program_id: crate::MPL_TOKEN_METADATA_ID,
145 accounts,
146 data,
147 }
148 }
149}
150
151#[derive(BorshDeserialize, BorshSerialize)]
152struct UseV1InstructionData {
153 discriminator: u8,
154 use_v1_discriminator: u8,
155}
156
157impl UseV1InstructionData {
158 fn new() -> Self {
159 Self {
160 discriminator: 51,
161 use_v1_discriminator: 0,
162 }
163 }
164}
165
166#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
167#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
168pub struct UseV1InstructionArgs {
169 pub authorization_data: Option<AuthorizationData>,
170}
171
172#[derive(Default)]
189pub struct UseV1Builder {
190 authority: Option<solana_program::pubkey::Pubkey>,
191 delegate_record: Option<solana_program::pubkey::Pubkey>,
192 token: Option<solana_program::pubkey::Pubkey>,
193 mint: Option<solana_program::pubkey::Pubkey>,
194 metadata: Option<solana_program::pubkey::Pubkey>,
195 edition: Option<solana_program::pubkey::Pubkey>,
196 payer: Option<solana_program::pubkey::Pubkey>,
197 system_program: Option<solana_program::pubkey::Pubkey>,
198 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
199 spl_token_program: Option<solana_program::pubkey::Pubkey>,
200 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
201 authorization_rules: Option<solana_program::pubkey::Pubkey>,
202 authorization_data: Option<AuthorizationData>,
203 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
204}
205
206impl UseV1Builder {
207 pub fn new() -> Self {
208 Self::default()
209 }
210 #[inline(always)]
212 pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
213 self.authority = Some(authority);
214 self
215 }
216 #[inline(always)]
219 pub fn delegate_record(
220 &mut self,
221 delegate_record: Option<solana_program::pubkey::Pubkey>,
222 ) -> &mut Self {
223 self.delegate_record = delegate_record;
224 self
225 }
226 #[inline(always)]
229 pub fn token(&mut self, token: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
230 self.token = token;
231 self
232 }
233 #[inline(always)]
235 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
236 self.mint = Some(mint);
237 self
238 }
239 #[inline(always)]
241 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
242 self.metadata = Some(metadata);
243 self
244 }
245 #[inline(always)]
248 pub fn edition(&mut self, edition: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
249 self.edition = edition;
250 self
251 }
252 #[inline(always)]
254 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
255 self.payer = Some(payer);
256 self
257 }
258 #[inline(always)]
261 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
262 self.system_program = Some(system_program);
263 self
264 }
265 #[inline(always)]
268 pub fn sysvar_instructions(
269 &mut self,
270 sysvar_instructions: solana_program::pubkey::Pubkey,
271 ) -> &mut Self {
272 self.sysvar_instructions = Some(sysvar_instructions);
273 self
274 }
275 #[inline(always)]
278 pub fn spl_token_program(
279 &mut self,
280 spl_token_program: Option<solana_program::pubkey::Pubkey>,
281 ) -> &mut Self {
282 self.spl_token_program = spl_token_program;
283 self
284 }
285 #[inline(always)]
288 pub fn authorization_rules_program(
289 &mut self,
290 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
291 ) -> &mut Self {
292 self.authorization_rules_program = authorization_rules_program;
293 self
294 }
295 #[inline(always)]
298 pub fn authorization_rules(
299 &mut self,
300 authorization_rules: Option<solana_program::pubkey::Pubkey>,
301 ) -> &mut Self {
302 self.authorization_rules = authorization_rules;
303 self
304 }
305 #[inline(always)]
307 pub fn authorization_data(&mut self, authorization_data: AuthorizationData) -> &mut Self {
308 self.authorization_data = Some(authorization_data);
309 self
310 }
311 #[inline(always)]
313 pub fn add_remaining_account(
314 &mut self,
315 account: solana_program::instruction::AccountMeta,
316 ) -> &mut Self {
317 self.__remaining_accounts.push(account);
318 self
319 }
320 #[inline(always)]
322 pub fn add_remaining_accounts(
323 &mut self,
324 accounts: &[solana_program::instruction::AccountMeta],
325 ) -> &mut Self {
326 self.__remaining_accounts.extend_from_slice(accounts);
327 self
328 }
329 #[allow(clippy::clone_on_copy)]
330 pub fn instruction(&self) -> solana_program::instruction::Instruction {
331 let accounts = UseV1 {
332 authority: self.authority.expect("authority is not set"),
333 delegate_record: self.delegate_record,
334 token: self.token,
335 mint: self.mint.expect("mint is not set"),
336 metadata: self.metadata.expect("metadata is not set"),
337 edition: self.edition,
338 payer: self.payer.expect("payer is not set"),
339 system_program: self
340 .system_program
341 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
342 sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
343 "Sysvar1nstructions1111111111111111111111111"
344 )),
345 spl_token_program: self.spl_token_program,
346 authorization_rules_program: self.authorization_rules_program,
347 authorization_rules: self.authorization_rules,
348 };
349 let args = UseV1InstructionArgs {
350 authorization_data: self.authorization_data.clone(),
351 };
352
353 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
354 }
355}
356
357pub struct UseV1CpiAccounts<'a, 'b> {
359 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
361 pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
363 pub token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
365 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
367 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
369 pub edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
371 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
373 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
375 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
377 pub spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
379 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
381 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
383}
384
385pub struct UseV1Cpi<'a, 'b> {
387 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
389 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
391 pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
393 pub token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
395 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
397 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
399 pub edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
401 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
403 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
405 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
407 pub spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
409 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
411 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
413 pub __args: UseV1InstructionArgs,
415}
416
417impl<'a, 'b> UseV1Cpi<'a, 'b> {
418 pub fn new(
419 program: &'b solana_program::account_info::AccountInfo<'a>,
420 accounts: UseV1CpiAccounts<'a, 'b>,
421 args: UseV1InstructionArgs,
422 ) -> Self {
423 Self {
424 __program: program,
425 authority: accounts.authority,
426 delegate_record: accounts.delegate_record,
427 token: accounts.token,
428 mint: accounts.mint,
429 metadata: accounts.metadata,
430 edition: accounts.edition,
431 payer: accounts.payer,
432 system_program: accounts.system_program,
433 sysvar_instructions: accounts.sysvar_instructions,
434 spl_token_program: accounts.spl_token_program,
435 authorization_rules_program: accounts.authorization_rules_program,
436 authorization_rules: accounts.authorization_rules,
437 __args: args,
438 }
439 }
440 #[inline(always)]
441 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
442 self.invoke_signed_with_remaining_accounts(&[], &[])
443 }
444 #[inline(always)]
445 pub fn invoke_with_remaining_accounts(
446 &self,
447 remaining_accounts: &[(
448 &'b solana_program::account_info::AccountInfo<'a>,
449 bool,
450 bool,
451 )],
452 ) -> solana_program::entrypoint::ProgramResult {
453 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
454 }
455 #[inline(always)]
456 pub fn invoke_signed(
457 &self,
458 signers_seeds: &[&[&[u8]]],
459 ) -> solana_program::entrypoint::ProgramResult {
460 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
461 }
462 #[allow(clippy::clone_on_copy)]
463 #[allow(clippy::vec_init_then_push)]
464 pub fn invoke_signed_with_remaining_accounts(
465 &self,
466 signers_seeds: &[&[&[u8]]],
467 remaining_accounts: &[(
468 &'b solana_program::account_info::AccountInfo<'a>,
469 bool,
470 bool,
471 )],
472 ) -> solana_program::entrypoint::ProgramResult {
473 let mut accounts = Vec::with_capacity(12 + remaining_accounts.len());
474 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
475 *self.authority.key,
476 true,
477 ));
478 if let Some(delegate_record) = self.delegate_record {
479 accounts.push(solana_program::instruction::AccountMeta::new(
480 *delegate_record.key,
481 false,
482 ));
483 } else {
484 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
485 crate::MPL_TOKEN_METADATA_ID,
486 false,
487 ));
488 }
489 if let Some(token) = self.token {
490 accounts.push(solana_program::instruction::AccountMeta::new(
491 *token.key, false,
492 ));
493 } else {
494 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
495 crate::MPL_TOKEN_METADATA_ID,
496 false,
497 ));
498 }
499 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
500 *self.mint.key,
501 false,
502 ));
503 accounts.push(solana_program::instruction::AccountMeta::new(
504 *self.metadata.key,
505 false,
506 ));
507 if let Some(edition) = self.edition {
508 accounts.push(solana_program::instruction::AccountMeta::new(
509 *edition.key,
510 false,
511 ));
512 } else {
513 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
514 crate::MPL_TOKEN_METADATA_ID,
515 false,
516 ));
517 }
518 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
519 *self.payer.key,
520 true,
521 ));
522 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
523 *self.system_program.key,
524 false,
525 ));
526 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
527 *self.sysvar_instructions.key,
528 false,
529 ));
530 if let Some(spl_token_program) = self.spl_token_program {
531 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
532 *spl_token_program.key,
533 false,
534 ));
535 } else {
536 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
537 crate::MPL_TOKEN_METADATA_ID,
538 false,
539 ));
540 }
541 if let Some(authorization_rules_program) = self.authorization_rules_program {
542 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
543 *authorization_rules_program.key,
544 false,
545 ));
546 } else {
547 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
548 crate::MPL_TOKEN_METADATA_ID,
549 false,
550 ));
551 }
552 if let Some(authorization_rules) = self.authorization_rules {
553 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
554 *authorization_rules.key,
555 false,
556 ));
557 } else {
558 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
559 crate::MPL_TOKEN_METADATA_ID,
560 false,
561 ));
562 }
563 remaining_accounts.iter().for_each(|remaining_account| {
564 accounts.push(solana_program::instruction::AccountMeta {
565 pubkey: *remaining_account.0.key,
566 is_signer: remaining_account.1,
567 is_writable: remaining_account.2,
568 })
569 });
570 let mut data = UseV1InstructionData::new().try_to_vec().unwrap();
571 let mut args = self.__args.try_to_vec().unwrap();
572 data.append(&mut args);
573
574 let instruction = solana_program::instruction::Instruction {
575 program_id: crate::MPL_TOKEN_METADATA_ID,
576 accounts,
577 data,
578 };
579 let mut account_infos = Vec::with_capacity(12 + 1 + remaining_accounts.len());
580 account_infos.push(self.__program.clone());
581 account_infos.push(self.authority.clone());
582 if let Some(delegate_record) = self.delegate_record {
583 account_infos.push(delegate_record.clone());
584 }
585 if let Some(token) = self.token {
586 account_infos.push(token.clone());
587 }
588 account_infos.push(self.mint.clone());
589 account_infos.push(self.metadata.clone());
590 if let Some(edition) = self.edition {
591 account_infos.push(edition.clone());
592 }
593 account_infos.push(self.payer.clone());
594 account_infos.push(self.system_program.clone());
595 account_infos.push(self.sysvar_instructions.clone());
596 if let Some(spl_token_program) = self.spl_token_program {
597 account_infos.push(spl_token_program.clone());
598 }
599 if let Some(authorization_rules_program) = self.authorization_rules_program {
600 account_infos.push(authorization_rules_program.clone());
601 }
602 if let Some(authorization_rules) = self.authorization_rules {
603 account_infos.push(authorization_rules.clone());
604 }
605 remaining_accounts
606 .iter()
607 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
608
609 if signers_seeds.is_empty() {
610 solana_program::program::invoke(&instruction, &account_infos)
611 } else {
612 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
613 }
614 }
615}
616
617pub struct UseV1CpiBuilder<'a, 'b> {
634 instruction: Box<UseV1CpiBuilderInstruction<'a, 'b>>,
635}
636
637impl<'a, 'b> UseV1CpiBuilder<'a, 'b> {
638 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
639 let instruction = Box::new(UseV1CpiBuilderInstruction {
640 __program: program,
641 authority: None,
642 delegate_record: None,
643 token: None,
644 mint: None,
645 metadata: None,
646 edition: None,
647 payer: None,
648 system_program: None,
649 sysvar_instructions: None,
650 spl_token_program: None,
651 authorization_rules_program: None,
652 authorization_rules: None,
653 authorization_data: None,
654 __remaining_accounts: Vec::new(),
655 });
656 Self { instruction }
657 }
658 #[inline(always)]
660 pub fn authority(
661 &mut self,
662 authority: &'b solana_program::account_info::AccountInfo<'a>,
663 ) -> &mut Self {
664 self.instruction.authority = Some(authority);
665 self
666 }
667 #[inline(always)]
670 pub fn delegate_record(
671 &mut self,
672 delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
673 ) -> &mut Self {
674 self.instruction.delegate_record = delegate_record;
675 self
676 }
677 #[inline(always)]
680 pub fn token(
681 &mut self,
682 token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
683 ) -> &mut Self {
684 self.instruction.token = token;
685 self
686 }
687 #[inline(always)]
689 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
690 self.instruction.mint = Some(mint);
691 self
692 }
693 #[inline(always)]
695 pub fn metadata(
696 &mut self,
697 metadata: &'b solana_program::account_info::AccountInfo<'a>,
698 ) -> &mut Self {
699 self.instruction.metadata = Some(metadata);
700 self
701 }
702 #[inline(always)]
705 pub fn edition(
706 &mut self,
707 edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
708 ) -> &mut Self {
709 self.instruction.edition = edition;
710 self
711 }
712 #[inline(always)]
714 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
715 self.instruction.payer = Some(payer);
716 self
717 }
718 #[inline(always)]
720 pub fn system_program(
721 &mut self,
722 system_program: &'b solana_program::account_info::AccountInfo<'a>,
723 ) -> &mut Self {
724 self.instruction.system_program = Some(system_program);
725 self
726 }
727 #[inline(always)]
729 pub fn sysvar_instructions(
730 &mut self,
731 sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
732 ) -> &mut Self {
733 self.instruction.sysvar_instructions = Some(sysvar_instructions);
734 self
735 }
736 #[inline(always)]
739 pub fn spl_token_program(
740 &mut self,
741 spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
742 ) -> &mut Self {
743 self.instruction.spl_token_program = spl_token_program;
744 self
745 }
746 #[inline(always)]
749 pub fn authorization_rules_program(
750 &mut self,
751 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
752 ) -> &mut Self {
753 self.instruction.authorization_rules_program = authorization_rules_program;
754 self
755 }
756 #[inline(always)]
759 pub fn authorization_rules(
760 &mut self,
761 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
762 ) -> &mut Self {
763 self.instruction.authorization_rules = authorization_rules;
764 self
765 }
766 #[inline(always)]
768 pub fn authorization_data(&mut self, authorization_data: AuthorizationData) -> &mut Self {
769 self.instruction.authorization_data = Some(authorization_data);
770 self
771 }
772 #[inline(always)]
774 pub fn add_remaining_account(
775 &mut self,
776 account: &'b solana_program::account_info::AccountInfo<'a>,
777 is_writable: bool,
778 is_signer: bool,
779 ) -> &mut Self {
780 self.instruction
781 .__remaining_accounts
782 .push((account, is_writable, is_signer));
783 self
784 }
785 #[inline(always)]
790 pub fn add_remaining_accounts(
791 &mut self,
792 accounts: &[(
793 &'b solana_program::account_info::AccountInfo<'a>,
794 bool,
795 bool,
796 )],
797 ) -> &mut Self {
798 self.instruction
799 .__remaining_accounts
800 .extend_from_slice(accounts);
801 self
802 }
803 #[inline(always)]
804 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
805 self.invoke_signed(&[])
806 }
807 #[allow(clippy::clone_on_copy)]
808 #[allow(clippy::vec_init_then_push)]
809 pub fn invoke_signed(
810 &self,
811 signers_seeds: &[&[&[u8]]],
812 ) -> solana_program::entrypoint::ProgramResult {
813 let args = UseV1InstructionArgs {
814 authorization_data: self.instruction.authorization_data.clone(),
815 };
816 let instruction = UseV1Cpi {
817 __program: self.instruction.__program,
818
819 authority: self.instruction.authority.expect("authority is not set"),
820
821 delegate_record: self.instruction.delegate_record,
822
823 token: self.instruction.token,
824
825 mint: self.instruction.mint.expect("mint is not set"),
826
827 metadata: self.instruction.metadata.expect("metadata is not set"),
828
829 edition: self.instruction.edition,
830
831 payer: self.instruction.payer.expect("payer is not set"),
832
833 system_program: self
834 .instruction
835 .system_program
836 .expect("system_program is not set"),
837
838 sysvar_instructions: self
839 .instruction
840 .sysvar_instructions
841 .expect("sysvar_instructions is not set"),
842
843 spl_token_program: self.instruction.spl_token_program,
844
845 authorization_rules_program: self.instruction.authorization_rules_program,
846
847 authorization_rules: self.instruction.authorization_rules,
848 __args: args,
849 };
850 instruction.invoke_signed_with_remaining_accounts(
851 signers_seeds,
852 &self.instruction.__remaining_accounts,
853 )
854 }
855}
856
857struct UseV1CpiBuilderInstruction<'a, 'b> {
858 __program: &'b solana_program::account_info::AccountInfo<'a>,
859 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
860 delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
861 token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
862 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
863 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
864 edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
865 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
866 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
867 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
868 spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
869 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
870 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
871 authorization_data: Option<AuthorizationData>,
872 __remaining_accounts: Vec<(
874 &'b solana_program::account_info::AccountInfo<'a>,
875 bool,
876 bool,
877 )>,
878}