Skip to main content

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