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