Skip to main content

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