Skip to main content

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