jito_restaking_client/generated/instructions/
operator_set_secondary_admin.rs1use borsh::{BorshDeserialize, BorshSerialize};
8
9use crate::generated::types::OperatorAdminRole;
10
11pub struct OperatorSetSecondaryAdmin {
13 pub operator: solana_program::pubkey::Pubkey,
14
15 pub admin: solana_program::pubkey::Pubkey,
16
17 pub new_admin: solana_program::pubkey::Pubkey,
18}
19
20impl OperatorSetSecondaryAdmin {
21 pub fn instruction(
22 &self,
23 args: OperatorSetSecondaryAdminInstructionArgs,
24 ) -> solana_program::instruction::Instruction {
25 self.instruction_with_remaining_accounts(args, &[])
26 }
27 #[allow(clippy::vec_init_then_push)]
28 pub fn instruction_with_remaining_accounts(
29 &self,
30 args: OperatorSetSecondaryAdminInstructionArgs,
31 remaining_accounts: &[solana_program::instruction::AccountMeta],
32 ) -> solana_program::instruction::Instruction {
33 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.operator,
36 false,
37 ));
38 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
39 self.admin, true,
40 ));
41 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
42 self.new_admin,
43 false,
44 ));
45 accounts.extend_from_slice(remaining_accounts);
46 let mut data = OperatorSetSecondaryAdminInstructionData::new()
47 .try_to_vec()
48 .unwrap();
49 let mut args = args.try_to_vec().unwrap();
50 data.append(&mut args);
51
52 solana_program::instruction::Instruction {
53 program_id: crate::JITO_RESTAKING_ID,
54 accounts,
55 data,
56 }
57 }
58}
59
60#[derive(BorshDeserialize, BorshSerialize)]
61pub struct OperatorSetSecondaryAdminInstructionData {
62 discriminator: u8,
63}
64
65impl OperatorSetSecondaryAdminInstructionData {
66 pub fn new() -> Self {
67 Self { discriminator: 20 }
68 }
69}
70
71impl Default for OperatorSetSecondaryAdminInstructionData {
72 fn default() -> Self {
73 Self::new()
74 }
75}
76
77#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
78#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
79pub struct OperatorSetSecondaryAdminInstructionArgs {
80 pub operator_admin_role: OperatorAdminRole,
81}
82
83#[derive(Clone, Debug, Default)]
91pub struct OperatorSetSecondaryAdminBuilder {
92 operator: Option<solana_program::pubkey::Pubkey>,
93 admin: Option<solana_program::pubkey::Pubkey>,
94 new_admin: Option<solana_program::pubkey::Pubkey>,
95 operator_admin_role: Option<OperatorAdminRole>,
96 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
97}
98
99impl OperatorSetSecondaryAdminBuilder {
100 pub fn new() -> Self {
101 Self::default()
102 }
103 #[inline(always)]
104 pub fn operator(&mut self, operator: solana_program::pubkey::Pubkey) -> &mut Self {
105 self.operator = Some(operator);
106 self
107 }
108 #[inline(always)]
109 pub fn admin(&mut self, admin: solana_program::pubkey::Pubkey) -> &mut Self {
110 self.admin = Some(admin);
111 self
112 }
113 #[inline(always)]
114 pub fn new_admin(&mut self, new_admin: solana_program::pubkey::Pubkey) -> &mut Self {
115 self.new_admin = Some(new_admin);
116 self
117 }
118 #[inline(always)]
119 pub fn operator_admin_role(&mut self, operator_admin_role: OperatorAdminRole) -> &mut Self {
120 self.operator_admin_role = Some(operator_admin_role);
121 self
122 }
123 #[inline(always)]
125 pub fn add_remaining_account(
126 &mut self,
127 account: solana_program::instruction::AccountMeta,
128 ) -> &mut Self {
129 self.__remaining_accounts.push(account);
130 self
131 }
132 #[inline(always)]
134 pub fn add_remaining_accounts(
135 &mut self,
136 accounts: &[solana_program::instruction::AccountMeta],
137 ) -> &mut Self {
138 self.__remaining_accounts.extend_from_slice(accounts);
139 self
140 }
141 #[allow(clippy::clone_on_copy)]
142 pub fn instruction(&self) -> solana_program::instruction::Instruction {
143 let accounts = OperatorSetSecondaryAdmin {
144 operator: self.operator.expect("operator is not set"),
145 admin: self.admin.expect("admin is not set"),
146 new_admin: self.new_admin.expect("new_admin is not set"),
147 };
148 let args = OperatorSetSecondaryAdminInstructionArgs {
149 operator_admin_role: self
150 .operator_admin_role
151 .clone()
152 .expect("operator_admin_role is not set"),
153 };
154
155 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
156 }
157}
158
159pub struct OperatorSetSecondaryAdminCpiAccounts<'a, 'b> {
161 pub operator: &'b solana_program::account_info::AccountInfo<'a>,
162
163 pub admin: &'b solana_program::account_info::AccountInfo<'a>,
164
165 pub new_admin: &'b solana_program::account_info::AccountInfo<'a>,
166}
167
168pub struct OperatorSetSecondaryAdminCpi<'a, 'b> {
170 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
172
173 pub operator: &'b solana_program::account_info::AccountInfo<'a>,
174
175 pub admin: &'b solana_program::account_info::AccountInfo<'a>,
176
177 pub new_admin: &'b solana_program::account_info::AccountInfo<'a>,
178 pub __args: OperatorSetSecondaryAdminInstructionArgs,
180}
181
182impl<'a, 'b> OperatorSetSecondaryAdminCpi<'a, 'b> {
183 pub fn new(
184 program: &'b solana_program::account_info::AccountInfo<'a>,
185 accounts: OperatorSetSecondaryAdminCpiAccounts<'a, 'b>,
186 args: OperatorSetSecondaryAdminInstructionArgs,
187 ) -> Self {
188 Self {
189 __program: program,
190 operator: accounts.operator,
191 admin: accounts.admin,
192 new_admin: accounts.new_admin,
193 __args: args,
194 }
195 }
196 #[inline(always)]
197 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
198 self.invoke_signed_with_remaining_accounts(&[], &[])
199 }
200 #[inline(always)]
201 pub fn invoke_with_remaining_accounts(
202 &self,
203 remaining_accounts: &[(
204 &'b solana_program::account_info::AccountInfo<'a>,
205 bool,
206 bool,
207 )],
208 ) -> solana_program::entrypoint::ProgramResult {
209 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
210 }
211 #[inline(always)]
212 pub fn invoke_signed(
213 &self,
214 signers_seeds: &[&[&[u8]]],
215 ) -> solana_program::entrypoint::ProgramResult {
216 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
217 }
218 #[allow(clippy::clone_on_copy)]
219 #[allow(clippy::vec_init_then_push)]
220 pub fn invoke_signed_with_remaining_accounts(
221 &self,
222 signers_seeds: &[&[&[u8]]],
223 remaining_accounts: &[(
224 &'b solana_program::account_info::AccountInfo<'a>,
225 bool,
226 bool,
227 )],
228 ) -> solana_program::entrypoint::ProgramResult {
229 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
230 accounts.push(solana_program::instruction::AccountMeta::new(
231 *self.operator.key,
232 false,
233 ));
234 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
235 *self.admin.key,
236 true,
237 ));
238 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
239 *self.new_admin.key,
240 false,
241 ));
242 remaining_accounts.iter().for_each(|remaining_account| {
243 accounts.push(solana_program::instruction::AccountMeta {
244 pubkey: *remaining_account.0.key,
245 is_signer: remaining_account.1,
246 is_writable: remaining_account.2,
247 })
248 });
249 let mut data = OperatorSetSecondaryAdminInstructionData::new()
250 .try_to_vec()
251 .unwrap();
252 let mut args = self.__args.try_to_vec().unwrap();
253 data.append(&mut args);
254
255 let instruction = solana_program::instruction::Instruction {
256 program_id: crate::JITO_RESTAKING_ID,
257 accounts,
258 data,
259 };
260 let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len());
261 account_infos.push(self.__program.clone());
262 account_infos.push(self.operator.clone());
263 account_infos.push(self.admin.clone());
264 account_infos.push(self.new_admin.clone());
265 remaining_accounts
266 .iter()
267 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
268
269 if signers_seeds.is_empty() {
270 solana_program::program::invoke(&instruction, &account_infos)
271 } else {
272 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
273 }
274 }
275}
276
277#[derive(Clone, Debug)]
285pub struct OperatorSetSecondaryAdminCpiBuilder<'a, 'b> {
286 instruction: Box<OperatorSetSecondaryAdminCpiBuilderInstruction<'a, 'b>>,
287}
288
289impl<'a, 'b> OperatorSetSecondaryAdminCpiBuilder<'a, 'b> {
290 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
291 let instruction = Box::new(OperatorSetSecondaryAdminCpiBuilderInstruction {
292 __program: program,
293 operator: None,
294 admin: None,
295 new_admin: None,
296 operator_admin_role: None,
297 __remaining_accounts: Vec::new(),
298 });
299 Self { instruction }
300 }
301 #[inline(always)]
302 pub fn operator(
303 &mut self,
304 operator: &'b solana_program::account_info::AccountInfo<'a>,
305 ) -> &mut Self {
306 self.instruction.operator = Some(operator);
307 self
308 }
309 #[inline(always)]
310 pub fn admin(&mut self, admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
311 self.instruction.admin = Some(admin);
312 self
313 }
314 #[inline(always)]
315 pub fn new_admin(
316 &mut self,
317 new_admin: &'b solana_program::account_info::AccountInfo<'a>,
318 ) -> &mut Self {
319 self.instruction.new_admin = Some(new_admin);
320 self
321 }
322 #[inline(always)]
323 pub fn operator_admin_role(&mut self, operator_admin_role: OperatorAdminRole) -> &mut Self {
324 self.instruction.operator_admin_role = Some(operator_admin_role);
325 self
326 }
327 #[inline(always)]
329 pub fn add_remaining_account(
330 &mut self,
331 account: &'b solana_program::account_info::AccountInfo<'a>,
332 is_writable: bool,
333 is_signer: bool,
334 ) -> &mut Self {
335 self.instruction
336 .__remaining_accounts
337 .push((account, is_writable, is_signer));
338 self
339 }
340 #[inline(always)]
345 pub fn add_remaining_accounts(
346 &mut self,
347 accounts: &[(
348 &'b solana_program::account_info::AccountInfo<'a>,
349 bool,
350 bool,
351 )],
352 ) -> &mut Self {
353 self.instruction
354 .__remaining_accounts
355 .extend_from_slice(accounts);
356 self
357 }
358 #[inline(always)]
359 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
360 self.invoke_signed(&[])
361 }
362 #[allow(clippy::clone_on_copy)]
363 #[allow(clippy::vec_init_then_push)]
364 pub fn invoke_signed(
365 &self,
366 signers_seeds: &[&[&[u8]]],
367 ) -> solana_program::entrypoint::ProgramResult {
368 let args = OperatorSetSecondaryAdminInstructionArgs {
369 operator_admin_role: self
370 .instruction
371 .operator_admin_role
372 .clone()
373 .expect("operator_admin_role is not set"),
374 };
375 let instruction = OperatorSetSecondaryAdminCpi {
376 __program: self.instruction.__program,
377
378 operator: self.instruction.operator.expect("operator is not set"),
379
380 admin: self.instruction.admin.expect("admin is not set"),
381
382 new_admin: self.instruction.new_admin.expect("new_admin is not set"),
383 __args: args,
384 };
385 instruction.invoke_signed_with_remaining_accounts(
386 signers_seeds,
387 &self.instruction.__remaining_accounts,
388 )
389 }
390}
391
392#[derive(Clone, Debug)]
393struct OperatorSetSecondaryAdminCpiBuilderInstruction<'a, 'b> {
394 __program: &'b solana_program::account_info::AccountInfo<'a>,
395 operator: Option<&'b solana_program::account_info::AccountInfo<'a>>,
396 admin: Option<&'b solana_program::account_info::AccountInfo<'a>>,
397 new_admin: Option<&'b solana_program::account_info::AccountInfo<'a>>,
398 operator_admin_role: Option<OperatorAdminRole>,
399 __remaining_accounts: Vec<(
401 &'b solana_program::account_info::AccountInfo<'a>,
402 bool,
403 bool,
404 )>,
405}