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