1use crate::generated::types::UpdateProofArgs;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub const UPDATE_PROOF_ACCOUNT_DISCRIMINATOR: u8 = 19;
13
14#[derive(Debug)]
16pub struct UpdateProofAccount {
17 pub mint: solana_pubkey::Pubkey,
18
19 pub verification_config: solana_pubkey::Pubkey,
20
21 pub instructions_sysvar: solana_pubkey::Pubkey,
22
23 pub payer: solana_pubkey::Pubkey,
24
25 pub mint_account: solana_pubkey::Pubkey,
26
27 pub proof_account: solana_pubkey::Pubkey,
28
29 pub token_account: solana_pubkey::Pubkey,
30
31 pub system_program: solana_pubkey::Pubkey,
32}
33
34impl UpdateProofAccount {
35 pub fn instruction(
36 &self,
37 args: UpdateProofAccountInstructionArgs,
38 ) -> solana_instruction::Instruction {
39 self.instruction_with_remaining_accounts(args, &[])
40 }
41 #[allow(clippy::arithmetic_side_effects)]
42 #[allow(clippy::vec_init_then_push)]
43 pub fn instruction_with_remaining_accounts(
44 &self,
45 args: UpdateProofAccountInstructionArgs,
46 remaining_accounts: &[solana_instruction::AccountMeta],
47 ) -> solana_instruction::Instruction {
48 let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
49 accounts.push(solana_instruction::AccountMeta::new_readonly(
50 self.mint, false,
51 ));
52 accounts.push(solana_instruction::AccountMeta::new_readonly(
53 self.verification_config,
54 false,
55 ));
56 accounts.push(solana_instruction::AccountMeta::new_readonly(
57 self.instructions_sysvar,
58 false,
59 ));
60 accounts.push(solana_instruction::AccountMeta::new(self.payer, true));
61 accounts.push(solana_instruction::AccountMeta::new_readonly(
62 self.mint_account,
63 false,
64 ));
65 accounts.push(solana_instruction::AccountMeta::new(
66 self.proof_account,
67 false,
68 ));
69 accounts.push(solana_instruction::AccountMeta::new_readonly(
70 self.token_account,
71 false,
72 ));
73 accounts.push(solana_instruction::AccountMeta::new_readonly(
74 self.system_program,
75 false,
76 ));
77 accounts.extend_from_slice(remaining_accounts);
78 let mut data = borsh::to_vec(&UpdateProofAccountInstructionData::new()).unwrap();
79 let mut args = borsh::to_vec(&args).unwrap();
80 data.append(&mut args);
81
82 solana_instruction::Instruction {
83 program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
84 accounts,
85 data,
86 }
87 }
88}
89
90#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
91#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
92pub struct UpdateProofAccountInstructionData {
93 discriminator: u8,
94}
95
96impl UpdateProofAccountInstructionData {
97 pub fn new() -> Self {
98 Self { discriminator: 19 }
99 }
100}
101
102impl Default for UpdateProofAccountInstructionData {
103 fn default() -> Self {
104 Self::new()
105 }
106}
107
108#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
109#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
110pub struct UpdateProofAccountInstructionArgs {
111 pub update_proof_args: UpdateProofArgs,
112}
113
114#[derive(Clone, Debug, Default)]
127pub struct UpdateProofAccountBuilder {
128 mint: Option<solana_pubkey::Pubkey>,
129 verification_config: Option<solana_pubkey::Pubkey>,
130 instructions_sysvar: Option<solana_pubkey::Pubkey>,
131 payer: Option<solana_pubkey::Pubkey>,
132 mint_account: Option<solana_pubkey::Pubkey>,
133 proof_account: Option<solana_pubkey::Pubkey>,
134 token_account: Option<solana_pubkey::Pubkey>,
135 system_program: Option<solana_pubkey::Pubkey>,
136 update_proof_args: Option<UpdateProofArgs>,
137 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
138}
139
140impl UpdateProofAccountBuilder {
141 pub fn new() -> Self {
142 Self::default()
143 }
144 #[inline(always)]
145 pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
146 self.mint = Some(mint);
147 self
148 }
149 #[inline(always)]
150 pub fn verification_config(&mut self, verification_config: solana_pubkey::Pubkey) -> &mut Self {
151 self.verification_config = Some(verification_config);
152 self
153 }
154 #[inline(always)]
156 pub fn instructions_sysvar(&mut self, instructions_sysvar: solana_pubkey::Pubkey) -> &mut Self {
157 self.instructions_sysvar = Some(instructions_sysvar);
158 self
159 }
160 #[inline(always)]
161 pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self {
162 self.payer = Some(payer);
163 self
164 }
165 #[inline(always)]
166 pub fn mint_account(&mut self, mint_account: solana_pubkey::Pubkey) -> &mut Self {
167 self.mint_account = Some(mint_account);
168 self
169 }
170 #[inline(always)]
171 pub fn proof_account(&mut self, proof_account: solana_pubkey::Pubkey) -> &mut Self {
172 self.proof_account = Some(proof_account);
173 self
174 }
175 #[inline(always)]
176 pub fn token_account(&mut self, token_account: solana_pubkey::Pubkey) -> &mut Self {
177 self.token_account = Some(token_account);
178 self
179 }
180 #[inline(always)]
182 pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
183 self.system_program = Some(system_program);
184 self
185 }
186 #[inline(always)]
187 pub fn update_proof_args(&mut self, update_proof_args: UpdateProofArgs) -> &mut Self {
188 self.update_proof_args = Some(update_proof_args);
189 self
190 }
191 #[inline(always)]
193 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
194 self.__remaining_accounts.push(account);
195 self
196 }
197 #[inline(always)]
199 pub fn add_remaining_accounts(
200 &mut self,
201 accounts: &[solana_instruction::AccountMeta],
202 ) -> &mut Self {
203 self.__remaining_accounts.extend_from_slice(accounts);
204 self
205 }
206 #[allow(clippy::clone_on_copy)]
207 pub fn instruction(&self) -> solana_instruction::Instruction {
208 let accounts = UpdateProofAccount {
209 mint: self.mint.expect("mint is not set"),
210 verification_config: self
211 .verification_config
212 .expect("verification_config is not set"),
213 instructions_sysvar: self.instructions_sysvar.unwrap_or(solana_pubkey::pubkey!(
214 "Sysvar1nstructions1111111111111111111111111"
215 )),
216 payer: self.payer.expect("payer is not set"),
217 mint_account: self.mint_account.expect("mint_account is not set"),
218 proof_account: self.proof_account.expect("proof_account is not set"),
219 token_account: self.token_account.expect("token_account is not set"),
220 system_program: self
221 .system_program
222 .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
223 };
224 let args = UpdateProofAccountInstructionArgs {
225 update_proof_args: self
226 .update_proof_args
227 .clone()
228 .expect("update_proof_args is not set"),
229 };
230
231 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
232 }
233}
234
235pub struct UpdateProofAccountCpiAccounts<'a, 'b> {
237 pub mint: &'b solana_account_info::AccountInfo<'a>,
238
239 pub verification_config: &'b solana_account_info::AccountInfo<'a>,
240
241 pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
242
243 pub payer: &'b solana_account_info::AccountInfo<'a>,
244
245 pub mint_account: &'b solana_account_info::AccountInfo<'a>,
246
247 pub proof_account: &'b solana_account_info::AccountInfo<'a>,
248
249 pub token_account: &'b solana_account_info::AccountInfo<'a>,
250
251 pub system_program: &'b solana_account_info::AccountInfo<'a>,
252}
253
254pub struct UpdateProofAccountCpi<'a, 'b> {
256 pub __program: &'b solana_account_info::AccountInfo<'a>,
258
259 pub mint: &'b solana_account_info::AccountInfo<'a>,
260
261 pub verification_config: &'b solana_account_info::AccountInfo<'a>,
262
263 pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
264
265 pub payer: &'b solana_account_info::AccountInfo<'a>,
266
267 pub mint_account: &'b solana_account_info::AccountInfo<'a>,
268
269 pub proof_account: &'b solana_account_info::AccountInfo<'a>,
270
271 pub token_account: &'b solana_account_info::AccountInfo<'a>,
272
273 pub system_program: &'b solana_account_info::AccountInfo<'a>,
274 pub __args: UpdateProofAccountInstructionArgs,
276}
277
278impl<'a, 'b> UpdateProofAccountCpi<'a, 'b> {
279 pub fn new(
280 program: &'b solana_account_info::AccountInfo<'a>,
281 accounts: UpdateProofAccountCpiAccounts<'a, 'b>,
282 args: UpdateProofAccountInstructionArgs,
283 ) -> Self {
284 Self {
285 __program: program,
286 mint: accounts.mint,
287 verification_config: accounts.verification_config,
288 instructions_sysvar: accounts.instructions_sysvar,
289 payer: accounts.payer,
290 mint_account: accounts.mint_account,
291 proof_account: accounts.proof_account,
292 token_account: accounts.token_account,
293 system_program: accounts.system_program,
294 __args: args,
295 }
296 }
297 #[inline(always)]
298 pub fn invoke(&self) -> solana_program_error::ProgramResult {
299 self.invoke_signed_with_remaining_accounts(&[], &[])
300 }
301 #[inline(always)]
302 pub fn invoke_with_remaining_accounts(
303 &self,
304 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
305 ) -> solana_program_error::ProgramResult {
306 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
307 }
308 #[inline(always)]
309 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
310 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
311 }
312 #[allow(clippy::arithmetic_side_effects)]
313 #[allow(clippy::clone_on_copy)]
314 #[allow(clippy::vec_init_then_push)]
315 pub fn invoke_signed_with_remaining_accounts(
316 &self,
317 signers_seeds: &[&[&[u8]]],
318 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
319 ) -> solana_program_error::ProgramResult {
320 let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
321 accounts.push(solana_instruction::AccountMeta::new_readonly(
322 *self.mint.key,
323 false,
324 ));
325 accounts.push(solana_instruction::AccountMeta::new_readonly(
326 *self.verification_config.key,
327 false,
328 ));
329 accounts.push(solana_instruction::AccountMeta::new_readonly(
330 *self.instructions_sysvar.key,
331 false,
332 ));
333 accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true));
334 accounts.push(solana_instruction::AccountMeta::new_readonly(
335 *self.mint_account.key,
336 false,
337 ));
338 accounts.push(solana_instruction::AccountMeta::new(
339 *self.proof_account.key,
340 false,
341 ));
342 accounts.push(solana_instruction::AccountMeta::new_readonly(
343 *self.token_account.key,
344 false,
345 ));
346 accounts.push(solana_instruction::AccountMeta::new_readonly(
347 *self.system_program.key,
348 false,
349 ));
350 remaining_accounts.iter().for_each(|remaining_account| {
351 accounts.push(solana_instruction::AccountMeta {
352 pubkey: *remaining_account.0.key,
353 is_signer: remaining_account.1,
354 is_writable: remaining_account.2,
355 })
356 });
357 let mut data = borsh::to_vec(&UpdateProofAccountInstructionData::new()).unwrap();
358 let mut args = borsh::to_vec(&self.__args).unwrap();
359 data.append(&mut args);
360
361 let instruction = solana_instruction::Instruction {
362 program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
363 accounts,
364 data,
365 };
366 let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len());
367 account_infos.push(self.__program.clone());
368 account_infos.push(self.mint.clone());
369 account_infos.push(self.verification_config.clone());
370 account_infos.push(self.instructions_sysvar.clone());
371 account_infos.push(self.payer.clone());
372 account_infos.push(self.mint_account.clone());
373 account_infos.push(self.proof_account.clone());
374 account_infos.push(self.token_account.clone());
375 account_infos.push(self.system_program.clone());
376 remaining_accounts
377 .iter()
378 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
379
380 if signers_seeds.is_empty() {
381 solana_cpi::invoke(&instruction, &account_infos)
382 } else {
383 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
384 }
385 }
386}
387
388#[derive(Clone, Debug)]
401pub struct UpdateProofAccountCpiBuilder<'a, 'b> {
402 instruction: Box<UpdateProofAccountCpiBuilderInstruction<'a, 'b>>,
403}
404
405impl<'a, 'b> UpdateProofAccountCpiBuilder<'a, 'b> {
406 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
407 let instruction = Box::new(UpdateProofAccountCpiBuilderInstruction {
408 __program: program,
409 mint: None,
410 verification_config: None,
411 instructions_sysvar: None,
412 payer: None,
413 mint_account: None,
414 proof_account: None,
415 token_account: None,
416 system_program: None,
417 update_proof_args: None,
418 __remaining_accounts: Vec::new(),
419 });
420 Self { instruction }
421 }
422 #[inline(always)]
423 pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
424 self.instruction.mint = Some(mint);
425 self
426 }
427 #[inline(always)]
428 pub fn verification_config(
429 &mut self,
430 verification_config: &'b solana_account_info::AccountInfo<'a>,
431 ) -> &mut Self {
432 self.instruction.verification_config = Some(verification_config);
433 self
434 }
435 #[inline(always)]
436 pub fn instructions_sysvar(
437 &mut self,
438 instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
439 ) -> &mut Self {
440 self.instruction.instructions_sysvar = Some(instructions_sysvar);
441 self
442 }
443 #[inline(always)]
444 pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
445 self.instruction.payer = Some(payer);
446 self
447 }
448 #[inline(always)]
449 pub fn mint_account(
450 &mut self,
451 mint_account: &'b solana_account_info::AccountInfo<'a>,
452 ) -> &mut Self {
453 self.instruction.mint_account = Some(mint_account);
454 self
455 }
456 #[inline(always)]
457 pub fn proof_account(
458 &mut self,
459 proof_account: &'b solana_account_info::AccountInfo<'a>,
460 ) -> &mut Self {
461 self.instruction.proof_account = Some(proof_account);
462 self
463 }
464 #[inline(always)]
465 pub fn token_account(
466 &mut self,
467 token_account: &'b solana_account_info::AccountInfo<'a>,
468 ) -> &mut Self {
469 self.instruction.token_account = Some(token_account);
470 self
471 }
472 #[inline(always)]
473 pub fn system_program(
474 &mut self,
475 system_program: &'b solana_account_info::AccountInfo<'a>,
476 ) -> &mut Self {
477 self.instruction.system_program = Some(system_program);
478 self
479 }
480 #[inline(always)]
481 pub fn update_proof_args(&mut self, update_proof_args: UpdateProofArgs) -> &mut Self {
482 self.instruction.update_proof_args = Some(update_proof_args);
483 self
484 }
485 #[inline(always)]
487 pub fn add_remaining_account(
488 &mut self,
489 account: &'b solana_account_info::AccountInfo<'a>,
490 is_writable: bool,
491 is_signer: bool,
492 ) -> &mut Self {
493 self.instruction
494 .__remaining_accounts
495 .push((account, is_writable, is_signer));
496 self
497 }
498 #[inline(always)]
503 pub fn add_remaining_accounts(
504 &mut self,
505 accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
506 ) -> &mut Self {
507 self.instruction
508 .__remaining_accounts
509 .extend_from_slice(accounts);
510 self
511 }
512 #[inline(always)]
513 pub fn invoke(&self) -> solana_program_error::ProgramResult {
514 self.invoke_signed(&[])
515 }
516 #[allow(clippy::clone_on_copy)]
517 #[allow(clippy::vec_init_then_push)]
518 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
519 let args = UpdateProofAccountInstructionArgs {
520 update_proof_args: self
521 .instruction
522 .update_proof_args
523 .clone()
524 .expect("update_proof_args is not set"),
525 };
526 let instruction = UpdateProofAccountCpi {
527 __program: self.instruction.__program,
528
529 mint: self.instruction.mint.expect("mint is not set"),
530
531 verification_config: self
532 .instruction
533 .verification_config
534 .expect("verification_config is not set"),
535
536 instructions_sysvar: self
537 .instruction
538 .instructions_sysvar
539 .expect("instructions_sysvar is not set"),
540
541 payer: self.instruction.payer.expect("payer is not set"),
542
543 mint_account: self
544 .instruction
545 .mint_account
546 .expect("mint_account is not set"),
547
548 proof_account: self
549 .instruction
550 .proof_account
551 .expect("proof_account is not set"),
552
553 token_account: self
554 .instruction
555 .token_account
556 .expect("token_account is not set"),
557
558 system_program: self
559 .instruction
560 .system_program
561 .expect("system_program is not set"),
562 __args: args,
563 };
564 instruction.invoke_signed_with_remaining_accounts(
565 signers_seeds,
566 &self.instruction.__remaining_accounts,
567 )
568 }
569}
570
571#[derive(Clone, Debug)]
572struct UpdateProofAccountCpiBuilderInstruction<'a, 'b> {
573 __program: &'b solana_account_info::AccountInfo<'a>,
574 mint: Option<&'b solana_account_info::AccountInfo<'a>>,
575 verification_config: Option<&'b solana_account_info::AccountInfo<'a>>,
576 instructions_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>,
577 payer: Option<&'b solana_account_info::AccountInfo<'a>>,
578 mint_account: Option<&'b solana_account_info::AccountInfo<'a>>,
579 proof_account: Option<&'b solana_account_info::AccountInfo<'a>>,
580 token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
581 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
582 update_proof_args: Option<UpdateProofArgs>,
583 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
585}