1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct Migrate {
13 pub metadata: solana_program::pubkey::Pubkey,
15 pub edition: solana_program::pubkey::Pubkey,
17 pub token: solana_program::pubkey::Pubkey,
19 pub token_owner: solana_program::pubkey::Pubkey,
21 pub mint: solana_program::pubkey::Pubkey,
23 pub payer: solana_program::pubkey::Pubkey,
25 pub authority: solana_program::pubkey::Pubkey,
27 pub collection_metadata: solana_program::pubkey::Pubkey,
29 pub delegate_record: solana_program::pubkey::Pubkey,
31 pub token_record: solana_program::pubkey::Pubkey,
33 pub system_program: solana_program::pubkey::Pubkey,
35 pub sysvar_instructions: solana_program::pubkey::Pubkey,
37 pub spl_token_program: solana_program::pubkey::Pubkey,
39 pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
41 pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
43}
44
45impl Migrate {
46 pub fn instruction(&self) -> solana_program::instruction::Instruction {
47 self.instruction_with_remaining_accounts(&[])
48 }
49 #[allow(clippy::vec_init_then_push)]
50 pub fn instruction_with_remaining_accounts(
51 &self,
52 remaining_accounts: &[solana_program::instruction::AccountMeta],
53 ) -> solana_program::instruction::Instruction {
54 let mut accounts = Vec::with_capacity(15 + remaining_accounts.len());
55 accounts.push(solana_program::instruction::AccountMeta::new(
56 self.metadata,
57 false,
58 ));
59 accounts.push(solana_program::instruction::AccountMeta::new(
60 self.edition,
61 false,
62 ));
63 accounts.push(solana_program::instruction::AccountMeta::new(
64 self.token, false,
65 ));
66 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
67 self.token_owner,
68 false,
69 ));
70 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
71 self.mint, false,
72 ));
73 accounts.push(solana_program::instruction::AccountMeta::new(
74 self.payer, true,
75 ));
76 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
77 self.authority,
78 true,
79 ));
80 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
81 self.collection_metadata,
82 false,
83 ));
84 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
85 self.delegate_record,
86 false,
87 ));
88 accounts.push(solana_program::instruction::AccountMeta::new(
89 self.token_record,
90 false,
91 ));
92 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
93 self.system_program,
94 false,
95 ));
96 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
97 self.sysvar_instructions,
98 false,
99 ));
100 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
101 self.spl_token_program,
102 false,
103 ));
104 if let Some(authorization_rules_program) = self.authorization_rules_program {
105 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
106 authorization_rules_program,
107 false,
108 ));
109 } else {
110 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
111 crate::MPL_TOKEN_METADATA_ID,
112 false,
113 ));
114 }
115 if let Some(authorization_rules) = self.authorization_rules {
116 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
117 authorization_rules,
118 false,
119 ));
120 } else {
121 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
122 crate::MPL_TOKEN_METADATA_ID,
123 false,
124 ));
125 }
126 accounts.extend_from_slice(remaining_accounts);
127 let data = MigrateInstructionData::new().try_to_vec().unwrap();
128
129 solana_program::instruction::Instruction {
130 program_id: crate::MPL_TOKEN_METADATA_ID,
131 accounts,
132 data,
133 }
134 }
135}
136
137#[derive(BorshDeserialize, BorshSerialize)]
138struct MigrateInstructionData {
139 discriminator: u8,
140}
141
142impl MigrateInstructionData {
143 fn new() -> Self {
144 Self { discriminator: 48 }
145 }
146}
147
148#[derive(Default)]
168pub struct MigrateBuilder {
169 metadata: Option<solana_program::pubkey::Pubkey>,
170 edition: Option<solana_program::pubkey::Pubkey>,
171 token: Option<solana_program::pubkey::Pubkey>,
172 token_owner: Option<solana_program::pubkey::Pubkey>,
173 mint: Option<solana_program::pubkey::Pubkey>,
174 payer: Option<solana_program::pubkey::Pubkey>,
175 authority: Option<solana_program::pubkey::Pubkey>,
176 collection_metadata: Option<solana_program::pubkey::Pubkey>,
177 delegate_record: Option<solana_program::pubkey::Pubkey>,
178 token_record: Option<solana_program::pubkey::Pubkey>,
179 system_program: Option<solana_program::pubkey::Pubkey>,
180 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
181 spl_token_program: Option<solana_program::pubkey::Pubkey>,
182 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
183 authorization_rules: Option<solana_program::pubkey::Pubkey>,
184 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
185}
186
187impl MigrateBuilder {
188 pub fn new() -> Self {
189 Self::default()
190 }
191 #[inline(always)]
193 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
194 self.metadata = Some(metadata);
195 self
196 }
197 #[inline(always)]
199 pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
200 self.edition = Some(edition);
201 self
202 }
203 #[inline(always)]
205 pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self {
206 self.token = Some(token);
207 self
208 }
209 #[inline(always)]
211 pub fn token_owner(&mut self, token_owner: solana_program::pubkey::Pubkey) -> &mut Self {
212 self.token_owner = Some(token_owner);
213 self
214 }
215 #[inline(always)]
217 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
218 self.mint = Some(mint);
219 self
220 }
221 #[inline(always)]
223 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
224 self.payer = Some(payer);
225 self
226 }
227 #[inline(always)]
229 pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
230 self.authority = Some(authority);
231 self
232 }
233 #[inline(always)]
235 pub fn collection_metadata(
236 &mut self,
237 collection_metadata: solana_program::pubkey::Pubkey,
238 ) -> &mut Self {
239 self.collection_metadata = Some(collection_metadata);
240 self
241 }
242 #[inline(always)]
244 pub fn delegate_record(
245 &mut self,
246 delegate_record: solana_program::pubkey::Pubkey,
247 ) -> &mut Self {
248 self.delegate_record = Some(delegate_record);
249 self
250 }
251 #[inline(always)]
253 pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self {
254 self.token_record = Some(token_record);
255 self
256 }
257 #[inline(always)]
260 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
261 self.system_program = Some(system_program);
262 self
263 }
264 #[inline(always)]
267 pub fn sysvar_instructions(
268 &mut self,
269 sysvar_instructions: solana_program::pubkey::Pubkey,
270 ) -> &mut Self {
271 self.sysvar_instructions = Some(sysvar_instructions);
272 self
273 }
274 #[inline(always)]
277 pub fn spl_token_program(
278 &mut self,
279 spl_token_program: solana_program::pubkey::Pubkey,
280 ) -> &mut Self {
281 self.spl_token_program = Some(spl_token_program);
282 self
283 }
284 #[inline(always)]
287 pub fn authorization_rules_program(
288 &mut self,
289 authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
290 ) -> &mut Self {
291 self.authorization_rules_program = authorization_rules_program;
292 self
293 }
294 #[inline(always)]
297 pub fn authorization_rules(
298 &mut self,
299 authorization_rules: Option<solana_program::pubkey::Pubkey>,
300 ) -> &mut Self {
301 self.authorization_rules = authorization_rules;
302 self
303 }
304 #[inline(always)]
306 pub fn add_remaining_account(
307 &mut self,
308 account: solana_program::instruction::AccountMeta,
309 ) -> &mut Self {
310 self.__remaining_accounts.push(account);
311 self
312 }
313 #[inline(always)]
315 pub fn add_remaining_accounts(
316 &mut self,
317 accounts: &[solana_program::instruction::AccountMeta],
318 ) -> &mut Self {
319 self.__remaining_accounts.extend_from_slice(accounts);
320 self
321 }
322 #[allow(clippy::clone_on_copy)]
323 pub fn instruction(&self) -> solana_program::instruction::Instruction {
324 let accounts = Migrate {
325 metadata: self.metadata.expect("metadata is not set"),
326 edition: self.edition.expect("edition is not set"),
327 token: self.token.expect("token is not set"),
328 token_owner: self.token_owner.expect("token_owner is not set"),
329 mint: self.mint.expect("mint is not set"),
330 payer: self.payer.expect("payer is not set"),
331 authority: self.authority.expect("authority is not set"),
332 collection_metadata: self
333 .collection_metadata
334 .expect("collection_metadata is not set"),
335 delegate_record: self.delegate_record.expect("delegate_record is not set"),
336 token_record: self.token_record.expect("token_record is not set"),
337 system_program: self
338 .system_program
339 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
340 sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
341 "Sysvar1nstructions1111111111111111111111111"
342 )),
343 spl_token_program: self.spl_token_program.unwrap_or(solana_program::pubkey!(
344 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
345 )),
346 authorization_rules_program: self.authorization_rules_program,
347 authorization_rules: self.authorization_rules,
348 };
349
350 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
351 }
352}
353
354pub struct MigrateCpiAccounts<'a, 'b> {
356 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
358 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
360 pub token: &'b solana_program::account_info::AccountInfo<'a>,
362 pub token_owner: &'b solana_program::account_info::AccountInfo<'a>,
364 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
366 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
368 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
370 pub collection_metadata: &'b solana_program::account_info::AccountInfo<'a>,
372 pub delegate_record: &'b solana_program::account_info::AccountInfo<'a>,
374 pub token_record: &'b solana_program::account_info::AccountInfo<'a>,
376 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
378 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
380 pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
382 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
384 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
386}
387
388pub struct MigrateCpi<'a, 'b> {
390 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
392 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
394 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
396 pub token: &'b solana_program::account_info::AccountInfo<'a>,
398 pub token_owner: &'b solana_program::account_info::AccountInfo<'a>,
400 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
402 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
404 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
406 pub collection_metadata: &'b solana_program::account_info::AccountInfo<'a>,
408 pub delegate_record: &'b solana_program::account_info::AccountInfo<'a>,
410 pub token_record: &'b solana_program::account_info::AccountInfo<'a>,
412 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
414 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
416 pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
418 pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
420 pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
422}
423
424impl<'a, 'b> MigrateCpi<'a, 'b> {
425 pub fn new(
426 program: &'b solana_program::account_info::AccountInfo<'a>,
427 accounts: MigrateCpiAccounts<'a, 'b>,
428 ) -> Self {
429 Self {
430 __program: program,
431 metadata: accounts.metadata,
432 edition: accounts.edition,
433 token: accounts.token,
434 token_owner: accounts.token_owner,
435 mint: accounts.mint,
436 payer: accounts.payer,
437 authority: accounts.authority,
438 collection_metadata: accounts.collection_metadata,
439 delegate_record: accounts.delegate_record,
440 token_record: accounts.token_record,
441 system_program: accounts.system_program,
442 sysvar_instructions: accounts.sysvar_instructions,
443 spl_token_program: accounts.spl_token_program,
444 authorization_rules_program: accounts.authorization_rules_program,
445 authorization_rules: accounts.authorization_rules,
446 }
447 }
448 #[inline(always)]
449 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
450 self.invoke_signed_with_remaining_accounts(&[], &[])
451 }
452 #[inline(always)]
453 pub fn invoke_with_remaining_accounts(
454 &self,
455 remaining_accounts: &[(
456 &'b solana_program::account_info::AccountInfo<'a>,
457 bool,
458 bool,
459 )],
460 ) -> solana_program::entrypoint::ProgramResult {
461 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
462 }
463 #[inline(always)]
464 pub fn invoke_signed(
465 &self,
466 signers_seeds: &[&[&[u8]]],
467 ) -> solana_program::entrypoint::ProgramResult {
468 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
469 }
470 #[allow(clippy::clone_on_copy)]
471 #[allow(clippy::vec_init_then_push)]
472 pub fn invoke_signed_with_remaining_accounts(
473 &self,
474 signers_seeds: &[&[&[u8]]],
475 remaining_accounts: &[(
476 &'b solana_program::account_info::AccountInfo<'a>,
477 bool,
478 bool,
479 )],
480 ) -> solana_program::entrypoint::ProgramResult {
481 let mut accounts = Vec::with_capacity(15 + remaining_accounts.len());
482 accounts.push(solana_program::instruction::AccountMeta::new(
483 *self.metadata.key,
484 false,
485 ));
486 accounts.push(solana_program::instruction::AccountMeta::new(
487 *self.edition.key,
488 false,
489 ));
490 accounts.push(solana_program::instruction::AccountMeta::new(
491 *self.token.key,
492 false,
493 ));
494 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
495 *self.token_owner.key,
496 false,
497 ));
498 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
499 *self.mint.key,
500 false,
501 ));
502 accounts.push(solana_program::instruction::AccountMeta::new(
503 *self.payer.key,
504 true,
505 ));
506 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
507 *self.authority.key,
508 true,
509 ));
510 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
511 *self.collection_metadata.key,
512 false,
513 ));
514 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
515 *self.delegate_record.key,
516 false,
517 ));
518 accounts.push(solana_program::instruction::AccountMeta::new(
519 *self.token_record.key,
520 false,
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 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
531 *self.spl_token_program.key,
532 false,
533 ));
534 if let Some(authorization_rules_program) = self.authorization_rules_program {
535 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
536 *authorization_rules_program.key,
537 false,
538 ));
539 } else {
540 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
541 crate::MPL_TOKEN_METADATA_ID,
542 false,
543 ));
544 }
545 if let Some(authorization_rules) = self.authorization_rules {
546 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
547 *authorization_rules.key,
548 false,
549 ));
550 } else {
551 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
552 crate::MPL_TOKEN_METADATA_ID,
553 false,
554 ));
555 }
556 remaining_accounts.iter().for_each(|remaining_account| {
557 accounts.push(solana_program::instruction::AccountMeta {
558 pubkey: *remaining_account.0.key,
559 is_signer: remaining_account.1,
560 is_writable: remaining_account.2,
561 })
562 });
563 let data = MigrateInstructionData::new().try_to_vec().unwrap();
564
565 let instruction = solana_program::instruction::Instruction {
566 program_id: crate::MPL_TOKEN_METADATA_ID,
567 accounts,
568 data,
569 };
570 let mut account_infos = Vec::with_capacity(15 + 1 + remaining_accounts.len());
571 account_infos.push(self.__program.clone());
572 account_infos.push(self.metadata.clone());
573 account_infos.push(self.edition.clone());
574 account_infos.push(self.token.clone());
575 account_infos.push(self.token_owner.clone());
576 account_infos.push(self.mint.clone());
577 account_infos.push(self.payer.clone());
578 account_infos.push(self.authority.clone());
579 account_infos.push(self.collection_metadata.clone());
580 account_infos.push(self.delegate_record.clone());
581 account_infos.push(self.token_record.clone());
582 account_infos.push(self.system_program.clone());
583 account_infos.push(self.sysvar_instructions.clone());
584 account_infos.push(self.spl_token_program.clone());
585 if let Some(authorization_rules_program) = self.authorization_rules_program {
586 account_infos.push(authorization_rules_program.clone());
587 }
588 if let Some(authorization_rules) = self.authorization_rules {
589 account_infos.push(authorization_rules.clone());
590 }
591 remaining_accounts
592 .iter()
593 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
594
595 if signers_seeds.is_empty() {
596 solana_program::program::invoke(&instruction, &account_infos)
597 } else {
598 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
599 }
600 }
601}
602
603pub struct MigrateCpiBuilder<'a, 'b> {
623 instruction: Box<MigrateCpiBuilderInstruction<'a, 'b>>,
624}
625
626impl<'a, 'b> MigrateCpiBuilder<'a, 'b> {
627 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
628 let instruction = Box::new(MigrateCpiBuilderInstruction {
629 __program: program,
630 metadata: None,
631 edition: None,
632 token: None,
633 token_owner: None,
634 mint: None,
635 payer: None,
636 authority: None,
637 collection_metadata: None,
638 delegate_record: None,
639 token_record: None,
640 system_program: None,
641 sysvar_instructions: None,
642 spl_token_program: None,
643 authorization_rules_program: None,
644 authorization_rules: None,
645 __remaining_accounts: Vec::new(),
646 });
647 Self { instruction }
648 }
649 #[inline(always)]
651 pub fn metadata(
652 &mut self,
653 metadata: &'b solana_program::account_info::AccountInfo<'a>,
654 ) -> &mut Self {
655 self.instruction.metadata = Some(metadata);
656 self
657 }
658 #[inline(always)]
660 pub fn edition(
661 &mut self,
662 edition: &'b solana_program::account_info::AccountInfo<'a>,
663 ) -> &mut Self {
664 self.instruction.edition = Some(edition);
665 self
666 }
667 #[inline(always)]
669 pub fn token(&mut self, token: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
670 self.instruction.token = Some(token);
671 self
672 }
673 #[inline(always)]
675 pub fn token_owner(
676 &mut self,
677 token_owner: &'b solana_program::account_info::AccountInfo<'a>,
678 ) -> &mut Self {
679 self.instruction.token_owner = Some(token_owner);
680 self
681 }
682 #[inline(always)]
684 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
685 self.instruction.mint = Some(mint);
686 self
687 }
688 #[inline(always)]
690 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
691 self.instruction.payer = Some(payer);
692 self
693 }
694 #[inline(always)]
696 pub fn authority(
697 &mut self,
698 authority: &'b solana_program::account_info::AccountInfo<'a>,
699 ) -> &mut Self {
700 self.instruction.authority = Some(authority);
701 self
702 }
703 #[inline(always)]
705 pub fn collection_metadata(
706 &mut self,
707 collection_metadata: &'b solana_program::account_info::AccountInfo<'a>,
708 ) -> &mut Self {
709 self.instruction.collection_metadata = Some(collection_metadata);
710 self
711 }
712 #[inline(always)]
714 pub fn delegate_record(
715 &mut self,
716 delegate_record: &'b solana_program::account_info::AccountInfo<'a>,
717 ) -> &mut Self {
718 self.instruction.delegate_record = Some(delegate_record);
719 self
720 }
721 #[inline(always)]
723 pub fn token_record(
724 &mut self,
725 token_record: &'b solana_program::account_info::AccountInfo<'a>,
726 ) -> &mut Self {
727 self.instruction.token_record = Some(token_record);
728 self
729 }
730 #[inline(always)]
732 pub fn system_program(
733 &mut self,
734 system_program: &'b solana_program::account_info::AccountInfo<'a>,
735 ) -> &mut Self {
736 self.instruction.system_program = Some(system_program);
737 self
738 }
739 #[inline(always)]
741 pub fn sysvar_instructions(
742 &mut self,
743 sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
744 ) -> &mut Self {
745 self.instruction.sysvar_instructions = Some(sysvar_instructions);
746 self
747 }
748 #[inline(always)]
750 pub fn spl_token_program(
751 &mut self,
752 spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
753 ) -> &mut Self {
754 self.instruction.spl_token_program = Some(spl_token_program);
755 self
756 }
757 #[inline(always)]
760 pub fn authorization_rules_program(
761 &mut self,
762 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
763 ) -> &mut Self {
764 self.instruction.authorization_rules_program = authorization_rules_program;
765 self
766 }
767 #[inline(always)]
770 pub fn authorization_rules(
771 &mut self,
772 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
773 ) -> &mut Self {
774 self.instruction.authorization_rules = authorization_rules;
775 self
776 }
777 #[inline(always)]
779 pub fn add_remaining_account(
780 &mut self,
781 account: &'b solana_program::account_info::AccountInfo<'a>,
782 is_writable: bool,
783 is_signer: bool,
784 ) -> &mut Self {
785 self.instruction
786 .__remaining_accounts
787 .push((account, is_writable, is_signer));
788 self
789 }
790 #[inline(always)]
795 pub fn add_remaining_accounts(
796 &mut self,
797 accounts: &[(
798 &'b solana_program::account_info::AccountInfo<'a>,
799 bool,
800 bool,
801 )],
802 ) -> &mut Self {
803 self.instruction
804 .__remaining_accounts
805 .extend_from_slice(accounts);
806 self
807 }
808 #[inline(always)]
809 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
810 self.invoke_signed(&[])
811 }
812 #[allow(clippy::clone_on_copy)]
813 #[allow(clippy::vec_init_then_push)]
814 pub fn invoke_signed(
815 &self,
816 signers_seeds: &[&[&[u8]]],
817 ) -> solana_program::entrypoint::ProgramResult {
818 let instruction = MigrateCpi {
819 __program: self.instruction.__program,
820
821 metadata: self.instruction.metadata.expect("metadata is not set"),
822
823 edition: self.instruction.edition.expect("edition is not set"),
824
825 token: self.instruction.token.expect("token is not set"),
826
827 token_owner: self
828 .instruction
829 .token_owner
830 .expect("token_owner is not set"),
831
832 mint: self.instruction.mint.expect("mint is not set"),
833
834 payer: self.instruction.payer.expect("payer is not set"),
835
836 authority: self.instruction.authority.expect("authority is not set"),
837
838 collection_metadata: self
839 .instruction
840 .collection_metadata
841 .expect("collection_metadata is not set"),
842
843 delegate_record: self
844 .instruction
845 .delegate_record
846 .expect("delegate_record is not set"),
847
848 token_record: self
849 .instruction
850 .token_record
851 .expect("token_record is not set"),
852
853 system_program: self
854 .instruction
855 .system_program
856 .expect("system_program is not set"),
857
858 sysvar_instructions: self
859 .instruction
860 .sysvar_instructions
861 .expect("sysvar_instructions is not set"),
862
863 spl_token_program: self
864 .instruction
865 .spl_token_program
866 .expect("spl_token_program is not set"),
867
868 authorization_rules_program: self.instruction.authorization_rules_program,
869
870 authorization_rules: self.instruction.authorization_rules,
871 };
872 instruction.invoke_signed_with_remaining_accounts(
873 signers_seeds,
874 &self.instruction.__remaining_accounts,
875 )
876 }
877}
878
879struct MigrateCpiBuilderInstruction<'a, 'b> {
880 __program: &'b solana_program::account_info::AccountInfo<'a>,
881 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
882 edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
883 token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
884 token_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
885 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
886 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
887 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
888 collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
889 delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
890 token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
891 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
892 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
893 spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
894 authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
895 authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
896 __remaining_accounts: Vec<(
898 &'b solana_program::account_info::AccountInfo<'a>,
899 bool,
900 bool,
901 )>,
902}