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