1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct RequestRedemptionV2 {
13 pub kyc_account: solana_program::pubkey::Pubkey,
14
15 pub user_wallet: solana_program::pubkey::Pubkey,
16
17 pub bond_account: solana_program::pubkey::Pubkey,
18
19 pub mint_account: solana_program::pubkey::Pubkey,
20
21 pub issuance_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_issuance_vault_account: solana_program::pubkey::Pubkey,
34
35 pub nft_issuance_vault_token_account: solana_program::pubkey::Pubkey,
36
37 pub nft_collection_mint: solana_program::pubkey::Pubkey,
38
39 pub nft_collection_metadata_account: solana_program::pubkey::Pubkey,
40
41 pub nft_collection_master_edition_account: solana_program::pubkey::Pubkey,
42
43 pub config_account: solana_program::pubkey::Pubkey,
44
45 pub token2022_program: solana_program::pubkey::Pubkey,
46
47 pub associated_token_program: solana_program::pubkey::Pubkey,
48
49 pub token_program: solana_program::pubkey::Pubkey,
50
51 pub system_program: solana_program::pubkey::Pubkey,
52
53 pub metadata_program: solana_program::pubkey::Pubkey,
54
55 pub sysvar_instructions: solana_program::pubkey::Pubkey,
56}
57
58impl RequestRedemptionV2 {
59 pub fn instruction(
60 &self,
61 args: RequestRedemptionV2InstructionArgs,
62 ) -> solana_program::instruction::Instruction {
63 self.instruction_with_remaining_accounts(args, &[])
64 }
65 #[allow(clippy::vec_init_then_push)]
66 pub fn instruction_with_remaining_accounts(
67 &self,
68 args: RequestRedemptionV2InstructionArgs,
69 remaining_accounts: &[solana_program::instruction::AccountMeta],
70 ) -> solana_program::instruction::Instruction {
71 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
72 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
73 self.kyc_account,
74 false,
75 ));
76 accounts.push(solana_program::instruction::AccountMeta::new(
77 self.user_wallet,
78 true,
79 ));
80 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
81 self.bond_account,
82 false,
83 ));
84 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
85 self.mint_account,
86 false,
87 ));
88 accounts.push(solana_program::instruction::AccountMeta::new(
89 self.issuance_account,
90 false,
91 ));
92 accounts.push(solana_program::instruction::AccountMeta::new(
93 self.user_token_account,
94 false,
95 ));
96 accounts.push(solana_program::instruction::AccountMeta::new(
97 self.user_nft_token_account,
98 false,
99 ));
100 accounts.push(solana_program::instruction::AccountMeta::new(
101 self.nft_mint_account,
102 true,
103 ));
104 accounts.push(solana_program::instruction::AccountMeta::new(
105 self.nft_metadata_account,
106 false,
107 ));
108 accounts.push(solana_program::instruction::AccountMeta::new(
109 self.nft_master_edition_account,
110 false,
111 ));
112 accounts.push(solana_program::instruction::AccountMeta::new(
113 self.nft_issuance_vault_account,
114 false,
115 ));
116 accounts.push(solana_program::instruction::AccountMeta::new(
117 self.nft_issuance_vault_token_account,
118 false,
119 ));
120 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
121 self.nft_collection_mint,
122 false,
123 ));
124 accounts.push(solana_program::instruction::AccountMeta::new(
125 self.nft_collection_metadata_account,
126 false,
127 ));
128 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
129 self.nft_collection_master_edition_account,
130 false,
131 ));
132 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
133 self.config_account,
134 false,
135 ));
136 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
137 self.token2022_program,
138 false,
139 ));
140 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
141 self.associated_token_program,
142 false,
143 ));
144 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
145 self.token_program,
146 false,
147 ));
148 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
149 self.system_program,
150 false,
151 ));
152 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
153 self.metadata_program,
154 false,
155 ));
156 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
157 self.sysvar_instructions,
158 false,
159 ));
160 accounts.extend_from_slice(remaining_accounts);
161 let mut data = RequestRedemptionV2InstructionData::new()
162 .try_to_vec()
163 .unwrap();
164 let mut args = args.try_to_vec().unwrap();
165 data.append(&mut args);
166
167 solana_program::instruction::Instruction {
168 program_id: crate::STABLEBOND_ID,
169 accounts,
170 data,
171 }
172 }
173}
174
175#[derive(BorshDeserialize, BorshSerialize)]
176struct RequestRedemptionV2InstructionData {
177 discriminator: u8,
178}
179
180impl RequestRedemptionV2InstructionData {
181 fn new() -> Self {
182 Self { discriminator: 29 }
183 }
184}
185
186#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
187#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
188pub struct RequestRedemptionV2InstructionArgs {
189 pub amount: u64,
190}
191
192#[derive(Default)]
219pub struct RequestRedemptionV2Builder {
220 kyc_account: Option<solana_program::pubkey::Pubkey>,
221 user_wallet: Option<solana_program::pubkey::Pubkey>,
222 bond_account: Option<solana_program::pubkey::Pubkey>,
223 mint_account: Option<solana_program::pubkey::Pubkey>,
224 issuance_account: Option<solana_program::pubkey::Pubkey>,
225 user_token_account: Option<solana_program::pubkey::Pubkey>,
226 user_nft_token_account: Option<solana_program::pubkey::Pubkey>,
227 nft_mint_account: Option<solana_program::pubkey::Pubkey>,
228 nft_metadata_account: Option<solana_program::pubkey::Pubkey>,
229 nft_master_edition_account: Option<solana_program::pubkey::Pubkey>,
230 nft_issuance_vault_account: Option<solana_program::pubkey::Pubkey>,
231 nft_issuance_vault_token_account: Option<solana_program::pubkey::Pubkey>,
232 nft_collection_mint: Option<solana_program::pubkey::Pubkey>,
233 nft_collection_metadata_account: Option<solana_program::pubkey::Pubkey>,
234 nft_collection_master_edition_account: Option<solana_program::pubkey::Pubkey>,
235 config_account: Option<solana_program::pubkey::Pubkey>,
236 token2022_program: Option<solana_program::pubkey::Pubkey>,
237 associated_token_program: Option<solana_program::pubkey::Pubkey>,
238 token_program: Option<solana_program::pubkey::Pubkey>,
239 system_program: Option<solana_program::pubkey::Pubkey>,
240 metadata_program: Option<solana_program::pubkey::Pubkey>,
241 sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
242 amount: Option<u64>,
243 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
244}
245
246impl RequestRedemptionV2Builder {
247 pub fn new() -> Self {
248 Self::default()
249 }
250 #[inline(always)]
251 pub fn kyc_account(&mut self, kyc_account: solana_program::pubkey::Pubkey) -> &mut Self {
252 self.kyc_account = Some(kyc_account);
253 self
254 }
255 #[inline(always)]
256 pub fn user_wallet(&mut self, user_wallet: solana_program::pubkey::Pubkey) -> &mut Self {
257 self.user_wallet = Some(user_wallet);
258 self
259 }
260 #[inline(always)]
261 pub fn bond_account(&mut self, bond_account: solana_program::pubkey::Pubkey) -> &mut Self {
262 self.bond_account = Some(bond_account);
263 self
264 }
265 #[inline(always)]
266 pub fn mint_account(&mut self, mint_account: solana_program::pubkey::Pubkey) -> &mut Self {
267 self.mint_account = Some(mint_account);
268 self
269 }
270 #[inline(always)]
271 pub fn issuance_account(
272 &mut self,
273 issuance_account: solana_program::pubkey::Pubkey,
274 ) -> &mut Self {
275 self.issuance_account = Some(issuance_account);
276 self
277 }
278 #[inline(always)]
279 pub fn user_token_account(
280 &mut self,
281 user_token_account: solana_program::pubkey::Pubkey,
282 ) -> &mut Self {
283 self.user_token_account = Some(user_token_account);
284 self
285 }
286 #[inline(always)]
287 pub fn user_nft_token_account(
288 &mut self,
289 user_nft_token_account: solana_program::pubkey::Pubkey,
290 ) -> &mut Self {
291 self.user_nft_token_account = Some(user_nft_token_account);
292 self
293 }
294 #[inline(always)]
295 pub fn nft_mint_account(
296 &mut self,
297 nft_mint_account: solana_program::pubkey::Pubkey,
298 ) -> &mut Self {
299 self.nft_mint_account = Some(nft_mint_account);
300 self
301 }
302 #[inline(always)]
303 pub fn nft_metadata_account(
304 &mut self,
305 nft_metadata_account: solana_program::pubkey::Pubkey,
306 ) -> &mut Self {
307 self.nft_metadata_account = Some(nft_metadata_account);
308 self
309 }
310 #[inline(always)]
311 pub fn nft_master_edition_account(
312 &mut self,
313 nft_master_edition_account: solana_program::pubkey::Pubkey,
314 ) -> &mut Self {
315 self.nft_master_edition_account = Some(nft_master_edition_account);
316 self
317 }
318 #[inline(always)]
319 pub fn nft_issuance_vault_account(
320 &mut self,
321 nft_issuance_vault_account: solana_program::pubkey::Pubkey,
322 ) -> &mut Self {
323 self.nft_issuance_vault_account = Some(nft_issuance_vault_account);
324 self
325 }
326 #[inline(always)]
327 pub fn nft_issuance_vault_token_account(
328 &mut self,
329 nft_issuance_vault_token_account: solana_program::pubkey::Pubkey,
330 ) -> &mut Self {
331 self.nft_issuance_vault_token_account = Some(nft_issuance_vault_token_account);
332 self
333 }
334 #[inline(always)]
335 pub fn nft_collection_mint(
336 &mut self,
337 nft_collection_mint: solana_program::pubkey::Pubkey,
338 ) -> &mut Self {
339 self.nft_collection_mint = Some(nft_collection_mint);
340 self
341 }
342 #[inline(always)]
343 pub fn nft_collection_metadata_account(
344 &mut self,
345 nft_collection_metadata_account: solana_program::pubkey::Pubkey,
346 ) -> &mut Self {
347 self.nft_collection_metadata_account = Some(nft_collection_metadata_account);
348 self
349 }
350 #[inline(always)]
351 pub fn nft_collection_master_edition_account(
352 &mut self,
353 nft_collection_master_edition_account: solana_program::pubkey::Pubkey,
354 ) -> &mut Self {
355 self.nft_collection_master_edition_account = Some(nft_collection_master_edition_account);
356 self
357 }
358 #[inline(always)]
359 pub fn config_account(&mut self, config_account: solana_program::pubkey::Pubkey) -> &mut Self {
360 self.config_account = Some(config_account);
361 self
362 }
363 #[inline(always)]
364 pub fn token2022_program(
365 &mut self,
366 token2022_program: solana_program::pubkey::Pubkey,
367 ) -> &mut Self {
368 self.token2022_program = Some(token2022_program);
369 self
370 }
371 #[inline(always)]
372 pub fn associated_token_program(
373 &mut self,
374 associated_token_program: solana_program::pubkey::Pubkey,
375 ) -> &mut Self {
376 self.associated_token_program = Some(associated_token_program);
377 self
378 }
379 #[inline(always)]
381 pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
382 self.token_program = Some(token_program);
383 self
384 }
385 #[inline(always)]
387 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
388 self.system_program = Some(system_program);
389 self
390 }
391 #[inline(always)]
392 pub fn metadata_program(
393 &mut self,
394 metadata_program: solana_program::pubkey::Pubkey,
395 ) -> &mut Self {
396 self.metadata_program = Some(metadata_program);
397 self
398 }
399 #[inline(always)]
401 pub fn sysvar_instructions(
402 &mut self,
403 sysvar_instructions: solana_program::pubkey::Pubkey,
404 ) -> &mut Self {
405 self.sysvar_instructions = Some(sysvar_instructions);
406 self
407 }
408 #[inline(always)]
409 pub fn amount(&mut self, amount: u64) -> &mut Self {
410 self.amount = Some(amount);
411 self
412 }
413 #[inline(always)]
415 pub fn add_remaining_account(
416 &mut self,
417 account: solana_program::instruction::AccountMeta,
418 ) -> &mut Self {
419 self.__remaining_accounts.push(account);
420 self
421 }
422 #[inline(always)]
424 pub fn add_remaining_accounts(
425 &mut self,
426 accounts: &[solana_program::instruction::AccountMeta],
427 ) -> &mut Self {
428 self.__remaining_accounts.extend_from_slice(accounts);
429 self
430 }
431 #[allow(clippy::clone_on_copy)]
432 pub fn instruction(&self) -> solana_program::instruction::Instruction {
433 let accounts = RequestRedemptionV2 {
434 kyc_account: self.kyc_account.expect("kyc_account is not set"),
435 user_wallet: self.user_wallet.expect("user_wallet is not set"),
436 bond_account: self.bond_account.expect("bond_account is not set"),
437 mint_account: self.mint_account.expect("mint_account is not set"),
438 issuance_account: self.issuance_account.expect("issuance_account is not set"),
439 user_token_account: self
440 .user_token_account
441 .expect("user_token_account is not set"),
442 user_nft_token_account: self
443 .user_nft_token_account
444 .expect("user_nft_token_account is not set"),
445 nft_mint_account: self.nft_mint_account.expect("nft_mint_account is not set"),
446 nft_metadata_account: self
447 .nft_metadata_account
448 .expect("nft_metadata_account is not set"),
449 nft_master_edition_account: self
450 .nft_master_edition_account
451 .expect("nft_master_edition_account is not set"),
452 nft_issuance_vault_account: self
453 .nft_issuance_vault_account
454 .expect("nft_issuance_vault_account is not set"),
455 nft_issuance_vault_token_account: self
456 .nft_issuance_vault_token_account
457 .expect("nft_issuance_vault_token_account is not set"),
458 nft_collection_mint: self
459 .nft_collection_mint
460 .expect("nft_collection_mint is not set"),
461 nft_collection_metadata_account: self
462 .nft_collection_metadata_account
463 .expect("nft_collection_metadata_account is not set"),
464 nft_collection_master_edition_account: self
465 .nft_collection_master_edition_account
466 .expect("nft_collection_master_edition_account is not set"),
467 config_account: self.config_account.expect("config_account is not set"),
468 token2022_program: self
469 .token2022_program
470 .expect("token2022_program is not set"),
471 associated_token_program: self
472 .associated_token_program
473 .expect("associated_token_program is not set"),
474 token_program: self.token_program.unwrap_or(solana_program::pubkey!(
475 "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
476 )),
477 system_program: self
478 .system_program
479 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
480 metadata_program: self.metadata_program.expect("metadata_program is not set"),
481 sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
482 "Sysvar1nstructions1111111111111111111111111"
483 )),
484 };
485 let args = RequestRedemptionV2InstructionArgs {
486 amount: self.amount.clone().expect("amount is not set"),
487 };
488
489 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
490 }
491}
492
493pub struct RequestRedemptionV2CpiAccounts<'a, 'b> {
495 pub kyc_account: &'b solana_program::account_info::AccountInfo<'a>,
496
497 pub user_wallet: &'b solana_program::account_info::AccountInfo<'a>,
498
499 pub bond_account: &'b solana_program::account_info::AccountInfo<'a>,
500
501 pub mint_account: &'b solana_program::account_info::AccountInfo<'a>,
502
503 pub issuance_account: &'b solana_program::account_info::AccountInfo<'a>,
504
505 pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>,
506
507 pub user_nft_token_account: &'b solana_program::account_info::AccountInfo<'a>,
508
509 pub nft_mint_account: &'b solana_program::account_info::AccountInfo<'a>,
510
511 pub nft_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
512
513 pub nft_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
514
515 pub nft_issuance_vault_account: &'b solana_program::account_info::AccountInfo<'a>,
516
517 pub nft_issuance_vault_token_account: &'b solana_program::account_info::AccountInfo<'a>,
518
519 pub nft_collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
520
521 pub nft_collection_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
522
523 pub nft_collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
524
525 pub config_account: &'b solana_program::account_info::AccountInfo<'a>,
526
527 pub token2022_program: &'b solana_program::account_info::AccountInfo<'a>,
528
529 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
530
531 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
532
533 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
534
535 pub metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
536
537 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
538}
539
540pub struct RequestRedemptionV2Cpi<'a, 'b> {
542 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
544
545 pub kyc_account: &'b solana_program::account_info::AccountInfo<'a>,
546
547 pub user_wallet: &'b solana_program::account_info::AccountInfo<'a>,
548
549 pub bond_account: &'b solana_program::account_info::AccountInfo<'a>,
550
551 pub mint_account: &'b solana_program::account_info::AccountInfo<'a>,
552
553 pub issuance_account: &'b solana_program::account_info::AccountInfo<'a>,
554
555 pub user_token_account: &'b solana_program::account_info::AccountInfo<'a>,
556
557 pub user_nft_token_account: &'b solana_program::account_info::AccountInfo<'a>,
558
559 pub nft_mint_account: &'b solana_program::account_info::AccountInfo<'a>,
560
561 pub nft_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
562
563 pub nft_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
564
565 pub nft_issuance_vault_account: &'b solana_program::account_info::AccountInfo<'a>,
566
567 pub nft_issuance_vault_token_account: &'b solana_program::account_info::AccountInfo<'a>,
568
569 pub nft_collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
570
571 pub nft_collection_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
572
573 pub nft_collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
574
575 pub config_account: &'b solana_program::account_info::AccountInfo<'a>,
576
577 pub token2022_program: &'b solana_program::account_info::AccountInfo<'a>,
578
579 pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
580
581 pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
582
583 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
584
585 pub metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
586
587 pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
588 pub __args: RequestRedemptionV2InstructionArgs,
590}
591
592impl<'a, 'b> RequestRedemptionV2Cpi<'a, 'b> {
593 pub fn new(
594 program: &'b solana_program::account_info::AccountInfo<'a>,
595 accounts: RequestRedemptionV2CpiAccounts<'a, 'b>,
596 args: RequestRedemptionV2InstructionArgs,
597 ) -> Self {
598 Self {
599 __program: program,
600 kyc_account: accounts.kyc_account,
601 user_wallet: accounts.user_wallet,
602 bond_account: accounts.bond_account,
603 mint_account: accounts.mint_account,
604 issuance_account: accounts.issuance_account,
605 user_token_account: accounts.user_token_account,
606 user_nft_token_account: accounts.user_nft_token_account,
607 nft_mint_account: accounts.nft_mint_account,
608 nft_metadata_account: accounts.nft_metadata_account,
609 nft_master_edition_account: accounts.nft_master_edition_account,
610 nft_issuance_vault_account: accounts.nft_issuance_vault_account,
611 nft_issuance_vault_token_account: accounts.nft_issuance_vault_token_account,
612 nft_collection_mint: accounts.nft_collection_mint,
613 nft_collection_metadata_account: accounts.nft_collection_metadata_account,
614 nft_collection_master_edition_account: accounts.nft_collection_master_edition_account,
615 config_account: accounts.config_account,
616 token2022_program: accounts.token2022_program,
617 associated_token_program: accounts.associated_token_program,
618 token_program: accounts.token_program,
619 system_program: accounts.system_program,
620 metadata_program: accounts.metadata_program,
621 sysvar_instructions: accounts.sysvar_instructions,
622 __args: args,
623 }
624 }
625 #[inline(always)]
626 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
627 self.invoke_signed_with_remaining_accounts(&[], &[])
628 }
629 #[inline(always)]
630 pub fn invoke_with_remaining_accounts(
631 &self,
632 remaining_accounts: &[(
633 &'b solana_program::account_info::AccountInfo<'a>,
634 bool,
635 bool,
636 )],
637 ) -> solana_program::entrypoint::ProgramResult {
638 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
639 }
640 #[inline(always)]
641 pub fn invoke_signed(
642 &self,
643 signers_seeds: &[&[&[u8]]],
644 ) -> solana_program::entrypoint::ProgramResult {
645 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
646 }
647 #[allow(clippy::clone_on_copy)]
648 #[allow(clippy::vec_init_then_push)]
649 pub fn invoke_signed_with_remaining_accounts(
650 &self,
651 signers_seeds: &[&[&[u8]]],
652 remaining_accounts: &[(
653 &'b solana_program::account_info::AccountInfo<'a>,
654 bool,
655 bool,
656 )],
657 ) -> solana_program::entrypoint::ProgramResult {
658 let mut accounts = Vec::with_capacity(22 + remaining_accounts.len());
659 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
660 *self.kyc_account.key,
661 false,
662 ));
663 accounts.push(solana_program::instruction::AccountMeta::new(
664 *self.user_wallet.key,
665 true,
666 ));
667 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
668 *self.bond_account.key,
669 false,
670 ));
671 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
672 *self.mint_account.key,
673 false,
674 ));
675 accounts.push(solana_program::instruction::AccountMeta::new(
676 *self.issuance_account.key,
677 false,
678 ));
679 accounts.push(solana_program::instruction::AccountMeta::new(
680 *self.user_token_account.key,
681 false,
682 ));
683 accounts.push(solana_program::instruction::AccountMeta::new(
684 *self.user_nft_token_account.key,
685 false,
686 ));
687 accounts.push(solana_program::instruction::AccountMeta::new(
688 *self.nft_mint_account.key,
689 true,
690 ));
691 accounts.push(solana_program::instruction::AccountMeta::new(
692 *self.nft_metadata_account.key,
693 false,
694 ));
695 accounts.push(solana_program::instruction::AccountMeta::new(
696 *self.nft_master_edition_account.key,
697 false,
698 ));
699 accounts.push(solana_program::instruction::AccountMeta::new(
700 *self.nft_issuance_vault_account.key,
701 false,
702 ));
703 accounts.push(solana_program::instruction::AccountMeta::new(
704 *self.nft_issuance_vault_token_account.key,
705 false,
706 ));
707 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
708 *self.nft_collection_mint.key,
709 false,
710 ));
711 accounts.push(solana_program::instruction::AccountMeta::new(
712 *self.nft_collection_metadata_account.key,
713 false,
714 ));
715 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
716 *self.nft_collection_master_edition_account.key,
717 false,
718 ));
719 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
720 *self.config_account.key,
721 false,
722 ));
723 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
724 *self.token2022_program.key,
725 false,
726 ));
727 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
728 *self.associated_token_program.key,
729 false,
730 ));
731 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
732 *self.token_program.key,
733 false,
734 ));
735 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
736 *self.system_program.key,
737 false,
738 ));
739 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
740 *self.metadata_program.key,
741 false,
742 ));
743 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
744 *self.sysvar_instructions.key,
745 false,
746 ));
747 remaining_accounts.iter().for_each(|remaining_account| {
748 accounts.push(solana_program::instruction::AccountMeta {
749 pubkey: *remaining_account.0.key,
750 is_signer: remaining_account.1,
751 is_writable: remaining_account.2,
752 })
753 });
754 let mut data = RequestRedemptionV2InstructionData::new()
755 .try_to_vec()
756 .unwrap();
757 let mut args = self.__args.try_to_vec().unwrap();
758 data.append(&mut args);
759
760 let instruction = solana_program::instruction::Instruction {
761 program_id: crate::STABLEBOND_ID,
762 accounts,
763 data,
764 };
765 let mut account_infos = Vec::with_capacity(22 + 1 + remaining_accounts.len());
766 account_infos.push(self.__program.clone());
767 account_infos.push(self.kyc_account.clone());
768 account_infos.push(self.user_wallet.clone());
769 account_infos.push(self.bond_account.clone());
770 account_infos.push(self.mint_account.clone());
771 account_infos.push(self.issuance_account.clone());
772 account_infos.push(self.user_token_account.clone());
773 account_infos.push(self.user_nft_token_account.clone());
774 account_infos.push(self.nft_mint_account.clone());
775 account_infos.push(self.nft_metadata_account.clone());
776 account_infos.push(self.nft_master_edition_account.clone());
777 account_infos.push(self.nft_issuance_vault_account.clone());
778 account_infos.push(self.nft_issuance_vault_token_account.clone());
779 account_infos.push(self.nft_collection_mint.clone());
780 account_infos.push(self.nft_collection_metadata_account.clone());
781 account_infos.push(self.nft_collection_master_edition_account.clone());
782 account_infos.push(self.config_account.clone());
783 account_infos.push(self.token2022_program.clone());
784 account_infos.push(self.associated_token_program.clone());
785 account_infos.push(self.token_program.clone());
786 account_infos.push(self.system_program.clone());
787 account_infos.push(self.metadata_program.clone());
788 account_infos.push(self.sysvar_instructions.clone());
789 remaining_accounts
790 .iter()
791 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
792
793 if signers_seeds.is_empty() {
794 solana_program::program::invoke(&instruction, &account_infos)
795 } else {
796 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
797 }
798 }
799}
800
801pub struct RequestRedemptionV2CpiBuilder<'a, 'b> {
828 instruction: Box<RequestRedemptionV2CpiBuilderInstruction<'a, 'b>>,
829}
830
831impl<'a, 'b> RequestRedemptionV2CpiBuilder<'a, 'b> {
832 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
833 let instruction = Box::new(RequestRedemptionV2CpiBuilderInstruction {
834 __program: program,
835 kyc_account: None,
836 user_wallet: None,
837 bond_account: None,
838 mint_account: None,
839 issuance_account: None,
840 user_token_account: None,
841 user_nft_token_account: None,
842 nft_mint_account: None,
843 nft_metadata_account: None,
844 nft_master_edition_account: None,
845 nft_issuance_vault_account: None,
846 nft_issuance_vault_token_account: None,
847 nft_collection_mint: None,
848 nft_collection_metadata_account: None,
849 nft_collection_master_edition_account: None,
850 config_account: None,
851 token2022_program: None,
852 associated_token_program: None,
853 token_program: None,
854 system_program: None,
855 metadata_program: None,
856 sysvar_instructions: None,
857 amount: None,
858 __remaining_accounts: Vec::new(),
859 });
860 Self { instruction }
861 }
862 #[inline(always)]
863 pub fn kyc_account(
864 &mut self,
865 kyc_account: &'b solana_program::account_info::AccountInfo<'a>,
866 ) -> &mut Self {
867 self.instruction.kyc_account = Some(kyc_account);
868 self
869 }
870 #[inline(always)]
871 pub fn user_wallet(
872 &mut self,
873 user_wallet: &'b solana_program::account_info::AccountInfo<'a>,
874 ) -> &mut Self {
875 self.instruction.user_wallet = Some(user_wallet);
876 self
877 }
878 #[inline(always)]
879 pub fn bond_account(
880 &mut self,
881 bond_account: &'b solana_program::account_info::AccountInfo<'a>,
882 ) -> &mut Self {
883 self.instruction.bond_account = Some(bond_account);
884 self
885 }
886 #[inline(always)]
887 pub fn mint_account(
888 &mut self,
889 mint_account: &'b solana_program::account_info::AccountInfo<'a>,
890 ) -> &mut Self {
891 self.instruction.mint_account = Some(mint_account);
892 self
893 }
894 #[inline(always)]
895 pub fn issuance_account(
896 &mut self,
897 issuance_account: &'b solana_program::account_info::AccountInfo<'a>,
898 ) -> &mut Self {
899 self.instruction.issuance_account = Some(issuance_account);
900 self
901 }
902 #[inline(always)]
903 pub fn user_token_account(
904 &mut self,
905 user_token_account: &'b solana_program::account_info::AccountInfo<'a>,
906 ) -> &mut Self {
907 self.instruction.user_token_account = Some(user_token_account);
908 self
909 }
910 #[inline(always)]
911 pub fn user_nft_token_account(
912 &mut self,
913 user_nft_token_account: &'b solana_program::account_info::AccountInfo<'a>,
914 ) -> &mut Self {
915 self.instruction.user_nft_token_account = Some(user_nft_token_account);
916 self
917 }
918 #[inline(always)]
919 pub fn nft_mint_account(
920 &mut self,
921 nft_mint_account: &'b solana_program::account_info::AccountInfo<'a>,
922 ) -> &mut Self {
923 self.instruction.nft_mint_account = Some(nft_mint_account);
924 self
925 }
926 #[inline(always)]
927 pub fn nft_metadata_account(
928 &mut self,
929 nft_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
930 ) -> &mut Self {
931 self.instruction.nft_metadata_account = Some(nft_metadata_account);
932 self
933 }
934 #[inline(always)]
935 pub fn nft_master_edition_account(
936 &mut self,
937 nft_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
938 ) -> &mut Self {
939 self.instruction.nft_master_edition_account = Some(nft_master_edition_account);
940 self
941 }
942 #[inline(always)]
943 pub fn nft_issuance_vault_account(
944 &mut self,
945 nft_issuance_vault_account: &'b solana_program::account_info::AccountInfo<'a>,
946 ) -> &mut Self {
947 self.instruction.nft_issuance_vault_account = Some(nft_issuance_vault_account);
948 self
949 }
950 #[inline(always)]
951 pub fn nft_issuance_vault_token_account(
952 &mut self,
953 nft_issuance_vault_token_account: &'b solana_program::account_info::AccountInfo<'a>,
954 ) -> &mut Self {
955 self.instruction.nft_issuance_vault_token_account = Some(nft_issuance_vault_token_account);
956 self
957 }
958 #[inline(always)]
959 pub fn nft_collection_mint(
960 &mut self,
961 nft_collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
962 ) -> &mut Self {
963 self.instruction.nft_collection_mint = Some(nft_collection_mint);
964 self
965 }
966 #[inline(always)]
967 pub fn nft_collection_metadata_account(
968 &mut self,
969 nft_collection_metadata_account: &'b solana_program::account_info::AccountInfo<'a>,
970 ) -> &mut Self {
971 self.instruction.nft_collection_metadata_account = Some(nft_collection_metadata_account);
972 self
973 }
974 #[inline(always)]
975 pub fn nft_collection_master_edition_account(
976 &mut self,
977 nft_collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
978 ) -> &mut Self {
979 self.instruction.nft_collection_master_edition_account =
980 Some(nft_collection_master_edition_account);
981 self
982 }
983 #[inline(always)]
984 pub fn config_account(
985 &mut self,
986 config_account: &'b solana_program::account_info::AccountInfo<'a>,
987 ) -> &mut Self {
988 self.instruction.config_account = Some(config_account);
989 self
990 }
991 #[inline(always)]
992 pub fn token2022_program(
993 &mut self,
994 token2022_program: &'b solana_program::account_info::AccountInfo<'a>,
995 ) -> &mut Self {
996 self.instruction.token2022_program = Some(token2022_program);
997 self
998 }
999 #[inline(always)]
1000 pub fn associated_token_program(
1001 &mut self,
1002 associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1003 ) -> &mut Self {
1004 self.instruction.associated_token_program = Some(associated_token_program);
1005 self
1006 }
1007 #[inline(always)]
1008 pub fn token_program(
1009 &mut self,
1010 token_program: &'b solana_program::account_info::AccountInfo<'a>,
1011 ) -> &mut Self {
1012 self.instruction.token_program = Some(token_program);
1013 self
1014 }
1015 #[inline(always)]
1016 pub fn system_program(
1017 &mut self,
1018 system_program: &'b solana_program::account_info::AccountInfo<'a>,
1019 ) -> &mut Self {
1020 self.instruction.system_program = Some(system_program);
1021 self
1022 }
1023 #[inline(always)]
1024 pub fn metadata_program(
1025 &mut self,
1026 metadata_program: &'b solana_program::account_info::AccountInfo<'a>,
1027 ) -> &mut Self {
1028 self.instruction.metadata_program = Some(metadata_program);
1029 self
1030 }
1031 #[inline(always)]
1032 pub fn sysvar_instructions(
1033 &mut self,
1034 sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
1035 ) -> &mut Self {
1036 self.instruction.sysvar_instructions = Some(sysvar_instructions);
1037 self
1038 }
1039 #[inline(always)]
1040 pub fn amount(&mut self, amount: u64) -> &mut Self {
1041 self.instruction.amount = Some(amount);
1042 self
1043 }
1044 #[inline(always)]
1046 pub fn add_remaining_account(
1047 &mut self,
1048 account: &'b solana_program::account_info::AccountInfo<'a>,
1049 is_writable: bool,
1050 is_signer: bool,
1051 ) -> &mut Self {
1052 self.instruction
1053 .__remaining_accounts
1054 .push((account, is_writable, is_signer));
1055 self
1056 }
1057 #[inline(always)]
1062 pub fn add_remaining_accounts(
1063 &mut self,
1064 accounts: &[(
1065 &'b solana_program::account_info::AccountInfo<'a>,
1066 bool,
1067 bool,
1068 )],
1069 ) -> &mut Self {
1070 self.instruction
1071 .__remaining_accounts
1072 .extend_from_slice(accounts);
1073 self
1074 }
1075 #[inline(always)]
1076 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1077 self.invoke_signed(&[])
1078 }
1079 #[allow(clippy::clone_on_copy)]
1080 #[allow(clippy::vec_init_then_push)]
1081 pub fn invoke_signed(
1082 &self,
1083 signers_seeds: &[&[&[u8]]],
1084 ) -> solana_program::entrypoint::ProgramResult {
1085 let args = RequestRedemptionV2InstructionArgs {
1086 amount: self.instruction.amount.clone().expect("amount is not set"),
1087 };
1088 let instruction = RequestRedemptionV2Cpi {
1089 __program: self.instruction.__program,
1090
1091 kyc_account: self
1092 .instruction
1093 .kyc_account
1094 .expect("kyc_account is not set"),
1095
1096 user_wallet: self
1097 .instruction
1098 .user_wallet
1099 .expect("user_wallet is not set"),
1100
1101 bond_account: self
1102 .instruction
1103 .bond_account
1104 .expect("bond_account is not set"),
1105
1106 mint_account: self
1107 .instruction
1108 .mint_account
1109 .expect("mint_account is not set"),
1110
1111 issuance_account: self
1112 .instruction
1113 .issuance_account
1114 .expect("issuance_account is not set"),
1115
1116 user_token_account: self
1117 .instruction
1118 .user_token_account
1119 .expect("user_token_account is not set"),
1120
1121 user_nft_token_account: self
1122 .instruction
1123 .user_nft_token_account
1124 .expect("user_nft_token_account is not set"),
1125
1126 nft_mint_account: self
1127 .instruction
1128 .nft_mint_account
1129 .expect("nft_mint_account is not set"),
1130
1131 nft_metadata_account: self
1132 .instruction
1133 .nft_metadata_account
1134 .expect("nft_metadata_account is not set"),
1135
1136 nft_master_edition_account: self
1137 .instruction
1138 .nft_master_edition_account
1139 .expect("nft_master_edition_account is not set"),
1140
1141 nft_issuance_vault_account: self
1142 .instruction
1143 .nft_issuance_vault_account
1144 .expect("nft_issuance_vault_account is not set"),
1145
1146 nft_issuance_vault_token_account: self
1147 .instruction
1148 .nft_issuance_vault_token_account
1149 .expect("nft_issuance_vault_token_account is not set"),
1150
1151 nft_collection_mint: self
1152 .instruction
1153 .nft_collection_mint
1154 .expect("nft_collection_mint is not set"),
1155
1156 nft_collection_metadata_account: self
1157 .instruction
1158 .nft_collection_metadata_account
1159 .expect("nft_collection_metadata_account is not set"),
1160
1161 nft_collection_master_edition_account: self
1162 .instruction
1163 .nft_collection_master_edition_account
1164 .expect("nft_collection_master_edition_account is not set"),
1165
1166 config_account: self
1167 .instruction
1168 .config_account
1169 .expect("config_account is not set"),
1170
1171 token2022_program: self
1172 .instruction
1173 .token2022_program
1174 .expect("token2022_program is not set"),
1175
1176 associated_token_program: self
1177 .instruction
1178 .associated_token_program
1179 .expect("associated_token_program is not set"),
1180
1181 token_program: self
1182 .instruction
1183 .token_program
1184 .expect("token_program is not set"),
1185
1186 system_program: self
1187 .instruction
1188 .system_program
1189 .expect("system_program is not set"),
1190
1191 metadata_program: self
1192 .instruction
1193 .metadata_program
1194 .expect("metadata_program is not set"),
1195
1196 sysvar_instructions: self
1197 .instruction
1198 .sysvar_instructions
1199 .expect("sysvar_instructions is not set"),
1200 __args: args,
1201 };
1202 instruction.invoke_signed_with_remaining_accounts(
1203 signers_seeds,
1204 &self.instruction.__remaining_accounts,
1205 )
1206 }
1207}
1208
1209struct RequestRedemptionV2CpiBuilderInstruction<'a, 'b> {
1210 __program: &'b solana_program::account_info::AccountInfo<'a>,
1211 kyc_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1212 user_wallet: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1213 bond_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1214 mint_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1215 issuance_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1216 user_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1217 user_nft_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1218 nft_mint_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1219 nft_metadata_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1220 nft_master_edition_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1221 nft_issuance_vault_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1222 nft_issuance_vault_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1223 nft_collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1224 nft_collection_metadata_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1225 nft_collection_master_edition_account:
1226 Option<&'b solana_program::account_info::AccountInfo<'a>>,
1227 config_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1228 token2022_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1229 associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1230 token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1231 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1232 metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1233 sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1234 amount: Option<u64>,
1235 __remaining_accounts: Vec<(
1237 &'b solana_program::account_info::AccountInfo<'a>,
1238 bool,
1239 bool,
1240 )>,
1241}