Skip to main content

satrush_client/generated/instructions/
execute_public_automation.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const EXECUTE_PUBLIC_AUTOMATION_DISCRIMINATOR: [u8; 8] = [212, 191, 100, 136, 18, 213, 42, 72];
12
13/// Accounts.
14#[derive(Debug)]
15pub struct ExecutePublicAutomation {
16            /// The crank (round authority); pays the deployment rent, recovered at
17/// settle.
18
19    
20              
21          pub authority: solana_address::Address,
22          
23              
24          pub satrush_config: solana_address::Address,
25          
26              
27          pub board: solana_address::Address,
28                /// Round the automation deploys into. Must be the board's current round.
29
30    
31              
32          pub round: solana_address::Address,
33                /// The automation being executed; its `authority` field keys the
34/// deployment and miner PDAs below. A regular Account (boxed): its fields
35/// feed seeds, which LazyAccount cannot do.
36
37    
38              
39          pub public_automation: solana_address::Address,
40          
41              
42          pub usd_mint: solana_address::Address,
43                /// The automation's escrow the deploy is funded from.
44
45    
46              
47          pub automation_usd_ata: solana_address::Address,
48                /// Board's USD deposit pool.
49
50    
51              
52          pub board_usd_ata: solana_address::Address,
53                /// Per-(user, round) deployment record. Init fails if the user already
54/// deployed into this round (manually or via this automation).
55
56    
57              
58          pub public_deployment: solana_address::Address,
59                /// The user's miner profile; guaranteed to exist by
60/// `create_public_automation`, so no `init_if_needed` here (stack + rent).
61
62    
63              
64          pub miner: solana_address::Address,
65                /// The affiliate the deploy earns for; the crank passes it for bound
66/// miners. Optional — executions without it succeed but earn nothing.
67/// Read only — the points are frozen on the deployment and credited at
68/// settlement. Boxed rather than lazy: the account is 99 bytes, and
69/// `Option<LazyAccount>` cannot satisfy the generated exit code.
70
71    
72              
73          pub affiliate: Option<solana_address::Address>,
74                /// because the sysvar is too large to deserialize. Feeds Random-strategy
75/// mask generation only, but is always passed (cheap).
76
77    
78              
79          pub slot_hashes: solana_address::Address,
80          
81              
82          pub token_program: solana_address::Address,
83          
84              
85          pub system_program: solana_address::Address,
86          
87              
88          pub event_authority: solana_address::Address,
89          
90              
91          pub program: solana_address::Address,
92      }
93
94impl ExecutePublicAutomation {
95  pub fn instruction(&self, args: ExecutePublicAutomationInstructionArgs) -> solana_instruction::Instruction {
96    self.instruction_with_remaining_accounts(args, &[])
97  }
98  #[allow(clippy::arithmetic_side_effects)]
99  #[allow(clippy::vec_init_then_push)]
100  pub fn instruction_with_remaining_accounts(&self, args: ExecutePublicAutomationInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
101    let mut accounts = Vec::with_capacity(16+ remaining_accounts.len());
102                            accounts.push(solana_instruction::AccountMeta::new(
103            self.authority,
104            true
105          ));
106                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
107            self.satrush_config,
108            false
109          ));
110                                          accounts.push(solana_instruction::AccountMeta::new(
111            self.board,
112            false
113          ));
114                                          accounts.push(solana_instruction::AccountMeta::new(
115            self.round,
116            false
117          ));
118                                          accounts.push(solana_instruction::AccountMeta::new(
119            self.public_automation,
120            false
121          ));
122                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
123            self.usd_mint,
124            false
125          ));
126                                          accounts.push(solana_instruction::AccountMeta::new(
127            self.automation_usd_ata,
128            false
129          ));
130                                          accounts.push(solana_instruction::AccountMeta::new(
131            self.board_usd_ata,
132            false
133          ));
134                                          accounts.push(solana_instruction::AccountMeta::new(
135            self.public_deployment,
136            false
137          ));
138                                          accounts.push(solana_instruction::AccountMeta::new(
139            self.miner,
140            false
141          ));
142                                                      if let Some(affiliate) = self.affiliate {
143              accounts.push(solana_instruction::AccountMeta::new_readonly(
144                affiliate,
145                false,
146              ));
147            } else {
148              accounts.push(solana_instruction::AccountMeta::new_readonly(
149                crate::SATRUSH_ID,
150                false,
151              ));
152            }
153                                                    accounts.push(solana_instruction::AccountMeta::new_readonly(
154            self.slot_hashes,
155            false
156          ));
157                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
158            self.token_program,
159            false
160          ));
161                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
162            self.system_program,
163            false
164          ));
165                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
166            self.event_authority,
167            false
168          ));
169                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
170            self.program,
171            false
172          ));
173                      accounts.extend_from_slice(remaining_accounts);
174    let mut data = ExecutePublicAutomationInstructionData::new().try_to_vec().unwrap();
175          let mut args = args.try_to_vec().unwrap();
176      data.append(&mut args);
177    
178    solana_instruction::Instruction {
179      program_id: crate::SATRUSH_ID,
180      accounts,
181      data,
182    }
183  }
184}
185
186#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
187 pub struct ExecutePublicAutomationInstructionData {
188            discriminator: [u8; 8],
189            }
190
191impl ExecutePublicAutomationInstructionData {
192  pub fn new() -> Self {
193    Self {
194                        discriminator: [212, 191, 100, 136, 18, 213, 42, 72],
195                                }
196  }
197
198    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
199    borsh::to_vec(self)
200  }
201  }
202
203impl Default for ExecutePublicAutomationInstructionData {
204  fn default() -> Self {
205    Self::new()
206  }
207}
208
209#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
210 pub struct ExecutePublicAutomationInstructionArgs {
211                  pub selection_mask: Option<u32>,
212      }
213
214impl ExecutePublicAutomationInstructionArgs {
215  pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
216    borsh::to_vec(self)
217  }
218}
219
220
221/// Instruction builder for `ExecutePublicAutomation`.
222///
223/// ### Accounts:
224///
225                      ///   0. `[writable, signer]` authority
226          ///   1. `[]` satrush_config
227                ///   2. `[writable]` board
228                ///   3. `[writable]` round
229                ///   4. `[writable]` public_automation
230          ///   5. `[]` usd_mint
231                ///   6. `[writable]` automation_usd_ata
232                ///   7. `[writable]` board_usd_ata
233                ///   8. `[writable]` public_deployment
234                ///   9. `[writable]` miner
235                ///   10. `[optional]` affiliate
236                ///   11. `[optional]` slot_hashes (default to `SysvarS1otHashes111111111111111111111111111`)
237                ///   12. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
238                ///   13. `[optional]` system_program (default to `11111111111111111111111111111111`)
239          ///   14. `[]` event_authority
240          ///   15. `[]` program
241#[derive(Clone, Debug, Default)]
242pub struct ExecutePublicAutomationBuilder {
243            authority: Option<solana_address::Address>,
244                satrush_config: Option<solana_address::Address>,
245                board: Option<solana_address::Address>,
246                round: Option<solana_address::Address>,
247                public_automation: Option<solana_address::Address>,
248                usd_mint: Option<solana_address::Address>,
249                automation_usd_ata: Option<solana_address::Address>,
250                board_usd_ata: Option<solana_address::Address>,
251                public_deployment: Option<solana_address::Address>,
252                miner: Option<solana_address::Address>,
253                affiliate: Option<solana_address::Address>,
254                slot_hashes: Option<solana_address::Address>,
255                token_program: Option<solana_address::Address>,
256                system_program: Option<solana_address::Address>,
257                event_authority: Option<solana_address::Address>,
258                program: Option<solana_address::Address>,
259                        selection_mask: Option<u32>,
260        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
261}
262
263impl ExecutePublicAutomationBuilder {
264  pub fn new() -> Self {
265    Self::default()
266  }
267            /// The crank (round authority); pays the deployment rent, recovered at
268/// settle.
269#[inline(always)]
270    pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
271                        self.authority = Some(authority);
272                    self
273    }
274            #[inline(always)]
275    pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
276                        self.satrush_config = Some(satrush_config);
277                    self
278    }
279            #[inline(always)]
280    pub fn board(&mut self, board: solana_address::Address) -> &mut Self {
281                        self.board = Some(board);
282                    self
283    }
284            /// Round the automation deploys into. Must be the board's current round.
285#[inline(always)]
286    pub fn round(&mut self, round: solana_address::Address) -> &mut Self {
287                        self.round = Some(round);
288                    self
289    }
290            /// The automation being executed; its `authority` field keys the
291/// deployment and miner PDAs below. A regular Account (boxed): its fields
292/// feed seeds, which LazyAccount cannot do.
293#[inline(always)]
294    pub fn public_automation(&mut self, public_automation: solana_address::Address) -> &mut Self {
295                        self.public_automation = Some(public_automation);
296                    self
297    }
298            #[inline(always)]
299    pub fn usd_mint(&mut self, usd_mint: solana_address::Address) -> &mut Self {
300                        self.usd_mint = Some(usd_mint);
301                    self
302    }
303            /// The automation's escrow the deploy is funded from.
304#[inline(always)]
305    pub fn automation_usd_ata(&mut self, automation_usd_ata: solana_address::Address) -> &mut Self {
306                        self.automation_usd_ata = Some(automation_usd_ata);
307                    self
308    }
309            /// Board's USD deposit pool.
310#[inline(always)]
311    pub fn board_usd_ata(&mut self, board_usd_ata: solana_address::Address) -> &mut Self {
312                        self.board_usd_ata = Some(board_usd_ata);
313                    self
314    }
315            /// Per-(user, round) deployment record. Init fails if the user already
316/// deployed into this round (manually or via this automation).
317#[inline(always)]
318    pub fn public_deployment(&mut self, public_deployment: solana_address::Address) -> &mut Self {
319                        self.public_deployment = Some(public_deployment);
320                    self
321    }
322            /// The user's miner profile; guaranteed to exist by
323/// `create_public_automation`, so no `init_if_needed` here (stack + rent).
324#[inline(always)]
325    pub fn miner(&mut self, miner: solana_address::Address) -> &mut Self {
326                        self.miner = Some(miner);
327                    self
328    }
329            /// `[optional account]`
330/// The affiliate the deploy earns for; the crank passes it for bound
331/// miners. Optional — executions without it succeed but earn nothing.
332/// Read only — the points are frozen on the deployment and credited at
333/// settlement. Boxed rather than lazy: the account is 99 bytes, and
334/// `Option<LazyAccount>` cannot satisfy the generated exit code.
335#[inline(always)]
336    pub fn affiliate(&mut self, affiliate: Option<solana_address::Address>) -> &mut Self {
337                        self.affiliate = affiliate;
338                    self
339    }
340            /// `[optional account, default to 'SysvarS1otHashes111111111111111111111111111']`
341/// because the sysvar is too large to deserialize. Feeds Random-strategy
342/// mask generation only, but is always passed (cheap).
343#[inline(always)]
344    pub fn slot_hashes(&mut self, slot_hashes: solana_address::Address) -> &mut Self {
345                        self.slot_hashes = Some(slot_hashes);
346                    self
347    }
348            /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
349#[inline(always)]
350    pub fn token_program(&mut self, token_program: solana_address::Address) -> &mut Self {
351                        self.token_program = Some(token_program);
352                    self
353    }
354            /// `[optional account, default to '11111111111111111111111111111111']`
355#[inline(always)]
356    pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
357                        self.system_program = Some(system_program);
358                    self
359    }
360            #[inline(always)]
361    pub fn event_authority(&mut self, event_authority: solana_address::Address) -> &mut Self {
362                        self.event_authority = Some(event_authority);
363                    self
364    }
365            #[inline(always)]
366    pub fn program(&mut self, program: solana_address::Address) -> &mut Self {
367                        self.program = Some(program);
368                    self
369    }
370                    /// `[optional argument]`
371#[inline(always)]
372      pub fn selection_mask(&mut self, selection_mask: u32) -> &mut Self {
373        self.selection_mask = Some(selection_mask);
374        self
375      }
376        /// Add an additional account to the instruction.
377  #[inline(always)]
378  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
379    self.__remaining_accounts.push(account);
380    self
381  }
382  /// Add additional accounts to the instruction.
383  #[inline(always)]
384  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
385    self.__remaining_accounts.extend_from_slice(accounts);
386    self
387  }
388  #[allow(clippy::clone_on_copy)]
389  pub fn instruction(&self) -> solana_instruction::Instruction {
390    let accounts = ExecutePublicAutomation {
391                              authority: self.authority.expect("authority is not set"),
392                                        satrush_config: self.satrush_config.expect("satrush_config is not set"),
393                                        board: self.board.expect("board is not set"),
394                                        round: self.round.expect("round is not set"),
395                                        public_automation: self.public_automation.expect("public_automation is not set"),
396                                        usd_mint: self.usd_mint.expect("usd_mint is not set"),
397                                        automation_usd_ata: self.automation_usd_ata.expect("automation_usd_ata is not set"),
398                                        board_usd_ata: self.board_usd_ata.expect("board_usd_ata is not set"),
399                                        public_deployment: self.public_deployment.expect("public_deployment is not set"),
400                                        miner: self.miner.expect("miner is not set"),
401                                        affiliate: self.affiliate,
402                                        slot_hashes: self.slot_hashes.unwrap_or(solana_address::address!("SysvarS1otHashes111111111111111111111111111")),
403                                        token_program: self.token_program.unwrap_or(solana_address::address!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")),
404                                        system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
405                                        event_authority: self.event_authority.expect("event_authority is not set"),
406                                        program: self.program.expect("program is not set"),
407                      };
408          let args = ExecutePublicAutomationInstructionArgs {
409                                                              selection_mask: self.selection_mask.clone(),
410                                    };
411    
412    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
413  }
414}
415
416  /// `execute_public_automation` CPI accounts.
417  pub struct ExecutePublicAutomationCpiAccounts<'a, 'b> {
418                  /// The crank (round authority); pays the deployment rent, recovered at
419/// settle.
420
421      
422                    
423              pub authority: &'b solana_account_info::AccountInfo<'a>,
424                
425                    
426              pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
427                
428                    
429              pub board: &'b solana_account_info::AccountInfo<'a>,
430                        /// Round the automation deploys into. Must be the board's current round.
431
432      
433                    
434              pub round: &'b solana_account_info::AccountInfo<'a>,
435                        /// The automation being executed; its `authority` field keys the
436/// deployment and miner PDAs below. A regular Account (boxed): its fields
437/// feed seeds, which LazyAccount cannot do.
438
439      
440                    
441              pub public_automation: &'b solana_account_info::AccountInfo<'a>,
442                
443                    
444              pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
445                        /// The automation's escrow the deploy is funded from.
446
447      
448                    
449              pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
450                        /// Board's USD deposit pool.
451
452      
453                    
454              pub board_usd_ata: &'b solana_account_info::AccountInfo<'a>,
455                        /// Per-(user, round) deployment record. Init fails if the user already
456/// deployed into this round (manually or via this automation).
457
458      
459                    
460              pub public_deployment: &'b solana_account_info::AccountInfo<'a>,
461                        /// The user's miner profile; guaranteed to exist by
462/// `create_public_automation`, so no `init_if_needed` here (stack + rent).
463
464      
465                    
466              pub miner: &'b solana_account_info::AccountInfo<'a>,
467                        /// The affiliate the deploy earns for; the crank passes it for bound
468/// miners. Optional — executions without it succeed but earn nothing.
469/// Read only — the points are frozen on the deployment and credited at
470/// settlement. Boxed rather than lazy: the account is 99 bytes, and
471/// `Option<LazyAccount>` cannot satisfy the generated exit code.
472
473      
474                    
475              pub affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
476                        /// because the sysvar is too large to deserialize. Feeds Random-strategy
477/// mask generation only, but is always passed (cheap).
478
479      
480                    
481              pub slot_hashes: &'b solana_account_info::AccountInfo<'a>,
482                
483                    
484              pub token_program: &'b solana_account_info::AccountInfo<'a>,
485                
486                    
487              pub system_program: &'b solana_account_info::AccountInfo<'a>,
488                
489                    
490              pub event_authority: &'b solana_account_info::AccountInfo<'a>,
491                
492                    
493              pub program: &'b solana_account_info::AccountInfo<'a>,
494            }
495
496/// `execute_public_automation` CPI instruction.
497pub struct ExecutePublicAutomationCpi<'a, 'b> {
498  /// The program to invoke.
499  pub __program: &'b solana_account_info::AccountInfo<'a>,
500            /// The crank (round authority); pays the deployment rent, recovered at
501/// settle.
502
503    
504              
505          pub authority: &'b solana_account_info::AccountInfo<'a>,
506          
507              
508          pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
509          
510              
511          pub board: &'b solana_account_info::AccountInfo<'a>,
512                /// Round the automation deploys into. Must be the board's current round.
513
514    
515              
516          pub round: &'b solana_account_info::AccountInfo<'a>,
517                /// The automation being executed; its `authority` field keys the
518/// deployment and miner PDAs below. A regular Account (boxed): its fields
519/// feed seeds, which LazyAccount cannot do.
520
521    
522              
523          pub public_automation: &'b solana_account_info::AccountInfo<'a>,
524          
525              
526          pub usd_mint: &'b solana_account_info::AccountInfo<'a>,
527                /// The automation's escrow the deploy is funded from.
528
529    
530              
531          pub automation_usd_ata: &'b solana_account_info::AccountInfo<'a>,
532                /// Board's USD deposit pool.
533
534    
535              
536          pub board_usd_ata: &'b solana_account_info::AccountInfo<'a>,
537                /// Per-(user, round) deployment record. Init fails if the user already
538/// deployed into this round (manually or via this automation).
539
540    
541              
542          pub public_deployment: &'b solana_account_info::AccountInfo<'a>,
543                /// The user's miner profile; guaranteed to exist by
544/// `create_public_automation`, so no `init_if_needed` here (stack + rent).
545
546    
547              
548          pub miner: &'b solana_account_info::AccountInfo<'a>,
549                /// The affiliate the deploy earns for; the crank passes it for bound
550/// miners. Optional — executions without it succeed but earn nothing.
551/// Read only — the points are frozen on the deployment and credited at
552/// settlement. Boxed rather than lazy: the account is 99 bytes, and
553/// `Option<LazyAccount>` cannot satisfy the generated exit code.
554
555    
556              
557          pub affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
558                /// because the sysvar is too large to deserialize. Feeds Random-strategy
559/// mask generation only, but is always passed (cheap).
560
561    
562              
563          pub slot_hashes: &'b solana_account_info::AccountInfo<'a>,
564          
565              
566          pub token_program: &'b solana_account_info::AccountInfo<'a>,
567          
568              
569          pub system_program: &'b solana_account_info::AccountInfo<'a>,
570          
571              
572          pub event_authority: &'b solana_account_info::AccountInfo<'a>,
573          
574              
575          pub program: &'b solana_account_info::AccountInfo<'a>,
576            /// The arguments for the instruction.
577    pub __args: ExecutePublicAutomationInstructionArgs,
578  }
579
580impl<'a, 'b> ExecutePublicAutomationCpi<'a, 'b> {
581  pub fn new(
582    program: &'b solana_account_info::AccountInfo<'a>,
583          accounts: ExecutePublicAutomationCpiAccounts<'a, 'b>,
584              args: ExecutePublicAutomationInstructionArgs,
585      ) -> Self {
586    Self {
587      __program: program,
588              authority: accounts.authority,
589              satrush_config: accounts.satrush_config,
590              board: accounts.board,
591              round: accounts.round,
592              public_automation: accounts.public_automation,
593              usd_mint: accounts.usd_mint,
594              automation_usd_ata: accounts.automation_usd_ata,
595              board_usd_ata: accounts.board_usd_ata,
596              public_deployment: accounts.public_deployment,
597              miner: accounts.miner,
598              affiliate: accounts.affiliate,
599              slot_hashes: accounts.slot_hashes,
600              token_program: accounts.token_program,
601              system_program: accounts.system_program,
602              event_authority: accounts.event_authority,
603              program: accounts.program,
604                    __args: args,
605          }
606  }
607  #[inline(always)]
608  pub fn invoke(&self) -> solana_program_error::ProgramResult {
609    self.invoke_signed_with_remaining_accounts(&[], &[])
610  }
611  #[inline(always)]
612  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
613    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
614  }
615  #[inline(always)]
616  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
617    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
618  }
619  #[allow(clippy::arithmetic_side_effects)]
620  #[allow(clippy::clone_on_copy)]
621  #[allow(clippy::vec_init_then_push)]
622  pub fn invoke_signed_with_remaining_accounts(
623    &self,
624    signers_seeds: &[&[&[u8]]],
625    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
626  ) -> solana_program_error::ProgramResult {
627    let mut accounts = Vec::with_capacity(16+ remaining_accounts.len());
628                            accounts.push(solana_instruction::AccountMeta::new(
629            *self.authority.key,
630            true
631          ));
632                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
633            *self.satrush_config.key,
634            false
635          ));
636                                          accounts.push(solana_instruction::AccountMeta::new(
637            *self.board.key,
638            false
639          ));
640                                          accounts.push(solana_instruction::AccountMeta::new(
641            *self.round.key,
642            false
643          ));
644                                          accounts.push(solana_instruction::AccountMeta::new(
645            *self.public_automation.key,
646            false
647          ));
648                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
649            *self.usd_mint.key,
650            false
651          ));
652                                          accounts.push(solana_instruction::AccountMeta::new(
653            *self.automation_usd_ata.key,
654            false
655          ));
656                                          accounts.push(solana_instruction::AccountMeta::new(
657            *self.board_usd_ata.key,
658            false
659          ));
660                                          accounts.push(solana_instruction::AccountMeta::new(
661            *self.public_deployment.key,
662            false
663          ));
664                                          accounts.push(solana_instruction::AccountMeta::new(
665            *self.miner.key,
666            false
667          ));
668                                          if let Some(affiliate) = self.affiliate {
669            accounts.push(solana_instruction::AccountMeta::new_readonly(
670              *affiliate.key,
671              false,
672            ));
673          } else {
674            accounts.push(solana_instruction::AccountMeta::new_readonly(
675              crate::SATRUSH_ID,
676              false,
677            ));
678          }
679                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
680            *self.slot_hashes.key,
681            false
682          ));
683                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
684            *self.token_program.key,
685            false
686          ));
687                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
688            *self.system_program.key,
689            false
690          ));
691                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
692            *self.event_authority.key,
693            false
694          ));
695                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
696            *self.program.key,
697            false
698          ));
699                      remaining_accounts.iter().for_each(|remaining_account| {
700      accounts.push(solana_instruction::AccountMeta {
701          pubkey: *remaining_account.0.key,
702          is_signer: remaining_account.1,
703          is_writable: remaining_account.2,
704      })
705    });
706    let mut data = ExecutePublicAutomationInstructionData::new().try_to_vec().unwrap();
707          let mut args = self.__args.try_to_vec().unwrap();
708      data.append(&mut args);
709    
710    let instruction = solana_instruction::Instruction {
711      program_id: crate::SATRUSH_ID,
712      accounts,
713      data,
714    };
715    let mut account_infos = Vec::with_capacity(17 + remaining_accounts.len());
716    account_infos.push(self.__program.clone());
717                  account_infos.push(self.authority.clone());
718                        account_infos.push(self.satrush_config.clone());
719                        account_infos.push(self.board.clone());
720                        account_infos.push(self.round.clone());
721                        account_infos.push(self.public_automation.clone());
722                        account_infos.push(self.usd_mint.clone());
723                        account_infos.push(self.automation_usd_ata.clone());
724                        account_infos.push(self.board_usd_ata.clone());
725                        account_infos.push(self.public_deployment.clone());
726                        account_infos.push(self.miner.clone());
727                        if let Some(affiliate) = self.affiliate {
728          account_infos.push(affiliate.clone());
729        }
730                        account_infos.push(self.slot_hashes.clone());
731                        account_infos.push(self.token_program.clone());
732                        account_infos.push(self.system_program.clone());
733                        account_infos.push(self.event_authority.clone());
734                        account_infos.push(self.program.clone());
735              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
736
737    if signers_seeds.is_empty() {
738      solana_cpi::invoke(&instruction, &account_infos)
739    } else {
740      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
741    }
742  }
743}
744
745/// Instruction builder for `ExecutePublicAutomation` via CPI.
746///
747/// ### Accounts:
748///
749                      ///   0. `[writable, signer]` authority
750          ///   1. `[]` satrush_config
751                ///   2. `[writable]` board
752                ///   3. `[writable]` round
753                ///   4. `[writable]` public_automation
754          ///   5. `[]` usd_mint
755                ///   6. `[writable]` automation_usd_ata
756                ///   7. `[writable]` board_usd_ata
757                ///   8. `[writable]` public_deployment
758                ///   9. `[writable]` miner
759                ///   10. `[optional]` affiliate
760          ///   11. `[]` slot_hashes
761          ///   12. `[]` token_program
762          ///   13. `[]` system_program
763          ///   14. `[]` event_authority
764          ///   15. `[]` program
765#[derive(Clone, Debug)]
766pub struct ExecutePublicAutomationCpiBuilder<'a, 'b> {
767  instruction: Box<ExecutePublicAutomationCpiBuilderInstruction<'a, 'b>>,
768}
769
770impl<'a, 'b> ExecutePublicAutomationCpiBuilder<'a, 'b> {
771  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
772    let instruction = Box::new(ExecutePublicAutomationCpiBuilderInstruction {
773      __program: program,
774              authority: None,
775              satrush_config: None,
776              board: None,
777              round: None,
778              public_automation: None,
779              usd_mint: None,
780              automation_usd_ata: None,
781              board_usd_ata: None,
782              public_deployment: None,
783              miner: None,
784              affiliate: None,
785              slot_hashes: None,
786              token_program: None,
787              system_program: None,
788              event_authority: None,
789              program: None,
790                                            selection_mask: None,
791                    __remaining_accounts: Vec::new(),
792    });
793    Self { instruction }
794  }
795      /// The crank (round authority); pays the deployment rent, recovered at
796/// settle.
797#[inline(always)]
798    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
799                        self.instruction.authority = Some(authority);
800                    self
801    }
802      #[inline(always)]
803    pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
804                        self.instruction.satrush_config = Some(satrush_config);
805                    self
806    }
807      #[inline(always)]
808    pub fn board(&mut self, board: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
809                        self.instruction.board = Some(board);
810                    self
811    }
812      /// Round the automation deploys into. Must be the board's current round.
813#[inline(always)]
814    pub fn round(&mut self, round: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
815                        self.instruction.round = Some(round);
816                    self
817    }
818      /// The automation being executed; its `authority` field keys the
819/// deployment and miner PDAs below. A regular Account (boxed): its fields
820/// feed seeds, which LazyAccount cannot do.
821#[inline(always)]
822    pub fn public_automation(&mut self, public_automation: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
823                        self.instruction.public_automation = Some(public_automation);
824                    self
825    }
826      #[inline(always)]
827    pub fn usd_mint(&mut self, usd_mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
828                        self.instruction.usd_mint = Some(usd_mint);
829                    self
830    }
831      /// The automation's escrow the deploy is funded from.
832#[inline(always)]
833    pub fn automation_usd_ata(&mut self, automation_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
834                        self.instruction.automation_usd_ata = Some(automation_usd_ata);
835                    self
836    }
837      /// Board's USD deposit pool.
838#[inline(always)]
839    pub fn board_usd_ata(&mut self, board_usd_ata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
840                        self.instruction.board_usd_ata = Some(board_usd_ata);
841                    self
842    }
843      /// Per-(user, round) deployment record. Init fails if the user already
844/// deployed into this round (manually or via this automation).
845#[inline(always)]
846    pub fn public_deployment(&mut self, public_deployment: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
847                        self.instruction.public_deployment = Some(public_deployment);
848                    self
849    }
850      /// The user's miner profile; guaranteed to exist by
851/// `create_public_automation`, so no `init_if_needed` here (stack + rent).
852#[inline(always)]
853    pub fn miner(&mut self, miner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
854                        self.instruction.miner = Some(miner);
855                    self
856    }
857      /// `[optional account]`
858/// The affiliate the deploy earns for; the crank passes it for bound
859/// miners. Optional — executions without it succeed but earn nothing.
860/// Read only — the points are frozen on the deployment and credited at
861/// settlement. Boxed rather than lazy: the account is 99 bytes, and
862/// `Option<LazyAccount>` cannot satisfy the generated exit code.
863#[inline(always)]
864    pub fn affiliate(&mut self, affiliate: Option<&'b solana_account_info::AccountInfo<'a>>) -> &mut Self {
865                        self.instruction.affiliate = affiliate;
866                    self
867    }
868      /// because the sysvar is too large to deserialize. Feeds Random-strategy
869/// mask generation only, but is always passed (cheap).
870#[inline(always)]
871    pub fn slot_hashes(&mut self, slot_hashes: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
872                        self.instruction.slot_hashes = Some(slot_hashes);
873                    self
874    }
875      #[inline(always)]
876    pub fn token_program(&mut self, token_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
877                        self.instruction.token_program = Some(token_program);
878                    self
879    }
880      #[inline(always)]
881    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
882                        self.instruction.system_program = Some(system_program);
883                    self
884    }
885      #[inline(always)]
886    pub fn event_authority(&mut self, event_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
887                        self.instruction.event_authority = Some(event_authority);
888                    self
889    }
890      #[inline(always)]
891    pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
892                        self.instruction.program = Some(program);
893                    self
894    }
895                    /// `[optional argument]`
896#[inline(always)]
897      pub fn selection_mask(&mut self, selection_mask: u32) -> &mut Self {
898        self.instruction.selection_mask = Some(selection_mask);
899        self
900      }
901        /// Add an additional account to the instruction.
902  #[inline(always)]
903  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
904    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
905    self
906  }
907  /// Add additional accounts to the instruction.
908  ///
909  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
910  /// and a `bool` indicating whether the account is a signer or not.
911  #[inline(always)]
912  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
913    self.instruction.__remaining_accounts.extend_from_slice(accounts);
914    self
915  }
916  #[inline(always)]
917  pub fn invoke(&self) -> solana_program_error::ProgramResult {
918    self.invoke_signed(&[])
919  }
920  #[allow(clippy::clone_on_copy)]
921  #[allow(clippy::vec_init_then_push)]
922  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
923          let args = ExecutePublicAutomationInstructionArgs {
924                                                              selection_mask: self.instruction.selection_mask.clone(),
925                                    };
926        let instruction = ExecutePublicAutomationCpi {
927        __program: self.instruction.__program,
928                  
929          authority: self.instruction.authority.expect("authority is not set"),
930                  
931          satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
932                  
933          board: self.instruction.board.expect("board is not set"),
934                  
935          round: self.instruction.round.expect("round is not set"),
936                  
937          public_automation: self.instruction.public_automation.expect("public_automation is not set"),
938                  
939          usd_mint: self.instruction.usd_mint.expect("usd_mint is not set"),
940                  
941          automation_usd_ata: self.instruction.automation_usd_ata.expect("automation_usd_ata is not set"),
942                  
943          board_usd_ata: self.instruction.board_usd_ata.expect("board_usd_ata is not set"),
944                  
945          public_deployment: self.instruction.public_deployment.expect("public_deployment is not set"),
946                  
947          miner: self.instruction.miner.expect("miner is not set"),
948                  
949          affiliate: self.instruction.affiliate,
950                  
951          slot_hashes: self.instruction.slot_hashes.expect("slot_hashes is not set"),
952                  
953          token_program: self.instruction.token_program.expect("token_program is not set"),
954                  
955          system_program: self.instruction.system_program.expect("system_program is not set"),
956                  
957          event_authority: self.instruction.event_authority.expect("event_authority is not set"),
958                  
959          program: self.instruction.program.expect("program is not set"),
960                          __args: args,
961            };
962    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
963  }
964}
965
966#[derive(Clone, Debug)]
967struct ExecutePublicAutomationCpiBuilderInstruction<'a, 'b> {
968  __program: &'b solana_account_info::AccountInfo<'a>,
969            authority: Option<&'b solana_account_info::AccountInfo<'a>>,
970                satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
971                board: Option<&'b solana_account_info::AccountInfo<'a>>,
972                round: Option<&'b solana_account_info::AccountInfo<'a>>,
973                public_automation: Option<&'b solana_account_info::AccountInfo<'a>>,
974                usd_mint: Option<&'b solana_account_info::AccountInfo<'a>>,
975                automation_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
976                board_usd_ata: Option<&'b solana_account_info::AccountInfo<'a>>,
977                public_deployment: Option<&'b solana_account_info::AccountInfo<'a>>,
978                miner: Option<&'b solana_account_info::AccountInfo<'a>>,
979                affiliate: Option<&'b solana_account_info::AccountInfo<'a>>,
980                slot_hashes: Option<&'b solana_account_info::AccountInfo<'a>>,
981                token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
982                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
983                event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
984                program: Option<&'b solana_account_info::AccountInfo<'a>>,
985                        selection_mask: Option<u32>,
986        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
987  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
988}
989