Skip to main content

satrush_client/generated/instructions/
close_epoch_entry.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 CLOSE_EPOCH_ENTRY_DISCRIMINATOR: [u8; 8] = [27, 23, 127, 47, 147, 184, 239, 190];
12
13/// Accounts.
14#[derive(Debug)]
15pub struct CloseEpochEntry {
16      
17              
18          pub authority: solana_address::Address,
19          
20              
21          pub satrush_config: solana_address::Address,
22          
23              
24          pub epoch_vault_iteration: solana_address::Address,
25          
26              
27          pub epoch_vault_entry: solana_address::Address,
28      }
29
30impl CloseEpochEntry {
31  pub fn instruction(&self) -> solana_instruction::Instruction {
32    self.instruction_with_remaining_accounts(&[])
33  }
34  #[allow(clippy::arithmetic_side_effects)]
35  #[allow(clippy::vec_init_then_push)]
36  pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
37    let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
38                            accounts.push(solana_instruction::AccountMeta::new(
39            self.authority,
40            true
41          ));
42                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
43            self.satrush_config,
44            false
45          ));
46                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
47            self.epoch_vault_iteration,
48            false
49          ));
50                                          accounts.push(solana_instruction::AccountMeta::new(
51            self.epoch_vault_entry,
52            false
53          ));
54                      accounts.extend_from_slice(remaining_accounts);
55    let data = CloseEpochEntryInstructionData::new().try_to_vec().unwrap();
56    
57    solana_instruction::Instruction {
58      program_id: crate::SATRUSH_ID,
59      accounts,
60      data,
61    }
62  }
63}
64
65#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
66 pub struct CloseEpochEntryInstructionData {
67            discriminator: [u8; 8],
68      }
69
70impl CloseEpochEntryInstructionData {
71  pub fn new() -> Self {
72    Self {
73                        discriminator: [27, 23, 127, 47, 147, 184, 239, 190],
74                  }
75  }
76
77    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
78    borsh::to_vec(self)
79  }
80  }
81
82impl Default for CloseEpochEntryInstructionData {
83  fn default() -> Self {
84    Self::new()
85  }
86}
87
88
89
90/// Instruction builder for `CloseEpochEntry`.
91///
92/// ### Accounts:
93///
94                      ///   0. `[writable, signer]` authority
95          ///   1. `[]` satrush_config
96          ///   2. `[]` epoch_vault_iteration
97                ///   3. `[writable]` epoch_vault_entry
98#[derive(Clone, Debug, Default)]
99pub struct CloseEpochEntryBuilder {
100            authority: Option<solana_address::Address>,
101                satrush_config: Option<solana_address::Address>,
102                epoch_vault_iteration: Option<solana_address::Address>,
103                epoch_vault_entry: Option<solana_address::Address>,
104                __remaining_accounts: Vec<solana_instruction::AccountMeta>,
105}
106
107impl CloseEpochEntryBuilder {
108  pub fn new() -> Self {
109    Self::default()
110  }
111            #[inline(always)]
112    pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
113                        self.authority = Some(authority);
114                    self
115    }
116            #[inline(always)]
117    pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
118                        self.satrush_config = Some(satrush_config);
119                    self
120    }
121            #[inline(always)]
122    pub fn epoch_vault_iteration(&mut self, epoch_vault_iteration: solana_address::Address) -> &mut Self {
123                        self.epoch_vault_iteration = Some(epoch_vault_iteration);
124                    self
125    }
126            #[inline(always)]
127    pub fn epoch_vault_entry(&mut self, epoch_vault_entry: solana_address::Address) -> &mut Self {
128                        self.epoch_vault_entry = Some(epoch_vault_entry);
129                    self
130    }
131            /// Add an additional account to the instruction.
132  #[inline(always)]
133  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
134    self.__remaining_accounts.push(account);
135    self
136  }
137  /// Add additional accounts to the instruction.
138  #[inline(always)]
139  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
140    self.__remaining_accounts.extend_from_slice(accounts);
141    self
142  }
143  #[allow(clippy::clone_on_copy)]
144  pub fn instruction(&self) -> solana_instruction::Instruction {
145    let accounts = CloseEpochEntry {
146                              authority: self.authority.expect("authority is not set"),
147                                        satrush_config: self.satrush_config.expect("satrush_config is not set"),
148                                        epoch_vault_iteration: self.epoch_vault_iteration.expect("epoch_vault_iteration is not set"),
149                                        epoch_vault_entry: self.epoch_vault_entry.expect("epoch_vault_entry is not set"),
150                      };
151    
152    accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
153  }
154}
155
156  /// `close_epoch_entry` CPI accounts.
157  pub struct CloseEpochEntryCpiAccounts<'a, 'b> {
158          
159                    
160              pub authority: &'b solana_account_info::AccountInfo<'a>,
161                
162                    
163              pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
164                
165                    
166              pub epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
167                
168                    
169              pub epoch_vault_entry: &'b solana_account_info::AccountInfo<'a>,
170            }
171
172/// `close_epoch_entry` CPI instruction.
173pub struct CloseEpochEntryCpi<'a, 'b> {
174  /// The program to invoke.
175  pub __program: &'b solana_account_info::AccountInfo<'a>,
176      
177              
178          pub authority: &'b solana_account_info::AccountInfo<'a>,
179          
180              
181          pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
182          
183              
184          pub epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
185          
186              
187          pub epoch_vault_entry: &'b solana_account_info::AccountInfo<'a>,
188        }
189
190impl<'a, 'b> CloseEpochEntryCpi<'a, 'b> {
191  pub fn new(
192    program: &'b solana_account_info::AccountInfo<'a>,
193          accounts: CloseEpochEntryCpiAccounts<'a, 'b>,
194          ) -> Self {
195    Self {
196      __program: program,
197              authority: accounts.authority,
198              satrush_config: accounts.satrush_config,
199              epoch_vault_iteration: accounts.epoch_vault_iteration,
200              epoch_vault_entry: accounts.epoch_vault_entry,
201                }
202  }
203  #[inline(always)]
204  pub fn invoke(&self) -> solana_program_error::ProgramResult {
205    self.invoke_signed_with_remaining_accounts(&[], &[])
206  }
207  #[inline(always)]
208  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
209    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
210  }
211  #[inline(always)]
212  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
213    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
214  }
215  #[allow(clippy::arithmetic_side_effects)]
216  #[allow(clippy::clone_on_copy)]
217  #[allow(clippy::vec_init_then_push)]
218  pub fn invoke_signed_with_remaining_accounts(
219    &self,
220    signers_seeds: &[&[&[u8]]],
221    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
222  ) -> solana_program_error::ProgramResult {
223    let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
224                            accounts.push(solana_instruction::AccountMeta::new(
225            *self.authority.key,
226            true
227          ));
228                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
229            *self.satrush_config.key,
230            false
231          ));
232                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
233            *self.epoch_vault_iteration.key,
234            false
235          ));
236                                          accounts.push(solana_instruction::AccountMeta::new(
237            *self.epoch_vault_entry.key,
238            false
239          ));
240                      remaining_accounts.iter().for_each(|remaining_account| {
241      accounts.push(solana_instruction::AccountMeta {
242          pubkey: *remaining_account.0.key,
243          is_signer: remaining_account.1,
244          is_writable: remaining_account.2,
245      })
246    });
247    let data = CloseEpochEntryInstructionData::new().try_to_vec().unwrap();
248    
249    let instruction = solana_instruction::Instruction {
250      program_id: crate::SATRUSH_ID,
251      accounts,
252      data,
253    };
254    let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
255    account_infos.push(self.__program.clone());
256                  account_infos.push(self.authority.clone());
257                        account_infos.push(self.satrush_config.clone());
258                        account_infos.push(self.epoch_vault_iteration.clone());
259                        account_infos.push(self.epoch_vault_entry.clone());
260              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
261
262    if signers_seeds.is_empty() {
263      solana_cpi::invoke(&instruction, &account_infos)
264    } else {
265      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
266    }
267  }
268}
269
270/// Instruction builder for `CloseEpochEntry` via CPI.
271///
272/// ### Accounts:
273///
274                      ///   0. `[writable, signer]` authority
275          ///   1. `[]` satrush_config
276          ///   2. `[]` epoch_vault_iteration
277                ///   3. `[writable]` epoch_vault_entry
278#[derive(Clone, Debug)]
279pub struct CloseEpochEntryCpiBuilder<'a, 'b> {
280  instruction: Box<CloseEpochEntryCpiBuilderInstruction<'a, 'b>>,
281}
282
283impl<'a, 'b> CloseEpochEntryCpiBuilder<'a, 'b> {
284  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
285    let instruction = Box::new(CloseEpochEntryCpiBuilderInstruction {
286      __program: program,
287              authority: None,
288              satrush_config: None,
289              epoch_vault_iteration: None,
290              epoch_vault_entry: None,
291                                __remaining_accounts: Vec::new(),
292    });
293    Self { instruction }
294  }
295      #[inline(always)]
296    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
297                        self.instruction.authority = Some(authority);
298                    self
299    }
300      #[inline(always)]
301    pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
302                        self.instruction.satrush_config = Some(satrush_config);
303                    self
304    }
305      #[inline(always)]
306    pub fn epoch_vault_iteration(&mut self, epoch_vault_iteration: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
307                        self.instruction.epoch_vault_iteration = Some(epoch_vault_iteration);
308                    self
309    }
310      #[inline(always)]
311    pub fn epoch_vault_entry(&mut self, epoch_vault_entry: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
312                        self.instruction.epoch_vault_entry = Some(epoch_vault_entry);
313                    self
314    }
315            /// Add an additional account to the instruction.
316  #[inline(always)]
317  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
318    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
319    self
320  }
321  /// Add additional accounts to the instruction.
322  ///
323  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
324  /// and a `bool` indicating whether the account is a signer or not.
325  #[inline(always)]
326  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
327    self.instruction.__remaining_accounts.extend_from_slice(accounts);
328    self
329  }
330  #[inline(always)]
331  pub fn invoke(&self) -> solana_program_error::ProgramResult {
332    self.invoke_signed(&[])
333  }
334  #[allow(clippy::clone_on_copy)]
335  #[allow(clippy::vec_init_then_push)]
336  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
337        let instruction = CloseEpochEntryCpi {
338        __program: self.instruction.__program,
339                  
340          authority: self.instruction.authority.expect("authority is not set"),
341                  
342          satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
343                  
344          epoch_vault_iteration: self.instruction.epoch_vault_iteration.expect("epoch_vault_iteration is not set"),
345                  
346          epoch_vault_entry: self.instruction.epoch_vault_entry.expect("epoch_vault_entry is not set"),
347                    };
348    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
349  }
350}
351
352#[derive(Clone, Debug)]
353struct CloseEpochEntryCpiBuilderInstruction<'a, 'b> {
354  __program: &'b solana_account_info::AccountInfo<'a>,
355            authority: Option<&'b solana_account_info::AccountInfo<'a>>,
356                satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
357                epoch_vault_iteration: Option<&'b solana_account_info::AccountInfo<'a>>,
358                epoch_vault_entry: Option<&'b solana_account_info::AccountInfo<'a>>,
359                /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
360  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
361}
362