Skip to main content

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