1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct PrintV2 {
13 pub edition_metadata: solana_program::pubkey::Pubkey,
15 pub edition: solana_program::pubkey::Pubkey,
17 pub edition_mint: (solana_program::pubkey::Pubkey, bool),
19 pub edition_token_account_owner: solana_program::pubkey::Pubkey,
21 pub edition_token_account: solana_program::pubkey::Pubkey,
23 pub edition_mint_authority: solana_program::pubkey::Pubkey,
25 pub edition_token_record: Option<solana_program::pubkey::Pubkey>,
27 pub master_edition: solana_program::pubkey::Pubkey,
29 pub edition_marker_pda: solana_program::pubkey::Pubkey,
31 pub payer: solana_program::pubkey::Pubkey,
33 pub master_token_account_owner: (solana_program::pubkey::Pubkey, bool),
35 pub master_token_account: solana_program::pubkey::Pubkey,
37 pub master_metadata: solana_program::pubkey::Pubkey,
39 pub update_authority: solana_program::pubkey::Pubkey,
41 pub spl_token_program: solana_program::pubkey::Pubkey,
43 pub spl_ata_program: solana_program::pubkey::Pubkey,
45 pub sysvar_instructions: solana_program::pubkey::Pubkey,
47 pub system_program: solana_program::pubkey::Pubkey,
49 pub holder_delegate_record: Option<solana_program::pubkey::Pubkey>,
51 pub delegate: Option<solana_program::pubkey::Pubkey>,
53}
54
55impl PrintV2 {
56 pub fn instruction(
57 &self,
58 args: PrintV2InstructionArgs,
59 ) -> solana_program::instruction::Instruction {
60 self.instruction_with_remaining_accounts(args, &[])
61 }
62 #[allow(clippy::vec_init_then_push)]
63 pub fn instruction_with_remaining_accounts(
64 &self,
65 args: PrintV2InstructionArgs,
66 remaining_accounts: &[solana_program::instruction::AccountMeta],
67 ) -> solana_program::instruction::Instruction {
68 let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
69 accounts.push(solana_program::instruction::AccountMeta::new(
70 self.edition_metadata,
71 false,
72 ));
73 accounts.push(solana_program::instruction::AccountMeta::new(
74 self.edition,
75 false,
76 ));
77 accounts.push(solana_program::instruction::AccountMeta::new(
78 self.edition_mint.0,
79 self.edition_mint.1,
80 ));
81 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82 self.edition_token_account_owner,
83 false,
84 ));
85 accounts.push(solana_program::instruction::AccountMeta::new(
86 self.edition_token_account,
87 false,
88 ));
89 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
90 self.edition_mint_authority,
91 true,
92 ));
93 if let Some(edition_token_record) = self.edition_token_record {
94 accounts.push(solana_program::instruction::AccountMeta::new(
95 edition_token_record,
96 false,
97 ));
98 } else {
99 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
100 crate::MPL_TOKEN_METADATA_ID,
101 false,
102 ));
103 }
104 accounts.push(solana_program::instruction::AccountMeta::new(
105 self.master_edition,
106 false,
107 ));
108 accounts.push(solana_program::instruction::AccountMeta::new(
109 self.edition_marker_pda,
110 false,
111 ));
112 accounts.push(solana_program::instruction::AccountMeta::new(
113 self.payer, true,
114 ));
115 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
116 self.master_token_account_owner.0,
117 self.master_token_account_owner.1,
118 ));
119 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
120 self.master_token_account,
121 false,
122 ));
123 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
124 self.master_metadata,
125 false,
126 ));
127 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
128 self.update_authority,
129 false,
130 ));
131 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
132 self.spl_token_program,
133 false,
134 ));
135 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
136 self.spl_ata_program,
137 false,
138 ));
139 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
140 self.sysvar_instructions,
141 false,
142 ));
143 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
144 self.system_program,
145 false,
146 ));
147 if let Some(holder_delegate_record) = self.holder_delegate_record {
148 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
149 holder_delegate_record,
150 false,
151 ));
152 } else {
153 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
154 crate::MPL_TOKEN_METADATA_ID,
155 false,
156 ));
157 }
158 if let Some(delegate) = self.delegate {
159 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
160 delegate, true,
161 ));
162 } else {
163 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
164 crate::MPL_TOKEN_METADATA_ID,
165 false,
166 ));
167 }
168 accounts.extend_from_slice(remaining_accounts);
169 let mut data = PrintV2InstructionData::new().try_to_vec().unwrap();
170 let mut args = args.try_to_vec().unwrap();
171 data.append(&mut args);
172
173 solana_program::instruction::Instruction {
174 program_id: crate::MPL_TOKEN_METADATA_ID,
175 accounts,
176 data,
177 }
178 }
179}
180
181#[derive(BorshDeserialize, BorshSerialize)]
182struct PrintV2InstructionData {
183 discriminator: u8,
184 print_v2_discriminator: u8,
185}
186
187impl PrintV2InstructionData {
188 fn new() -> Self {
189 Self {
190 discriminator: 55,
191 print_v2_discriminator: 1,
192 }
193 }
194}
195
196#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
197#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
198pub struct PrintV2InstructionArgs {
199 pub edition_number: u64,
200}
201
202#[derive(Default)]
227pub struct PrintV2Builder {
228 edition_metadata: Option<solana_program::pubkey::Pubkey>,
229 edition: Option<solana_program::pubkey::Pubkey>,
230 edition_mint: Option<(solana_program::pubkey::Pubkey, bool)>,
231 edition_token_account_owner: Option<solana_program::pubkey::Pubkey>,
232 edition_token_account: Option<solana_program::pubkey::Pubkey>,
233 edition_mint_authority: Option<solana_program::pubkey::Pubkey>,
234 edition_token_record: Option<solana_program::pubkey::Pubkey>,
235 master_edition: Option<solana_program::pubkey::Pubkey>,
236 edition_marker_pda: Option<solana_program::pubkey::Pubkey>,
237 payer: Option<solana_program::pubkey::Pubkey>,
238 master_token_account_owner: Option<(solana_program::pubkey::Pubkey, bool)>,
239 master_token_account: Option<solana_program::pubkey::Pubkey>,
240 master_metadata: Option<solana_program::pubkey::Pubkey>,
241 update_authority: Option<solana_program::pubkey::Pubkey>,
242 spl_token_program: Option<solana_program::pubkey::Pubkey>,
243 spl_ata_program: Option<solana_program::pubkey::Pubkey>,
244 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
245 system_program: Option<solana_program::pubkey::Pubkey>,
246 holder_delegate_record: Option<solana_program::pubkey::Pubkey>,
247 delegate: Option<solana_program::pubkey::Pubkey>,
248 edition_number: Option<u64>,
249 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
250}
251
252impl PrintV2Builder {
253 pub fn new() -> Self {
254 Self::default()
255 }
256 #[inline(always)]
258 pub fn edition_metadata(
259 &mut self,
260 edition_metadata: solana_program::pubkey::Pubkey,
261 ) -> &mut Self {
262 self.edition_metadata = Some(edition_metadata);
263 self
264 }
265 #[inline(always)]
267 pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
268 self.edition = Some(edition);
269 self
270 }
271 #[inline(always)]
273 pub fn edition_mint(
274 &mut self,
275 edition_mint: solana_program::pubkey::Pubkey,
276 as_signer: bool,
277 ) -> &mut Self {
278 self.edition_mint = Some((edition_mint, as_signer));
279 self
280 }
281 #[inline(always)]
283 pub fn edition_token_account_owner(
284 &mut self,
285 edition_token_account_owner: solana_program::pubkey::Pubkey,
286 ) -> &mut Self {
287 self.edition_token_account_owner = Some(edition_token_account_owner);
288 self
289 }
290 #[inline(always)]
292 pub fn edition_token_account(
293 &mut self,
294 edition_token_account: solana_program::pubkey::Pubkey,
295 ) -> &mut Self {
296 self.edition_token_account = Some(edition_token_account);
297 self
298 }
299 #[inline(always)]
301 pub fn edition_mint_authority(
302 &mut self,
303 edition_mint_authority: solana_program::pubkey::Pubkey,
304 ) -> &mut Self {
305 self.edition_mint_authority = Some(edition_mint_authority);
306 self
307 }
308 #[inline(always)]
311 pub fn edition_token_record(
312 &mut self,
313 edition_token_record: Option<solana_program::pubkey::Pubkey>,
314 ) -> &mut Self {
315 self.edition_token_record = edition_token_record;
316 self
317 }
318 #[inline(always)]
320 pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self {
321 self.master_edition = Some(master_edition);
322 self
323 }
324 #[inline(always)]
326 pub fn edition_marker_pda(
327 &mut self,
328 edition_marker_pda: solana_program::pubkey::Pubkey,
329 ) -> &mut Self {
330 self.edition_marker_pda = Some(edition_marker_pda);
331 self
332 }
333 #[inline(always)]
335 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
336 self.payer = Some(payer);
337 self
338 }
339 #[inline(always)]
341 pub fn master_token_account_owner(
342 &mut self,
343 master_token_account_owner: solana_program::pubkey::Pubkey,
344 as_signer: bool,
345 ) -> &mut Self {
346 self.master_token_account_owner = Some((master_token_account_owner, as_signer));
347 self
348 }
349 #[inline(always)]
351 pub fn master_token_account(
352 &mut self,
353 master_token_account: solana_program::pubkey::Pubkey,
354 ) -> &mut Self {
355 self.master_token_account = Some(master_token_account);
356 self
357 }
358 #[inline(always)]
360 pub fn master_metadata(
361 &mut self,
362 master_metadata: solana_program::pubkey::Pubkey,
363 ) -> &mut Self {
364 self.master_metadata = Some(master_metadata);
365 self
366 }
367 #[inline(always)]
369 pub fn update_authority(
370 &mut self,
371 update_authority: solana_program::pubkey::Pubkey,
372 ) -> &mut Self {
373 self.update_authority = Some(update_authority);
374 self
375 }
376 #[inline(always)]
379 pub fn spl_token_program(
380 &mut self,
381 spl_token_program: solana_program::pubkey::Pubkey,
382 ) -> &mut Self {
383 self.spl_token_program = Some(spl_token_program);
384 self
385 }
386 #[inline(always)]
389 pub fn spl_ata_program(
390 &mut self,
391 spl_ata_program: solana_program::pubkey::Pubkey,
392 ) -> &mut Self {
393 self.spl_ata_program = Some(spl_ata_program);
394 self
395 }
396 #[inline(always)]
399 pub fn sysvar_instructions(
400 &mut self,
401 sysvar_instructions: solana_program::pubkey::Pubkey,
402 ) -> &mut Self {
403 self.sysvar_instructions = Some(sysvar_instructions);
404 self
405 }
406 #[inline(always)]
409 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
410 self.system_program = Some(system_program);
411 self
412 }
413 #[inline(always)]
416 pub fn holder_delegate_record(
417 &mut self,
418 holder_delegate_record: Option<solana_program::pubkey::Pubkey>,
419 ) -> &mut Self {
420 self.holder_delegate_record = holder_delegate_record;
421 self
422 }
423 #[inline(always)]
426 pub fn delegate(&mut self, delegate: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
427 self.delegate = delegate;
428 self
429 }
430 #[inline(always)]
431 pub fn edition_number(&mut self, edition_number: u64) -> &mut Self {
432 self.edition_number = Some(edition_number);
433 self
434 }
435 #[inline(always)]
437 pub fn add_remaining_account(
438 &mut self,
439 account: solana_program::instruction::AccountMeta,
440 ) -> &mut Self {
441 self.__remaining_accounts.push(account);
442 self
443 }
444 #[inline(always)]
446 pub fn add_remaining_accounts(
447 &mut self,
448 accounts: &[solana_program::instruction::AccountMeta],
449 ) -> &mut Self {
450 self.__remaining_accounts.extend_from_slice(accounts);
451 self
452 }
453 #[allow(clippy::clone_on_copy)]
454 pub fn instruction(&self) -> solana_program::instruction::Instruction {
455 let accounts = PrintV2 {
456 edition_metadata: self.edition_metadata.expect("edition_metadata is not set"),
457 edition: self.edition.expect("edition is not set"),
458 edition_mint: self.edition_mint.expect("edition_mint is not set"),
459 edition_token_account_owner: self
460 .edition_token_account_owner
461 .expect("edition_token_account_owner is not set"),
462 edition_token_account: self
463 .edition_token_account
464 .expect("edition_token_account is not set"),
465 edition_mint_authority: self
466 .edition_mint_authority
467 .expect("edition_mint_authority is not set"),
468 edition_token_record: self.edition_token_record,
469 master_edition: self.master_edition.expect("master_edition is not set"),
470 edition_marker_pda: self
471 .edition_marker_pda
472 .expect("edition_marker_pda is not set"),
473 payer: self.payer.expect("payer is not set"),
474 master_token_account_owner: self
475 .master_token_account_owner
476 .expect("master_token_account_owner is not set"),
477 master_token_account: self
478 .master_token_account
479 .expect("master_token_account is not set"),
480 master_metadata: self.master_metadata.expect("master_metadata is not set"),
481 update_authority: self.update_authority.expect("update_authority is not set"),
482 spl_token_program: self.spl_token_program.unwrap_or(solana_program::pubkey!(
483 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
484 )),
485 spl_ata_program: self.spl_ata_program.unwrap_or(solana_program::pubkey!(
486 "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
487 )),
488 sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
489 "Sysvar1nstructions1111111111111111111111111"
490 )),
491 system_program: self
492 .system_program
493 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
494 holder_delegate_record: self.holder_delegate_record,
495 delegate: self.delegate,
496 };
497 let args = PrintV2InstructionArgs {
498 edition_number: self
499 .edition_number
500 .clone()
501 .expect("edition_number is not set"),
502 };
503
504 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
505 }
506}
507
508pub struct PrintV2CpiAccounts<'a, 'b> {
510 pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
512 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
514 pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
516 pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
518 pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
520 pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
522 pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
524 pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
526 pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
528 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
530 pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
532 pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
534 pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
536 pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
538 pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
540 pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
542 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
544 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
546 pub holder_delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
548 pub delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
550}
551
552pub struct PrintV2Cpi<'a, 'b> {
554 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
556 pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
558 pub edition: &'b solana_program::account_info::AccountInfo<'a>,
560 pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
562 pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
564 pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
566 pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
568 pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
570 pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
572 pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
574 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
576 pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
578 pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
580 pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
582 pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
584 pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
586 pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
588 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
590 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
592 pub holder_delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
594 pub delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
596 pub __args: PrintV2InstructionArgs,
598}
599
600impl<'a, 'b> PrintV2Cpi<'a, 'b> {
601 pub fn new(
602 program: &'b solana_program::account_info::AccountInfo<'a>,
603 accounts: PrintV2CpiAccounts<'a, 'b>,
604 args: PrintV2InstructionArgs,
605 ) -> Self {
606 Self {
607 __program: program,
608 edition_metadata: accounts.edition_metadata,
609 edition: accounts.edition,
610 edition_mint: accounts.edition_mint,
611 edition_token_account_owner: accounts.edition_token_account_owner,
612 edition_token_account: accounts.edition_token_account,
613 edition_mint_authority: accounts.edition_mint_authority,
614 edition_token_record: accounts.edition_token_record,
615 master_edition: accounts.master_edition,
616 edition_marker_pda: accounts.edition_marker_pda,
617 payer: accounts.payer,
618 master_token_account_owner: accounts.master_token_account_owner,
619 master_token_account: accounts.master_token_account,
620 master_metadata: accounts.master_metadata,
621 update_authority: accounts.update_authority,
622 spl_token_program: accounts.spl_token_program,
623 spl_ata_program: accounts.spl_ata_program,
624 sysvar_instructions: accounts.sysvar_instructions,
625 system_program: accounts.system_program,
626 holder_delegate_record: accounts.holder_delegate_record,
627 delegate: accounts.delegate,
628 __args: args,
629 }
630 }
631 #[inline(always)]
632 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
633 self.invoke_signed_with_remaining_accounts(&[], &[])
634 }
635 #[inline(always)]
636 pub fn invoke_with_remaining_accounts(
637 &self,
638 remaining_accounts: &[(
639 &'b solana_program::account_info::AccountInfo<'a>,
640 bool,
641 bool,
642 )],
643 ) -> solana_program::entrypoint::ProgramResult {
644 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
645 }
646 #[inline(always)]
647 pub fn invoke_signed(
648 &self,
649 signers_seeds: &[&[&[u8]]],
650 ) -> solana_program::entrypoint::ProgramResult {
651 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
652 }
653 #[allow(clippy::clone_on_copy)]
654 #[allow(clippy::vec_init_then_push)]
655 pub fn invoke_signed_with_remaining_accounts(
656 &self,
657 signers_seeds: &[&[&[u8]]],
658 remaining_accounts: &[(
659 &'b solana_program::account_info::AccountInfo<'a>,
660 bool,
661 bool,
662 )],
663 ) -> solana_program::entrypoint::ProgramResult {
664 let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
665 accounts.push(solana_program::instruction::AccountMeta::new(
666 *self.edition_metadata.key,
667 false,
668 ));
669 accounts.push(solana_program::instruction::AccountMeta::new(
670 *self.edition.key,
671 false,
672 ));
673 accounts.push(solana_program::instruction::AccountMeta::new(
674 *self.edition_mint.0.key,
675 self.edition_mint.1,
676 ));
677 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
678 *self.edition_token_account_owner.key,
679 false,
680 ));
681 accounts.push(solana_program::instruction::AccountMeta::new(
682 *self.edition_token_account.key,
683 false,
684 ));
685 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
686 *self.edition_mint_authority.key,
687 true,
688 ));
689 if let Some(edition_token_record) = self.edition_token_record {
690 accounts.push(solana_program::instruction::AccountMeta::new(
691 *edition_token_record.key,
692 false,
693 ));
694 } else {
695 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
696 crate::MPL_TOKEN_METADATA_ID,
697 false,
698 ));
699 }
700 accounts.push(solana_program::instruction::AccountMeta::new(
701 *self.master_edition.key,
702 false,
703 ));
704 accounts.push(solana_program::instruction::AccountMeta::new(
705 *self.edition_marker_pda.key,
706 false,
707 ));
708 accounts.push(solana_program::instruction::AccountMeta::new(
709 *self.payer.key,
710 true,
711 ));
712 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
713 *self.master_token_account_owner.0.key,
714 self.master_token_account_owner.1,
715 ));
716 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
717 *self.master_token_account.key,
718 false,
719 ));
720 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
721 *self.master_metadata.key,
722 false,
723 ));
724 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
725 *self.update_authority.key,
726 false,
727 ));
728 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
729 *self.spl_token_program.key,
730 false,
731 ));
732 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
733 *self.spl_ata_program.key,
734 false,
735 ));
736 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
737 *self.sysvar_instructions.key,
738 false,
739 ));
740 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
741 *self.system_program.key,
742 false,
743 ));
744 if let Some(holder_delegate_record) = self.holder_delegate_record {
745 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
746 *holder_delegate_record.key,
747 false,
748 ));
749 } else {
750 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
751 crate::MPL_TOKEN_METADATA_ID,
752 false,
753 ));
754 }
755 if let Some(delegate) = self.delegate {
756 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
757 *delegate.key,
758 true,
759 ));
760 } else {
761 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
762 crate::MPL_TOKEN_METADATA_ID,
763 false,
764 ));
765 }
766 remaining_accounts.iter().for_each(|remaining_account| {
767 accounts.push(solana_program::instruction::AccountMeta {
768 pubkey: *remaining_account.0.key,
769 is_signer: remaining_account.1,
770 is_writable: remaining_account.2,
771 })
772 });
773 let mut data = PrintV2InstructionData::new().try_to_vec().unwrap();
774 let mut args = self.__args.try_to_vec().unwrap();
775 data.append(&mut args);
776
777 let instruction = solana_program::instruction::Instruction {
778 program_id: crate::MPL_TOKEN_METADATA_ID,
779 accounts,
780 data,
781 };
782 let mut account_infos = Vec::with_capacity(20 + 1 + remaining_accounts.len());
783 account_infos.push(self.__program.clone());
784 account_infos.push(self.edition_metadata.clone());
785 account_infos.push(self.edition.clone());
786 account_infos.push(self.edition_mint.0.clone());
787 account_infos.push(self.edition_token_account_owner.clone());
788 account_infos.push(self.edition_token_account.clone());
789 account_infos.push(self.edition_mint_authority.clone());
790 if let Some(edition_token_record) = self.edition_token_record {
791 account_infos.push(edition_token_record.clone());
792 }
793 account_infos.push(self.master_edition.clone());
794 account_infos.push(self.edition_marker_pda.clone());
795 account_infos.push(self.payer.clone());
796 account_infos.push(self.master_token_account_owner.0.clone());
797 account_infos.push(self.master_token_account.clone());
798 account_infos.push(self.master_metadata.clone());
799 account_infos.push(self.update_authority.clone());
800 account_infos.push(self.spl_token_program.clone());
801 account_infos.push(self.spl_ata_program.clone());
802 account_infos.push(self.sysvar_instructions.clone());
803 account_infos.push(self.system_program.clone());
804 if let Some(holder_delegate_record) = self.holder_delegate_record {
805 account_infos.push(holder_delegate_record.clone());
806 }
807 if let Some(delegate) = self.delegate {
808 account_infos.push(delegate.clone());
809 }
810 remaining_accounts
811 .iter()
812 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
813
814 if signers_seeds.is_empty() {
815 solana_program::program::invoke(&instruction, &account_infos)
816 } else {
817 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
818 }
819 }
820}
821
822pub struct PrintV2CpiBuilder<'a, 'b> {
847 instruction: Box<PrintV2CpiBuilderInstruction<'a, 'b>>,
848}
849
850impl<'a, 'b> PrintV2CpiBuilder<'a, 'b> {
851 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
852 let instruction = Box::new(PrintV2CpiBuilderInstruction {
853 __program: program,
854 edition_metadata: None,
855 edition: None,
856 edition_mint: None,
857 edition_token_account_owner: None,
858 edition_token_account: None,
859 edition_mint_authority: None,
860 edition_token_record: None,
861 master_edition: None,
862 edition_marker_pda: None,
863 payer: None,
864 master_token_account_owner: None,
865 master_token_account: None,
866 master_metadata: None,
867 update_authority: None,
868 spl_token_program: None,
869 spl_ata_program: None,
870 sysvar_instructions: None,
871 system_program: None,
872 holder_delegate_record: None,
873 delegate: None,
874 edition_number: None,
875 __remaining_accounts: Vec::new(),
876 });
877 Self { instruction }
878 }
879 #[inline(always)]
881 pub fn edition_metadata(
882 &mut self,
883 edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
884 ) -> &mut Self {
885 self.instruction.edition_metadata = Some(edition_metadata);
886 self
887 }
888 #[inline(always)]
890 pub fn edition(
891 &mut self,
892 edition: &'b solana_program::account_info::AccountInfo<'a>,
893 ) -> &mut Self {
894 self.instruction.edition = Some(edition);
895 self
896 }
897 #[inline(always)]
899 pub fn edition_mint(
900 &mut self,
901 edition_mint: &'b solana_program::account_info::AccountInfo<'a>,
902 as_signer: bool,
903 ) -> &mut Self {
904 self.instruction.edition_mint = Some((edition_mint, as_signer));
905 self
906 }
907 #[inline(always)]
909 pub fn edition_token_account_owner(
910 &mut self,
911 edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
912 ) -> &mut Self {
913 self.instruction.edition_token_account_owner = Some(edition_token_account_owner);
914 self
915 }
916 #[inline(always)]
918 pub fn edition_token_account(
919 &mut self,
920 edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
921 ) -> &mut Self {
922 self.instruction.edition_token_account = Some(edition_token_account);
923 self
924 }
925 #[inline(always)]
927 pub fn edition_mint_authority(
928 &mut self,
929 edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
930 ) -> &mut Self {
931 self.instruction.edition_mint_authority = Some(edition_mint_authority);
932 self
933 }
934 #[inline(always)]
937 pub fn edition_token_record(
938 &mut self,
939 edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
940 ) -> &mut Self {
941 self.instruction.edition_token_record = edition_token_record;
942 self
943 }
944 #[inline(always)]
946 pub fn master_edition(
947 &mut self,
948 master_edition: &'b solana_program::account_info::AccountInfo<'a>,
949 ) -> &mut Self {
950 self.instruction.master_edition = Some(master_edition);
951 self
952 }
953 #[inline(always)]
955 pub fn edition_marker_pda(
956 &mut self,
957 edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
958 ) -> &mut Self {
959 self.instruction.edition_marker_pda = Some(edition_marker_pda);
960 self
961 }
962 #[inline(always)]
964 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
965 self.instruction.payer = Some(payer);
966 self
967 }
968 #[inline(always)]
970 pub fn master_token_account_owner(
971 &mut self,
972 master_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
973 as_signer: bool,
974 ) -> &mut Self {
975 self.instruction.master_token_account_owner = Some((master_token_account_owner, as_signer));
976 self
977 }
978 #[inline(always)]
980 pub fn master_token_account(
981 &mut self,
982 master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
983 ) -> &mut Self {
984 self.instruction.master_token_account = Some(master_token_account);
985 self
986 }
987 #[inline(always)]
989 pub fn master_metadata(
990 &mut self,
991 master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
992 ) -> &mut Self {
993 self.instruction.master_metadata = Some(master_metadata);
994 self
995 }
996 #[inline(always)]
998 pub fn update_authority(
999 &mut self,
1000 update_authority: &'b solana_program::account_info::AccountInfo<'a>,
1001 ) -> &mut Self {
1002 self.instruction.update_authority = Some(update_authority);
1003 self
1004 }
1005 #[inline(always)]
1007 pub fn spl_token_program(
1008 &mut self,
1009 spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1010 ) -> &mut Self {
1011 self.instruction.spl_token_program = Some(spl_token_program);
1012 self
1013 }
1014 #[inline(always)]
1016 pub fn spl_ata_program(
1017 &mut self,
1018 spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
1019 ) -> &mut Self {
1020 self.instruction.spl_ata_program = Some(spl_ata_program);
1021 self
1022 }
1023 #[inline(always)]
1025 pub fn sysvar_instructions(
1026 &mut self,
1027 sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
1028 ) -> &mut Self {
1029 self.instruction.sysvar_instructions = Some(sysvar_instructions);
1030 self
1031 }
1032 #[inline(always)]
1034 pub fn system_program(
1035 &mut self,
1036 system_program: &'b solana_program::account_info::AccountInfo<'a>,
1037 ) -> &mut Self {
1038 self.instruction.system_program = Some(system_program);
1039 self
1040 }
1041 #[inline(always)]
1044 pub fn holder_delegate_record(
1045 &mut self,
1046 holder_delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1047 ) -> &mut Self {
1048 self.instruction.holder_delegate_record = holder_delegate_record;
1049 self
1050 }
1051 #[inline(always)]
1054 pub fn delegate(
1055 &mut self,
1056 delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1057 ) -> &mut Self {
1058 self.instruction.delegate = delegate;
1059 self
1060 }
1061 #[inline(always)]
1062 pub fn edition_number(&mut self, edition_number: u64) -> &mut Self {
1063 self.instruction.edition_number = Some(edition_number);
1064 self
1065 }
1066 #[inline(always)]
1068 pub fn add_remaining_account(
1069 &mut self,
1070 account: &'b solana_program::account_info::AccountInfo<'a>,
1071 is_writable: bool,
1072 is_signer: bool,
1073 ) -> &mut Self {
1074 self.instruction
1075 .__remaining_accounts
1076 .push((account, is_writable, is_signer));
1077 self
1078 }
1079 #[inline(always)]
1084 pub fn add_remaining_accounts(
1085 &mut self,
1086 accounts: &[(
1087 &'b solana_program::account_info::AccountInfo<'a>,
1088 bool,
1089 bool,
1090 )],
1091 ) -> &mut Self {
1092 self.instruction
1093 .__remaining_accounts
1094 .extend_from_slice(accounts);
1095 self
1096 }
1097 #[inline(always)]
1098 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1099 self.invoke_signed(&[])
1100 }
1101 #[allow(clippy::clone_on_copy)]
1102 #[allow(clippy::vec_init_then_push)]
1103 pub fn invoke_signed(
1104 &self,
1105 signers_seeds: &[&[&[u8]]],
1106 ) -> solana_program::entrypoint::ProgramResult {
1107 let args = PrintV2InstructionArgs {
1108 edition_number: self
1109 .instruction
1110 .edition_number
1111 .clone()
1112 .expect("edition_number is not set"),
1113 };
1114 let instruction = PrintV2Cpi {
1115 __program: self.instruction.__program,
1116
1117 edition_metadata: self
1118 .instruction
1119 .edition_metadata
1120 .expect("edition_metadata is not set"),
1121
1122 edition: self.instruction.edition.expect("edition is not set"),
1123
1124 edition_mint: self
1125 .instruction
1126 .edition_mint
1127 .expect("edition_mint is not set"),
1128
1129 edition_token_account_owner: self
1130 .instruction
1131 .edition_token_account_owner
1132 .expect("edition_token_account_owner is not set"),
1133
1134 edition_token_account: self
1135 .instruction
1136 .edition_token_account
1137 .expect("edition_token_account is not set"),
1138
1139 edition_mint_authority: self
1140 .instruction
1141 .edition_mint_authority
1142 .expect("edition_mint_authority is not set"),
1143
1144 edition_token_record: self.instruction.edition_token_record,
1145
1146 master_edition: self
1147 .instruction
1148 .master_edition
1149 .expect("master_edition is not set"),
1150
1151 edition_marker_pda: self
1152 .instruction
1153 .edition_marker_pda
1154 .expect("edition_marker_pda is not set"),
1155
1156 payer: self.instruction.payer.expect("payer is not set"),
1157
1158 master_token_account_owner: self
1159 .instruction
1160 .master_token_account_owner
1161 .expect("master_token_account_owner is not set"),
1162
1163 master_token_account: self
1164 .instruction
1165 .master_token_account
1166 .expect("master_token_account is not set"),
1167
1168 master_metadata: self
1169 .instruction
1170 .master_metadata
1171 .expect("master_metadata is not set"),
1172
1173 update_authority: self
1174 .instruction
1175 .update_authority
1176 .expect("update_authority is not set"),
1177
1178 spl_token_program: self
1179 .instruction
1180 .spl_token_program
1181 .expect("spl_token_program is not set"),
1182
1183 spl_ata_program: self
1184 .instruction
1185 .spl_ata_program
1186 .expect("spl_ata_program is not set"),
1187
1188 sysvar_instructions: self
1189 .instruction
1190 .sysvar_instructions
1191 .expect("sysvar_instructions is not set"),
1192
1193 system_program: self
1194 .instruction
1195 .system_program
1196 .expect("system_program is not set"),
1197
1198 holder_delegate_record: self.instruction.holder_delegate_record,
1199
1200 delegate: self.instruction.delegate,
1201 __args: args,
1202 };
1203 instruction.invoke_signed_with_remaining_accounts(
1204 signers_seeds,
1205 &self.instruction.__remaining_accounts,
1206 )
1207 }
1208}
1209
1210struct PrintV2CpiBuilderInstruction<'a, 'b> {
1211 __program: &'b solana_program::account_info::AccountInfo<'a>,
1212 edition_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1213 edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1214 edition_mint: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
1215 edition_token_account_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1216 edition_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1217 edition_mint_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1218 edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1219 master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1220 edition_marker_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1221 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1222 master_token_account_owner: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
1223 master_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1224 master_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1225 update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1226 spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1227 spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1228 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1229 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1230 holder_delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1231 delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1232 edition_number: Option<u64>,
1233 __remaining_accounts: Vec<(
1235 &'b solana_program::account_info::AccountInfo<'a>,
1236 bool,
1237 bool,
1238 )>,
1239}