Skip to main content

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