mpl_core/generated/instructions/
create_v2.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::DataState;
9use crate::generated::types::ExternalPluginAdapterInitInfo;
10use crate::generated::types::PluginAuthorityPair;
11#[cfg(feature = "anchor")]
12use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
13#[cfg(not(feature = "anchor"))]
14use borsh::{BorshDeserialize, BorshSerialize};
15
16/// Accounts.
17pub struct CreateV2 {
18    /// The address of the new asset
19    pub asset: solana_program::pubkey::Pubkey,
20    /// The collection to which the asset belongs
21    pub collection: Option<solana_program::pubkey::Pubkey>,
22    /// The authority signing for creation
23    pub authority: Option<solana_program::pubkey::Pubkey>,
24    /// The account paying for the storage fees
25    pub payer: solana_program::pubkey::Pubkey,
26    /// The owner of the new asset. Defaults to the authority if not present.
27    pub owner: Option<solana_program::pubkey::Pubkey>,
28    /// The authority on the new asset
29    pub update_authority: Option<solana_program::pubkey::Pubkey>,
30    /// The system program
31    pub system_program: solana_program::pubkey::Pubkey,
32    /// The SPL Noop Program
33    pub log_wrapper: Option<solana_program::pubkey::Pubkey>,
34}
35
36impl CreateV2 {
37    pub fn instruction(
38        &self,
39        args: CreateV2InstructionArgs,
40    ) -> solana_program::instruction::Instruction {
41        self.instruction_with_remaining_accounts(args, &[])
42    }
43    #[allow(clippy::vec_init_then_push)]
44    pub fn instruction_with_remaining_accounts(
45        &self,
46        args: CreateV2InstructionArgs,
47        remaining_accounts: &[solana_program::instruction::AccountMeta],
48    ) -> solana_program::instruction::Instruction {
49        let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
50        accounts.push(solana_program::instruction::AccountMeta::new(
51            self.asset, true,
52        ));
53        if let Some(collection) = self.collection {
54            accounts.push(solana_program::instruction::AccountMeta::new(
55                collection, false,
56            ));
57        } else {
58            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59                crate::MPL_CORE_ID,
60                false,
61            ));
62        }
63        if let Some(authority) = self.authority {
64            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65                authority, true,
66            ));
67        } else {
68            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
69                crate::MPL_CORE_ID,
70                false,
71            ));
72        }
73        accounts.push(solana_program::instruction::AccountMeta::new(
74            self.payer, true,
75        ));
76        if let Some(owner) = self.owner {
77            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
78                owner, false,
79            ));
80        } else {
81            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82                crate::MPL_CORE_ID,
83                false,
84            ));
85        }
86        if let Some(update_authority) = self.update_authority {
87            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
88                update_authority,
89                false,
90            ));
91        } else {
92            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
93                crate::MPL_CORE_ID,
94                false,
95            ));
96        }
97        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
98            self.system_program,
99            false,
100        ));
101        if let Some(log_wrapper) = self.log_wrapper {
102            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
103                log_wrapper,
104                false,
105            ));
106        } else {
107            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
108                crate::MPL_CORE_ID,
109                false,
110            ));
111        }
112        accounts.extend_from_slice(remaining_accounts);
113        let mut data = CreateV2InstructionData::new().try_to_vec().unwrap();
114        let mut args = args.try_to_vec().unwrap();
115        data.append(&mut args);
116
117        solana_program::instruction::Instruction {
118            program_id: crate::MPL_CORE_ID,
119            accounts,
120            data,
121        }
122    }
123}
124
125#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
126#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
127pub struct CreateV2InstructionData {
128    discriminator: u8,
129}
130
131impl CreateV2InstructionData {
132    pub fn new() -> Self {
133        Self { discriminator: 20 }
134    }
135}
136
137#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
138#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
139#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
140#[derive(Clone, Debug, Eq, PartialEq)]
141pub struct CreateV2InstructionArgs {
142    pub data_state: DataState,
143    pub name: String,
144    pub uri: String,
145    pub plugins: Option<Vec<PluginAuthorityPair>>,
146    pub external_plugin_adapters: Option<Vec<ExternalPluginAdapterInitInfo>>,
147}
148
149/// Instruction builder for `CreateV2`.
150///
151/// ### Accounts:
152///
153///   0. `[writable, signer]` asset
154///   1. `[writable, optional]` collection
155///   2. `[signer, optional]` authority
156///   3. `[writable, signer]` payer
157///   4. `[optional]` owner
158///   5. `[optional]` update_authority
159///   6. `[optional]` system_program (default to `11111111111111111111111111111111`)
160///   7. `[optional]` log_wrapper
161#[derive(Default)]
162pub struct CreateV2Builder {
163    asset: Option<solana_program::pubkey::Pubkey>,
164    collection: Option<solana_program::pubkey::Pubkey>,
165    authority: Option<solana_program::pubkey::Pubkey>,
166    payer: Option<solana_program::pubkey::Pubkey>,
167    owner: Option<solana_program::pubkey::Pubkey>,
168    update_authority: Option<solana_program::pubkey::Pubkey>,
169    system_program: Option<solana_program::pubkey::Pubkey>,
170    log_wrapper: Option<solana_program::pubkey::Pubkey>,
171    data_state: Option<DataState>,
172    name: Option<String>,
173    uri: Option<String>,
174    plugins: Option<Vec<PluginAuthorityPair>>,
175    external_plugin_adapters: Option<Vec<ExternalPluginAdapterInitInfo>>,
176    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
177}
178
179impl CreateV2Builder {
180    pub fn new() -> Self {
181        Self::default()
182    }
183    /// The address of the new asset
184    #[inline(always)]
185    pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self {
186        self.asset = Some(asset);
187        self
188    }
189    /// `[optional account]`
190    /// The collection to which the asset belongs
191    #[inline(always)]
192    pub fn collection(&mut self, collection: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
193        self.collection = collection;
194        self
195    }
196    /// `[optional account]`
197    /// The authority signing for creation
198    #[inline(always)]
199    pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
200        self.authority = authority;
201        self
202    }
203    /// The account paying for the storage fees
204    #[inline(always)]
205    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
206        self.payer = Some(payer);
207        self
208    }
209    /// `[optional account]`
210    /// The owner of the new asset. Defaults to the authority if not present.
211    #[inline(always)]
212    pub fn owner(&mut self, owner: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
213        self.owner = owner;
214        self
215    }
216    /// `[optional account]`
217    /// The authority on the new asset
218    #[inline(always)]
219    pub fn update_authority(
220        &mut self,
221        update_authority: Option<solana_program::pubkey::Pubkey>,
222    ) -> &mut Self {
223        self.update_authority = update_authority;
224        self
225    }
226    /// `[optional account, default to '11111111111111111111111111111111']`
227    /// The system program
228    #[inline(always)]
229    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
230        self.system_program = Some(system_program);
231        self
232    }
233    /// `[optional account]`
234    /// The SPL Noop Program
235    #[inline(always)]
236    pub fn log_wrapper(
237        &mut self,
238        log_wrapper: Option<solana_program::pubkey::Pubkey>,
239    ) -> &mut Self {
240        self.log_wrapper = log_wrapper;
241        self
242    }
243    /// `[optional argument, defaults to 'DataState::AccountState']`
244    #[inline(always)]
245    pub fn data_state(&mut self, data_state: DataState) -> &mut Self {
246        self.data_state = Some(data_state);
247        self
248    }
249    #[inline(always)]
250    pub fn name(&mut self, name: String) -> &mut Self {
251        self.name = Some(name);
252        self
253    }
254    #[inline(always)]
255    pub fn uri(&mut self, uri: String) -> &mut Self {
256        self.uri = Some(uri);
257        self
258    }
259    /// `[optional argument]`
260    #[inline(always)]
261    pub fn plugins(&mut self, plugins: Vec<PluginAuthorityPair>) -> &mut Self {
262        self.plugins = Some(plugins);
263        self
264    }
265    /// `[optional argument]`
266    #[inline(always)]
267    pub fn external_plugin_adapters(
268        &mut self,
269        external_plugin_adapters: Vec<ExternalPluginAdapterInitInfo>,
270    ) -> &mut Self {
271        self.external_plugin_adapters = Some(external_plugin_adapters);
272        self
273    }
274    /// Add an aditional account to the instruction.
275    #[inline(always)]
276    pub fn add_remaining_account(
277        &mut self,
278        account: solana_program::instruction::AccountMeta,
279    ) -> &mut Self {
280        self.__remaining_accounts.push(account);
281        self
282    }
283    /// Add additional accounts to the instruction.
284    #[inline(always)]
285    pub fn add_remaining_accounts(
286        &mut self,
287        accounts: &[solana_program::instruction::AccountMeta],
288    ) -> &mut Self {
289        self.__remaining_accounts.extend_from_slice(accounts);
290        self
291    }
292    #[allow(clippy::clone_on_copy)]
293    pub fn instruction(&self) -> solana_program::instruction::Instruction {
294        let accounts = CreateV2 {
295            asset: self.asset.expect("asset is not set"),
296            collection: self.collection,
297            authority: self.authority,
298            payer: self.payer.expect("payer is not set"),
299            owner: self.owner,
300            update_authority: self.update_authority,
301            system_program: self
302                .system_program
303                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
304            log_wrapper: self.log_wrapper,
305        };
306        let args = CreateV2InstructionArgs {
307            data_state: self.data_state.clone().unwrap_or(DataState::AccountState),
308            name: self.name.clone().expect("name is not set"),
309            uri: self.uri.clone().expect("uri is not set"),
310            plugins: self.plugins.clone(),
311            external_plugin_adapters: self.external_plugin_adapters.clone(),
312        };
313
314        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
315    }
316}
317
318/// `create_v2` CPI accounts.
319pub struct CreateV2CpiAccounts<'a, 'b> {
320    /// The address of the new asset
321    pub asset: &'b solana_program::account_info::AccountInfo<'a>,
322    /// The collection to which the asset belongs
323    pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
324    /// The authority signing for creation
325    pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
326    /// The account paying for the storage fees
327    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
328    /// The owner of the new asset. Defaults to the authority if not present.
329    pub owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
330    /// The authority on the new asset
331    pub update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
332    /// The system program
333    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
334    /// The SPL Noop Program
335    pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
336}
337
338/// `create_v2` CPI instruction.
339pub struct CreateV2Cpi<'a, 'b> {
340    /// The program to invoke.
341    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
342    /// The address of the new asset
343    pub asset: &'b solana_program::account_info::AccountInfo<'a>,
344    /// The collection to which the asset belongs
345    pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
346    /// The authority signing for creation
347    pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
348    /// The account paying for the storage fees
349    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
350    /// The owner of the new asset. Defaults to the authority if not present.
351    pub owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
352    /// The authority on the new asset
353    pub update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
354    /// The system program
355    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
356    /// The SPL Noop Program
357    pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
358    /// The arguments for the instruction.
359    pub __args: CreateV2InstructionArgs,
360}
361
362impl<'a, 'b> CreateV2Cpi<'a, 'b> {
363    pub fn new(
364        program: &'b solana_program::account_info::AccountInfo<'a>,
365        accounts: CreateV2CpiAccounts<'a, 'b>,
366        args: CreateV2InstructionArgs,
367    ) -> Self {
368        Self {
369            __program: program,
370            asset: accounts.asset,
371            collection: accounts.collection,
372            authority: accounts.authority,
373            payer: accounts.payer,
374            owner: accounts.owner,
375            update_authority: accounts.update_authority,
376            system_program: accounts.system_program,
377            log_wrapper: accounts.log_wrapper,
378            __args: args,
379        }
380    }
381    #[inline(always)]
382    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
383        self.invoke_signed_with_remaining_accounts(&[], &[])
384    }
385    #[inline(always)]
386    pub fn invoke_with_remaining_accounts(
387        &self,
388        remaining_accounts: &[(
389            &'b solana_program::account_info::AccountInfo<'a>,
390            bool,
391            bool,
392        )],
393    ) -> solana_program::entrypoint::ProgramResult {
394        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
395    }
396    #[inline(always)]
397    pub fn invoke_signed(
398        &self,
399        signers_seeds: &[&[&[u8]]],
400    ) -> solana_program::entrypoint::ProgramResult {
401        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
402    }
403    #[allow(clippy::clone_on_copy)]
404    #[allow(clippy::vec_init_then_push)]
405    pub fn invoke_signed_with_remaining_accounts(
406        &self,
407        signers_seeds: &[&[&[u8]]],
408        remaining_accounts: &[(
409            &'b solana_program::account_info::AccountInfo<'a>,
410            bool,
411            bool,
412        )],
413    ) -> solana_program::entrypoint::ProgramResult {
414        let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
415        accounts.push(solana_program::instruction::AccountMeta::new(
416            *self.asset.key,
417            true,
418        ));
419        if let Some(collection) = self.collection {
420            accounts.push(solana_program::instruction::AccountMeta::new(
421                *collection.key,
422                false,
423            ));
424        } else {
425            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
426                crate::MPL_CORE_ID,
427                false,
428            ));
429        }
430        if let Some(authority) = self.authority {
431            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
432                *authority.key,
433                true,
434            ));
435        } else {
436            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
437                crate::MPL_CORE_ID,
438                false,
439            ));
440        }
441        accounts.push(solana_program::instruction::AccountMeta::new(
442            *self.payer.key,
443            true,
444        ));
445        if let Some(owner) = self.owner {
446            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
447                *owner.key, false,
448            ));
449        } else {
450            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
451                crate::MPL_CORE_ID,
452                false,
453            ));
454        }
455        if let Some(update_authority) = self.update_authority {
456            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
457                *update_authority.key,
458                false,
459            ));
460        } else {
461            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
462                crate::MPL_CORE_ID,
463                false,
464            ));
465        }
466        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
467            *self.system_program.key,
468            false,
469        ));
470        if let Some(log_wrapper) = self.log_wrapper {
471            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
472                *log_wrapper.key,
473                false,
474            ));
475        } else {
476            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
477                crate::MPL_CORE_ID,
478                false,
479            ));
480        }
481        remaining_accounts.iter().for_each(|remaining_account| {
482            accounts.push(solana_program::instruction::AccountMeta {
483                pubkey: *remaining_account.0.key,
484                is_signer: remaining_account.1,
485                is_writable: remaining_account.2,
486            })
487        });
488        let mut data = CreateV2InstructionData::new().try_to_vec().unwrap();
489        let mut args = self.__args.try_to_vec().unwrap();
490        data.append(&mut args);
491
492        let instruction = solana_program::instruction::Instruction {
493            program_id: crate::MPL_CORE_ID,
494            accounts,
495            data,
496        };
497        let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len());
498        account_infos.push(self.__program.clone());
499        account_infos.push(self.asset.clone());
500        if let Some(collection) = self.collection {
501            account_infos.push(collection.clone());
502        }
503        if let Some(authority) = self.authority {
504            account_infos.push(authority.clone());
505        }
506        account_infos.push(self.payer.clone());
507        if let Some(owner) = self.owner {
508            account_infos.push(owner.clone());
509        }
510        if let Some(update_authority) = self.update_authority {
511            account_infos.push(update_authority.clone());
512        }
513        account_infos.push(self.system_program.clone());
514        if let Some(log_wrapper) = self.log_wrapper {
515            account_infos.push(log_wrapper.clone());
516        }
517        remaining_accounts
518            .iter()
519            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
520
521        if signers_seeds.is_empty() {
522            solana_program::program::invoke(&instruction, &account_infos)
523        } else {
524            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
525        }
526    }
527}
528
529/// Instruction builder for `CreateV2` via CPI.
530///
531/// ### Accounts:
532///
533///   0. `[writable, signer]` asset
534///   1. `[writable, optional]` collection
535///   2. `[signer, optional]` authority
536///   3. `[writable, signer]` payer
537///   4. `[optional]` owner
538///   5. `[optional]` update_authority
539///   6. `[]` system_program
540///   7. `[optional]` log_wrapper
541pub struct CreateV2CpiBuilder<'a, 'b> {
542    instruction: Box<CreateV2CpiBuilderInstruction<'a, 'b>>,
543}
544
545impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> {
546    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
547        let instruction = Box::new(CreateV2CpiBuilderInstruction {
548            __program: program,
549            asset: None,
550            collection: None,
551            authority: None,
552            payer: None,
553            owner: None,
554            update_authority: None,
555            system_program: None,
556            log_wrapper: None,
557            data_state: None,
558            name: None,
559            uri: None,
560            plugins: None,
561            external_plugin_adapters: None,
562            __remaining_accounts: Vec::new(),
563        });
564        Self { instruction }
565    }
566    /// The address of the new asset
567    #[inline(always)]
568    pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
569        self.instruction.asset = Some(asset);
570        self
571    }
572    /// `[optional account]`
573    /// The collection to which the asset belongs
574    #[inline(always)]
575    pub fn collection(
576        &mut self,
577        collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
578    ) -> &mut Self {
579        self.instruction.collection = collection;
580        self
581    }
582    /// `[optional account]`
583    /// The authority signing for creation
584    #[inline(always)]
585    pub fn authority(
586        &mut self,
587        authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
588    ) -> &mut Self {
589        self.instruction.authority = authority;
590        self
591    }
592    /// The account paying for the storage fees
593    #[inline(always)]
594    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
595        self.instruction.payer = Some(payer);
596        self
597    }
598    /// `[optional account]`
599    /// The owner of the new asset. Defaults to the authority if not present.
600    #[inline(always)]
601    pub fn owner(
602        &mut self,
603        owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
604    ) -> &mut Self {
605        self.instruction.owner = owner;
606        self
607    }
608    /// `[optional account]`
609    /// The authority on the new asset
610    #[inline(always)]
611    pub fn update_authority(
612        &mut self,
613        update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
614    ) -> &mut Self {
615        self.instruction.update_authority = update_authority;
616        self
617    }
618    /// The system program
619    #[inline(always)]
620    pub fn system_program(
621        &mut self,
622        system_program: &'b solana_program::account_info::AccountInfo<'a>,
623    ) -> &mut Self {
624        self.instruction.system_program = Some(system_program);
625        self
626    }
627    /// `[optional account]`
628    /// The SPL Noop Program
629    #[inline(always)]
630    pub fn log_wrapper(
631        &mut self,
632        log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
633    ) -> &mut Self {
634        self.instruction.log_wrapper = log_wrapper;
635        self
636    }
637    /// `[optional argument, defaults to 'DataState::AccountState']`
638    #[inline(always)]
639    pub fn data_state(&mut self, data_state: DataState) -> &mut Self {
640        self.instruction.data_state = Some(data_state);
641        self
642    }
643    #[inline(always)]
644    pub fn name(&mut self, name: String) -> &mut Self {
645        self.instruction.name = Some(name);
646        self
647    }
648    #[inline(always)]
649    pub fn uri(&mut self, uri: String) -> &mut Self {
650        self.instruction.uri = Some(uri);
651        self
652    }
653    /// `[optional argument]`
654    #[inline(always)]
655    pub fn plugins(&mut self, plugins: Vec<PluginAuthorityPair>) -> &mut Self {
656        self.instruction.plugins = Some(plugins);
657        self
658    }
659    /// `[optional argument]`
660    #[inline(always)]
661    pub fn external_plugin_adapters(
662        &mut self,
663        external_plugin_adapters: Vec<ExternalPluginAdapterInitInfo>,
664    ) -> &mut Self {
665        self.instruction.external_plugin_adapters = Some(external_plugin_adapters);
666        self
667    }
668    /// Add an additional account to the instruction.
669    #[inline(always)]
670    pub fn add_remaining_account(
671        &mut self,
672        account: &'b solana_program::account_info::AccountInfo<'a>,
673        is_writable: bool,
674        is_signer: bool,
675    ) -> &mut Self {
676        self.instruction
677            .__remaining_accounts
678            .push((account, is_writable, is_signer));
679        self
680    }
681    /// Add additional accounts to the instruction.
682    ///
683    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
684    /// and a `bool` indicating whether the account is a signer or not.
685    #[inline(always)]
686    pub fn add_remaining_accounts(
687        &mut self,
688        accounts: &[(
689            &'b solana_program::account_info::AccountInfo<'a>,
690            bool,
691            bool,
692        )],
693    ) -> &mut Self {
694        self.instruction
695            .__remaining_accounts
696            .extend_from_slice(accounts);
697        self
698    }
699    #[inline(always)]
700    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
701        self.invoke_signed(&[])
702    }
703    #[allow(clippy::clone_on_copy)]
704    #[allow(clippy::vec_init_then_push)]
705    pub fn invoke_signed(
706        &self,
707        signers_seeds: &[&[&[u8]]],
708    ) -> solana_program::entrypoint::ProgramResult {
709        let args = CreateV2InstructionArgs {
710            data_state: self
711                .instruction
712                .data_state
713                .clone()
714                .unwrap_or(DataState::AccountState),
715            name: self.instruction.name.clone().expect("name is not set"),
716            uri: self.instruction.uri.clone().expect("uri is not set"),
717            plugins: self.instruction.plugins.clone(),
718            external_plugin_adapters: self.instruction.external_plugin_adapters.clone(),
719        };
720        let instruction = CreateV2Cpi {
721            __program: self.instruction.__program,
722
723            asset: self.instruction.asset.expect("asset is not set"),
724
725            collection: self.instruction.collection,
726
727            authority: self.instruction.authority,
728
729            payer: self.instruction.payer.expect("payer is not set"),
730
731            owner: self.instruction.owner,
732
733            update_authority: self.instruction.update_authority,
734
735            system_program: self
736                .instruction
737                .system_program
738                .expect("system_program is not set"),
739
740            log_wrapper: self.instruction.log_wrapper,
741            __args: args,
742        };
743        instruction.invoke_signed_with_remaining_accounts(
744            signers_seeds,
745            &self.instruction.__remaining_accounts,
746        )
747    }
748}
749
750struct CreateV2CpiBuilderInstruction<'a, 'b> {
751    __program: &'b solana_program::account_info::AccountInfo<'a>,
752    asset: Option<&'b solana_program::account_info::AccountInfo<'a>>,
753    collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
754    authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
755    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
756    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
757    update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
758    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
759    log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
760    data_state: Option<DataState>,
761    name: Option<String>,
762    uri: Option<String>,
763    plugins: Option<Vec<PluginAuthorityPair>>,
764    external_plugin_adapters: Option<Vec<ExternalPluginAdapterInitInfo>>,
765    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
766    __remaining_accounts: Vec<(
767        &'b solana_program::account_info::AccountInfo<'a>,
768        bool,
769        bool,
770    )>,
771}