Skip to main content

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