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