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