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