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
26
27 pub usd_mint: solana_address::Address,
28
29
30 pub automation_usd_ata: solana_address::Address,
31 pub authority_usd_ata: solana_address::Address,
36
37
38 pub token_program: solana_address::Address,
39
40
41 pub associated_token_program: solana_address::Address,
42
43
44 pub system_program: solana_address::Address,
45 }
46
47impl CancelPublicAutomation {
48 pub fn instruction(&self) -> solana_instruction::Instruction {
49 self.instruction_with_remaining_accounts(&[])
50 }
51 #[allow(clippy::arithmetic_side_effects)]
52 #[allow(clippy::vec_init_then_push)]
53 pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
54 let mut accounts = Vec::with_capacity(9+ remaining_accounts.len());
55 accounts.push(solana_instruction::AccountMeta::new(
56 self.authority,
57 true
58 ));
59 accounts.push(solana_instruction::AccountMeta::new_readonly(
60 self.satrush_config,
61 false
62 ));
63 accounts.push(solana_instruction::AccountMeta::new(
64 self.public_automation,
65 false
66 ));
67 accounts.push(solana_instruction::AccountMeta::new_readonly(
68 self.usd_mint,
69 false
70 ));
71 accounts.push(solana_instruction::AccountMeta::new(
72 self.automation_usd_ata,
73 false
74 ));
75 accounts.push(solana_instruction::AccountMeta::new(
76 self.authority_usd_ata,
77 false
78 ));
79 accounts.push(solana_instruction::AccountMeta::new_readonly(
80 self.token_program,
81 false
82 ));
83 accounts.push(solana_instruction::AccountMeta::new_readonly(
84 self.associated_token_program,
85 false
86 ));
87 accounts.push(solana_instruction::AccountMeta::new_readonly(
88 self.system_program,
89 false
90 ));
91 accounts.extend_from_slice(remaining_accounts);
92 let data = CancelPublicAutomationInstructionData::new().try_to_vec().unwrap();
93
94 solana_instruction::Instruction {
95 program_id: crate::SATRUSH_ID,
96 accounts,
97 data,
98 }
99 }
100}
101
102#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
103 pub struct CancelPublicAutomationInstructionData {
104 discriminator: [u8; 8],
105 }
106
107impl CancelPublicAutomationInstructionData {
108 pub fn new() -> Self {
109 Self {
110 discriminator: [87, 135, 14, 43, 190, 79, 45, 212],
111 }
112 }
113
114 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
115 borsh::to_vec(self)
116 }
117 }
118
119impl Default for CancelPublicAutomationInstructionData {
120 fn default() -> Self {
121 Self::new()
122 }
123}
124
125
126
127#[derive(Clone, Debug, Default)]
141pub struct CancelPublicAutomationBuilder {
142 authority: Option<solana_address::Address>,
143 satrush_config: Option<solana_address::Address>,
144 public_automation: Option<solana_address::Address>,
145 usd_mint: Option<solana_address::Address>,
146 automation_usd_ata: Option<solana_address::Address>,
147 authority_usd_ata: Option<solana_address::Address>,
148 token_program: Option<solana_address::Address>,
149 associated_token_program: Option<solana_address::Address>,
150 system_program: Option<solana_address::Address>,
151 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
152}
153
154impl CancelPublicAutomationBuilder {
155 pub fn new() -> Self {
156 Self::default()
157 }
158 #[inline(always)]
159 pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
160 self.authority = Some(authority);
161 self
162 }
163 #[inline(always)]
164 pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
165 self.satrush_config = Some(satrush_config);
166 self
167 }
168 #[inline(always)]
169 pub fn public_automation(&mut self, public_automation: solana_address::Address) -> &mut Self {
170 self.public_automation = Some(public_automation);
171 self
172 }
173 #[inline(always)]
174 pub fn usd_mint(&mut self, usd_mint: solana_address::Address) -> &mut Self {
175 self.usd_mint = Some(usd_mint);
176 self
177 }
178 #[inline(always)]
179 pub fn automation_usd_ata(&mut self, automation_usd_ata: solana_address::Address) -> &mut Self {
180 self.automation_usd_ata = Some(automation_usd_ata);
181 self
182 }
183 #[inline(always)]
185 pub fn authority_usd_ata(&mut self, authority_usd_ata: solana_address::Address) -> &mut Self {
186 self.authority_usd_ata = Some(authority_usd_ata);
187 self
188 }
189 #[inline(always)]
191 pub fn token_program(&mut self, token_program: solana_address::Address) -> &mut Self {
192 self.token_program = Some(token_program);
193 self
194 }
195 #[inline(always)]
197 pub fn associated_token_program(&mut self, associated_token_program: solana_address::Address) -> &mut Self {
198 self.associated_token_program = Some(associated_token_program);
199 self
200 }
201 #[inline(always)]
203 pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
204 self.system_program = Some(system_program);
205 self
206 }
207 #[inline(always)]
209 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
210 self.__remaining_accounts.push(account);
211 self
212 }
213 #[inline(always)]
215 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
216 self.__remaining_accounts.extend_from_slice(accounts);
217 self
218 }
219 #[allow(clippy::clone_on_copy)]
220 pub fn instruction(&self) -> solana_instruction::Instruction {
221 let accounts = CancelPublicAutomation {
222 authority: self.authority.expect("authority is not set"),
223 satrush_config: self.satrush_config.expect("satrush_config is not set"),
224 public_automation: self.public_automation.expect("public_automation is not set"),
225 usd_mint: self.usd_mint.expect("usd_mint is not set"),
226 automation_usd_ata: self.automation_usd_ata.expect("automation_usd_ata is not set"),
227 authority_usd_ata: self.authority_usd_ata.expect("authority_usd_ata is not set"),
228 token_program: self.token_program.unwrap_or(solana_address::address!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
229 associated_token_program: self.associated_token_program.unwrap_or(solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")),
230 system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
231 };
232
233 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
234 }
235}
236
237 pub struct CancelPublicAutomationCpiAccounts<'a, 'b> {
239
240
241 pub authority: &'b solana_account_info::AccountInfo<'a>,
242
243
244 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
245
246
247 pub public_automation: &'b solana_account_info::AccountInfo<'a>,
248
249
250 pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
251
252
253 pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
254 pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
259
260
261 pub token_program: &'b solana_account_info::AccountInfo<'a>,
262
263
264 pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
265
266
267 pub system_program: &'b solana_account_info::AccountInfo<'a>,
268 }
269
270pub struct CancelPublicAutomationCpi<'a, 'b> {
272 pub __program: &'b solana_account_info::AccountInfo<'a>,
274
275
276 pub authority: &'b solana_account_info::AccountInfo<'a>,
277
278
279 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
280
281
282 pub public_automation: &'b solana_account_info::AccountInfo<'a>,
283
284
285 pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
286
287
288 pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
289 pub authority_usd_ata: &'b solana_account_info::AccountInfo<'a>,
294
295
296 pub token_program: &'b solana_account_info::AccountInfo<'a>,
297
298
299 pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
300
301
302 pub system_program: &'b solana_account_info::AccountInfo<'a>,
303 }
304
305impl<'a, 'b> CancelPublicAutomationCpi<'a, 'b> {
306 pub fn new(
307 program: &'b solana_account_info::AccountInfo<'a>,
308 accounts: CancelPublicAutomationCpiAccounts<'a, 'b>,
309 ) -> Self {
310 Self {
311 __program: program,
312 authority: accounts.authority,
313 satrush_config: accounts.satrush_config,
314 public_automation: accounts.public_automation,
315 usd_mint: accounts.usd_mint,
316 automation_usd_ata: accounts.automation_usd_ata,
317 authority_usd_ata: accounts.authority_usd_ata,
318 token_program: accounts.token_program,
319 associated_token_program: accounts.associated_token_program,
320 system_program: accounts.system_program,
321 }
322 }
323 #[inline(always)]
324 pub fn invoke(&self) -> solana_program_error::ProgramResult {
325 self.invoke_signed_with_remaining_accounts(&[], &[])
326 }
327 #[inline(always)]
328 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
329 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
330 }
331 #[inline(always)]
332 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
333 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
334 }
335 #[allow(clippy::arithmetic_side_effects)]
336 #[allow(clippy::clone_on_copy)]
337 #[allow(clippy::vec_init_then_push)]
338 pub fn invoke_signed_with_remaining_accounts(
339 &self,
340 signers_seeds: &[&[&[u8]]],
341 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
342 ) -> solana_program_error::ProgramResult {
343 let mut accounts = Vec::with_capacity(9+ remaining_accounts.len());
344 accounts.push(solana_instruction::AccountMeta::new(
345 *self.authority.key,
346 true
347 ));
348 accounts.push(solana_instruction::AccountMeta::new_readonly(
349 *self.satrush_config.key,
350 false
351 ));
352 accounts.push(solana_instruction::AccountMeta::new(
353 *self.public_automation.key,
354 false
355 ));
356 accounts.push(solana_instruction::AccountMeta::new_readonly(
357 *self.usd_mint.key,
358 false
359 ));
360 accounts.push(solana_instruction::AccountMeta::new(
361 *self.automation_usd_ata.key,
362 false
363 ));
364 accounts.push(solana_instruction::AccountMeta::new(
365 *self.authority_usd_ata.key,
366 false
367 ));
368 accounts.push(solana_instruction::AccountMeta::new_readonly(
369 *self.token_program.key,
370 false
371 ));
372 accounts.push(solana_instruction::AccountMeta::new_readonly(
373 *self.associated_token_program.key,
374 false
375 ));
376 accounts.push(solana_instruction::AccountMeta::new_readonly(
377 *self.system_program.key,
378 false
379 ));
380 remaining_accounts.iter().for_each(|remaining_account| {
381 accounts.push(solana_instruction::AccountMeta {
382 pubkey: *remaining_account.0.key,
383 is_signer: remaining_account.1,
384 is_writable: remaining_account.2,
385 })
386 });
387 let data = CancelPublicAutomationInstructionData::new().try_to_vec().unwrap();
388
389 let instruction = solana_instruction::Instruction {
390 program_id: crate::SATRUSH_ID,
391 accounts,
392 data,
393 };
394 let mut account_infos = Vec::with_capacity(10 + remaining_accounts.len());
395 account_infos.push(self.__program.clone());
396 account_infos.push(self.authority.clone());
397 account_infos.push(self.satrush_config.clone());
398 account_infos.push(self.public_automation.clone());
399 account_infos.push(self.usd_mint.clone());
400 account_infos.push(self.automation_usd_ata.clone());
401 account_infos.push(self.authority_usd_ata.clone());
402 account_infos.push(self.token_program.clone());
403 account_infos.push(self.associated_token_program.clone());
404 account_infos.push(self.system_program.clone());
405 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
406
407 if signers_seeds.is_empty() {
408 solana_cpi::invoke(&instruction, &account_infos)
409 } else {
410 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
411 }
412 }
413}
414
415#[derive(Clone, Debug)]
429pub struct CancelPublicAutomationCpiBuilder<'a, 'b> {
430 instruction: Box<CancelPublicAutomationCpiBuilderInstruction<'a, 'b>>,
431}
432
433impl<'a, 'b> CancelPublicAutomationCpiBuilder<'a, 'b> {
434 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
435 let instruction = Box::new(CancelPublicAutomationCpiBuilderInstruction {
436 __program: program,
437 authority: None,
438 satrush_config: None,
439 public_automation: None,
440 usd_mint: None,
441 automation_usd_ata: None,
442 authority_usd_ata: None,
443 token_program: None,
444 associated_token_program: None,
445 system_program: None,
446 __remaining_accounts: Vec::new(),
447 });
448 Self { instruction }
449 }
450 #[inline(always)]
451 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
452 self.instruction.authority = Some(authority);
453 self
454 }
455 #[inline(always)]
456 pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
457 self.instruction.satrush_config = Some(satrush_config);
458 self
459 }
460 #[inline(always)]
461 pub fn public_automation(&mut self, public_automation: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
462 self.instruction.public_automation = Some(public_automation);
463 self
464 }
465 #[inline(always)]
466 pub fn usd_mint(&mut self, usd_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
467 self.instruction.usd_mint = Some(usd_mint);
468 self
469 }
470 #[inline(always)]
471 pub fn automation_usd_ata(&mut self, automation_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
472 self.instruction.automation_usd_ata = Some(automation_usd_ata);
473 self
474 }
475 #[inline(always)]
477 pub fn authority_usd_ata(&mut self, authority_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
478 self.instruction.authority_usd_ata = Some(authority_usd_ata);
479 self
480 }
481 #[inline(always)]
482 pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
483 self.instruction.token_program = Some(token_program);
484 self
485 }
486 #[inline(always)]
487 pub fn associated_token_program(&mut self, associated_token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
488 self.instruction.associated_token_program = Some(associated_token_program);
489 self
490 }
491 #[inline(always)]
492 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
493 self.instruction.system_program = Some(system_program);
494 self
495 }
496 #[inline(always)]
498 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
499 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
500 self
501 }
502 #[inline(always)]
507 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
508 self.instruction.__remaining_accounts.extend_from_slice(accounts);
509 self
510 }
511 #[inline(always)]
512 pub fn invoke(&self) -> solana_program_error::ProgramResult {
513 self.invoke_signed(&[])
514 }
515 #[allow(clippy::clone_on_copy)]
516 #[allow(clippy::vec_init_then_push)]
517 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
518 let instruction = CancelPublicAutomationCpi {
519 __program: self.instruction.__program,
520
521 authority: self.instruction.authority.expect("authority is not set"),
522
523 satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
524
525 public_automation: self.instruction.public_automation.expect("public_automation is not set"),
526
527 usd_mint: self.instruction.usd_mint.expect("usd_mint is not set"),
528
529 automation_usd_ata: self.instruction.automation_usd_ata.expect("automation_usd_ata is not set"),
530
531 authority_usd_ata: self.instruction.authority_usd_ata.expect("authority_usd_ata is not set"),
532
533 token_program: self.instruction.token_program.expect("token_program is not set"),
534
535 associated_token_program: self.instruction.associated_token_program.expect("associated_token_program is not set"),
536
537 system_program: self.instruction.system_program.expect("system_program is not set"),
538 };
539 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
540 }
541}
542
543#[derive(Clone, Debug)]
544struct CancelPublicAutomationCpiBuilderInstruction<'a, 'b> {
545 __program: &'b solana_account_info::AccountInfo<'a>,
546 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
547 satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
548 public_automation: Option<&'b solana_account_info::AccountInfo<'a>>,
549 usd_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
550 automation_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
551 authority_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
552 token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
553 associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
554 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
555 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
557}
558