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