1use crate::generated::types::MetadataArgs;
9use crate::generated::types::UpdateArgs;
10use borsh::BorshDeserialize;
11use borsh::BorshSerialize;
12
13pub struct UpdateMetadata {
15 pub tree_config: solana_program::pubkey::Pubkey,
16 pub authority: solana_program::pubkey::Pubkey,
19 pub collection_mint: Option<solana_program::pubkey::Pubkey>,
21 pub collection_metadata: Option<solana_program::pubkey::Pubkey>,
23
24 pub collection_authority_record_pda: Option<solana_program::pubkey::Pubkey>,
25
26 pub leaf_owner: solana_program::pubkey::Pubkey,
27
28 pub leaf_delegate: solana_program::pubkey::Pubkey,
29
30 pub payer: solana_program::pubkey::Pubkey,
31
32 pub merkle_tree: solana_program::pubkey::Pubkey,
33
34 pub log_wrapper: solana_program::pubkey::Pubkey,
35
36 pub compression_program: solana_program::pubkey::Pubkey,
37
38 pub token_metadata_program: solana_program::pubkey::Pubkey,
39
40 pub system_program: solana_program::pubkey::Pubkey,
41}
42
43impl UpdateMetadata {
44 pub fn instruction(
45 &self,
46 args: UpdateMetadataInstructionArgs,
47 ) -> solana_program::instruction::Instruction {
48 self.instruction_with_remaining_accounts(args, &[])
49 }
50 #[allow(clippy::vec_init_then_push)]
51 pub fn instruction_with_remaining_accounts(
52 &self,
53 args: UpdateMetadataInstructionArgs,
54 remaining_accounts: &[solana_program::instruction::AccountMeta],
55 ) -> solana_program::instruction::Instruction {
56 let mut accounts = Vec::with_capacity(13 + remaining_accounts.len());
57 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
58 self.tree_config,
59 false,
60 ));
61 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
62 self.authority,
63 true,
64 ));
65 if let Some(collection_mint) = self.collection_mint {
66 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
67 collection_mint,
68 false,
69 ));
70 } else {
71 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
72 crate::MPL_BUBBLEGUM_ID,
73 false,
74 ));
75 }
76 if let Some(collection_metadata) = self.collection_metadata {
77 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
78 collection_metadata,
79 false,
80 ));
81 } else {
82 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
83 crate::MPL_BUBBLEGUM_ID,
84 false,
85 ));
86 }
87 if let Some(collection_authority_record_pda) = self.collection_authority_record_pda {
88 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
89 collection_authority_record_pda,
90 false,
91 ));
92 } else {
93 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
94 crate::MPL_BUBBLEGUM_ID,
95 false,
96 ));
97 }
98 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
99 self.leaf_owner,
100 false,
101 ));
102 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
103 self.leaf_delegate,
104 false,
105 ));
106 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
107 self.payer, true,
108 ));
109 accounts.push(solana_program::instruction::AccountMeta::new(
110 self.merkle_tree,
111 false,
112 ));
113 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
114 self.log_wrapper,
115 false,
116 ));
117 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
118 self.compression_program,
119 false,
120 ));
121 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
122 self.token_metadata_program,
123 false,
124 ));
125 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
126 self.system_program,
127 false,
128 ));
129 accounts.extend_from_slice(remaining_accounts);
130 let mut data = UpdateMetadataInstructionData::new().try_to_vec().unwrap();
131 let mut args = args.try_to_vec().unwrap();
132 data.append(&mut args);
133
134 solana_program::instruction::Instruction {
135 program_id: crate::MPL_BUBBLEGUM_ID,
136 accounts,
137 data,
138 }
139 }
140}
141
142#[derive(BorshDeserialize, BorshSerialize)]
143struct UpdateMetadataInstructionData {
144 discriminator: [u8; 8],
145}
146
147impl UpdateMetadataInstructionData {
148 fn new() -> Self {
149 Self {
150 discriminator: [170, 182, 43, 239, 97, 78, 225, 186],
151 }
152 }
153}
154
155#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
156#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
157pub struct UpdateMetadataInstructionArgs {
158 pub root: [u8; 32],
159 pub nonce: u64,
160 pub index: u32,
161 pub current_metadata: MetadataArgs,
162 pub update_args: UpdateArgs,
163}
164
165#[derive(Default)]
167pub struct UpdateMetadataBuilder {
168 tree_config: Option<solana_program::pubkey::Pubkey>,
169 authority: Option<solana_program::pubkey::Pubkey>,
170 collection_mint: Option<solana_program::pubkey::Pubkey>,
171 collection_metadata: Option<solana_program::pubkey::Pubkey>,
172 collection_authority_record_pda: Option<solana_program::pubkey::Pubkey>,
173 leaf_owner: Option<solana_program::pubkey::Pubkey>,
174 leaf_delegate: Option<solana_program::pubkey::Pubkey>,
175 payer: Option<solana_program::pubkey::Pubkey>,
176 merkle_tree: Option<solana_program::pubkey::Pubkey>,
177 log_wrapper: Option<solana_program::pubkey::Pubkey>,
178 compression_program: Option<solana_program::pubkey::Pubkey>,
179 token_metadata_program: Option<solana_program::pubkey::Pubkey>,
180 system_program: Option<solana_program::pubkey::Pubkey>,
181 root: Option<[u8; 32]>,
182 nonce: Option<u64>,
183 index: Option<u32>,
184 current_metadata: Option<MetadataArgs>,
185 update_args: Option<UpdateArgs>,
186 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
187}
188
189impl UpdateMetadataBuilder {
190 pub fn new() -> Self {
191 Self::default()
192 }
193 #[inline(always)]
194 pub fn tree_config(&mut self, tree_config: solana_program::pubkey::Pubkey) -> &mut Self {
195 self.tree_config = Some(tree_config);
196 self
197 }
198 #[inline(always)]
201 pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
202 self.authority = Some(authority);
203 self
204 }
205 #[inline(always)]
208 pub fn collection_mint(
209 &mut self,
210 collection_mint: Option<solana_program::pubkey::Pubkey>,
211 ) -> &mut Self {
212 self.collection_mint = collection_mint;
213 self
214 }
215 #[inline(always)]
218 pub fn collection_metadata(
219 &mut self,
220 collection_metadata: Option<solana_program::pubkey::Pubkey>,
221 ) -> &mut Self {
222 self.collection_metadata = collection_metadata;
223 self
224 }
225 #[inline(always)]
227 pub fn collection_authority_record_pda(
228 &mut self,
229 collection_authority_record_pda: Option<solana_program::pubkey::Pubkey>,
230 ) -> &mut Self {
231 self.collection_authority_record_pda = collection_authority_record_pda;
232 self
233 }
234 #[inline(always)]
235 pub fn leaf_owner(&mut self, leaf_owner: solana_program::pubkey::Pubkey) -> &mut Self {
236 self.leaf_owner = Some(leaf_owner);
237 self
238 }
239 #[inline(always)]
240 pub fn leaf_delegate(&mut self, leaf_delegate: solana_program::pubkey::Pubkey) -> &mut Self {
241 self.leaf_delegate = Some(leaf_delegate);
242 self
243 }
244 #[inline(always)]
245 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
246 self.payer = Some(payer);
247 self
248 }
249 #[inline(always)]
250 pub fn merkle_tree(&mut self, merkle_tree: solana_program::pubkey::Pubkey) -> &mut Self {
251 self.merkle_tree = Some(merkle_tree);
252 self
253 }
254 #[inline(always)]
256 pub fn log_wrapper(&mut self, log_wrapper: solana_program::pubkey::Pubkey) -> &mut Self {
257 self.log_wrapper = Some(log_wrapper);
258 self
259 }
260 #[inline(always)]
262 pub fn compression_program(
263 &mut self,
264 compression_program: solana_program::pubkey::Pubkey,
265 ) -> &mut Self {
266 self.compression_program = Some(compression_program);
267 self
268 }
269 #[inline(always)]
271 pub fn token_metadata_program(
272 &mut self,
273 token_metadata_program: solana_program::pubkey::Pubkey,
274 ) -> &mut Self {
275 self.token_metadata_program = Some(token_metadata_program);
276 self
277 }
278 #[inline(always)]
280 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
281 self.system_program = Some(system_program);
282 self
283 }
284 #[inline(always)]
285 pub fn root(&mut self, root: [u8; 32]) -> &mut Self {
286 self.root = Some(root);
287 self
288 }
289 #[inline(always)]
290 pub fn nonce(&mut self, nonce: u64) -> &mut Self {
291 self.nonce = Some(nonce);
292 self
293 }
294 #[inline(always)]
295 pub fn index(&mut self, index: u32) -> &mut Self {
296 self.index = Some(index);
297 self
298 }
299 #[inline(always)]
300 pub fn current_metadata(&mut self, current_metadata: MetadataArgs) -> &mut Self {
301 self.current_metadata = Some(current_metadata);
302 self
303 }
304 #[inline(always)]
305 pub fn update_args(&mut self, update_args: UpdateArgs) -> &mut Self {
306 self.update_args = Some(update_args);
307 self
308 }
309 #[inline(always)]
311 pub fn add_remaining_account(
312 &mut self,
313 account: solana_program::instruction::AccountMeta,
314 ) -> &mut Self {
315 self.__remaining_accounts.push(account);
316 self
317 }
318 #[inline(always)]
320 pub fn add_remaining_accounts(
321 &mut self,
322 accounts: &[solana_program::instruction::AccountMeta],
323 ) -> &mut Self {
324 self.__remaining_accounts.extend_from_slice(accounts);
325 self
326 }
327 #[allow(clippy::clone_on_copy)]
328 pub fn instruction(&self) -> solana_program::instruction::Instruction {
329 let accounts =
330 UpdateMetadata {
331 tree_config: self.tree_config.expect("tree_config is not set"),
332 authority: self.authority.expect("authority is not set"),
333 collection_mint: self.collection_mint,
334 collection_metadata: self.collection_metadata,
335 collection_authority_record_pda: self.collection_authority_record_pda,
336 leaf_owner: self.leaf_owner.expect("leaf_owner is not set"),
337 leaf_delegate: self.leaf_delegate.expect("leaf_delegate is not set"),
338 payer: self.payer.expect("payer is not set"),
339 merkle_tree: self.merkle_tree.expect("merkle_tree is not set"),
340 log_wrapper: self.log_wrapper.unwrap_or(solana_program::pubkey!(
341 "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"
342 )),
343 compression_program: self.compression_program.unwrap_or(solana_program::pubkey!(
344 "cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK"
345 )),
346 token_metadata_program: self.token_metadata_program.unwrap_or(
347 solana_program::pubkey!("BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY"),
348 ),
349 system_program: self
350 .system_program
351 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
352 };
353 let args = UpdateMetadataInstructionArgs {
354 root: self.root.clone().expect("root is not set"),
355 nonce: self.nonce.clone().expect("nonce is not set"),
356 index: self.index.clone().expect("index is not set"),
357 current_metadata: self
358 .current_metadata
359 .clone()
360 .expect("current_metadata is not set"),
361 update_args: self.update_args.clone().expect("update_args is not set"),
362 };
363
364 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
365 }
366}
367
368pub struct UpdateMetadataCpiAccounts<'a, 'b> {
370 pub tree_config: &'b solana_program::account_info::AccountInfo<'a>,
371 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
374 pub collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
376 pub collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
378
379 pub collection_authority_record_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
380
381 pub leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
382
383 pub leaf_delegate: &'b solana_program::account_info::AccountInfo<'a>,
384
385 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
386
387 pub merkle_tree: &'b solana_program::account_info::AccountInfo<'a>,
388
389 pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
390
391 pub compression_program: &'b solana_program::account_info::AccountInfo<'a>,
392
393 pub token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
394
395 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
396}
397
398pub struct UpdateMetadataCpi<'a, 'b> {
400 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
402
403 pub tree_config: &'b solana_program::account_info::AccountInfo<'a>,
404 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
407 pub collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
409 pub collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
411
412 pub collection_authority_record_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
413
414 pub leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
415
416 pub leaf_delegate: &'b solana_program::account_info::AccountInfo<'a>,
417
418 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
419
420 pub merkle_tree: &'b solana_program::account_info::AccountInfo<'a>,
421
422 pub log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
423
424 pub compression_program: &'b solana_program::account_info::AccountInfo<'a>,
425
426 pub token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
427
428 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
429 pub __args: UpdateMetadataInstructionArgs,
431}
432
433impl<'a, 'b> UpdateMetadataCpi<'a, 'b> {
434 pub fn new(
435 program: &'b solana_program::account_info::AccountInfo<'a>,
436 accounts: UpdateMetadataCpiAccounts<'a, 'b>,
437 args: UpdateMetadataInstructionArgs,
438 ) -> Self {
439 Self {
440 __program: program,
441 tree_config: accounts.tree_config,
442 authority: accounts.authority,
443 collection_mint: accounts.collection_mint,
444 collection_metadata: accounts.collection_metadata,
445 collection_authority_record_pda: accounts.collection_authority_record_pda,
446 leaf_owner: accounts.leaf_owner,
447 leaf_delegate: accounts.leaf_delegate,
448 payer: accounts.payer,
449 merkle_tree: accounts.merkle_tree,
450 log_wrapper: accounts.log_wrapper,
451 compression_program: accounts.compression_program,
452 token_metadata_program: accounts.token_metadata_program,
453 system_program: accounts.system_program,
454 __args: args,
455 }
456 }
457 #[inline(always)]
458 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
459 self.invoke_signed_with_remaining_accounts(&[], &[])
460 }
461 #[inline(always)]
462 pub fn invoke_with_remaining_accounts(
463 &self,
464 remaining_accounts: &[(
465 &'b solana_program::account_info::AccountInfo<'a>,
466 bool,
467 bool,
468 )],
469 ) -> solana_program::entrypoint::ProgramResult {
470 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
471 }
472 #[inline(always)]
473 pub fn invoke_signed(
474 &self,
475 signers_seeds: &[&[&[u8]]],
476 ) -> solana_program::entrypoint::ProgramResult {
477 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
478 }
479 #[allow(clippy::clone_on_copy)]
480 #[allow(clippy::vec_init_then_push)]
481 pub fn invoke_signed_with_remaining_accounts(
482 &self,
483 signers_seeds: &[&[&[u8]]],
484 remaining_accounts: &[(
485 &'b solana_program::account_info::AccountInfo<'a>,
486 bool,
487 bool,
488 )],
489 ) -> solana_program::entrypoint::ProgramResult {
490 let mut accounts = Vec::with_capacity(13 + remaining_accounts.len());
491 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
492 *self.tree_config.key,
493 false,
494 ));
495 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
496 *self.authority.key,
497 true,
498 ));
499 if let Some(collection_mint) = self.collection_mint {
500 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
501 *collection_mint.key,
502 false,
503 ));
504 } else {
505 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
506 crate::MPL_BUBBLEGUM_ID,
507 false,
508 ));
509 }
510 if let Some(collection_metadata) = self.collection_metadata {
511 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
512 *collection_metadata.key,
513 false,
514 ));
515 } else {
516 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
517 crate::MPL_BUBBLEGUM_ID,
518 false,
519 ));
520 }
521 if let Some(collection_authority_record_pda) = self.collection_authority_record_pda {
522 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
523 *collection_authority_record_pda.key,
524 false,
525 ));
526 } else {
527 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
528 crate::MPL_BUBBLEGUM_ID,
529 false,
530 ));
531 }
532 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
533 *self.leaf_owner.key,
534 false,
535 ));
536 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
537 *self.leaf_delegate.key,
538 false,
539 ));
540 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
541 *self.payer.key,
542 true,
543 ));
544 accounts.push(solana_program::instruction::AccountMeta::new(
545 *self.merkle_tree.key,
546 false,
547 ));
548 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
549 *self.log_wrapper.key,
550 false,
551 ));
552 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
553 *self.compression_program.key,
554 false,
555 ));
556 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
557 *self.token_metadata_program.key,
558 false,
559 ));
560 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
561 *self.system_program.key,
562 false,
563 ));
564 remaining_accounts.iter().for_each(|remaining_account| {
565 accounts.push(solana_program::instruction::AccountMeta {
566 pubkey: *remaining_account.0.key,
567 is_signer: remaining_account.1,
568 is_writable: remaining_account.2,
569 })
570 });
571 let mut data = UpdateMetadataInstructionData::new().try_to_vec().unwrap();
572 let mut args = self.__args.try_to_vec().unwrap();
573 data.append(&mut args);
574
575 let instruction = solana_program::instruction::Instruction {
576 program_id: crate::MPL_BUBBLEGUM_ID,
577 accounts,
578 data,
579 };
580 let mut account_infos = Vec::with_capacity(13 + 1 + remaining_accounts.len());
581 account_infos.push(self.__program.clone());
582 account_infos.push(self.tree_config.clone());
583 account_infos.push(self.authority.clone());
584 if let Some(collection_mint) = self.collection_mint {
585 account_infos.push(collection_mint.clone());
586 }
587 if let Some(collection_metadata) = self.collection_metadata {
588 account_infos.push(collection_metadata.clone());
589 }
590 if let Some(collection_authority_record_pda) = self.collection_authority_record_pda {
591 account_infos.push(collection_authority_record_pda.clone());
592 }
593 account_infos.push(self.leaf_owner.clone());
594 account_infos.push(self.leaf_delegate.clone());
595 account_infos.push(self.payer.clone());
596 account_infos.push(self.merkle_tree.clone());
597 account_infos.push(self.log_wrapper.clone());
598 account_infos.push(self.compression_program.clone());
599 account_infos.push(self.token_metadata_program.clone());
600 account_infos.push(self.system_program.clone());
601 remaining_accounts
602 .iter()
603 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
604
605 if signers_seeds.is_empty() {
606 solana_program::program::invoke(&instruction, &account_infos)
607 } else {
608 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
609 }
610 }
611}
612
613pub struct UpdateMetadataCpiBuilder<'a, 'b> {
615 instruction: Box<UpdateMetadataCpiBuilderInstruction<'a, 'b>>,
616}
617
618impl<'a, 'b> UpdateMetadataCpiBuilder<'a, 'b> {
619 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
620 let instruction = Box::new(UpdateMetadataCpiBuilderInstruction {
621 __program: program,
622 tree_config: None,
623 authority: None,
624 collection_mint: None,
625 collection_metadata: None,
626 collection_authority_record_pda: None,
627 leaf_owner: None,
628 leaf_delegate: None,
629 payer: None,
630 merkle_tree: None,
631 log_wrapper: None,
632 compression_program: None,
633 token_metadata_program: None,
634 system_program: None,
635 root: None,
636 nonce: None,
637 index: None,
638 current_metadata: None,
639 update_args: None,
640 __remaining_accounts: Vec::new(),
641 });
642 Self { instruction }
643 }
644 #[inline(always)]
645 pub fn tree_config(
646 &mut self,
647 tree_config: &'b solana_program::account_info::AccountInfo<'a>,
648 ) -> &mut Self {
649 self.instruction.tree_config = Some(tree_config);
650 self
651 }
652 #[inline(always)]
655 pub fn authority(
656 &mut self,
657 authority: &'b solana_program::account_info::AccountInfo<'a>,
658 ) -> &mut Self {
659 self.instruction.authority = Some(authority);
660 self
661 }
662 #[inline(always)]
665 pub fn collection_mint(
666 &mut self,
667 collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
668 ) -> &mut Self {
669 self.instruction.collection_mint = collection_mint;
670 self
671 }
672 #[inline(always)]
675 pub fn collection_metadata(
676 &mut self,
677 collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
678 ) -> &mut Self {
679 self.instruction.collection_metadata = collection_metadata;
680 self
681 }
682 #[inline(always)]
684 pub fn collection_authority_record_pda(
685 &mut self,
686 collection_authority_record_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
687 ) -> &mut Self {
688 self.instruction.collection_authority_record_pda = collection_authority_record_pda;
689 self
690 }
691 #[inline(always)]
692 pub fn leaf_owner(
693 &mut self,
694 leaf_owner: &'b solana_program::account_info::AccountInfo<'a>,
695 ) -> &mut Self {
696 self.instruction.leaf_owner = Some(leaf_owner);
697 self
698 }
699 #[inline(always)]
700 pub fn leaf_delegate(
701 &mut self,
702 leaf_delegate: &'b solana_program::account_info::AccountInfo<'a>,
703 ) -> &mut Self {
704 self.instruction.leaf_delegate = Some(leaf_delegate);
705 self
706 }
707 #[inline(always)]
708 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
709 self.instruction.payer = Some(payer);
710 self
711 }
712 #[inline(always)]
713 pub fn merkle_tree(
714 &mut self,
715 merkle_tree: &'b solana_program::account_info::AccountInfo<'a>,
716 ) -> &mut Self {
717 self.instruction.merkle_tree = Some(merkle_tree);
718 self
719 }
720 #[inline(always)]
721 pub fn log_wrapper(
722 &mut self,
723 log_wrapper: &'b solana_program::account_info::AccountInfo<'a>,
724 ) -> &mut Self {
725 self.instruction.log_wrapper = Some(log_wrapper);
726 self
727 }
728 #[inline(always)]
729 pub fn compression_program(
730 &mut self,
731 compression_program: &'b solana_program::account_info::AccountInfo<'a>,
732 ) -> &mut Self {
733 self.instruction.compression_program = Some(compression_program);
734 self
735 }
736 #[inline(always)]
737 pub fn token_metadata_program(
738 &mut self,
739 token_metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
740 ) -> &mut Self {
741 self.instruction.token_metadata_program = Some(token_metadata_program);
742 self
743 }
744 #[inline(always)]
745 pub fn system_program(
746 &mut self,
747 system_program: &'b solana_program::account_info::AccountInfo<'a>,
748 ) -> &mut Self {
749 self.instruction.system_program = Some(system_program);
750 self
751 }
752 #[inline(always)]
753 pub fn root(&mut self, root: [u8; 32]) -> &mut Self {
754 self.instruction.root = Some(root);
755 self
756 }
757 #[inline(always)]
758 pub fn nonce(&mut self, nonce: u64) -> &mut Self {
759 self.instruction.nonce = Some(nonce);
760 self
761 }
762 #[inline(always)]
763 pub fn index(&mut self, index: u32) -> &mut Self {
764 self.instruction.index = Some(index);
765 self
766 }
767 #[inline(always)]
768 pub fn current_metadata(&mut self, current_metadata: MetadataArgs) -> &mut Self {
769 self.instruction.current_metadata = Some(current_metadata);
770 self
771 }
772 #[inline(always)]
773 pub fn update_args(&mut self, update_args: UpdateArgs) -> &mut Self {
774 self.instruction.update_args = Some(update_args);
775 self
776 }
777 #[inline(always)]
779 pub fn add_remaining_account(
780 &mut self,
781 account: &'b solana_program::account_info::AccountInfo<'a>,
782 is_writable: bool,
783 is_signer: bool,
784 ) -> &mut Self {
785 self.instruction
786 .__remaining_accounts
787 .push((account, is_writable, is_signer));
788 self
789 }
790 #[inline(always)]
795 pub fn add_remaining_accounts(
796 &mut self,
797 accounts: &[(
798 &'b solana_program::account_info::AccountInfo<'a>,
799 bool,
800 bool,
801 )],
802 ) -> &mut Self {
803 self.instruction
804 .__remaining_accounts
805 .extend_from_slice(accounts);
806 self
807 }
808 #[inline(always)]
809 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
810 self.invoke_signed(&[])
811 }
812 #[allow(clippy::clone_on_copy)]
813 #[allow(clippy::vec_init_then_push)]
814 pub fn invoke_signed(
815 &self,
816 signers_seeds: &[&[&[u8]]],
817 ) -> solana_program::entrypoint::ProgramResult {
818 let args = UpdateMetadataInstructionArgs {
819 root: self.instruction.root.clone().expect("root is not set"),
820 nonce: self.instruction.nonce.clone().expect("nonce is not set"),
821 index: self.instruction.index.clone().expect("index is not set"),
822 current_metadata: self
823 .instruction
824 .current_metadata
825 .clone()
826 .expect("current_metadata is not set"),
827 update_args: self
828 .instruction
829 .update_args
830 .clone()
831 .expect("update_args is not set"),
832 };
833 let instruction = UpdateMetadataCpi {
834 __program: self.instruction.__program,
835
836 tree_config: self
837 .instruction
838 .tree_config
839 .expect("tree_config is not set"),
840
841 authority: self.instruction.authority.expect("authority is not set"),
842
843 collection_mint: self.instruction.collection_mint,
844
845 collection_metadata: self.instruction.collection_metadata,
846
847 collection_authority_record_pda: self.instruction.collection_authority_record_pda,
848
849 leaf_owner: self.instruction.leaf_owner.expect("leaf_owner is not set"),
850
851 leaf_delegate: self
852 .instruction
853 .leaf_delegate
854 .expect("leaf_delegate is not set"),
855
856 payer: self.instruction.payer.expect("payer is not set"),
857
858 merkle_tree: self
859 .instruction
860 .merkle_tree
861 .expect("merkle_tree is not set"),
862
863 log_wrapper: self
864 .instruction
865 .log_wrapper
866 .expect("log_wrapper is not set"),
867
868 compression_program: self
869 .instruction
870 .compression_program
871 .expect("compression_program is not set"),
872
873 token_metadata_program: self
874 .instruction
875 .token_metadata_program
876 .expect("token_metadata_program is not set"),
877
878 system_program: self
879 .instruction
880 .system_program
881 .expect("system_program is not set"),
882 __args: args,
883 };
884 instruction.invoke_signed_with_remaining_accounts(
885 signers_seeds,
886 &self.instruction.__remaining_accounts,
887 )
888 }
889}
890
891struct UpdateMetadataCpiBuilderInstruction<'a, 'b> {
892 __program: &'b solana_program::account_info::AccountInfo<'a>,
893 tree_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
894 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
895 collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
896 collection_metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
897 collection_authority_record_pda: Option<&'b solana_program::account_info::AccountInfo<'a>>,
898 leaf_owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
899 leaf_delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
900 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
901 merkle_tree: Option<&'b solana_program::account_info::AccountInfo<'a>>,
902 log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
903 compression_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
904 token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
905 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
906 root: Option<[u8; 32]>,
907 nonce: Option<u64>,
908 index: Option<u32>,
909 current_metadata: Option<MetadataArgs>,
910 update_args: Option<UpdateArgs>,
911 __remaining_accounts: Vec<(
913 &'b solana_program::account_info::AccountInfo<'a>,
914 bool,
915 bool,
916 )>,
917}