Skip to main content

mpl_token_metadata/generated/instructions/
print.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! [https://github.com/metaplex-foundation/kinobi]
6//!
7
8use crate::generated::types::PrintArgs;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12/// Accounts.
13pub struct Print {
14    /// New Metadata key (pda of ['metadata', program id, mint id])
15    pub edition_metadata: solana_program::pubkey::Pubkey,
16    /// New Edition (pda of ['metadata', program id, mint id, 'edition'])
17    pub edition: solana_program::pubkey::Pubkey,
18    /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY
19    pub edition_mint: (solana_program::pubkey::Pubkey, bool),
20    /// Owner of the token account of new token
21    pub edition_token_account_owner: solana_program::pubkey::Pubkey,
22    /// Token account of new token
23    pub edition_token_account: solana_program::pubkey::Pubkey,
24    /// Mint authority of new mint
25    pub edition_mint_authority: solana_program::pubkey::Pubkey,
26    /// Token record account
27    pub edition_token_record: Option<solana_program::pubkey::Pubkey>,
28    /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'])
29    pub master_edition: solana_program::pubkey::Pubkey,
30    /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE).
31    pub edition_marker_pda: solana_program::pubkey::Pubkey,
32    /// payer
33    pub payer: solana_program::pubkey::Pubkey,
34    /// owner of token account containing master token
35    pub master_token_account_owner: (solana_program::pubkey::Pubkey, bool),
36    /// token account containing token from master metadata mint
37    pub master_token_account: solana_program::pubkey::Pubkey,
38    /// Master record metadata account
39    pub master_metadata: solana_program::pubkey::Pubkey,
40    /// The update authority of the master edition.
41    pub update_authority: solana_program::pubkey::Pubkey,
42    /// Token program
43    pub spl_token_program: solana_program::pubkey::Pubkey,
44    /// SPL Associated Token Account program
45    pub spl_ata_program: solana_program::pubkey::Pubkey,
46    /// Instructions sysvar account
47    pub sysvar_instructions: solana_program::pubkey::Pubkey,
48    /// System program
49    pub system_program: solana_program::pubkey::Pubkey,
50}
51
52impl Print {
53    pub fn instruction(
54        &self,
55        args: PrintInstructionArgs,
56    ) -> solana_program::instruction::Instruction {
57        self.instruction_with_remaining_accounts(args, &[])
58    }
59    #[allow(clippy::vec_init_then_push)]
60    pub fn instruction_with_remaining_accounts(
61        &self,
62        args: PrintInstructionArgs,
63        remaining_accounts: &[solana_program::instruction::AccountMeta],
64    ) -> solana_program::instruction::Instruction {
65        let mut accounts = Vec::with_capacity(18 + remaining_accounts.len());
66        accounts.push(solana_program::instruction::AccountMeta::new(
67            self.edition_metadata,
68            false,
69        ));
70        accounts.push(solana_program::instruction::AccountMeta::new(
71            self.edition,
72            false,
73        ));
74        accounts.push(solana_program::instruction::AccountMeta::new(
75            self.edition_mint.0,
76            self.edition_mint.1,
77        ));
78        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
79            self.edition_token_account_owner,
80            false,
81        ));
82        accounts.push(solana_program::instruction::AccountMeta::new(
83            self.edition_token_account,
84            false,
85        ));
86        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
87            self.edition_mint_authority,
88            true,
89        ));
90        if let Some(edition_token_record) = self.edition_token_record {
91            accounts.push(solana_program::instruction::AccountMeta::new(
92                edition_token_record,
93                false,
94            ));
95        } else {
96            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
97                crate::MPL_TOKEN_METADATA_ID,
98                false,
99            ));
100        }
101        accounts.push(solana_program::instruction::AccountMeta::new(
102            self.master_edition,
103            false,
104        ));
105        accounts.push(solana_program::instruction::AccountMeta::new(
106            self.edition_marker_pda,
107            false,
108        ));
109        accounts.push(solana_program::instruction::AccountMeta::new(
110            self.payer, true,
111        ));
112        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
113            self.master_token_account_owner.0,
114            self.master_token_account_owner.1,
115        ));
116        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
117            self.master_token_account,
118            false,
119        ));
120        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
121            self.master_metadata,
122            false,
123        ));
124        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
125            self.update_authority,
126            false,
127        ));
128        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
129            self.spl_token_program,
130            false,
131        ));
132        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
133            self.spl_ata_program,
134            false,
135        ));
136        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
137            self.sysvar_instructions,
138            false,
139        ));
140        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
141            self.system_program,
142            false,
143        ));
144        accounts.extend_from_slice(remaining_accounts);
145        let mut data = PrintInstructionData::new().try_to_vec().unwrap();
146        let mut args = args.try_to_vec().unwrap();
147        data.append(&mut args);
148
149        solana_program::instruction::Instruction {
150            program_id: crate::MPL_TOKEN_METADATA_ID,
151            accounts,
152            data,
153        }
154    }
155}
156
157#[derive(BorshDeserialize, BorshSerialize)]
158struct PrintInstructionData {
159    discriminator: u8,
160}
161
162impl PrintInstructionData {
163    fn new() -> Self {
164        Self { discriminator: 55 }
165    }
166}
167
168#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
169#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
170pub struct PrintInstructionArgs {
171    pub print_args: PrintArgs,
172}
173
174/// Instruction builder for `Print`.
175///
176/// ### Accounts:
177///
178///   0. `[writable]` edition_metadata
179///   1. `[writable]` edition
180///   2. `[writable, signer]` edition_mint
181///   3. `[]` edition_token_account_owner
182///   4. `[writable]` edition_token_account
183///   5. `[signer]` edition_mint_authority
184///   6. `[writable, optional]` edition_token_record
185///   7. `[writable]` master_edition
186///   8. `[writable]` edition_marker_pda
187///   9. `[writable, signer]` payer
188///   10. `[signer]` master_token_account_owner
189///   11. `[]` master_token_account
190///   12. `[]` master_metadata
191///   13. `[]` update_authority
192///   14. `[optional]` spl_token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
193///   15. `[optional]` spl_ata_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
194///   16. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`)
195///   17. `[optional]` system_program (default to `11111111111111111111111111111111`)
196#[derive(Default)]
197pub struct PrintBuilder {
198    edition_metadata: Option<solana_program::pubkey::Pubkey>,
199    edition: Option<solana_program::pubkey::Pubkey>,
200    edition_mint: Option<(solana_program::pubkey::Pubkey, bool)>,
201    edition_token_account_owner: Option<solana_program::pubkey::Pubkey>,
202    edition_token_account: Option<solana_program::pubkey::Pubkey>,
203    edition_mint_authority: Option<solana_program::pubkey::Pubkey>,
204    edition_token_record: Option<solana_program::pubkey::Pubkey>,
205    master_edition: Option<solana_program::pubkey::Pubkey>,
206    edition_marker_pda: Option<solana_program::pubkey::Pubkey>,
207    payer: Option<solana_program::pubkey::Pubkey>,
208    master_token_account_owner: Option<(solana_program::pubkey::Pubkey, bool)>,
209    master_token_account: Option<solana_program::pubkey::Pubkey>,
210    master_metadata: Option<solana_program::pubkey::Pubkey>,
211    update_authority: Option<solana_program::pubkey::Pubkey>,
212    spl_token_program: Option<solana_program::pubkey::Pubkey>,
213    spl_ata_program: Option<solana_program::pubkey::Pubkey>,
214    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
215    system_program: Option<solana_program::pubkey::Pubkey>,
216    print_args: Option<PrintArgs>,
217    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
218}
219
220impl PrintBuilder {
221    pub fn new() -> Self {
222        Self::default()
223    }
224    /// New Metadata key (pda of ['metadata', program id, mint id])
225    #[inline(always)]
226    pub fn edition_metadata(
227        &mut self,
228        edition_metadata: solana_program::pubkey::Pubkey,
229    ) -> &mut Self {
230        self.edition_metadata = Some(edition_metadata);
231        self
232    }
233    /// New Edition (pda of ['metadata', program id, mint id, 'edition'])
234    #[inline(always)]
235    pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
236        self.edition = Some(edition);
237        self
238    }
239    /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY
240    #[inline(always)]
241    pub fn edition_mint(
242        &mut self,
243        edition_mint: solana_program::pubkey::Pubkey,
244        as_signer: bool,
245    ) -> &mut Self {
246        self.edition_mint = Some((edition_mint, as_signer));
247        self
248    }
249    /// Owner of the token account of new token
250    #[inline(always)]
251    pub fn edition_token_account_owner(
252        &mut self,
253        edition_token_account_owner: solana_program::pubkey::Pubkey,
254    ) -> &mut Self {
255        self.edition_token_account_owner = Some(edition_token_account_owner);
256        self
257    }
258    /// Token account of new token
259    #[inline(always)]
260    pub fn edition_token_account(
261        &mut self,
262        edition_token_account: solana_program::pubkey::Pubkey,
263    ) -> &mut Self {
264        self.edition_token_account = Some(edition_token_account);
265        self
266    }
267    /// Mint authority of new mint
268    #[inline(always)]
269    pub fn edition_mint_authority(
270        &mut self,
271        edition_mint_authority: solana_program::pubkey::Pubkey,
272    ) -> &mut Self {
273        self.edition_mint_authority = Some(edition_mint_authority);
274        self
275    }
276    /// `[optional account]`
277    /// Token record account
278    #[inline(always)]
279    pub fn edition_token_record(
280        &mut self,
281        edition_token_record: Option<solana_program::pubkey::Pubkey>,
282    ) -> &mut Self {
283        self.edition_token_record = edition_token_record;
284        self
285    }
286    /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'])
287    #[inline(always)]
288    pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self {
289        self.master_edition = Some(master_edition);
290        self
291    }
292    /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE).
293    #[inline(always)]
294    pub fn edition_marker_pda(
295        &mut self,
296        edition_marker_pda: solana_program::pubkey::Pubkey,
297    ) -> &mut Self {
298        self.edition_marker_pda = Some(edition_marker_pda);
299        self
300    }
301    /// payer
302    #[inline(always)]
303    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
304        self.payer = Some(payer);
305        self
306    }
307    /// owner of token account containing master token
308    #[inline(always)]
309    pub fn master_token_account_owner(
310        &mut self,
311        master_token_account_owner: solana_program::pubkey::Pubkey,
312        as_signer: bool,
313    ) -> &mut Self {
314        self.master_token_account_owner = Some((master_token_account_owner, as_signer));
315        self
316    }
317    /// token account containing token from master metadata mint
318    #[inline(always)]
319    pub fn master_token_account(
320        &mut self,
321        master_token_account: solana_program::pubkey::Pubkey,
322    ) -> &mut Self {
323        self.master_token_account = Some(master_token_account);
324        self
325    }
326    /// Master record metadata account
327    #[inline(always)]
328    pub fn master_metadata(
329        &mut self,
330        master_metadata: solana_program::pubkey::Pubkey,
331    ) -> &mut Self {
332        self.master_metadata = Some(master_metadata);
333        self
334    }
335    /// The update authority of the master edition.
336    #[inline(always)]
337    pub fn update_authority(
338        &mut self,
339        update_authority: solana_program::pubkey::Pubkey,
340    ) -> &mut Self {
341        self.update_authority = Some(update_authority);
342        self
343    }
344    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
345    /// Token program
346    #[inline(always)]
347    pub fn spl_token_program(
348        &mut self,
349        spl_token_program: solana_program::pubkey::Pubkey,
350    ) -> &mut Self {
351        self.spl_token_program = Some(spl_token_program);
352        self
353    }
354    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
355    /// SPL Associated Token Account program
356    #[inline(always)]
357    pub fn spl_ata_program(
358        &mut self,
359        spl_ata_program: solana_program::pubkey::Pubkey,
360    ) -> &mut Self {
361        self.spl_ata_program = Some(spl_ata_program);
362        self
363    }
364    /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']`
365    /// Instructions sysvar account
366    #[inline(always)]
367    pub fn sysvar_instructions(
368        &mut self,
369        sysvar_instructions: solana_program::pubkey::Pubkey,
370    ) -> &mut Self {
371        self.sysvar_instructions = Some(sysvar_instructions);
372        self
373    }
374    /// `[optional account, default to '11111111111111111111111111111111']`
375    /// System program
376    #[inline(always)]
377    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
378        self.system_program = Some(system_program);
379        self
380    }
381    #[inline(always)]
382    pub fn print_args(&mut self, print_args: PrintArgs) -> &mut Self {
383        self.print_args = Some(print_args);
384        self
385    }
386    /// Add an aditional account to the instruction.
387    #[inline(always)]
388    pub fn add_remaining_account(
389        &mut self,
390        account: solana_program::instruction::AccountMeta,
391    ) -> &mut Self {
392        self.__remaining_accounts.push(account);
393        self
394    }
395    /// Add additional accounts to the instruction.
396    #[inline(always)]
397    pub fn add_remaining_accounts(
398        &mut self,
399        accounts: &[solana_program::instruction::AccountMeta],
400    ) -> &mut Self {
401        self.__remaining_accounts.extend_from_slice(accounts);
402        self
403    }
404    #[allow(clippy::clone_on_copy)]
405    pub fn instruction(&self) -> solana_program::instruction::Instruction {
406        let accounts = Print {
407            edition_metadata: self.edition_metadata.expect("edition_metadata is not set"),
408            edition: self.edition.expect("edition is not set"),
409            edition_mint: self.edition_mint.expect("edition_mint is not set"),
410            edition_token_account_owner: self
411                .edition_token_account_owner
412                .expect("edition_token_account_owner is not set"),
413            edition_token_account: self
414                .edition_token_account
415                .expect("edition_token_account is not set"),
416            edition_mint_authority: self
417                .edition_mint_authority
418                .expect("edition_mint_authority is not set"),
419            edition_token_record: self.edition_token_record,
420            master_edition: self.master_edition.expect("master_edition is not set"),
421            edition_marker_pda: self
422                .edition_marker_pda
423                .expect("edition_marker_pda is not set"),
424            payer: self.payer.expect("payer is not set"),
425            master_token_account_owner: self
426                .master_token_account_owner
427                .expect("master_token_account_owner is not set"),
428            master_token_account: self
429                .master_token_account
430                .expect("master_token_account is not set"),
431            master_metadata: self.master_metadata.expect("master_metadata is not set"),
432            update_authority: self.update_authority.expect("update_authority is not set"),
433            spl_token_program: self.spl_token_program.unwrap_or(solana_program::pubkey!(
434                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
435            )),
436            spl_ata_program: self.spl_ata_program.unwrap_or(solana_program::pubkey!(
437                "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
438            )),
439            sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
440                "Sysvar1nstructions1111111111111111111111111"
441            )),
442            system_program: self
443                .system_program
444                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
445        };
446        let args = PrintInstructionArgs {
447            print_args: self.print_args.clone().expect("print_args is not set"),
448        };
449
450        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
451    }
452}
453
454/// `print` CPI accounts.
455pub struct PrintCpiAccounts<'a, 'b> {
456    /// New Metadata key (pda of ['metadata', program id, mint id])
457    pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
458    /// New Edition (pda of ['metadata', program id, mint id, 'edition'])
459    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
460    /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY
461    pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
462    /// Owner of the token account of new token
463    pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
464    /// Token account of new token
465    pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
466    /// Mint authority of new mint
467    pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
468    /// Token record account
469    pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
470    /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'])
471    pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
472    /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE).
473    pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
474    /// payer
475    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
476    /// owner of token account containing master token
477    pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
478    /// token account containing token from master metadata mint
479    pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
480    /// Master record metadata account
481    pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
482    /// The update authority of the master edition.
483    pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
484    /// Token program
485    pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
486    /// SPL Associated Token Account program
487    pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
488    /// Instructions sysvar account
489    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
490    /// System program
491    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
492}
493
494/// `print` CPI instruction.
495pub struct PrintCpi<'a, 'b> {
496    /// The program to invoke.
497    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
498    /// New Metadata key (pda of ['metadata', program id, mint id])
499    pub edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
500    /// New Edition (pda of ['metadata', program id, mint id, 'edition'])
501    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
502    /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY
503    pub edition_mint: (&'b solana_program::account_info::AccountInfo<'a>, bool),
504    /// Owner of the token account of new token
505    pub edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
506    /// Token account of new token
507    pub edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
508    /// Mint authority of new mint
509    pub edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
510    /// Token record account
511    pub edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
512    /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'])
513    pub master_edition: &'b solana_program::account_info::AccountInfo<'a>,
514    /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE).
515    pub edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
516    /// payer
517    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
518    /// owner of token account containing master token
519    pub master_token_account_owner: (&'b solana_program::account_info::AccountInfo<'a>, bool),
520    /// token account containing token from master metadata mint
521    pub master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
522    /// Master record metadata account
523    pub master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
524    /// The update authority of the master edition.
525    pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
526    /// Token program
527    pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
528    /// SPL Associated Token Account program
529    pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
530    /// Instructions sysvar account
531    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
532    /// System program
533    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
534    /// The arguments for the instruction.
535    pub __args: PrintInstructionArgs,
536}
537
538impl<'a, 'b> PrintCpi<'a, 'b> {
539    pub fn new(
540        program: &'b solana_program::account_info::AccountInfo<'a>,
541        accounts: PrintCpiAccounts<'a, 'b>,
542        args: PrintInstructionArgs,
543    ) -> Self {
544        Self {
545            __program: program,
546            edition_metadata: accounts.edition_metadata,
547            edition: accounts.edition,
548            edition_mint: accounts.edition_mint,
549            edition_token_account_owner: accounts.edition_token_account_owner,
550            edition_token_account: accounts.edition_token_account,
551            edition_mint_authority: accounts.edition_mint_authority,
552            edition_token_record: accounts.edition_token_record,
553            master_edition: accounts.master_edition,
554            edition_marker_pda: accounts.edition_marker_pda,
555            payer: accounts.payer,
556            master_token_account_owner: accounts.master_token_account_owner,
557            master_token_account: accounts.master_token_account,
558            master_metadata: accounts.master_metadata,
559            update_authority: accounts.update_authority,
560            spl_token_program: accounts.spl_token_program,
561            spl_ata_program: accounts.spl_ata_program,
562            sysvar_instructions: accounts.sysvar_instructions,
563            system_program: accounts.system_program,
564            __args: args,
565        }
566    }
567    #[inline(always)]
568    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
569        self.invoke_signed_with_remaining_accounts(&[], &[])
570    }
571    #[inline(always)]
572    pub fn invoke_with_remaining_accounts(
573        &self,
574        remaining_accounts: &[(
575            &'b solana_program::account_info::AccountInfo<'a>,
576            bool,
577            bool,
578        )],
579    ) -> solana_program::entrypoint::ProgramResult {
580        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
581    }
582    #[inline(always)]
583    pub fn invoke_signed(
584        &self,
585        signers_seeds: &[&[&[u8]]],
586    ) -> solana_program::entrypoint::ProgramResult {
587        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
588    }
589    #[allow(clippy::clone_on_copy)]
590    #[allow(clippy::vec_init_then_push)]
591    pub fn invoke_signed_with_remaining_accounts(
592        &self,
593        signers_seeds: &[&[&[u8]]],
594        remaining_accounts: &[(
595            &'b solana_program::account_info::AccountInfo<'a>,
596            bool,
597            bool,
598        )],
599    ) -> solana_program::entrypoint::ProgramResult {
600        let mut accounts = Vec::with_capacity(18 + remaining_accounts.len());
601        accounts.push(solana_program::instruction::AccountMeta::new(
602            *self.edition_metadata.key,
603            false,
604        ));
605        accounts.push(solana_program::instruction::AccountMeta::new(
606            *self.edition.key,
607            false,
608        ));
609        accounts.push(solana_program::instruction::AccountMeta::new(
610            *self.edition_mint.0.key,
611            self.edition_mint.1,
612        ));
613        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
614            *self.edition_token_account_owner.key,
615            false,
616        ));
617        accounts.push(solana_program::instruction::AccountMeta::new(
618            *self.edition_token_account.key,
619            false,
620        ));
621        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
622            *self.edition_mint_authority.key,
623            true,
624        ));
625        if let Some(edition_token_record) = self.edition_token_record {
626            accounts.push(solana_program::instruction::AccountMeta::new(
627                *edition_token_record.key,
628                false,
629            ));
630        } else {
631            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
632                crate::MPL_TOKEN_METADATA_ID,
633                false,
634            ));
635        }
636        accounts.push(solana_program::instruction::AccountMeta::new(
637            *self.master_edition.key,
638            false,
639        ));
640        accounts.push(solana_program::instruction::AccountMeta::new(
641            *self.edition_marker_pda.key,
642            false,
643        ));
644        accounts.push(solana_program::instruction::AccountMeta::new(
645            *self.payer.key,
646            true,
647        ));
648        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
649            *self.master_token_account_owner.0.key,
650            self.master_token_account_owner.1,
651        ));
652        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
653            *self.master_token_account.key,
654            false,
655        ));
656        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
657            *self.master_metadata.key,
658            false,
659        ));
660        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
661            *self.update_authority.key,
662            false,
663        ));
664        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
665            *self.spl_token_program.key,
666            false,
667        ));
668        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
669            *self.spl_ata_program.key,
670            false,
671        ));
672        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
673            *self.sysvar_instructions.key,
674            false,
675        ));
676        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
677            *self.system_program.key,
678            false,
679        ));
680        remaining_accounts.iter().for_each(|remaining_account| {
681            accounts.push(solana_program::instruction::AccountMeta {
682                pubkey: *remaining_account.0.key,
683                is_signer: remaining_account.1,
684                is_writable: remaining_account.2,
685            })
686        });
687        let mut data = PrintInstructionData::new().try_to_vec().unwrap();
688        let mut args = self.__args.try_to_vec().unwrap();
689        data.append(&mut args);
690
691        let instruction = solana_program::instruction::Instruction {
692            program_id: crate::MPL_TOKEN_METADATA_ID,
693            accounts,
694            data,
695        };
696        let mut account_infos = Vec::with_capacity(18 + 1 + remaining_accounts.len());
697        account_infos.push(self.__program.clone());
698        account_infos.push(self.edition_metadata.clone());
699        account_infos.push(self.edition.clone());
700        account_infos.push(self.edition_mint.0.clone());
701        account_infos.push(self.edition_token_account_owner.clone());
702        account_infos.push(self.edition_token_account.clone());
703        account_infos.push(self.edition_mint_authority.clone());
704        if let Some(edition_token_record) = self.edition_token_record {
705            account_infos.push(edition_token_record.clone());
706        }
707        account_infos.push(self.master_edition.clone());
708        account_infos.push(self.edition_marker_pda.clone());
709        account_infos.push(self.payer.clone());
710        account_infos.push(self.master_token_account_owner.0.clone());
711        account_infos.push(self.master_token_account.clone());
712        account_infos.push(self.master_metadata.clone());
713        account_infos.push(self.update_authority.clone());
714        account_infos.push(self.spl_token_program.clone());
715        account_infos.push(self.spl_ata_program.clone());
716        account_infos.push(self.sysvar_instructions.clone());
717        account_infos.push(self.system_program.clone());
718        remaining_accounts
719            .iter()
720            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
721
722        if signers_seeds.is_empty() {
723            solana_program::program::invoke(&instruction, &account_infos)
724        } else {
725            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
726        }
727    }
728}
729
730/// Instruction builder for `Print` via CPI.
731///
732/// ### Accounts:
733///
734///   0. `[writable]` edition_metadata
735///   1. `[writable]` edition
736///   2. `[writable, signer]` edition_mint
737///   3. `[]` edition_token_account_owner
738///   4. `[writable]` edition_token_account
739///   5. `[signer]` edition_mint_authority
740///   6. `[writable, optional]` edition_token_record
741///   7. `[writable]` master_edition
742///   8. `[writable]` edition_marker_pda
743///   9. `[writable, signer]` payer
744///   10. `[signer]` master_token_account_owner
745///   11. `[]` master_token_account
746///   12. `[]` master_metadata
747///   13. `[]` update_authority
748///   14. `[]` spl_token_program
749///   15. `[]` spl_ata_program
750///   16. `[]` sysvar_instructions
751///   17. `[]` system_program
752pub struct PrintCpiBuilder<'a, 'b> {
753    instruction: Box<PrintCpiBuilderInstruction<'a, 'b>>,
754}
755
756impl<'a, 'b> PrintCpiBuilder<'a, 'b> {
757    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
758        let instruction = Box::new(PrintCpiBuilderInstruction {
759            __program: program,
760            edition_metadata: None,
761            edition: None,
762            edition_mint: None,
763            edition_token_account_owner: None,
764            edition_token_account: None,
765            edition_mint_authority: None,
766            edition_token_record: None,
767            master_edition: None,
768            edition_marker_pda: None,
769            payer: None,
770            master_token_account_owner: None,
771            master_token_account: None,
772            master_metadata: None,
773            update_authority: None,
774            spl_token_program: None,
775            spl_ata_program: None,
776            sysvar_instructions: None,
777            system_program: None,
778            print_args: None,
779            __remaining_accounts: Vec::new(),
780        });
781        Self { instruction }
782    }
783    /// New Metadata key (pda of ['metadata', program id, mint id])
784    #[inline(always)]
785    pub fn edition_metadata(
786        &mut self,
787        edition_metadata: &'b solana_program::account_info::AccountInfo<'a>,
788    ) -> &mut Self {
789        self.instruction.edition_metadata = Some(edition_metadata);
790        self
791    }
792    /// New Edition (pda of ['metadata', program id, mint id, 'edition'])
793    #[inline(always)]
794    pub fn edition(
795        &mut self,
796        edition: &'b solana_program::account_info::AccountInfo<'a>,
797    ) -> &mut Self {
798        self.instruction.edition = Some(edition);
799        self
800    }
801    /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY
802    #[inline(always)]
803    pub fn edition_mint(
804        &mut self,
805        edition_mint: &'b solana_program::account_info::AccountInfo<'a>,
806        as_signer: bool,
807    ) -> &mut Self {
808        self.instruction.edition_mint = Some((edition_mint, as_signer));
809        self
810    }
811    /// Owner of the token account of new token
812    #[inline(always)]
813    pub fn edition_token_account_owner(
814        &mut self,
815        edition_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
816    ) -> &mut Self {
817        self.instruction.edition_token_account_owner = Some(edition_token_account_owner);
818        self
819    }
820    /// Token account of new token
821    #[inline(always)]
822    pub fn edition_token_account(
823        &mut self,
824        edition_token_account: &'b solana_program::account_info::AccountInfo<'a>,
825    ) -> &mut Self {
826        self.instruction.edition_token_account = Some(edition_token_account);
827        self
828    }
829    /// Mint authority of new mint
830    #[inline(always)]
831    pub fn edition_mint_authority(
832        &mut self,
833        edition_mint_authority: &'b solana_program::account_info::AccountInfo<'a>,
834    ) -> &mut Self {
835        self.instruction.edition_mint_authority = Some(edition_mint_authority);
836        self
837    }
838    /// `[optional account]`
839    /// Token record account
840    #[inline(always)]
841    pub fn edition_token_record(
842        &mut self,
843        edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
844    ) -> &mut Self {
845        self.instruction.edition_token_record = edition_token_record;
846        self
847    }
848    /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'])
849    #[inline(always)]
850    pub fn master_edition(
851        &mut self,
852        master_edition: &'b solana_program::account_info::AccountInfo<'a>,
853    ) -> &mut Self {
854        self.instruction.master_edition = Some(master_edition);
855        self
856    }
857    /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE).
858    #[inline(always)]
859    pub fn edition_marker_pda(
860        &mut self,
861        edition_marker_pda: &'b solana_program::account_info::AccountInfo<'a>,
862    ) -> &mut Self {
863        self.instruction.edition_marker_pda = Some(edition_marker_pda);
864        self
865    }
866    /// payer
867    #[inline(always)]
868    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
869        self.instruction.payer = Some(payer);
870        self
871    }
872    /// owner of token account containing master token
873    #[inline(always)]
874    pub fn master_token_account_owner(
875        &mut self,
876        master_token_account_owner: &'b solana_program::account_info::AccountInfo<'a>,
877        as_signer: bool,
878    ) -> &mut Self {
879        self.instruction.master_token_account_owner = Some((master_token_account_owner, as_signer));
880        self
881    }
882    /// token account containing token from master metadata mint
883    #[inline(always)]
884    pub fn master_token_account(
885        &mut self,
886        master_token_account: &'b solana_program::account_info::AccountInfo<'a>,
887    ) -> &mut Self {
888        self.instruction.master_token_account = Some(master_token_account);
889        self
890    }
891    /// Master record metadata account
892    #[inline(always)]
893    pub fn master_metadata(
894        &mut self,
895        master_metadata: &'b solana_program::account_info::AccountInfo<'a>,
896    ) -> &mut Self {
897        self.instruction.master_metadata = Some(master_metadata);
898        self
899    }
900    /// The update authority of the master edition.
901    #[inline(always)]
902    pub fn update_authority(
903        &mut self,
904        update_authority: &'b solana_program::account_info::AccountInfo<'a>,
905    ) -> &mut Self {
906        self.instruction.update_authority = Some(update_authority);
907        self
908    }
909    /// Token program
910    #[inline(always)]
911    pub fn spl_token_program(
912        &mut self,
913        spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
914    ) -> &mut Self {
915        self.instruction.spl_token_program = Some(spl_token_program);
916        self
917    }
918    /// SPL Associated Token Account program
919    #[inline(always)]
920    pub fn spl_ata_program(
921        &mut self,
922        spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
923    ) -> &mut Self {
924        self.instruction.spl_ata_program = Some(spl_ata_program);
925        self
926    }
927    /// Instructions sysvar account
928    #[inline(always)]
929    pub fn sysvar_instructions(
930        &mut self,
931        sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
932    ) -> &mut Self {
933        self.instruction.sysvar_instructions = Some(sysvar_instructions);
934        self
935    }
936    /// System program
937    #[inline(always)]
938    pub fn system_program(
939        &mut self,
940        system_program: &'b solana_program::account_info::AccountInfo<'a>,
941    ) -> &mut Self {
942        self.instruction.system_program = Some(system_program);
943        self
944    }
945    #[inline(always)]
946    pub fn print_args(&mut self, print_args: PrintArgs) -> &mut Self {
947        self.instruction.print_args = Some(print_args);
948        self
949    }
950    /// Add an additional account to the instruction.
951    #[inline(always)]
952    pub fn add_remaining_account(
953        &mut self,
954        account: &'b solana_program::account_info::AccountInfo<'a>,
955        is_writable: bool,
956        is_signer: bool,
957    ) -> &mut Self {
958        self.instruction
959            .__remaining_accounts
960            .push((account, is_writable, is_signer));
961        self
962    }
963    /// Add additional accounts to the instruction.
964    ///
965    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
966    /// and a `bool` indicating whether the account is a signer or not.
967    #[inline(always)]
968    pub fn add_remaining_accounts(
969        &mut self,
970        accounts: &[(
971            &'b solana_program::account_info::AccountInfo<'a>,
972            bool,
973            bool,
974        )],
975    ) -> &mut Self {
976        self.instruction
977            .__remaining_accounts
978            .extend_from_slice(accounts);
979        self
980    }
981    #[inline(always)]
982    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
983        self.invoke_signed(&[])
984    }
985    #[allow(clippy::clone_on_copy)]
986    #[allow(clippy::vec_init_then_push)]
987    pub fn invoke_signed(
988        &self,
989        signers_seeds: &[&[&[u8]]],
990    ) -> solana_program::entrypoint::ProgramResult {
991        let args = PrintInstructionArgs {
992            print_args: self
993                .instruction
994                .print_args
995                .clone()
996                .expect("print_args is not set"),
997        };
998        let instruction = PrintCpi {
999            __program: self.instruction.__program,
1000
1001            edition_metadata: self
1002                .instruction
1003                .edition_metadata
1004                .expect("edition_metadata is not set"),
1005
1006            edition: self.instruction.edition.expect("edition is not set"),
1007
1008            edition_mint: self
1009                .instruction
1010                .edition_mint
1011                .expect("edition_mint is not set"),
1012
1013            edition_token_account_owner: self
1014                .instruction
1015                .edition_token_account_owner
1016                .expect("edition_token_account_owner is not set"),
1017
1018            edition_token_account: self
1019                .instruction
1020                .edition_token_account
1021                .expect("edition_token_account is not set"),
1022
1023            edition_mint_authority: self
1024                .instruction
1025                .edition_mint_authority
1026                .expect("edition_mint_authority is not set"),
1027
1028            edition_token_record: self.instruction.edition_token_record,
1029
1030            master_edition: self
1031                .instruction
1032                .master_edition
1033                .expect("master_edition is not set"),
1034
1035            edition_marker_pda: self
1036                .instruction
1037                .edition_marker_pda
1038                .expect("edition_marker_pda is not set"),
1039
1040            payer: self.instruction.payer.expect("payer is not set"),
1041
1042            master_token_account_owner: self
1043                .instruction
1044                .master_token_account_owner
1045                .expect("master_token_account_owner is not set"),
1046
1047            master_token_account: self
1048                .instruction
1049                .master_token_account
1050                .expect("master_token_account is not set"),
1051
1052            master_metadata: self
1053                .instruction
1054                .master_metadata
1055                .expect("master_metadata is not set"),
1056
1057            update_authority: self
1058                .instruction
1059                .update_authority
1060                .expect("update_authority is not set"),
1061
1062            spl_token_program: self
1063                .instruction
1064                .spl_token_program
1065                .expect("spl_token_program is not set"),
1066
1067            spl_ata_program: self
1068                .instruction
1069                .spl_ata_program
1070                .expect("spl_ata_program is not set"),
1071
1072            sysvar_instructions: self
1073                .instruction
1074                .sysvar_instructions
1075                .expect("sysvar_instructions is not set"),
1076
1077            system_program: self
1078                .instruction
1079                .system_program
1080                .expect("system_program is not set"),
1081            __args: args,
1082        };
1083        instruction.invoke_signed_with_remaining_accounts(
1084            signers_seeds,
1085            &self.instruction.__remaining_accounts,
1086        )
1087    }
1088}
1089
1090struct PrintCpiBuilderInstruction<'a, 'b> {
1091    __program: &'b solana_program::account_info::AccountInfo<'a>,
1092    edition_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1093    edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1094    edition_mint: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
1095    edition_token_account_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1096    edition_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1097    edition_mint_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1098    edition_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1099    master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1100    edition_marker_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1101    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1102    master_token_account_owner: Option<(&'b solana_program::account_info::AccountInfo<'a>, bool)>,
1103    master_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1104    master_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1105    update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1106    spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1107    spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1108    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1109    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1110    print_args: Option<PrintArgs>,
1111    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
1112    __remaining_accounts: Vec<(
1113        &'b solana_program::account_info::AccountInfo<'a>,
1114        bool,
1115        bool,
1116    )>,
1117}