Skip to main content

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