1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const CLAIM_USD_DISCRIMINATOR: [u8; 8] = [241, 89, 98, 124, 223, 205, 215, 104];
12
13#[derive(Debug)]
15pub struct ClaimUsd {
16
17
18 pub authority: solana_address::Address,
19
20
21 pub satrush_config: solana_address::Address,
22 pub board: solana_address::Address,
27 pub miner: solana_address::Address,
32
33
34 pub usd_mint: solana_address::Address,
35 pub board_usd_ata: solana_address::Address,
40 pub authority_usd_ata: solana_address::Address,
45
46
47 pub token_program: solana_address::Address,
48
49
50 pub associated_token_program: solana_address::Address,
51
52
53 pub system_program: solana_address::Address,
54 }
55
56impl ClaimUsd {
57 pub fn instruction(&self, args: ClaimUsdInstructionArgs) -> solana_instruction::Instruction {
58 self.instruction_with_remaining_accounts(args, &[])
59 }
60 #[allow(clippy::arithmetic_side_effects)]
61 #[allow(clippy::vec_init_then_push)]
62 pub fn instruction_with_remaining_accounts(&self, args: ClaimUsdInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
63 let mut accounts = Vec::with_capacity(10+ remaining_accounts.len());
64 accounts.push(solana_instruction::AccountMeta::new(
65 self.authority,
66 true
67 ));
68 accounts.push(solana_instruction::AccountMeta::new_readonly(
69 self.satrush_config,
70 false
71 ));
72 accounts.push(solana_instruction::AccountMeta::new_readonly(
73 self.board,
74 false
75 ));
76 accounts.push(solana_instruction::AccountMeta::new(
77 self.miner,
78 false
79 ));
80 accounts.push(solana_instruction::AccountMeta::new_readonly(
81 self.usd_mint,
82 false
83 ));
84 accounts.push(solana_instruction::AccountMeta::new(
85 self.board_usd_ata,
86 false
87 ));
88 accounts.push(solana_instruction::AccountMeta::new(
89 self.authority_usd_ata,
90 false
91 ));
92 accounts.push(solana_instruction::AccountMeta::new_readonly(
93 self.token_program,
94 false
95 ));
96 accounts.push(solana_instruction::AccountMeta::new_readonly(
97 self.associated_token_program,
98 false
99 ));
100 accounts.push(solana_instruction::AccountMeta::new_readonly(
101 self.system_program,
102 false
103 ));
104 accounts.extend_from_slice(remaining_accounts);
105 let mut data = ClaimUsdInstructionData::new().try_to_vec().unwrap();
106 let mut args = args.try_to_vec().unwrap();
107 data.append(&mut args);
108
109 solana_instruction::Instruction {
110 program_id: crate::SATRUSH_ID,
111 accounts,
112 data,
113 }
114 }
115}
116
117#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
118 pub struct ClaimUsdInstructionData {
119 discriminator: [u8; 8],
120 }
121
122impl ClaimUsdInstructionData {
123 pub fn new() -> Self {
124 Self {
125 discriminator: [241, 89, 98, 124, 223, 205, 215, 104],
126 }
127 }
128
129 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
130 borsh::to_vec(self)
131 }
132 }
133
134impl Default for ClaimUsdInstructionData {
135 fn default() -> Self {
136 Self::new()
137 }
138}
139
140#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
141 pub struct ClaimUsdInstructionArgs {
142 pub amount: u64,
143 }
144
145impl ClaimUsdInstructionArgs {
146 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
147 borsh::to_vec(self)
148 }
149}
150
151
152#[derive(Clone, Debug, Default)]
167pub struct ClaimUsdBuilder {
168 authority: Option<solana_address::Address>,
169 satrush_config: Option<solana_address::Address>,
170 board: Option<solana_address::Address>,
171 miner: Option<solana_address::Address>,
172 usd_mint: Option<solana_address::Address>,
173 board_usd_ata: Option<solana_address::Address>,
174 authority_usd_ata: Option<solana_address::Address>,
175 token_program: Option<solana_address::Address>,
176 associated_token_program: Option<solana_address::Address>,
177 system_program: Option<solana_address::Address>,
178 amount: Option<u64>,
179 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
180}
181
182impl ClaimUsdBuilder {
183 pub fn new() -> Self {
184 Self::default()
185 }
186 #[inline(always)]
187 pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
188 self.authority = Some(authority);
189 self
190 }
191 #[inline(always)]
192 pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
193 self.satrush_config = Some(satrush_config);
194 self
195 }
196 #[inline(always)]
198 pub fn board(&mut self, board: solana_address::Address) -> &mut Self {
199 self.board = Some(board);
200 self
201 }
202 #[inline(always)]
204 pub fn miner(&mut self, miner: solana_address::Address) -> &mut Self {
205 self.miner = Some(miner);
206 self
207 }
208 #[inline(always)]
209 pub fn usd_mint(&mut self, usd_mint: solana_address::Address) -> &mut Self {
210 self.usd_mint = Some(usd_mint);
211 self
212 }
213 #[inline(always)]
215 pub fn board_usd_ata(&mut self, board_usd_ata: solana_address::Address) -> &mut Self {
216 self.board_usd_ata = Some(board_usd_ata);
217 self
218 }
219 #[inline(always)]
221 pub fn authority_usd_ata(&mut self, authority_usd_ata: solana_address::Address) -> &mut Self {
222 self.authority_usd_ata = Some(authority_usd_ata);
223 self
224 }
225 #[inline(always)]
227 pub fn token_program(&mut self, token_program: solana_address::Address) -> &mut Self {
228 self.token_program = Some(token_program);
229 self
230 }
231 #[inline(always)]
233 pub fn associated_token_program(&mut self, associated_token_program: solana_address::Address) -> &mut Self {
234 self.associated_token_program = Some(associated_token_program);
235 self
236 }
237 #[inline(always)]
239 pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
240 self.system_program = Some(system_program);
241 self
242 }
243 #[inline(always)]
244 pub fn amount(&mut self, amount: u64) -> &mut Self {
245 self.amount = Some(amount);
246 self
247 }
248 #[inline(always)]
250 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
251 self.__remaining_accounts.push(account);
252 self
253 }
254 #[inline(always)]
256 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
257 self.__remaining_accounts.extend_from_slice(accounts);
258 self
259 }
260 #[allow(clippy::clone_on_copy)]
261 pub fn instruction(&self) -> solana_instruction::Instruction {
262 let accounts = ClaimUsd {
263 authority: self.authority.expect("authority is not set"),
264 satrush_config: self.satrush_config.expect("satrush_config is not set"),
265 board: self.board.expect("board is not set"),
266 miner: self.miner.expect("miner is not set"),
267 usd_mint: self.usd_mint.expect("usd_mint is not set"),
268 board_usd_ata: self.board_usd_ata.expect("board_usd_ata is not set"),
269 authority_usd_ata: self.authority_usd_ata.expect("authority_usd_ata is not set"),
270 token_program: self.token_program.unwrap_or(solana_address::address!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
271 associated_token_program: self.associated_token_program.unwrap_or(solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),
272 system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
273 };
274 let args = ClaimUsdInstructionArgs {
275 amount: self.amount.clone().expect("amount is not set"),
276 };
277
278 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
279 }
280}
281
282 pub struct ClaimUsdCpiAccounts<'a, 'b> {
284
285
286 pub authority: &'b solana_account_info::AccountInfo<'a>,
287
288
289 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
290 pub board: &'b solana_account_info::AccountInfo<'a>,
295 pub miner: &'b solana_account_info::AccountInfo<'a>,
300
301
302 pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
303 pub board_usd_ata: &'b solana_account_info::AccountInfo<'a>,
308 pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
313
314
315 pub token_program: &'b solana_account_info::AccountInfo<'a>,
316
317
318 pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
319
320
321 pub system_program: &'b solana_account_info::AccountInfo<'a>,
322 }
323
324pub struct ClaimUsdCpi<'a, 'b> {
326 pub __program: &'b solana_account_info::AccountInfo<'a>,
328
329
330 pub authority: &'b solana_account_info::AccountInfo<'a>,
331
332
333 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
334 pub board: &'b solana_account_info::AccountInfo<'a>,
339 pub miner: &'b solana_account_info::AccountInfo<'a>,
344
345
346 pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
347 pub board_usd_ata: &'b solana_account_info::AccountInfo<'a>,
352 pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
357
358
359 pub token_program: &'b solana_account_info::AccountInfo<'a>,
360
361
362 pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
363
364
365 pub system_program: &'b solana_account_info::AccountInfo<'a>,
366 pub __args: ClaimUsdInstructionArgs,
368 }
369
370impl<'a, 'b> ClaimUsdCpi<'a, 'b> {
371 pub fn new(
372 program: &'b solana_account_info::AccountInfo<'a>,
373 accounts: ClaimUsdCpiAccounts<'a, 'b>,
374 args: ClaimUsdInstructionArgs,
375 ) -> Self {
376 Self {
377 __program: program,
378 authority: accounts.authority,
379 satrush_config: accounts.satrush_config,
380 board: accounts.board,
381 miner: accounts.miner,
382 usd_mint: accounts.usd_mint,
383 board_usd_ata: accounts.board_usd_ata,
384 authority_usd_ata: accounts.authority_usd_ata,
385 token_program: accounts.token_program,
386 associated_token_program: accounts.associated_token_program,
387 system_program: accounts.system_program,
388 __args: args,
389 }
390 }
391 #[inline(always)]
392 pub fn invoke(&self) -> solana_program_error::ProgramResult {
393 self.invoke_signed_with_remaining_accounts(&[], &[])
394 }
395 #[inline(always)]
396 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
397 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
398 }
399 #[inline(always)]
400 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
401 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
402 }
403 #[allow(clippy::arithmetic_side_effects)]
404 #[allow(clippy::clone_on_copy)]
405 #[allow(clippy::vec_init_then_push)]
406 pub fn invoke_signed_with_remaining_accounts(
407 &self,
408 signers_seeds: &[&[&[u8]]],
409 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
410 ) -> solana_program_error::ProgramResult {
411 let mut accounts = Vec::with_capacity(10+ remaining_accounts.len());
412 accounts.push(solana_instruction::AccountMeta::new(
413 *self.authority.key,
414 true
415 ));
416 accounts.push(solana_instruction::AccountMeta::new_readonly(
417 *self.satrush_config.key,
418 false
419 ));
420 accounts.push(solana_instruction::AccountMeta::new_readonly(
421 *self.board.key,
422 false
423 ));
424 accounts.push(solana_instruction::AccountMeta::new(
425 *self.miner.key,
426 false
427 ));
428 accounts.push(solana_instruction::AccountMeta::new_readonly(
429 *self.usd_mint.key,
430 false
431 ));
432 accounts.push(solana_instruction::AccountMeta::new(
433 *self.board_usd_ata.key,
434 false
435 ));
436 accounts.push(solana_instruction::AccountMeta::new(
437 *self.authority_usd_ata.key,
438 false
439 ));
440 accounts.push(solana_instruction::AccountMeta::new_readonly(
441 *self.token_program.key,
442 false
443 ));
444 accounts.push(solana_instruction::AccountMeta::new_readonly(
445 *self.associated_token_program.key,
446 false
447 ));
448 accounts.push(solana_instruction::AccountMeta::new_readonly(
449 *self.system_program.key,
450 false
451 ));
452 remaining_accounts.iter().for_each(|remaining_account| {
453 accounts.push(solana_instruction::AccountMeta {
454 pubkey: *remaining_account.0.key,
455 is_signer: remaining_account.1,
456 is_writable: remaining_account.2,
457 })
458 });
459 let mut data = ClaimUsdInstructionData::new().try_to_vec().unwrap();
460 let mut args = self.__args.try_to_vec().unwrap();
461 data.append(&mut args);
462
463 let instruction = solana_instruction::Instruction {
464 program_id: crate::SATRUSH_ID,
465 accounts,
466 data,
467 };
468 let mut account_infos = Vec::with_capacity(11 + remaining_accounts.len());
469 account_infos.push(self.__program.clone());
470 account_infos.push(self.authority.clone());
471 account_infos.push(self.satrush_config.clone());
472 account_infos.push(self.board.clone());
473 account_infos.push(self.miner.clone());
474 account_infos.push(self.usd_mint.clone());
475 account_infos.push(self.board_usd_ata.clone());
476 account_infos.push(self.authority_usd_ata.clone());
477 account_infos.push(self.token_program.clone());
478 account_infos.push(self.associated_token_program.clone());
479 account_infos.push(self.system_program.clone());
480 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
481
482 if signers_seeds.is_empty() {
483 solana_cpi::invoke(&instruction, &account_infos)
484 } else {
485 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
486 }
487 }
488}
489
490#[derive(Clone, Debug)]
505pub struct ClaimUsdCpiBuilder<'a, 'b> {
506 instruction: Box<ClaimUsdCpiBuilderInstruction<'a, 'b>>,
507}
508
509impl<'a, 'b> ClaimUsdCpiBuilder<'a, 'b> {
510 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
511 let instruction = Box::new(ClaimUsdCpiBuilderInstruction {
512 __program: program,
513 authority: None,
514 satrush_config: None,
515 board: None,
516 miner: None,
517 usd_mint: None,
518 board_usd_ata: None,
519 authority_usd_ata: None,
520 token_program: None,
521 associated_token_program: None,
522 system_program: None,
523 amount: None,
524 __remaining_accounts: Vec::new(),
525 });
526 Self { instruction }
527 }
528 #[inline(always)]
529 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
530 self.instruction.authority = Some(authority);
531 self
532 }
533 #[inline(always)]
534 pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
535 self.instruction.satrush_config = Some(satrush_config);
536 self
537 }
538 #[inline(always)]
540 pub fn board(&mut self, board: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
541 self.instruction.board = Some(board);
542 self
543 }
544 #[inline(always)]
546 pub fn miner(&mut self, miner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
547 self.instruction.miner = Some(miner);
548 self
549 }
550 #[inline(always)]
551 pub fn usd_mint(&mut self, usd_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
552 self.instruction.usd_mint = Some(usd_mint);
553 self
554 }
555 #[inline(always)]
557 pub fn board_usd_ata(&mut self, board_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
558 self.instruction.board_usd_ata = Some(board_usd_ata);
559 self
560 }
561 #[inline(always)]
563 pub fn authority_usd_ata(&mut self, authority_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
564 self.instruction.authority_usd_ata = Some(authority_usd_ata);
565 self
566 }
567 #[inline(always)]
568 pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
569 self.instruction.token_program = Some(token_program);
570 self
571 }
572 #[inline(always)]
573 pub fn associated_token_program(&mut self, associated_token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
574 self.instruction.associated_token_program = Some(associated_token_program);
575 self
576 }
577 #[inline(always)]
578 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
579 self.instruction.system_program = Some(system_program);
580 self
581 }
582 #[inline(always)]
583 pub fn amount(&mut self, amount: u64) -> &mut Self {
584 self.instruction.amount = Some(amount);
585 self
586 }
587 #[inline(always)]
589 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
590 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
591 self
592 }
593 #[inline(always)]
598 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
599 self.instruction.__remaining_accounts.extend_from_slice(accounts);
600 self
601 }
602 #[inline(always)]
603 pub fn invoke(&self) -> solana_program_error::ProgramResult {
604 self.invoke_signed(&[])
605 }
606 #[allow(clippy::clone_on_copy)]
607 #[allow(clippy::vec_init_then_push)]
608 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
609 let args = ClaimUsdInstructionArgs {
610 amount: self.instruction.amount.clone().expect("amount is not set"),
611 };
612 let instruction = ClaimUsdCpi {
613 __program: self.instruction.__program,
614
615 authority: self.instruction.authority.expect("authority is not set"),
616
617 satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
618
619 board: self.instruction.board.expect("board is not set"),
620
621 miner: self.instruction.miner.expect("miner is not set"),
622
623 usd_mint: self.instruction.usd_mint.expect("usd_mint is not set"),
624
625 board_usd_ata: self.instruction.board_usd_ata.expect("board_usd_ata is not set"),
626
627 authority_usd_ata: self.instruction.authority_usd_ata.expect("authority_usd_ata is not set"),
628
629 token_program: self.instruction.token_program.expect("token_program is not set"),
630
631 associated_token_program: self.instruction.associated_token_program.expect("associated_token_program is not set"),
632
633 system_program: self.instruction.system_program.expect("system_program is not set"),
634 __args: args,
635 };
636 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
637 }
638}
639
640#[derive(Clone, Debug)]
641struct ClaimUsdCpiBuilderInstruction<'a, 'b> {
642 __program: &'b solana_account_info::AccountInfo<'a>,
643 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
644 satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
645 board: Option<&'b solana_account_info::AccountInfo<'a>>,
646 miner: Option<&'b solana_account_info::AccountInfo<'a>>,
647 usd_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
648 board_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
649 authority_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
650 token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
651 associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
652 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
653 amount: Option<u64>,
654 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
656}
657