Skip to main content

mpl_token_metadata/generated/instructions/
verify_collection_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 VerifyCollectionV1 {
13    /// Creator to verify, collection update authority or delegate
14    pub authority: solana_program::pubkey::Pubkey,
15    /// Delegate record PDA
16    pub delegate_record: Option<solana_program::pubkey::Pubkey>,
17    /// Metadata account
18    pub metadata: solana_program::pubkey::Pubkey,
19    /// Mint of the Collection
20    pub collection_mint: solana_program::pubkey::Pubkey,
21    /// Metadata Account of the Collection
22    pub collection_metadata: Option<solana_program::pubkey::Pubkey>,
23    /// Master Edition Account of the Collection Token
24    pub collection_master_edition: Option<solana_program::pubkey::Pubkey>,
25    /// System program
26    pub system_program: solana_program::pubkey::Pubkey,
27    /// Instructions sysvar account
28    pub sysvar_instructions: solana_program::pubkey::Pubkey,
29}
30
31impl VerifyCollectionV1 {
32    pub fn instruction(&self) -> solana_program::instruction::Instruction {
33        self.instruction_with_remaining_accounts(&[])
34    }
35    #[allow(clippy::vec_init_then_push)]
36    pub fn instruction_with_remaining_accounts(
37        &self,
38        remaining_accounts: &[solana_program::instruction::AccountMeta],
39    ) -> solana_program::instruction::Instruction {
40        let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
41        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
42            self.authority,
43            true,
44        ));
45        if let Some(delegate_record) = self.delegate_record {
46            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
47                delegate_record,
48                false,
49            ));
50        } else {
51            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52                crate::MPL_TOKEN_METADATA_ID,
53                false,
54            ));
55        }
56        accounts.push(solana_program::instruction::AccountMeta::new(
57            self.metadata,
58            false,
59        ));
60        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
61            self.collection_mint,
62            false,
63        ));
64        if let Some(collection_metadata) = self.collection_metadata {
65            accounts.push(solana_program::instruction::AccountMeta::new(
66                collection_metadata,
67                false,
68            ));
69        } else {
70            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
71                crate::MPL_TOKEN_METADATA_ID,
72                false,
73            ));
74        }
75        if let Some(collection_master_edition) = self.collection_master_edition {
76            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
77                collection_master_edition,
78                false,
79            ));
80        } else {
81            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82                crate::MPL_TOKEN_METADATA_ID,
83                false,
84            ));
85        }
86        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
87            self.system_program,
88            false,
89        ));
90        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
91            self.sysvar_instructions,
92            false,
93        ));
94        accounts.extend_from_slice(remaining_accounts);
95        let data = VerifyCollectionV1InstructionData::new()
96            .try_to_vec()
97            .unwrap();
98
99        solana_program::instruction::Instruction {
100            program_id: crate::MPL_TOKEN_METADATA_ID,
101            accounts,
102            data,
103        }
104    }
105}
106
107#[derive(BorshDeserialize, BorshSerialize)]
108struct VerifyCollectionV1InstructionData {
109    discriminator: u8,
110    verify_collection_v1_discriminator: u8,
111}
112
113impl VerifyCollectionV1InstructionData {
114    fn new() -> Self {
115        Self {
116            discriminator: 52,
117            verify_collection_v1_discriminator: 1,
118        }
119    }
120}
121
122/// Instruction builder for `VerifyCollectionV1`.
123///
124/// ### Accounts:
125///
126///   0. `[signer]` authority
127///   1. `[optional]` delegate_record
128///   2. `[writable]` metadata
129///   3. `[]` collection_mint
130///   4. `[writable, optional]` collection_metadata
131///   5. `[optional]` collection_master_edition
132///   6. `[optional]` system_program (default to `11111111111111111111111111111111`)
133///   7. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`)
134#[derive(Default)]
135pub struct VerifyCollectionV1Builder {
136    authority: Option<solana_program::pubkey::Pubkey>,
137    delegate_record: Option<solana_program::pubkey::Pubkey>,
138    metadata: Option<solana_program::pubkey::Pubkey>,
139    collection_mint: Option<solana_program::pubkey::Pubkey>,
140    collection_metadata: Option<solana_program::pubkey::Pubkey>,
141    collection_master_edition: Option<solana_program::pubkey::Pubkey>,
142    system_program: Option<solana_program::pubkey::Pubkey>,
143    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
144    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
145}
146
147impl VerifyCollectionV1Builder {
148    pub fn new() -> Self {
149        Self::default()
150    }
151    /// Creator to verify, collection update authority or delegate
152    #[inline(always)]
153    pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
154        self.authority = Some(authority);
155        self
156    }
157    /// `[optional account]`
158    /// Delegate record PDA
159    #[inline(always)]
160    pub fn delegate_record(
161        &mut self,
162        delegate_record: Option<solana_program::pubkey::Pubkey>,
163    ) -> &mut Self {
164        self.delegate_record = delegate_record;
165        self
166    }
167    /// Metadata account
168    #[inline(always)]
169    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
170        self.metadata = Some(metadata);
171        self
172    }
173    /// Mint of the Collection
174    #[inline(always)]
175    pub fn collection_mint(
176        &mut self,
177        collection_mint: solana_program::pubkey::Pubkey,
178    ) -> &mut Self {
179        self.collection_mint = Some(collection_mint);
180        self
181    }
182    /// `[optional account]`
183    /// Metadata Account of the Collection
184    #[inline(always)]
185    pub fn collection_metadata(
186        &mut self,
187        collection_metadata: Option<solana_program::pubkey::Pubkey>,
188    ) -> &mut Self {
189        self.collection_metadata = collection_metadata;
190        self
191    }
192    /// `[optional account]`
193    /// Master Edition Account of the Collection Token
194    #[inline(always)]
195    pub fn collection_master_edition(
196        &mut self,
197        collection_master_edition: Option<solana_program::pubkey::Pubkey>,
198    ) -> &mut Self {
199        self.collection_master_edition = collection_master_edition;
200        self
201    }
202    /// `[optional account, default to '11111111111111111111111111111111']`
203    /// System program
204    #[inline(always)]
205    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
206        self.system_program = Some(system_program);
207        self
208    }
209    /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']`
210    /// Instructions sysvar account
211    #[inline(always)]
212    pub fn sysvar_instructions(
213        &mut self,
214        sysvar_instructions: solana_program::pubkey::Pubkey,
215    ) -> &mut Self {
216        self.sysvar_instructions = Some(sysvar_instructions);
217        self
218    }
219    /// Add an aditional account to the instruction.
220    #[inline(always)]
221    pub fn add_remaining_account(
222        &mut self,
223        account: solana_program::instruction::AccountMeta,
224    ) -> &mut Self {
225        self.__remaining_accounts.push(account);
226        self
227    }
228    /// Add additional accounts to the instruction.
229    #[inline(always)]
230    pub fn add_remaining_accounts(
231        &mut self,
232        accounts: &[solana_program::instruction::AccountMeta],
233    ) -> &mut Self {
234        self.__remaining_accounts.extend_from_slice(accounts);
235        self
236    }
237    #[allow(clippy::clone_on_copy)]
238    pub fn instruction(&self) -> solana_program::instruction::Instruction {
239        let accounts = VerifyCollectionV1 {
240            authority: self.authority.expect("authority is not set"),
241            delegate_record: self.delegate_record,
242            metadata: self.metadata.expect("metadata is not set"),
243            collection_mint: self.collection_mint.expect("collection_mint is not set"),
244            collection_metadata: self.collection_metadata,
245            collection_master_edition: self.collection_master_edition,
246            system_program: self
247                .system_program
248                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
249            sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
250                "Sysvar1nstructions1111111111111111111111111"
251            )),
252        };
253
254        accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
255    }
256}
257
258/// `verify_collection_v1` CPI accounts.
259pub struct VerifyCollectionV1CpiAccounts<'a, 'b> {
260    /// Creator to verify, collection update authority or delegate
261    pub authority: &'b solana_program::account_info::AccountInfo<'a>,
262    /// Delegate record PDA
263    pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
264    /// Metadata account
265    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
266    /// Mint of the Collection
267    pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
268    /// Metadata Account of the Collection
269    pub collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
270    /// Master Edition Account of the Collection Token
271    pub collection_master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
272    /// System program
273    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
274    /// Instructions sysvar account
275    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
276}
277
278/// `verify_collection_v1` CPI instruction.
279pub struct VerifyCollectionV1Cpi<'a, 'b> {
280    /// The program to invoke.
281    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
282    /// Creator to verify, collection update authority or delegate
283    pub authority: &'b solana_program::account_info::AccountInfo<'a>,
284    /// Delegate record PDA
285    pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
286    /// Metadata account
287    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
288    /// Mint of the Collection
289    pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
290    /// Metadata Account of the Collection
291    pub collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
292    /// Master Edition Account of the Collection Token
293    pub collection_master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
294    /// System program
295    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
296    /// Instructions sysvar account
297    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
298}
299
300impl<'a, 'b> VerifyCollectionV1Cpi<'a, 'b> {
301    pub fn new(
302        program: &'b solana_program::account_info::AccountInfo<'a>,
303        accounts: VerifyCollectionV1CpiAccounts<'a, 'b>,
304    ) -> Self {
305        Self {
306            __program: program,
307            authority: accounts.authority,
308            delegate_record: accounts.delegate_record,
309            metadata: accounts.metadata,
310            collection_mint: accounts.collection_mint,
311            collection_metadata: accounts.collection_metadata,
312            collection_master_edition: accounts.collection_master_edition,
313            system_program: accounts.system_program,
314            sysvar_instructions: accounts.sysvar_instructions,
315        }
316    }
317    #[inline(always)]
318    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
319        self.invoke_signed_with_remaining_accounts(&[], &[])
320    }
321    #[inline(always)]
322    pub fn invoke_with_remaining_accounts(
323        &self,
324        remaining_accounts: &[(
325            &'b solana_program::account_info::AccountInfo<'a>,
326            bool,
327            bool,
328        )],
329    ) -> solana_program::entrypoint::ProgramResult {
330        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
331    }
332    #[inline(always)]
333    pub fn invoke_signed(
334        &self,
335        signers_seeds: &[&[&[u8]]],
336    ) -> solana_program::entrypoint::ProgramResult {
337        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
338    }
339    #[allow(clippy::clone_on_copy)]
340    #[allow(clippy::vec_init_then_push)]
341    pub fn invoke_signed_with_remaining_accounts(
342        &self,
343        signers_seeds: &[&[&[u8]]],
344        remaining_accounts: &[(
345            &'b solana_program::account_info::AccountInfo<'a>,
346            bool,
347            bool,
348        )],
349    ) -> solana_program::entrypoint::ProgramResult {
350        let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
351        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
352            *self.authority.key,
353            true,
354        ));
355        if let Some(delegate_record) = self.delegate_record {
356            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
357                *delegate_record.key,
358                false,
359            ));
360        } else {
361            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
362                crate::MPL_TOKEN_METADATA_ID,
363                false,
364            ));
365        }
366        accounts.push(solana_program::instruction::AccountMeta::new(
367            *self.metadata.key,
368            false,
369        ));
370        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
371            *self.collection_mint.key,
372            false,
373        ));
374        if let Some(collection_metadata) = self.collection_metadata {
375            accounts.push(solana_program::instruction::AccountMeta::new(
376                *collection_metadata.key,
377                false,
378            ));
379        } else {
380            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
381                crate::MPL_TOKEN_METADATA_ID,
382                false,
383            ));
384        }
385        if let Some(collection_master_edition) = self.collection_master_edition {
386            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
387                *collection_master_edition.key,
388                false,
389            ));
390        } else {
391            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
392                crate::MPL_TOKEN_METADATA_ID,
393                false,
394            ));
395        }
396        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
397            *self.system_program.key,
398            false,
399        ));
400        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
401            *self.sysvar_instructions.key,
402            false,
403        ));
404        remaining_accounts.iter().for_each(|remaining_account| {
405            accounts.push(solana_program::instruction::AccountMeta {
406                pubkey: *remaining_account.0.key,
407                is_signer: remaining_account.1,
408                is_writable: remaining_account.2,
409            })
410        });
411        let data = VerifyCollectionV1InstructionData::new()
412            .try_to_vec()
413            .unwrap();
414
415        let instruction = solana_program::instruction::Instruction {
416            program_id: crate::MPL_TOKEN_METADATA_ID,
417            accounts,
418            data,
419        };
420        let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len());
421        account_infos.push(self.__program.clone());
422        account_infos.push(self.authority.clone());
423        if let Some(delegate_record) = self.delegate_record {
424            account_infos.push(delegate_record.clone());
425        }
426        account_infos.push(self.metadata.clone());
427        account_infos.push(self.collection_mint.clone());
428        if let Some(collection_metadata) = self.collection_metadata {
429            account_infos.push(collection_metadata.clone());
430        }
431        if let Some(collection_master_edition) = self.collection_master_edition {
432            account_infos.push(collection_master_edition.clone());
433        }
434        account_infos.push(self.system_program.clone());
435        account_infos.push(self.sysvar_instructions.clone());
436        remaining_accounts
437            .iter()
438            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
439
440        if signers_seeds.is_empty() {
441            solana_program::program::invoke(&instruction, &account_infos)
442        } else {
443            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
444        }
445    }
446}
447
448/// Instruction builder for `VerifyCollectionV1` via CPI.
449///
450/// ### Accounts:
451///
452///   0. `[signer]` authority
453///   1. `[optional]` delegate_record
454///   2. `[writable]` metadata
455///   3. `[]` collection_mint
456///   4. `[writable, optional]` collection_metadata
457///   5. `[optional]` collection_master_edition
458///   6. `[]` system_program
459///   7. `[]` sysvar_instructions
460pub struct VerifyCollectionV1CpiBuilder<'a, 'b> {
461    instruction: Box<VerifyCollectionV1CpiBuilderInstruction<'a, 'b>>,
462}
463
464impl<'a, 'b> VerifyCollectionV1CpiBuilder<'a, 'b> {
465    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
466        let instruction = Box::new(VerifyCollectionV1CpiBuilderInstruction {
467            __program: program,
468            authority: None,
469            delegate_record: None,
470            metadata: None,
471            collection_mint: None,
472            collection_metadata: None,
473            collection_master_edition: None,
474            system_program: None,
475            sysvar_instructions: None,
476            __remaining_accounts: Vec::new(),
477        });
478        Self { instruction }
479    }
480    /// Creator to verify, collection update authority or delegate
481    #[inline(always)]
482    pub fn authority(
483        &mut self,
484        authority: &'b solana_program::account_info::AccountInfo<'a>,
485    ) -> &mut Self {
486        self.instruction.authority = Some(authority);
487        self
488    }
489    /// `[optional account]`
490    /// Delegate record PDA
491    #[inline(always)]
492    pub fn delegate_record(
493        &mut self,
494        delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
495    ) -> &mut Self {
496        self.instruction.delegate_record = delegate_record;
497        self
498    }
499    /// Metadata account
500    #[inline(always)]
501    pub fn metadata(
502        &mut self,
503        metadata: &'b solana_program::account_info::AccountInfo<'a>,
504    ) -> &mut Self {
505        self.instruction.metadata = Some(metadata);
506        self
507    }
508    /// Mint of the Collection
509    #[inline(always)]
510    pub fn collection_mint(
511        &mut self,
512        collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
513    ) -> &mut Self {
514        self.instruction.collection_mint = Some(collection_mint);
515        self
516    }
517    /// `[optional account]`
518    /// Metadata Account of the Collection
519    #[inline(always)]
520    pub fn collection_metadata(
521        &mut self,
522        collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
523    ) -> &mut Self {
524        self.instruction.collection_metadata = collection_metadata;
525        self
526    }
527    /// `[optional account]`
528    /// Master Edition Account of the Collection Token
529    #[inline(always)]
530    pub fn collection_master_edition(
531        &mut self,
532        collection_master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
533    ) -> &mut Self {
534        self.instruction.collection_master_edition = collection_master_edition;
535        self
536    }
537    /// System program
538    #[inline(always)]
539    pub fn system_program(
540        &mut self,
541        system_program: &'b solana_program::account_info::AccountInfo<'a>,
542    ) -> &mut Self {
543        self.instruction.system_program = Some(system_program);
544        self
545    }
546    /// Instructions sysvar account
547    #[inline(always)]
548    pub fn sysvar_instructions(
549        &mut self,
550        sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
551    ) -> &mut Self {
552        self.instruction.sysvar_instructions = Some(sysvar_instructions);
553        self
554    }
555    /// Add an additional account to the instruction.
556    #[inline(always)]
557    pub fn add_remaining_account(
558        &mut self,
559        account: &'b solana_program::account_info::AccountInfo<'a>,
560        is_writable: bool,
561        is_signer: bool,
562    ) -> &mut Self {
563        self.instruction
564            .__remaining_accounts
565            .push((account, is_writable, is_signer));
566        self
567    }
568    /// Add additional accounts to the instruction.
569    ///
570    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
571    /// and a `bool` indicating whether the account is a signer or not.
572    #[inline(always)]
573    pub fn add_remaining_accounts(
574        &mut self,
575        accounts: &[(
576            &'b solana_program::account_info::AccountInfo<'a>,
577            bool,
578            bool,
579        )],
580    ) -> &mut Self {
581        self.instruction
582            .__remaining_accounts
583            .extend_from_slice(accounts);
584        self
585    }
586    #[inline(always)]
587    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
588        self.invoke_signed(&[])
589    }
590    #[allow(clippy::clone_on_copy)]
591    #[allow(clippy::vec_init_then_push)]
592    pub fn invoke_signed(
593        &self,
594        signers_seeds: &[&[&[u8]]],
595    ) -> solana_program::entrypoint::ProgramResult {
596        let instruction = VerifyCollectionV1Cpi {
597            __program: self.instruction.__program,
598
599            authority: self.instruction.authority.expect("authority is not set"),
600
601            delegate_record: self.instruction.delegate_record,
602
603            metadata: self.instruction.metadata.expect("metadata is not set"),
604
605            collection_mint: self
606                .instruction
607                .collection_mint
608                .expect("collection_mint is not set"),
609
610            collection_metadata: self.instruction.collection_metadata,
611
612            collection_master_edition: self.instruction.collection_master_edition,
613
614            system_program: self
615                .instruction
616                .system_program
617                .expect("system_program is not set"),
618
619            sysvar_instructions: self
620                .instruction
621                .sysvar_instructions
622                .expect("sysvar_instructions is not set"),
623        };
624        instruction.invoke_signed_with_remaining_accounts(
625            signers_seeds,
626            &self.instruction.__remaining_accounts,
627        )
628    }
629}
630
631struct VerifyCollectionV1CpiBuilderInstruction<'a, 'b> {
632    __program: &'b solana_program::account_info::AccountInfo<'a>,
633    authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
634    delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
635    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
636    collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
637    collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
638    collection_master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
639    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
640    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
641    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
642    __remaining_accounts: Vec<(
643        &'b solana_program::account_info::AccountInfo<'a>,
644        bool,
645        bool,
646    )>,
647}