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