Skip to main content

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