Skip to main content

satrush_client/generated/instructions/
trigger_epoch_draw.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 TRIGGER_EPOCH_DRAW_DISCRIMINATOR: [u8; 8] = [93, 12, 139, 55, 235, 88, 37, 117];
12
13/// Accounts.
14#[derive(Debug)]
15pub struct TriggerEpochDraw {
16      
17              
18          pub authority: solana_address::Address,
19          
20              
21          pub satrush_config: solana_address::Address,
22                /// The epoch rotor's registered rearm authority: signs the arm CPI.
23
24    
25              
26          pub epoch_vault: solana_address::Address,
27          
28              
29          pub epoch_vault_iteration: solana_address::Address,
30          
31              
32          pub next_epoch_vault_iteration: solana_address::Address,
33          
34              
35          pub system_program: solana_address::Address,
36          
37              
38          pub event_authority: solana_address::Address,
39          
40              
41          pub program: solana_address::Address,
42      }
43
44impl TriggerEpochDraw {
45  pub fn instruction(&self) -> solana_instruction::Instruction {
46    self.instruction_with_remaining_accounts(&[])
47  }
48  #[allow(clippy::arithmetic_side_effects)]
49  #[allow(clippy::vec_init_then_push)]
50  pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
51    let mut accounts = Vec::with_capacity(8+ remaining_accounts.len());
52                            accounts.push(solana_instruction::AccountMeta::new(
53            self.authority,
54            true
55          ));
56                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
57            self.satrush_config,
58            false
59          ));
60                                          accounts.push(solana_instruction::AccountMeta::new(
61            self.epoch_vault,
62            false
63          ));
64                                          accounts.push(solana_instruction::AccountMeta::new(
65            self.epoch_vault_iteration,
66            false
67          ));
68                                          accounts.push(solana_instruction::AccountMeta::new(
69            self.next_epoch_vault_iteration,
70            false
71          ));
72                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
73            self.system_program,
74            false
75          ));
76                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
77            self.event_authority,
78            false
79          ));
80                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
81            self.program,
82            false
83          ));
84                      accounts.extend_from_slice(remaining_accounts);
85    let data = TriggerEpochDrawInstructionData::new().try_to_vec().unwrap();
86    
87    solana_instruction::Instruction {
88      program_id: crate::SATRUSH_ID,
89      accounts,
90      data,
91    }
92  }
93}
94
95#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
96 pub struct TriggerEpochDrawInstructionData {
97            discriminator: [u8; 8],
98      }
99
100impl TriggerEpochDrawInstructionData {
101  pub fn new() -> Self {
102    Self {
103                        discriminator: [93, 12, 139, 55, 235, 88, 37, 117],
104                  }
105  }
106
107    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
108    borsh::to_vec(self)
109  }
110  }
111
112impl Default for TriggerEpochDrawInstructionData {
113  fn default() -> Self {
114    Self::new()
115  }
116}
117
118
119
120/// Instruction builder for `TriggerEpochDraw`.
121///
122/// ### Accounts:
123///
124                      ///   0. `[writable, signer]` authority
125          ///   1. `[]` satrush_config
126                ///   2. `[writable]` epoch_vault
127                ///   3. `[writable]` epoch_vault_iteration
128                ///   4. `[writable]` next_epoch_vault_iteration
129                ///   5. `[optional]` system_program (default to `11111111111111111111111111111111`)
130          ///   6. `[]` event_authority
131          ///   7. `[]` program
132#[derive(Clone, Debug, Default)]
133pub struct TriggerEpochDrawBuilder {
134            authority: Option<solana_address::Address>,
135                satrush_config: Option<solana_address::Address>,
136                epoch_vault: Option<solana_address::Address>,
137                epoch_vault_iteration: Option<solana_address::Address>,
138                next_epoch_vault_iteration: Option<solana_address::Address>,
139                system_program: Option<solana_address::Address>,
140                event_authority: Option<solana_address::Address>,
141                program: Option<solana_address::Address>,
142                __remaining_accounts: Vec<solana_instruction::AccountMeta>,
143}
144
145impl TriggerEpochDrawBuilder {
146  pub fn new() -> Self {
147    Self::default()
148  }
149            #[inline(always)]
150    pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
151                        self.authority = Some(authority);
152                    self
153    }
154            #[inline(always)]
155    pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
156                        self.satrush_config = Some(satrush_config);
157                    self
158    }
159            /// The epoch rotor's registered rearm authority: signs the arm CPI.
160#[inline(always)]
161    pub fn epoch_vault(&mut self, epoch_vault: solana_address::Address) -> &mut Self {
162                        self.epoch_vault = Some(epoch_vault);
163                    self
164    }
165            #[inline(always)]
166    pub fn epoch_vault_iteration(&mut self, epoch_vault_iteration: solana_address::Address) -> &mut Self {
167                        self.epoch_vault_iteration = Some(epoch_vault_iteration);
168                    self
169    }
170            #[inline(always)]
171    pub fn next_epoch_vault_iteration(&mut self, next_epoch_vault_iteration: solana_address::Address) -> &mut Self {
172                        self.next_epoch_vault_iteration = Some(next_epoch_vault_iteration);
173                    self
174    }
175            /// `[optional account, default to '11111111111111111111111111111111']`
176#[inline(always)]
177    pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
178                        self.system_program = Some(system_program);
179                    self
180    }
181            #[inline(always)]
182    pub fn event_authority(&mut self, event_authority: solana_address::Address) -> &mut Self {
183                        self.event_authority = Some(event_authority);
184                    self
185    }
186            #[inline(always)]
187    pub fn program(&mut self, program: solana_address::Address) -> &mut Self {
188                        self.program = Some(program);
189                    self
190    }
191            /// Add an additional account to the instruction.
192  #[inline(always)]
193  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
194    self.__remaining_accounts.push(account);
195    self
196  }
197  /// Add additional accounts to the instruction.
198  #[inline(always)]
199  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
200    self.__remaining_accounts.extend_from_slice(accounts);
201    self
202  }
203  #[allow(clippy::clone_on_copy)]
204  pub fn instruction(&self) -> solana_instruction::Instruction {
205    let accounts = TriggerEpochDraw {
206                              authority: self.authority.expect("authority is not set"),
207                                        satrush_config: self.satrush_config.expect("satrush_config is not set"),
208                                        epoch_vault: self.epoch_vault.expect("epoch_vault is not set"),
209                                        epoch_vault_iteration: self.epoch_vault_iteration.expect("epoch_vault_iteration is not set"),
210                                        next_epoch_vault_iteration: self.next_epoch_vault_iteration.expect("next_epoch_vault_iteration is not set"),
211                                        system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
212                                        event_authority: self.event_authority.expect("event_authority is not set"),
213                                        program: self.program.expect("program is not set"),
214                      };
215    
216    accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
217  }
218}
219
220  /// `trigger_epoch_draw` CPI accounts.
221  pub struct TriggerEpochDrawCpiAccounts<'a, 'b> {
222          
223                    
224              pub authority: &'b solana_account_info::AccountInfo<'a>,
225                
226                    
227              pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
228                        /// The epoch rotor's registered rearm authority: signs the arm CPI.
229
230      
231                    
232              pub epoch_vault: &'b solana_account_info::AccountInfo<'a>,
233                
234                    
235              pub epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
236                
237                    
238              pub next_epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
239                
240                    
241              pub system_program: &'b solana_account_info::AccountInfo<'a>,
242                
243                    
244              pub event_authority: &'b solana_account_info::AccountInfo<'a>,
245                
246                    
247              pub program: &'b solana_account_info::AccountInfo<'a>,
248            }
249
250/// `trigger_epoch_draw` CPI instruction.
251pub struct TriggerEpochDrawCpi<'a, 'b> {
252  /// The program to invoke.
253  pub __program: &'b solana_account_info::AccountInfo<'a>,
254      
255              
256          pub authority: &'b solana_account_info::AccountInfo<'a>,
257          
258              
259          pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
260                /// The epoch rotor's registered rearm authority: signs the arm CPI.
261
262    
263              
264          pub epoch_vault: &'b solana_account_info::AccountInfo<'a>,
265          
266              
267          pub epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
268          
269              
270          pub next_epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
271          
272              
273          pub system_program: &'b solana_account_info::AccountInfo<'a>,
274          
275              
276          pub event_authority: &'b solana_account_info::AccountInfo<'a>,
277          
278              
279          pub program: &'b solana_account_info::AccountInfo<'a>,
280        }
281
282impl<'a, 'b> TriggerEpochDrawCpi<'a, 'b> {
283  pub fn new(
284    program: &'b solana_account_info::AccountInfo<'a>,
285          accounts: TriggerEpochDrawCpiAccounts<'a, 'b>,
286          ) -> Self {
287    Self {
288      __program: program,
289              authority: accounts.authority,
290              satrush_config: accounts.satrush_config,
291              epoch_vault: accounts.epoch_vault,
292              epoch_vault_iteration: accounts.epoch_vault_iteration,
293              next_epoch_vault_iteration: accounts.next_epoch_vault_iteration,
294              system_program: accounts.system_program,
295              event_authority: accounts.event_authority,
296              program: accounts.program,
297                }
298  }
299  #[inline(always)]
300  pub fn invoke(&self) -> solana_program_error::ProgramResult {
301    self.invoke_signed_with_remaining_accounts(&[], &[])
302  }
303  #[inline(always)]
304  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
305    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
306  }
307  #[inline(always)]
308  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
309    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
310  }
311  #[allow(clippy::arithmetic_side_effects)]
312  #[allow(clippy::clone_on_copy)]
313  #[allow(clippy::vec_init_then_push)]
314  pub fn invoke_signed_with_remaining_accounts(
315    &self,
316    signers_seeds: &[&[&[u8]]],
317    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
318  ) -> solana_program_error::ProgramResult {
319    let mut accounts = Vec::with_capacity(8+ remaining_accounts.len());
320                            accounts.push(solana_instruction::AccountMeta::new(
321            *self.authority.key,
322            true
323          ));
324                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
325            *self.satrush_config.key,
326            false
327          ));
328                                          accounts.push(solana_instruction::AccountMeta::new(
329            *self.epoch_vault.key,
330            false
331          ));
332                                          accounts.push(solana_instruction::AccountMeta::new(
333            *self.epoch_vault_iteration.key,
334            false
335          ));
336                                          accounts.push(solana_instruction::AccountMeta::new(
337            *self.next_epoch_vault_iteration.key,
338            false
339          ));
340                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
341            *self.system_program.key,
342            false
343          ));
344                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
345            *self.event_authority.key,
346            false
347          ));
348                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
349            *self.program.key,
350            false
351          ));
352                      remaining_accounts.iter().for_each(|remaining_account| {
353      accounts.push(solana_instruction::AccountMeta {
354          pubkey: *remaining_account.0.key,
355          is_signer: remaining_account.1,
356          is_writable: remaining_account.2,
357      })
358    });
359    let data = TriggerEpochDrawInstructionData::new().try_to_vec().unwrap();
360    
361    let instruction = solana_instruction::Instruction {
362      program_id: crate::SATRUSH_ID,
363      accounts,
364      data,
365    };
366    let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len());
367    account_infos.push(self.__program.clone());
368                  account_infos.push(self.authority.clone());
369                        account_infos.push(self.satrush_config.clone());
370                        account_infos.push(self.epoch_vault.clone());
371                        account_infos.push(self.epoch_vault_iteration.clone());
372                        account_infos.push(self.next_epoch_vault_iteration.clone());
373                        account_infos.push(self.system_program.clone());
374                        account_infos.push(self.event_authority.clone());
375                        account_infos.push(self.program.clone());
376              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
377
378    if signers_seeds.is_empty() {
379      solana_cpi::invoke(&instruction, &account_infos)
380    } else {
381      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
382    }
383  }
384}
385
386/// Instruction builder for `TriggerEpochDraw` via CPI.
387///
388/// ### Accounts:
389///
390                      ///   0. `[writable, signer]` authority
391          ///   1. `[]` satrush_config
392                ///   2. `[writable]` epoch_vault
393                ///   3. `[writable]` epoch_vault_iteration
394                ///   4. `[writable]` next_epoch_vault_iteration
395          ///   5. `[]` system_program
396          ///   6. `[]` event_authority
397          ///   7. `[]` program
398#[derive(Clone, Debug)]
399pub struct TriggerEpochDrawCpiBuilder<'a, 'b> {
400  instruction: Box<TriggerEpochDrawCpiBuilderInstruction<'a, 'b>>,
401}
402
403impl<'a, 'b> TriggerEpochDrawCpiBuilder<'a, 'b> {
404  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
405    let instruction = Box::new(TriggerEpochDrawCpiBuilderInstruction {
406      __program: program,
407              authority: None,
408              satrush_config: None,
409              epoch_vault: None,
410              epoch_vault_iteration: None,
411              next_epoch_vault_iteration: None,
412              system_program: None,
413              event_authority: None,
414              program: None,
415                                __remaining_accounts: Vec::new(),
416    });
417    Self { instruction }
418  }
419      #[inline(always)]
420    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
421                        self.instruction.authority = Some(authority);
422                    self
423    }
424      #[inline(always)]
425    pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
426                        self.instruction.satrush_config = Some(satrush_config);
427                    self
428    }
429      /// The epoch rotor's registered rearm authority: signs the arm CPI.
430#[inline(always)]
431    pub fn epoch_vault(&mut self, epoch_vault: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
432                        self.instruction.epoch_vault = Some(epoch_vault);
433                    self
434    }
435      #[inline(always)]
436    pub fn epoch_vault_iteration(&mut self, epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
437                        self.instruction.epoch_vault_iteration = Some(epoch_vault_iteration);
438                    self
439    }
440      #[inline(always)]
441    pub fn next_epoch_vault_iteration(&mut self, next_epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
442                        self.instruction.next_epoch_vault_iteration = Some(next_epoch_vault_iteration);
443                    self
444    }
445      #[inline(always)]
446    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
447                        self.instruction.system_program = Some(system_program);
448                    self
449    }
450      #[inline(always)]
451    pub fn event_authority(&mut self, event_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
452                        self.instruction.event_authority = Some(event_authority);
453                    self
454    }
455      #[inline(always)]
456    pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
457                        self.instruction.program = Some(program);
458                    self
459    }
460            /// Add an additional account to the instruction.
461  #[inline(always)]
462  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
463    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
464    self
465  }
466  /// Add additional accounts to the instruction.
467  ///
468  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
469  /// and a `bool` indicating whether the account is a signer or not.
470  #[inline(always)]
471  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
472    self.instruction.__remaining_accounts.extend_from_slice(accounts);
473    self
474  }
475  #[inline(always)]
476  pub fn invoke(&self) -> solana_program_error::ProgramResult {
477    self.invoke_signed(&[])
478  }
479  #[allow(clippy::clone_on_copy)]
480  #[allow(clippy::vec_init_then_push)]
481  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
482        let instruction = TriggerEpochDrawCpi {
483        __program: self.instruction.__program,
484                  
485          authority: self.instruction.authority.expect("authority is not set"),
486                  
487          satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
488                  
489          epoch_vault: self.instruction.epoch_vault.expect("epoch_vault is not set"),
490                  
491          epoch_vault_iteration: self.instruction.epoch_vault_iteration.expect("epoch_vault_iteration is not set"),
492                  
493          next_epoch_vault_iteration: self.instruction.next_epoch_vault_iteration.expect("next_epoch_vault_iteration is not set"),
494                  
495          system_program: self.instruction.system_program.expect("system_program is not set"),
496                  
497          event_authority: self.instruction.event_authority.expect("event_authority is not set"),
498                  
499          program: self.instruction.program.expect("program is not set"),
500                    };
501    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
502  }
503}
504
505#[derive(Clone, Debug)]
506struct TriggerEpochDrawCpiBuilderInstruction<'a, 'b> {
507  __program: &'b solana_account_info::AccountInfo<'a>,
508            authority: Option<&'b solana_account_info::AccountInfo<'a>>,
509                satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
510                epoch_vault: Option<&'b solana_account_info::AccountInfo<'a>>,
511                epoch_vault_iteration: Option<&'b solana_account_info::AccountInfo<'a>>,
512                next_epoch_vault_iteration: Option<&'b solana_account_info::AccountInfo<'a>>,
513                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
514                event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
515                program: Option<&'b solana_account_info::AccountInfo<'a>>,
516                /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
517  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
518}
519