defituna_client/generated/instructions/
set_fee_recipient.rs1use solana_pubkey::Pubkey;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12pub const SET_FEE_RECIPIENT_DISCRIMINATOR: [u8; 8] = [227, 18, 215, 42, 237, 246, 151, 66];
13
14#[derive(Debug)]
16pub struct SetFeeRecipient {
17
18
19 pub authority: solana_pubkey::Pubkey,
20
21
22 pub tuna_config: solana_pubkey::Pubkey,
23 }
24
25impl SetFeeRecipient {
26 pub fn instruction(&self, args: SetFeeRecipientInstructionArgs) -> solana_instruction::Instruction {
27 self.instruction_with_remaining_accounts(args, &[])
28 }
29 #[allow(clippy::arithmetic_side_effects)]
30 #[allow(clippy::vec_init_then_push)]
31 pub fn instruction_with_remaining_accounts(&self, args: SetFeeRecipientInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
32 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
33 accounts.push(solana_instruction::AccountMeta::new(
34 self.authority,
35 true
36 ));
37 accounts.push(solana_instruction::AccountMeta::new(
38 self.tuna_config,
39 false
40 ));
41 accounts.extend_from_slice(remaining_accounts);
42 let mut data = borsh::to_vec(&SetFeeRecipientInstructionData::new()).unwrap();
43 let mut args = borsh::to_vec(&args).unwrap();
44 data.append(&mut args);
45
46 solana_instruction::Instruction {
47 program_id: crate::TUNA_ID,
48 accounts,
49 data,
50 }
51 }
52}
53
54#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
55#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
56 pub struct SetFeeRecipientInstructionData {
57 discriminator: [u8; 8],
58 }
59
60impl SetFeeRecipientInstructionData {
61 pub fn new() -> Self {
62 Self {
63 discriminator: [227, 18, 215, 42, 237, 246, 151, 66],
64 }
65 }
66}
67
68impl Default for SetFeeRecipientInstructionData {
69 fn default() -> Self {
70 Self::new()
71 }
72}
73
74#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76 pub struct SetFeeRecipientInstructionArgs {
77 pub fee_recipient: Pubkey,
78 }
79
80
81#[derive(Clone, Debug, Default)]
88pub struct SetFeeRecipientBuilder {
89 authority: Option<solana_pubkey::Pubkey>,
90 tuna_config: Option<solana_pubkey::Pubkey>,
91 fee_recipient: Option<Pubkey>,
92 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
93}
94
95impl SetFeeRecipientBuilder {
96 pub fn new() -> Self {
97 Self::default()
98 }
99 #[inline(always)]
100 pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
101 self.authority = Some(authority);
102 self
103 }
104 #[inline(always)]
105 pub fn tuna_config(&mut self, tuna_config: solana_pubkey::Pubkey) -> &mut Self {
106 self.tuna_config = Some(tuna_config);
107 self
108 }
109 #[inline(always)]
110 pub fn fee_recipient(&mut self, fee_recipient: Pubkey) -> &mut Self {
111 self.fee_recipient = Some(fee_recipient);
112 self
113 }
114 #[inline(always)]
116 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
117 self.__remaining_accounts.push(account);
118 self
119 }
120 #[inline(always)]
122 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
123 self.__remaining_accounts.extend_from_slice(accounts);
124 self
125 }
126 #[allow(clippy::clone_on_copy)]
127 pub fn instruction(&self) -> solana_instruction::Instruction {
128 let accounts = SetFeeRecipient {
129 authority: self.authority.expect("authority is not set"),
130 tuna_config: self.tuna_config.expect("tuna_config is not set"),
131 };
132 let args = SetFeeRecipientInstructionArgs {
133 fee_recipient: self.fee_recipient.clone().expect("fee_recipient is not set"),
134 };
135
136 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
137 }
138}
139
140 pub struct SetFeeRecipientCpiAccounts<'a, 'b> {
142
143
144 pub authority: &'b solana_account_info::AccountInfo<'a>,
145
146
147 pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
148 }
149
150pub struct SetFeeRecipientCpi<'a, 'b> {
152 pub __program: &'b solana_account_info::AccountInfo<'a>,
154
155
156 pub authority: &'b solana_account_info::AccountInfo<'a>,
157
158
159 pub tuna_config: &'b solana_account_info::AccountInfo<'a>,
160 pub __args: SetFeeRecipientInstructionArgs,
162 }
163
164impl<'a, 'b> SetFeeRecipientCpi<'a, 'b> {
165 pub fn new(
166 program: &'b solana_account_info::AccountInfo<'a>,
167 accounts: SetFeeRecipientCpiAccounts<'a, 'b>,
168 args: SetFeeRecipientInstructionArgs,
169 ) -> Self {
170 Self {
171 __program: program,
172 authority: accounts.authority,
173 tuna_config: accounts.tuna_config,
174 __args: args,
175 }
176 }
177 #[inline(always)]
178 pub fn invoke(&self) -> solana_program_error::ProgramResult {
179 self.invoke_signed_with_remaining_accounts(&[], &[])
180 }
181 #[inline(always)]
182 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
183 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
184 }
185 #[inline(always)]
186 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
187 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
188 }
189 #[allow(clippy::arithmetic_side_effects)]
190 #[allow(clippy::clone_on_copy)]
191 #[allow(clippy::vec_init_then_push)]
192 pub fn invoke_signed_with_remaining_accounts(
193 &self,
194 signers_seeds: &[&[&[u8]]],
195 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
196 ) -> solana_program_error::ProgramResult {
197 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
198 accounts.push(solana_instruction::AccountMeta::new(
199 *self.authority.key,
200 true
201 ));
202 accounts.push(solana_instruction::AccountMeta::new(
203 *self.tuna_config.key,
204 false
205 ));
206 remaining_accounts.iter().for_each(|remaining_account| {
207 accounts.push(solana_instruction::AccountMeta {
208 pubkey: *remaining_account.0.key,
209 is_signer: remaining_account.1,
210 is_writable: remaining_account.2,
211 })
212 });
213 let mut data = borsh::to_vec(&SetFeeRecipientInstructionData::new()).unwrap();
214 let mut args = borsh::to_vec(&self.__args).unwrap();
215 data.append(&mut args);
216
217 let instruction = solana_instruction::Instruction {
218 program_id: crate::TUNA_ID,
219 accounts,
220 data,
221 };
222 let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
223 account_infos.push(self.__program.clone());
224 account_infos.push(self.authority.clone());
225 account_infos.push(self.tuna_config.clone());
226 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
227
228 if signers_seeds.is_empty() {
229 solana_cpi::invoke(&instruction, &account_infos)
230 } else {
231 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
232 }
233 }
234}
235
236#[derive(Clone, Debug)]
243pub struct SetFeeRecipientCpiBuilder<'a, 'b> {
244 instruction: Box<SetFeeRecipientCpiBuilderInstruction<'a, 'b>>,
245}
246
247impl<'a, 'b> SetFeeRecipientCpiBuilder<'a, 'b> {
248 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
249 let instruction = Box::new(SetFeeRecipientCpiBuilderInstruction {
250 __program: program,
251 authority: None,
252 tuna_config: None,
253 fee_recipient: None,
254 __remaining_accounts: Vec::new(),
255 });
256 Self { instruction }
257 }
258 #[inline(always)]
259 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
260 self.instruction.authority = Some(authority);
261 self
262 }
263 #[inline(always)]
264 pub fn tuna_config(&mut self, tuna_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
265 self.instruction.tuna_config = Some(tuna_config);
266 self
267 }
268 #[inline(always)]
269 pub fn fee_recipient(&mut self, fee_recipient: Pubkey) -> &mut Self {
270 self.instruction.fee_recipient = Some(fee_recipient);
271 self
272 }
273 #[inline(always)]
275 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
276 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
277 self
278 }
279 #[inline(always)]
284 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
285 self.instruction.__remaining_accounts.extend_from_slice(accounts);
286 self
287 }
288 #[inline(always)]
289 pub fn invoke(&self) -> solana_program_error::ProgramResult {
290 self.invoke_signed(&[])
291 }
292 #[allow(clippy::clone_on_copy)]
293 #[allow(clippy::vec_init_then_push)]
294 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
295 let args = SetFeeRecipientInstructionArgs {
296 fee_recipient: self.instruction.fee_recipient.clone().expect("fee_recipient is not set"),
297 };
298 let instruction = SetFeeRecipientCpi {
299 __program: self.instruction.__program,
300
301 authority: self.instruction.authority.expect("authority is not set"),
302
303 tuna_config: self.instruction.tuna_config.expect("tuna_config is not set"),
304 __args: args,
305 };
306 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
307 }
308}
309
310#[derive(Clone, Debug)]
311struct SetFeeRecipientCpiBuilderInstruction<'a, 'b> {
312 __program: &'b solana_account_info::AccountInfo<'a>,
313 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
314 tuna_config: Option<&'b solana_account_info::AccountInfo<'a>>,
315 fee_recipient: Option<Pubkey>,
316 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
318}
319