1use borsh::{BorshDeserialize, BorshSerialize};
8
9pub struct InitializeOperatorVaultTicket {
11 pub config: solana_program::pubkey::Pubkey,
12
13 pub operator: solana_program::pubkey::Pubkey,
14
15 pub vault: solana_program::pubkey::Pubkey,
16
17 pub operator_vault_ticket: solana_program::pubkey::Pubkey,
18
19 pub admin: solana_program::pubkey::Pubkey,
20
21 pub payer: solana_program::pubkey::Pubkey,
22
23 pub system_program: solana_program::pubkey::Pubkey,
24}
25
26impl InitializeOperatorVaultTicket {
27 pub fn instruction(&self) -> solana_program::instruction::Instruction {
28 self.instruction_with_remaining_accounts(&[])
29 }
30 #[allow(clippy::vec_init_then_push)]
31 pub fn instruction_with_remaining_accounts(
32 &self,
33 remaining_accounts: &[solana_program::instruction::AccountMeta],
34 ) -> solana_program::instruction::Instruction {
35 let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
36 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
37 self.config,
38 false,
39 ));
40 accounts.push(solana_program::instruction::AccountMeta::new(
41 self.operator,
42 false,
43 ));
44 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
45 self.vault, false,
46 ));
47 accounts.push(solana_program::instruction::AccountMeta::new(
48 self.operator_vault_ticket,
49 false,
50 ));
51 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52 self.admin, true,
53 ));
54 accounts.push(solana_program::instruction::AccountMeta::new(
55 self.payer, true,
56 ));
57 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
58 self.system_program,
59 false,
60 ));
61 accounts.extend_from_slice(remaining_accounts);
62 let data = InitializeOperatorVaultTicketInstructionData::new()
63 .try_to_vec()
64 .unwrap();
65
66 solana_program::instruction::Instruction {
67 program_id: crate::JITO_RESTAKING_ID,
68 accounts,
69 data,
70 }
71 }
72}
73
74#[derive(BorshDeserialize, BorshSerialize)]
75pub struct InitializeOperatorVaultTicketInstructionData {
76 discriminator: u8,
77}
78
79impl InitializeOperatorVaultTicketInstructionData {
80 pub fn new() -> Self {
81 Self { discriminator: 5 }
82 }
83}
84
85impl Default for InitializeOperatorVaultTicketInstructionData {
86 fn default() -> Self {
87 Self::new()
88 }
89}
90
91#[derive(Clone, Debug, Default)]
103pub struct InitializeOperatorVaultTicketBuilder {
104 config: Option<solana_program::pubkey::Pubkey>,
105 operator: Option<solana_program::pubkey::Pubkey>,
106 vault: Option<solana_program::pubkey::Pubkey>,
107 operator_vault_ticket: Option<solana_program::pubkey::Pubkey>,
108 admin: Option<solana_program::pubkey::Pubkey>,
109 payer: Option<solana_program::pubkey::Pubkey>,
110 system_program: Option<solana_program::pubkey::Pubkey>,
111 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
112}
113
114impl InitializeOperatorVaultTicketBuilder {
115 pub fn new() -> Self {
116 Self::default()
117 }
118 #[inline(always)]
119 pub fn config(&mut self, config: solana_program::pubkey::Pubkey) -> &mut Self {
120 self.config = Some(config);
121 self
122 }
123 #[inline(always)]
124 pub fn operator(&mut self, operator: solana_program::pubkey::Pubkey) -> &mut Self {
125 self.operator = Some(operator);
126 self
127 }
128 #[inline(always)]
129 pub fn vault(&mut self, vault: solana_program::pubkey::Pubkey) -> &mut Self {
130 self.vault = Some(vault);
131 self
132 }
133 #[inline(always)]
134 pub fn operator_vault_ticket(
135 &mut self,
136 operator_vault_ticket: solana_program::pubkey::Pubkey,
137 ) -> &mut Self {
138 self.operator_vault_ticket = Some(operator_vault_ticket);
139 self
140 }
141 #[inline(always)]
142 pub fn admin(&mut self, admin: solana_program::pubkey::Pubkey) -> &mut Self {
143 self.admin = Some(admin);
144 self
145 }
146 #[inline(always)]
147 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
148 self.payer = Some(payer);
149 self
150 }
151 #[inline(always)]
153 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
154 self.system_program = Some(system_program);
155 self
156 }
157 #[inline(always)]
159 pub fn add_remaining_account(
160 &mut self,
161 account: solana_program::instruction::AccountMeta,
162 ) -> &mut Self {
163 self.__remaining_accounts.push(account);
164 self
165 }
166 #[inline(always)]
168 pub fn add_remaining_accounts(
169 &mut self,
170 accounts: &[solana_program::instruction::AccountMeta],
171 ) -> &mut Self {
172 self.__remaining_accounts.extend_from_slice(accounts);
173 self
174 }
175 #[allow(clippy::clone_on_copy)]
176 pub fn instruction(&self) -> solana_program::instruction::Instruction {
177 let accounts = InitializeOperatorVaultTicket {
178 config: self.config.expect("config is not set"),
179 operator: self.operator.expect("operator is not set"),
180 vault: self.vault.expect("vault is not set"),
181 operator_vault_ticket: self
182 .operator_vault_ticket
183 .expect("operator_vault_ticket is not set"),
184 admin: self.admin.expect("admin is not set"),
185 payer: self.payer.expect("payer is not set"),
186 system_program: self
187 .system_program
188 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
189 };
190
191 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
192 }
193}
194
195pub struct InitializeOperatorVaultTicketCpiAccounts<'a, 'b> {
197 pub config: &'b solana_program::account_info::AccountInfo<'a>,
198
199 pub operator: &'b solana_program::account_info::AccountInfo<'a>,
200
201 pub vault: &'b solana_program::account_info::AccountInfo<'a>,
202
203 pub operator_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>,
204
205 pub admin: &'b solana_program::account_info::AccountInfo<'a>,
206
207 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
208
209 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
210}
211
212pub struct InitializeOperatorVaultTicketCpi<'a, 'b> {
214 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
216
217 pub config: &'b solana_program::account_info::AccountInfo<'a>,
218
219 pub operator: &'b solana_program::account_info::AccountInfo<'a>,
220
221 pub vault: &'b solana_program::account_info::AccountInfo<'a>,
222
223 pub operator_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>,
224
225 pub admin: &'b solana_program::account_info::AccountInfo<'a>,
226
227 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
228
229 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
230}
231
232impl<'a, 'b> InitializeOperatorVaultTicketCpi<'a, 'b> {
233 pub fn new(
234 program: &'b solana_program::account_info::AccountInfo<'a>,
235 accounts: InitializeOperatorVaultTicketCpiAccounts<'a, 'b>,
236 ) -> Self {
237 Self {
238 __program: program,
239 config: accounts.config,
240 operator: accounts.operator,
241 vault: accounts.vault,
242 operator_vault_ticket: accounts.operator_vault_ticket,
243 admin: accounts.admin,
244 payer: accounts.payer,
245 system_program: accounts.system_program,
246 }
247 }
248 #[inline(always)]
249 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
250 self.invoke_signed_with_remaining_accounts(&[], &[])
251 }
252 #[inline(always)]
253 pub fn invoke_with_remaining_accounts(
254 &self,
255 remaining_accounts: &[(
256 &'b solana_program::account_info::AccountInfo<'a>,
257 bool,
258 bool,
259 )],
260 ) -> solana_program::entrypoint::ProgramResult {
261 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
262 }
263 #[inline(always)]
264 pub fn invoke_signed(
265 &self,
266 signers_seeds: &[&[&[u8]]],
267 ) -> solana_program::entrypoint::ProgramResult {
268 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
269 }
270 #[allow(clippy::clone_on_copy)]
271 #[allow(clippy::vec_init_then_push)]
272 pub fn invoke_signed_with_remaining_accounts(
273 &self,
274 signers_seeds: &[&[&[u8]]],
275 remaining_accounts: &[(
276 &'b solana_program::account_info::AccountInfo<'a>,
277 bool,
278 bool,
279 )],
280 ) -> solana_program::entrypoint::ProgramResult {
281 let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
282 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
283 *self.config.key,
284 false,
285 ));
286 accounts.push(solana_program::instruction::AccountMeta::new(
287 *self.operator.key,
288 false,
289 ));
290 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
291 *self.vault.key,
292 false,
293 ));
294 accounts.push(solana_program::instruction::AccountMeta::new(
295 *self.operator_vault_ticket.key,
296 false,
297 ));
298 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
299 *self.admin.key,
300 true,
301 ));
302 accounts.push(solana_program::instruction::AccountMeta::new(
303 *self.payer.key,
304 true,
305 ));
306 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
307 *self.system_program.key,
308 false,
309 ));
310 remaining_accounts.iter().for_each(|remaining_account| {
311 accounts.push(solana_program::instruction::AccountMeta {
312 pubkey: *remaining_account.0.key,
313 is_signer: remaining_account.1,
314 is_writable: remaining_account.2,
315 })
316 });
317 let data = InitializeOperatorVaultTicketInstructionData::new()
318 .try_to_vec()
319 .unwrap();
320
321 let instruction = solana_program::instruction::Instruction {
322 program_id: crate::JITO_RESTAKING_ID,
323 accounts,
324 data,
325 };
326 let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len());
327 account_infos.push(self.__program.clone());
328 account_infos.push(self.config.clone());
329 account_infos.push(self.operator.clone());
330 account_infos.push(self.vault.clone());
331 account_infos.push(self.operator_vault_ticket.clone());
332 account_infos.push(self.admin.clone());
333 account_infos.push(self.payer.clone());
334 account_infos.push(self.system_program.clone());
335 remaining_accounts
336 .iter()
337 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
338
339 if signers_seeds.is_empty() {
340 solana_program::program::invoke(&instruction, &account_infos)
341 } else {
342 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
343 }
344 }
345}
346
347#[derive(Clone, Debug)]
359pub struct InitializeOperatorVaultTicketCpiBuilder<'a, 'b> {
360 instruction: Box<InitializeOperatorVaultTicketCpiBuilderInstruction<'a, 'b>>,
361}
362
363impl<'a, 'b> InitializeOperatorVaultTicketCpiBuilder<'a, 'b> {
364 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
365 let instruction = Box::new(InitializeOperatorVaultTicketCpiBuilderInstruction {
366 __program: program,
367 config: None,
368 operator: None,
369 vault: None,
370 operator_vault_ticket: None,
371 admin: None,
372 payer: None,
373 system_program: None,
374 __remaining_accounts: Vec::new(),
375 });
376 Self { instruction }
377 }
378 #[inline(always)]
379 pub fn config(
380 &mut self,
381 config: &'b solana_program::account_info::AccountInfo<'a>,
382 ) -> &mut Self {
383 self.instruction.config = Some(config);
384 self
385 }
386 #[inline(always)]
387 pub fn operator(
388 &mut self,
389 operator: &'b solana_program::account_info::AccountInfo<'a>,
390 ) -> &mut Self {
391 self.instruction.operator = Some(operator);
392 self
393 }
394 #[inline(always)]
395 pub fn vault(&mut self, vault: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
396 self.instruction.vault = Some(vault);
397 self
398 }
399 #[inline(always)]
400 pub fn operator_vault_ticket(
401 &mut self,
402 operator_vault_ticket: &'b solana_program::account_info::AccountInfo<'a>,
403 ) -> &mut Self {
404 self.instruction.operator_vault_ticket = Some(operator_vault_ticket);
405 self
406 }
407 #[inline(always)]
408 pub fn admin(&mut self, admin: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
409 self.instruction.admin = Some(admin);
410 self
411 }
412 #[inline(always)]
413 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
414 self.instruction.payer = Some(payer);
415 self
416 }
417 #[inline(always)]
418 pub fn system_program(
419 &mut self,
420 system_program: &'b solana_program::account_info::AccountInfo<'a>,
421 ) -> &mut Self {
422 self.instruction.system_program = Some(system_program);
423 self
424 }
425 #[inline(always)]
427 pub fn add_remaining_account(
428 &mut self,
429 account: &'b solana_program::account_info::AccountInfo<'a>,
430 is_writable: bool,
431 is_signer: bool,
432 ) -> &mut Self {
433 self.instruction
434 .__remaining_accounts
435 .push((account, is_writable, is_signer));
436 self
437 }
438 #[inline(always)]
443 pub fn add_remaining_accounts(
444 &mut self,
445 accounts: &[(
446 &'b solana_program::account_info::AccountInfo<'a>,
447 bool,
448 bool,
449 )],
450 ) -> &mut Self {
451 self.instruction
452 .__remaining_accounts
453 .extend_from_slice(accounts);
454 self
455 }
456 #[inline(always)]
457 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
458 self.invoke_signed(&[])
459 }
460 #[allow(clippy::clone_on_copy)]
461 #[allow(clippy::vec_init_then_push)]
462 pub fn invoke_signed(
463 &self,
464 signers_seeds: &[&[&[u8]]],
465 ) -> solana_program::entrypoint::ProgramResult {
466 let instruction = InitializeOperatorVaultTicketCpi {
467 __program: self.instruction.__program,
468
469 config: self.instruction.config.expect("config is not set"),
470
471 operator: self.instruction.operator.expect("operator is not set"),
472
473 vault: self.instruction.vault.expect("vault is not set"),
474
475 operator_vault_ticket: self
476 .instruction
477 .operator_vault_ticket
478 .expect("operator_vault_ticket is not set"),
479
480 admin: self.instruction.admin.expect("admin is not set"),
481
482 payer: self.instruction.payer.expect("payer is not set"),
483
484 system_program: self
485 .instruction
486 .system_program
487 .expect("system_program is not set"),
488 };
489 instruction.invoke_signed_with_remaining_accounts(
490 signers_seeds,
491 &self.instruction.__remaining_accounts,
492 )
493 }
494}
495
496#[derive(Clone, Debug)]
497struct InitializeOperatorVaultTicketCpiBuilderInstruction<'a, 'b> {
498 __program: &'b solana_program::account_info::AccountInfo<'a>,
499 config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
500 operator: Option<&'b solana_program::account_info::AccountInfo<'a>>,
501 vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
502 operator_vault_ticket: Option<&'b solana_program::account_info::AccountInfo<'a>>,
503 admin: Option<&'b solana_program::account_info::AccountInfo<'a>>,
504 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
505 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
506 __remaining_accounts: Vec<(
508 &'b solana_program::account_info::AccountInfo<'a>,
509 bool,
510 bool,
511 )>,
512}