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