jito_vault_client/generated/instructions/
initialize_config.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! <https://github.com/kinobi-so/kinobi>
6
7use borsh::{BorshDeserialize, BorshSerialize};
8
9/// Accounts.
10pub struct InitializeConfig {
11    pub config: solana_program::pubkey::Pubkey,
12
13    pub admin: solana_program::pubkey::Pubkey,
14
15    pub restaking_program: solana_program::pubkey::Pubkey,
16
17    pub program_fee_wallet: solana_program::pubkey::Pubkey,
18
19    pub system_program: solana_program::pubkey::Pubkey,
20}
21
22impl InitializeConfig {
23    pub fn instruction(
24        &self,
25        args: InitializeConfigInstructionArgs,
26    ) -> solana_program::instruction::Instruction {
27        self.instruction_with_remaining_accounts(args, &[])
28    }
29    #[allow(clippy::vec_init_then_push)]
30    pub fn instruction_with_remaining_accounts(
31        &self,
32        args: InitializeConfigInstructionArgs,
33        remaining_accounts: &[solana_program::instruction::AccountMeta],
34    ) -> solana_program::instruction::Instruction {
35        let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
36        accounts.push(solana_program::instruction::AccountMeta::new(
37            self.config,
38            false,
39        ));
40        accounts.push(solana_program::instruction::AccountMeta::new(
41            self.admin, true,
42        ));
43        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
44            self.restaking_program,
45            false,
46        ));
47        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
48            self.program_fee_wallet,
49            false,
50        ));
51        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52            self.system_program,
53            false,
54        ));
55        accounts.extend_from_slice(remaining_accounts);
56        let mut data = InitializeConfigInstructionData::new().try_to_vec().unwrap();
57        let mut args = args.try_to_vec().unwrap();
58        data.append(&mut args);
59
60        solana_program::instruction::Instruction {
61            program_id: crate::JITO_VAULT_ID,
62            accounts,
63            data,
64        }
65    }
66}
67
68#[derive(BorshDeserialize, BorshSerialize)]
69pub struct InitializeConfigInstructionData {
70    discriminator: u8,
71}
72
73impl InitializeConfigInstructionData {
74    pub fn new() -> Self {
75        Self { discriminator: 0 }
76    }
77}
78
79impl Default for InitializeConfigInstructionData {
80    fn default() -> Self {
81        Self::new()
82    }
83}
84
85#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
86#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
87pub struct InitializeConfigInstructionArgs {
88    pub program_fee_bps: u16,
89}
90
91/// Instruction builder for `InitializeConfig`.
92///
93/// ### Accounts:
94///
95///   0. `[writable]` config
96///   1. `[writable, signer]` admin
97///   2. `[]` restaking_program
98///   3. `[]` program_fee_wallet
99///   4. `[optional]` system_program (default to `11111111111111111111111111111111`)
100#[derive(Clone, Debug, Default)]
101pub struct InitializeConfigBuilder {
102    config: Option<solana_program::pubkey::Pubkey>,
103    admin: Option<solana_program::pubkey::Pubkey>,
104    restaking_program: Option<solana_program::pubkey::Pubkey>,
105    program_fee_wallet: Option<solana_program::pubkey::Pubkey>,
106    system_program: Option<solana_program::pubkey::Pubkey>,
107    program_fee_bps: Option<u16>,
108    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
109}
110
111impl InitializeConfigBuilder {
112    pub fn new() -> Self {
113        Self::default()
114    }
115    #[inline(always)]
116    pub fn config(&mut self, config: solana_program::pubkey::Pubkey) -> &mut Self {
117        self.config = Some(config);
118        self
119    }
120    #[inline(always)]
121    pub fn admin(&mut self, admin: solana_program::pubkey::Pubkey) -> &mut Self {
122        self.admin = Some(admin);
123        self
124    }
125    #[inline(always)]
126    pub fn restaking_program(
127        &mut self,
128        restaking_program: solana_program::pubkey::Pubkey,
129    ) -> &mut Self {
130        self.restaking_program = Some(restaking_program);
131        self
132    }
133    #[inline(always)]
134    pub fn program_fee_wallet(
135        &mut self,
136        program_fee_wallet: solana_program::pubkey::Pubkey,
137    ) -> &mut Self {
138        self.program_fee_wallet = Some(program_fee_wallet);
139        self
140    }
141    /// `[optional account, default to '11111111111111111111111111111111']`
142    #[inline(always)]
143    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
144        self.system_program = Some(system_program);
145        self
146    }
147    #[inline(always)]
148    pub fn program_fee_bps(&mut self, program_fee_bps: u16) -> &mut Self {
149        self.program_fee_bps = Some(program_fee_bps);
150        self
151    }
152    /// Add an additional account to the instruction.
153    #[inline(always)]
154    pub fn add_remaining_account(
155        &mut self,
156        account: solana_program::instruction::AccountMeta,
157    ) -> &mut Self {
158        self.__remaining_accounts.push(account);
159        self
160    }
161    /// Add additional accounts to the instruction.
162    #[inline(always)]
163    pub fn add_remaining_accounts(
164        &mut self,
165        accounts: &[solana_program::instruction::AccountMeta],
166    ) -> &mut Self {
167        self.__remaining_accounts.extend_from_slice(accounts);
168        self
169    }
170    #[allow(clippy::clone_on_copy)]
171    pub fn instruction(&self) -> solana_program::instruction::Instruction {
172        let accounts = InitializeConfig {
173            config: self.config.expect("config is not set"),
174            admin: self.admin.expect("admin is not set"),
175            restaking_program: self
176                .restaking_program
177                .expect("restaking_program is not set"),
178            program_fee_wallet: self
179                .program_fee_wallet
180                .expect("program_fee_wallet is not set"),
181            system_program: self
182                .system_program
183                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
184        };
185        let args = InitializeConfigInstructionArgs {
186            program_fee_bps: self
187                .program_fee_bps
188                .clone()
189                .expect("program_fee_bps is not set"),
190        };
191
192        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
193    }
194}
195
196/// `initialize_config` CPI accounts.
197pub struct InitializeConfigCpiAccounts<'a, 'b> {
198    pub config: &'b solana_program::account_info::AccountInfo<'a>,
199
200    pub admin: &'b solana_program::account_info::AccountInfo<'a>,
201
202    pub restaking_program: &'b solana_program::account_info::AccountInfo<'a>,
203
204    pub program_fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
205
206    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
207}
208
209/// `initialize_config` CPI instruction.
210pub struct InitializeConfigCpi<'a, 'b> {
211    /// The program to invoke.
212    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
213
214    pub config: &'b solana_program::account_info::AccountInfo<'a>,
215
216    pub admin: &'b solana_program::account_info::AccountInfo<'a>,
217
218    pub restaking_program: &'b solana_program::account_info::AccountInfo<'a>,
219
220    pub program_fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
221
222    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
223    /// The arguments for the instruction.
224    pub __args: InitializeConfigInstructionArgs,
225}
226
227impl<'a, 'b> InitializeConfigCpi<'a, 'b> {
228    pub fn new(
229        program: &'b solana_program::account_info::AccountInfo<'a>,
230        accounts: InitializeConfigCpiAccounts<'a, 'b>,
231        args: InitializeConfigInstructionArgs,
232    ) -> Self {
233        Self {
234            __program: program,
235            config: accounts.config,
236            admin: accounts.admin,
237            restaking_program: accounts.restaking_program,
238            program_fee_wallet: accounts.program_fee_wallet,
239            system_program: accounts.system_program,
240            __args: args,
241        }
242    }
243    #[inline(always)]
244    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
245        self.invoke_signed_with_remaining_accounts(&[], &[])
246    }
247    #[inline(always)]
248    pub fn invoke_with_remaining_accounts(
249        &self,
250        remaining_accounts: &[(
251            &'b solana_program::account_info::AccountInfo<'a>,
252            bool,
253            bool,
254        )],
255    ) -> solana_program::entrypoint::ProgramResult {
256        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
257    }
258    #[inline(always)]
259    pub fn invoke_signed(
260        &self,
261        signers_seeds: &[&[&[u8]]],
262    ) -> solana_program::entrypoint::ProgramResult {
263        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
264    }
265    #[allow(clippy::clone_on_copy)]
266    #[allow(clippy::vec_init_then_push)]
267    pub fn invoke_signed_with_remaining_accounts(
268        &self,
269        signers_seeds: &[&[&[u8]]],
270        remaining_accounts: &[(
271            &'b solana_program::account_info::AccountInfo<'a>,
272            bool,
273            bool,
274        )],
275    ) -> solana_program::entrypoint::ProgramResult {
276        let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
277        accounts.push(solana_program::instruction::AccountMeta::new(
278            *self.config.key,
279            false,
280        ));
281        accounts.push(solana_program::instruction::AccountMeta::new(
282            *self.admin.key,
283            true,
284        ));
285        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
286            *self.restaking_program.key,
287            false,
288        ));
289        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
290            *self.program_fee_wallet.key,
291            false,
292        ));
293        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
294            *self.system_program.key,
295            false,
296        ));
297        remaining_accounts.iter().for_each(|remaining_account| {
298            accounts.push(solana_program::instruction::AccountMeta {
299                pubkey: *remaining_account.0.key,
300                is_signer: remaining_account.1,
301                is_writable: remaining_account.2,
302            })
303        });
304        let mut data = InitializeConfigInstructionData::new().try_to_vec().unwrap();
305        let mut args = self.__args.try_to_vec().unwrap();
306        data.append(&mut args);
307
308        let instruction = solana_program::instruction::Instruction {
309            program_id: crate::JITO_VAULT_ID,
310            accounts,
311            data,
312        };
313        let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len());
314        account_infos.push(self.__program.clone());
315        account_infos.push(self.config.clone());
316        account_infos.push(self.admin.clone());
317        account_infos.push(self.restaking_program.clone());
318        account_infos.push(self.program_fee_wallet.clone());
319        account_infos.push(self.system_program.clone());
320        remaining_accounts
321            .iter()
322            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
323
324        if signers_seeds.is_empty() {
325            solana_program::program::invoke(&instruction, &account_infos)
326        } else {
327            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
328        }
329    }
330}
331
332/// Instruction builder for `InitializeConfig` via CPI.
333///
334/// ### Accounts:
335///
336///   0. `[writable]` config
337///   1. `[writable, signer]` admin
338///   2. `[]` restaking_program
339///   3. `[]` program_fee_wallet
340///   4. `[]` system_program
341#[derive(Clone, Debug)]
342pub struct InitializeConfigCpiBuilder<'a, 'b> {
343    instruction: Box<InitializeConfigCpiBuilderInstruction<'a, 'b>>,
344}
345
346impl<'a, 'b> InitializeConfigCpiBuilder<'a, 'b> {
347    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
348        let instruction = Box::new(InitializeConfigCpiBuilderInstruction {
349            __program: program,
350            config: None,
351            admin: None,
352            restaking_program: None,
353            program_fee_wallet: None,
354            system_program: None,
355            program_fee_bps: None,
356            __remaining_accounts: Vec::new(),
357        });
358        Self { instruction }
359    }
360    #[inline(always)]
361    pub fn config(
362        &mut self,
363        config: &'b solana_program::account_info::AccountInfo<'a>,
364    ) -> &mut Self {
365        self.instruction.config = Some(config);
366        self
367    }
368    #[inline(always)]
369    pub fn admin(&mut self, admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
370        self.instruction.admin = Some(admin);
371        self
372    }
373    #[inline(always)]
374    pub fn restaking_program(
375        &mut self,
376        restaking_program: &'b solana_program::account_info::AccountInfo<'a>,
377    ) -> &mut Self {
378        self.instruction.restaking_program = Some(restaking_program);
379        self
380    }
381    #[inline(always)]
382    pub fn program_fee_wallet(
383        &mut self,
384        program_fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
385    ) -> &mut Self {
386        self.instruction.program_fee_wallet = Some(program_fee_wallet);
387        self
388    }
389    #[inline(always)]
390    pub fn system_program(
391        &mut self,
392        system_program: &'b solana_program::account_info::AccountInfo<'a>,
393    ) -> &mut Self {
394        self.instruction.system_program = Some(system_program);
395        self
396    }
397    #[inline(always)]
398    pub fn program_fee_bps(&mut self, program_fee_bps: u16) -> &mut Self {
399        self.instruction.program_fee_bps = Some(program_fee_bps);
400        self
401    }
402    /// Add an additional account to the instruction.
403    #[inline(always)]
404    pub fn add_remaining_account(
405        &mut self,
406        account: &'b solana_program::account_info::AccountInfo<'a>,
407        is_writable: bool,
408        is_signer: bool,
409    ) -> &mut Self {
410        self.instruction
411            .__remaining_accounts
412            .push((account, is_writable, is_signer));
413        self
414    }
415    /// Add additional accounts to the instruction.
416    ///
417    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
418    /// and a `bool` indicating whether the account is a signer or not.
419    #[inline(always)]
420    pub fn add_remaining_accounts(
421        &mut self,
422        accounts: &[(
423            &'b solana_program::account_info::AccountInfo<'a>,
424            bool,
425            bool,
426        )],
427    ) -> &mut Self {
428        self.instruction
429            .__remaining_accounts
430            .extend_from_slice(accounts);
431        self
432    }
433    #[inline(always)]
434    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
435        self.invoke_signed(&[])
436    }
437    #[allow(clippy::clone_on_copy)]
438    #[allow(clippy::vec_init_then_push)]
439    pub fn invoke_signed(
440        &self,
441        signers_seeds: &[&[&[u8]]],
442    ) -> solana_program::entrypoint::ProgramResult {
443        let args = InitializeConfigInstructionArgs {
444            program_fee_bps: self
445                .instruction
446                .program_fee_bps
447                .clone()
448                .expect("program_fee_bps is not set"),
449        };
450        let instruction = InitializeConfigCpi {
451            __program: self.instruction.__program,
452
453            config: self.instruction.config.expect("config is not set"),
454
455            admin: self.instruction.admin.expect("admin is not set"),
456
457            restaking_program: self
458                .instruction
459                .restaking_program
460                .expect("restaking_program is not set"),
461
462            program_fee_wallet: self
463                .instruction
464                .program_fee_wallet
465                .expect("program_fee_wallet is not set"),
466
467            system_program: self
468                .instruction
469                .system_program
470                .expect("system_program is not set"),
471            __args: args,
472        };
473        instruction.invoke_signed_with_remaining_accounts(
474            signers_seeds,
475            &self.instruction.__remaining_accounts,
476        )
477    }
478}
479
480#[derive(Clone, Debug)]
481struct InitializeConfigCpiBuilderInstruction<'a, 'b> {
482    __program: &'b solana_program::account_info::AccountInfo<'a>,
483    config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
484    admin: Option<&'b solana_program::account_info::AccountInfo<'a>>,
485    restaking_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
486    program_fee_wallet: Option<&'b solana_program::account_info::AccountInfo<'a>>,
487    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
488    program_fee_bps: Option<u16>,
489    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
490    __remaining_accounts: Vec<(
491        &'b solana_program::account_info::AccountInfo<'a>,
492        bool,
493        bool,
494    )>,
495}