Skip to main content

security_token_client/generated/instructions/
convert.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use crate::generated::types::ConvertArgs;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub const CONVERT_DISCRIMINATOR: u8 = 17;
13
14/// Accounts.
15#[derive(Debug)]
16pub struct Convert {
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 mint_authority: solana_pubkey::Pubkey,
24
25    pub permanent_delegate: solana_pubkey::Pubkey,
26
27    pub payer: solana_pubkey::Pubkey,
28
29    pub mint_from: solana_pubkey::Pubkey,
30
31    pub mint_to: solana_pubkey::Pubkey,
32
33    pub token_account_from: solana_pubkey::Pubkey,
34
35    pub token_account_to: solana_pubkey::Pubkey,
36
37    pub rate_account: solana_pubkey::Pubkey,
38
39    pub receipt_account: solana_pubkey::Pubkey,
40
41    pub token_program: solana_pubkey::Pubkey,
42
43    pub system_program: solana_pubkey::Pubkey,
44}
45
46impl Convert {
47    pub fn instruction(&self, args: ConvertInstructionArgs) -> solana_instruction::Instruction {
48        self.instruction_with_remaining_accounts(args, &[])
49    }
50    #[allow(clippy::arithmetic_side_effects)]
51    #[allow(clippy::vec_init_then_push)]
52    pub fn instruction_with_remaining_accounts(
53        &self,
54        args: ConvertInstructionArgs,
55        remaining_accounts: &[solana_instruction::AccountMeta],
56    ) -> solana_instruction::Instruction {
57        let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
58        accounts.push(solana_instruction::AccountMeta::new_readonly(
59            self.mint, false,
60        ));
61        accounts.push(solana_instruction::AccountMeta::new_readonly(
62            self.verification_config,
63            false,
64        ));
65        accounts.push(solana_instruction::AccountMeta::new_readonly(
66            self.instructions_sysvar,
67            false,
68        ));
69        accounts.push(solana_instruction::AccountMeta::new_readonly(
70            self.mint_authority,
71            false,
72        ));
73        accounts.push(solana_instruction::AccountMeta::new_readonly(
74            self.permanent_delegate,
75            false,
76        ));
77        accounts.push(solana_instruction::AccountMeta::new(self.payer, true));
78        accounts.push(solana_instruction::AccountMeta::new(self.mint_from, false));
79        accounts.push(solana_instruction::AccountMeta::new(self.mint_to, false));
80        accounts.push(solana_instruction::AccountMeta::new(
81            self.token_account_from,
82            false,
83        ));
84        accounts.push(solana_instruction::AccountMeta::new(
85            self.token_account_to,
86            false,
87        ));
88        accounts.push(solana_instruction::AccountMeta::new_readonly(
89            self.rate_account,
90            false,
91        ));
92        accounts.push(solana_instruction::AccountMeta::new(
93            self.receipt_account,
94            false,
95        ));
96        accounts.push(solana_instruction::AccountMeta::new_readonly(
97            self.token_program,
98            false,
99        ));
100        accounts.push(solana_instruction::AccountMeta::new_readonly(
101            self.system_program,
102            false,
103        ));
104        accounts.extend_from_slice(remaining_accounts);
105        let mut data = borsh::to_vec(&ConvertInstructionData::new()).unwrap();
106        let mut args = borsh::to_vec(&args).unwrap();
107        data.append(&mut args);
108
109        solana_instruction::Instruction {
110            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
111            accounts,
112            data,
113        }
114    }
115}
116
117#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
118#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
119pub struct ConvertInstructionData {
120    discriminator: u8,
121}
122
123impl ConvertInstructionData {
124    pub fn new() -> Self {
125        Self { discriminator: 17 }
126    }
127}
128
129impl Default for ConvertInstructionData {
130    fn default() -> Self {
131        Self::new()
132    }
133}
134
135#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
136#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
137pub struct ConvertInstructionArgs {
138    pub convert_args: ConvertArgs,
139}
140
141/// Instruction builder for `Convert`.
142///
143/// ### Accounts:
144///
145///   0. `[]` mint
146///   1. `[]` verification_config
147///   2. `[optional]` instructions_sysvar (default to `Sysvar1nstructions1111111111111111111111111`)
148///   3. `[]` mint_authority
149///   4. `[]` permanent_delegate
150///   5. `[writable, signer]` payer
151///   6. `[writable]` mint_from
152///   7. `[writable]` mint_to
153///   8. `[writable]` token_account_from
154///   9. `[writable]` token_account_to
155///   10. `[]` rate_account
156///   11. `[writable]` receipt_account
157///   12. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`)
158///   13. `[optional]` system_program (default to `11111111111111111111111111111111`)
159#[derive(Clone, Debug, Default)]
160pub struct ConvertBuilder {
161    mint: Option<solana_pubkey::Pubkey>,
162    verification_config: Option<solana_pubkey::Pubkey>,
163    instructions_sysvar: Option<solana_pubkey::Pubkey>,
164    mint_authority: Option<solana_pubkey::Pubkey>,
165    permanent_delegate: Option<solana_pubkey::Pubkey>,
166    payer: Option<solana_pubkey::Pubkey>,
167    mint_from: Option<solana_pubkey::Pubkey>,
168    mint_to: Option<solana_pubkey::Pubkey>,
169    token_account_from: Option<solana_pubkey::Pubkey>,
170    token_account_to: Option<solana_pubkey::Pubkey>,
171    rate_account: Option<solana_pubkey::Pubkey>,
172    receipt_account: Option<solana_pubkey::Pubkey>,
173    token_program: Option<solana_pubkey::Pubkey>,
174    system_program: Option<solana_pubkey::Pubkey>,
175    convert_args: Option<ConvertArgs>,
176    __remaining_accounts: Vec<solana_instruction::AccountMeta>,
177}
178
179impl ConvertBuilder {
180    pub fn new() -> Self {
181        Self::default()
182    }
183    #[inline(always)]
184    pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
185        self.mint = Some(mint);
186        self
187    }
188    #[inline(always)]
189    pub fn verification_config(&mut self, verification_config: solana_pubkey::Pubkey) -> &mut Self {
190        self.verification_config = Some(verification_config);
191        self
192    }
193    /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']`
194    #[inline(always)]
195    pub fn instructions_sysvar(&mut self, instructions_sysvar: solana_pubkey::Pubkey) -> &mut Self {
196        self.instructions_sysvar = Some(instructions_sysvar);
197        self
198    }
199    #[inline(always)]
200    pub fn mint_authority(&mut self, mint_authority: solana_pubkey::Pubkey) -> &mut Self {
201        self.mint_authority = Some(mint_authority);
202        self
203    }
204    #[inline(always)]
205    pub fn permanent_delegate(&mut self, permanent_delegate: solana_pubkey::Pubkey) -> &mut Self {
206        self.permanent_delegate = Some(permanent_delegate);
207        self
208    }
209    #[inline(always)]
210    pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self {
211        self.payer = Some(payer);
212        self
213    }
214    #[inline(always)]
215    pub fn mint_from(&mut self, mint_from: solana_pubkey::Pubkey) -> &mut Self {
216        self.mint_from = Some(mint_from);
217        self
218    }
219    #[inline(always)]
220    pub fn mint_to(&mut self, mint_to: solana_pubkey::Pubkey) -> &mut Self {
221        self.mint_to = Some(mint_to);
222        self
223    }
224    #[inline(always)]
225    pub fn token_account_from(&mut self, token_account_from: solana_pubkey::Pubkey) -> &mut Self {
226        self.token_account_from = Some(token_account_from);
227        self
228    }
229    #[inline(always)]
230    pub fn token_account_to(&mut self, token_account_to: solana_pubkey::Pubkey) -> &mut Self {
231        self.token_account_to = Some(token_account_to);
232        self
233    }
234    #[inline(always)]
235    pub fn rate_account(&mut self, rate_account: solana_pubkey::Pubkey) -> &mut Self {
236        self.rate_account = Some(rate_account);
237        self
238    }
239    #[inline(always)]
240    pub fn receipt_account(&mut self, receipt_account: solana_pubkey::Pubkey) -> &mut Self {
241        self.receipt_account = Some(receipt_account);
242        self
243    }
244    /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']`
245    #[inline(always)]
246    pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
247        self.token_program = Some(token_program);
248        self
249    }
250    /// `[optional account, default to '11111111111111111111111111111111']`
251    #[inline(always)]
252    pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
253        self.system_program = Some(system_program);
254        self
255    }
256    #[inline(always)]
257    pub fn convert_args(&mut self, convert_args: ConvertArgs) -> &mut Self {
258        self.convert_args = Some(convert_args);
259        self
260    }
261    /// Add an additional account to the instruction.
262    #[inline(always)]
263    pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
264        self.__remaining_accounts.push(account);
265        self
266    }
267    /// Add additional accounts to the instruction.
268    #[inline(always)]
269    pub fn add_remaining_accounts(
270        &mut self,
271        accounts: &[solana_instruction::AccountMeta],
272    ) -> &mut Self {
273        self.__remaining_accounts.extend_from_slice(accounts);
274        self
275    }
276    #[allow(clippy::clone_on_copy)]
277    pub fn instruction(&self) -> solana_instruction::Instruction {
278        let accounts = Convert {
279            mint: self.mint.expect("mint is not set"),
280            verification_config: self
281                .verification_config
282                .expect("verification_config is not set"),
283            instructions_sysvar: self.instructions_sysvar.unwrap_or(solana_pubkey::pubkey!(
284                "Sysvar1nstructions1111111111111111111111111"
285            )),
286            mint_authority: self.mint_authority.expect("mint_authority is not set"),
287            permanent_delegate: self
288                .permanent_delegate
289                .expect("permanent_delegate is not set"),
290            payer: self.payer.expect("payer is not set"),
291            mint_from: self.mint_from.expect("mint_from is not set"),
292            mint_to: self.mint_to.expect("mint_to is not set"),
293            token_account_from: self
294                .token_account_from
295                .expect("token_account_from is not set"),
296            token_account_to: self.token_account_to.expect("token_account_to is not set"),
297            rate_account: self.rate_account.expect("rate_account is not set"),
298            receipt_account: self.receipt_account.expect("receipt_account is not set"),
299            token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
300                "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
301            )),
302            system_program: self
303                .system_program
304                .unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
305        };
306        let args = ConvertInstructionArgs {
307            convert_args: self.convert_args.clone().expect("convert_args is not set"),
308        };
309
310        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
311    }
312}
313
314/// `convert` CPI accounts.
315pub struct ConvertCpiAccounts<'a, 'b> {
316    pub mint: &'b solana_account_info::AccountInfo<'a>,
317
318    pub verification_config: &'b solana_account_info::AccountInfo<'a>,
319
320    pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
321
322    pub mint_authority: &'b solana_account_info::AccountInfo<'a>,
323
324    pub permanent_delegate: &'b solana_account_info::AccountInfo<'a>,
325
326    pub payer: &'b solana_account_info::AccountInfo<'a>,
327
328    pub mint_from: &'b solana_account_info::AccountInfo<'a>,
329
330    pub mint_to: &'b solana_account_info::AccountInfo<'a>,
331
332    pub token_account_from: &'b solana_account_info::AccountInfo<'a>,
333
334    pub token_account_to: &'b solana_account_info::AccountInfo<'a>,
335
336    pub rate_account: &'b solana_account_info::AccountInfo<'a>,
337
338    pub receipt_account: &'b solana_account_info::AccountInfo<'a>,
339
340    pub token_program: &'b solana_account_info::AccountInfo<'a>,
341
342    pub system_program: &'b solana_account_info::AccountInfo<'a>,
343}
344
345/// `convert` CPI instruction.
346pub struct ConvertCpi<'a, 'b> {
347    /// The program to invoke.
348    pub __program: &'b solana_account_info::AccountInfo<'a>,
349
350    pub mint: &'b solana_account_info::AccountInfo<'a>,
351
352    pub verification_config: &'b solana_account_info::AccountInfo<'a>,
353
354    pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
355
356    pub mint_authority: &'b solana_account_info::AccountInfo<'a>,
357
358    pub permanent_delegate: &'b solana_account_info::AccountInfo<'a>,
359
360    pub payer: &'b solana_account_info::AccountInfo<'a>,
361
362    pub mint_from: &'b solana_account_info::AccountInfo<'a>,
363
364    pub mint_to: &'b solana_account_info::AccountInfo<'a>,
365
366    pub token_account_from: &'b solana_account_info::AccountInfo<'a>,
367
368    pub token_account_to: &'b solana_account_info::AccountInfo<'a>,
369
370    pub rate_account: &'b solana_account_info::AccountInfo<'a>,
371
372    pub receipt_account: &'b solana_account_info::AccountInfo<'a>,
373
374    pub token_program: &'b solana_account_info::AccountInfo<'a>,
375
376    pub system_program: &'b solana_account_info::AccountInfo<'a>,
377    /// The arguments for the instruction.
378    pub __args: ConvertInstructionArgs,
379}
380
381impl<'a, 'b> ConvertCpi<'a, 'b> {
382    pub fn new(
383        program: &'b solana_account_info::AccountInfo<'a>,
384        accounts: ConvertCpiAccounts<'a, 'b>,
385        args: ConvertInstructionArgs,
386    ) -> Self {
387        Self {
388            __program: program,
389            mint: accounts.mint,
390            verification_config: accounts.verification_config,
391            instructions_sysvar: accounts.instructions_sysvar,
392            mint_authority: accounts.mint_authority,
393            permanent_delegate: accounts.permanent_delegate,
394            payer: accounts.payer,
395            mint_from: accounts.mint_from,
396            mint_to: accounts.mint_to,
397            token_account_from: accounts.token_account_from,
398            token_account_to: accounts.token_account_to,
399            rate_account: accounts.rate_account,
400            receipt_account: accounts.receipt_account,
401            token_program: accounts.token_program,
402            system_program: accounts.system_program,
403            __args: args,
404        }
405    }
406    #[inline(always)]
407    pub fn invoke(&self) -> solana_program_error::ProgramResult {
408        self.invoke_signed_with_remaining_accounts(&[], &[])
409    }
410    #[inline(always)]
411    pub fn invoke_with_remaining_accounts(
412        &self,
413        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
414    ) -> solana_program_error::ProgramResult {
415        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
416    }
417    #[inline(always)]
418    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
419        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
420    }
421    #[allow(clippy::arithmetic_side_effects)]
422    #[allow(clippy::clone_on_copy)]
423    #[allow(clippy::vec_init_then_push)]
424    pub fn invoke_signed_with_remaining_accounts(
425        &self,
426        signers_seeds: &[&[&[u8]]],
427        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
428    ) -> solana_program_error::ProgramResult {
429        let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
430        accounts.push(solana_instruction::AccountMeta::new_readonly(
431            *self.mint.key,
432            false,
433        ));
434        accounts.push(solana_instruction::AccountMeta::new_readonly(
435            *self.verification_config.key,
436            false,
437        ));
438        accounts.push(solana_instruction::AccountMeta::new_readonly(
439            *self.instructions_sysvar.key,
440            false,
441        ));
442        accounts.push(solana_instruction::AccountMeta::new_readonly(
443            *self.mint_authority.key,
444            false,
445        ));
446        accounts.push(solana_instruction::AccountMeta::new_readonly(
447            *self.permanent_delegate.key,
448            false,
449        ));
450        accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true));
451        accounts.push(solana_instruction::AccountMeta::new(
452            *self.mint_from.key,
453            false,
454        ));
455        accounts.push(solana_instruction::AccountMeta::new(
456            *self.mint_to.key,
457            false,
458        ));
459        accounts.push(solana_instruction::AccountMeta::new(
460            *self.token_account_from.key,
461            false,
462        ));
463        accounts.push(solana_instruction::AccountMeta::new(
464            *self.token_account_to.key,
465            false,
466        ));
467        accounts.push(solana_instruction::AccountMeta::new_readonly(
468            *self.rate_account.key,
469            false,
470        ));
471        accounts.push(solana_instruction::AccountMeta::new(
472            *self.receipt_account.key,
473            false,
474        ));
475        accounts.push(solana_instruction::AccountMeta::new_readonly(
476            *self.token_program.key,
477            false,
478        ));
479        accounts.push(solana_instruction::AccountMeta::new_readonly(
480            *self.system_program.key,
481            false,
482        ));
483        remaining_accounts.iter().for_each(|remaining_account| {
484            accounts.push(solana_instruction::AccountMeta {
485                pubkey: *remaining_account.0.key,
486                is_signer: remaining_account.1,
487                is_writable: remaining_account.2,
488            })
489        });
490        let mut data = borsh::to_vec(&ConvertInstructionData::new()).unwrap();
491        let mut args = borsh::to_vec(&self.__args).unwrap();
492        data.append(&mut args);
493
494        let instruction = solana_instruction::Instruction {
495            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
496            accounts,
497            data,
498        };
499        let mut account_infos = Vec::with_capacity(15 + remaining_accounts.len());
500        account_infos.push(self.__program.clone());
501        account_infos.push(self.mint.clone());
502        account_infos.push(self.verification_config.clone());
503        account_infos.push(self.instructions_sysvar.clone());
504        account_infos.push(self.mint_authority.clone());
505        account_infos.push(self.permanent_delegate.clone());
506        account_infos.push(self.payer.clone());
507        account_infos.push(self.mint_from.clone());
508        account_infos.push(self.mint_to.clone());
509        account_infos.push(self.token_account_from.clone());
510        account_infos.push(self.token_account_to.clone());
511        account_infos.push(self.rate_account.clone());
512        account_infos.push(self.receipt_account.clone());
513        account_infos.push(self.token_program.clone());
514        account_infos.push(self.system_program.clone());
515        remaining_accounts
516            .iter()
517            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
518
519        if signers_seeds.is_empty() {
520            solana_cpi::invoke(&instruction, &account_infos)
521        } else {
522            solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
523        }
524    }
525}
526
527/// Instruction builder for `Convert` via CPI.
528///
529/// ### Accounts:
530///
531///   0. `[]` mint
532///   1. `[]` verification_config
533///   2. `[]` instructions_sysvar
534///   3. `[]` mint_authority
535///   4. `[]` permanent_delegate
536///   5. `[writable, signer]` payer
537///   6. `[writable]` mint_from
538///   7. `[writable]` mint_to
539///   8. `[writable]` token_account_from
540///   9. `[writable]` token_account_to
541///   10. `[]` rate_account
542///   11. `[writable]` receipt_account
543///   12. `[]` token_program
544///   13. `[]` system_program
545#[derive(Clone, Debug)]
546pub struct ConvertCpiBuilder<'a, 'b> {
547    instruction: Box<ConvertCpiBuilderInstruction<'a, 'b>>,
548}
549
550impl<'a, 'b> ConvertCpiBuilder<'a, 'b> {
551    pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
552        let instruction = Box::new(ConvertCpiBuilderInstruction {
553            __program: program,
554            mint: None,
555            verification_config: None,
556            instructions_sysvar: None,
557            mint_authority: None,
558            permanent_delegate: None,
559            payer: None,
560            mint_from: None,
561            mint_to: None,
562            token_account_from: None,
563            token_account_to: None,
564            rate_account: None,
565            receipt_account: None,
566            token_program: None,
567            system_program: None,
568            convert_args: None,
569            __remaining_accounts: Vec::new(),
570        });
571        Self { instruction }
572    }
573    #[inline(always)]
574    pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
575        self.instruction.mint = Some(mint);
576        self
577    }
578    #[inline(always)]
579    pub fn verification_config(
580        &mut self,
581        verification_config: &'b solana_account_info::AccountInfo<'a>,
582    ) -> &mut Self {
583        self.instruction.verification_config = Some(verification_config);
584        self
585    }
586    #[inline(always)]
587    pub fn instructions_sysvar(
588        &mut self,
589        instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
590    ) -> &mut Self {
591        self.instruction.instructions_sysvar = Some(instructions_sysvar);
592        self
593    }
594    #[inline(always)]
595    pub fn mint_authority(
596        &mut self,
597        mint_authority: &'b solana_account_info::AccountInfo<'a>,
598    ) -> &mut Self {
599        self.instruction.mint_authority = Some(mint_authority);
600        self
601    }
602    #[inline(always)]
603    pub fn permanent_delegate(
604        &mut self,
605        permanent_delegate: &'b solana_account_info::AccountInfo<'a>,
606    ) -> &mut Self {
607        self.instruction.permanent_delegate = Some(permanent_delegate);
608        self
609    }
610    #[inline(always)]
611    pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
612        self.instruction.payer = Some(payer);
613        self
614    }
615    #[inline(always)]
616    pub fn mint_from(&mut self, mint_from: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
617        self.instruction.mint_from = Some(mint_from);
618        self
619    }
620    #[inline(always)]
621    pub fn mint_to(&mut self, mint_to: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
622        self.instruction.mint_to = Some(mint_to);
623        self
624    }
625    #[inline(always)]
626    pub fn token_account_from(
627        &mut self,
628        token_account_from: &'b solana_account_info::AccountInfo<'a>,
629    ) -> &mut Self {
630        self.instruction.token_account_from = Some(token_account_from);
631        self
632    }
633    #[inline(always)]
634    pub fn token_account_to(
635        &mut self,
636        token_account_to: &'b solana_account_info::AccountInfo<'a>,
637    ) -> &mut Self {
638        self.instruction.token_account_to = Some(token_account_to);
639        self
640    }
641    #[inline(always)]
642    pub fn rate_account(
643        &mut self,
644        rate_account: &'b solana_account_info::AccountInfo<'a>,
645    ) -> &mut Self {
646        self.instruction.rate_account = Some(rate_account);
647        self
648    }
649    #[inline(always)]
650    pub fn receipt_account(
651        &mut self,
652        receipt_account: &'b solana_account_info::AccountInfo<'a>,
653    ) -> &mut Self {
654        self.instruction.receipt_account = Some(receipt_account);
655        self
656    }
657    #[inline(always)]
658    pub fn token_program(
659        &mut self,
660        token_program: &'b solana_account_info::AccountInfo<'a>,
661    ) -> &mut Self {
662        self.instruction.token_program = Some(token_program);
663        self
664    }
665    #[inline(always)]
666    pub fn system_program(
667        &mut self,
668        system_program: &'b solana_account_info::AccountInfo<'a>,
669    ) -> &mut Self {
670        self.instruction.system_program = Some(system_program);
671        self
672    }
673    #[inline(always)]
674    pub fn convert_args(&mut self, convert_args: ConvertArgs) -> &mut Self {
675        self.instruction.convert_args = Some(convert_args);
676        self
677    }
678    /// Add an additional account to the instruction.
679    #[inline(always)]
680    pub fn add_remaining_account(
681        &mut self,
682        account: &'b solana_account_info::AccountInfo<'a>,
683        is_writable: bool,
684        is_signer: bool,
685    ) -> &mut Self {
686        self.instruction
687            .__remaining_accounts
688            .push((account, is_writable, is_signer));
689        self
690    }
691    /// Add additional accounts to the instruction.
692    ///
693    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
694    /// and a `bool` indicating whether the account is a signer or not.
695    #[inline(always)]
696    pub fn add_remaining_accounts(
697        &mut self,
698        accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
699    ) -> &mut Self {
700        self.instruction
701            .__remaining_accounts
702            .extend_from_slice(accounts);
703        self
704    }
705    #[inline(always)]
706    pub fn invoke(&self) -> solana_program_error::ProgramResult {
707        self.invoke_signed(&[])
708    }
709    #[allow(clippy::clone_on_copy)]
710    #[allow(clippy::vec_init_then_push)]
711    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
712        let args = ConvertInstructionArgs {
713            convert_args: self
714                .instruction
715                .convert_args
716                .clone()
717                .expect("convert_args is not set"),
718        };
719        let instruction = ConvertCpi {
720            __program: self.instruction.__program,
721
722            mint: self.instruction.mint.expect("mint is not set"),
723
724            verification_config: self
725                .instruction
726                .verification_config
727                .expect("verification_config is not set"),
728
729            instructions_sysvar: self
730                .instruction
731                .instructions_sysvar
732                .expect("instructions_sysvar is not set"),
733
734            mint_authority: self
735                .instruction
736                .mint_authority
737                .expect("mint_authority is not set"),
738
739            permanent_delegate: self
740                .instruction
741                .permanent_delegate
742                .expect("permanent_delegate is not set"),
743
744            payer: self.instruction.payer.expect("payer is not set"),
745
746            mint_from: self.instruction.mint_from.expect("mint_from is not set"),
747
748            mint_to: self.instruction.mint_to.expect("mint_to is not set"),
749
750            token_account_from: self
751                .instruction
752                .token_account_from
753                .expect("token_account_from is not set"),
754
755            token_account_to: self
756                .instruction
757                .token_account_to
758                .expect("token_account_to is not set"),
759
760            rate_account: self
761                .instruction
762                .rate_account
763                .expect("rate_account is not set"),
764
765            receipt_account: self
766                .instruction
767                .receipt_account
768                .expect("receipt_account is not set"),
769
770            token_program: self
771                .instruction
772                .token_program
773                .expect("token_program is not set"),
774
775            system_program: self
776                .instruction
777                .system_program
778                .expect("system_program is not set"),
779            __args: args,
780        };
781        instruction.invoke_signed_with_remaining_accounts(
782            signers_seeds,
783            &self.instruction.__remaining_accounts,
784        )
785    }
786}
787
788#[derive(Clone, Debug)]
789struct ConvertCpiBuilderInstruction<'a, 'b> {
790    __program: &'b solana_account_info::AccountInfo<'a>,
791    mint: Option<&'b solana_account_info::AccountInfo<'a>>,
792    verification_config: Option<&'b solana_account_info::AccountInfo<'a>>,
793    instructions_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>,
794    mint_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
795    permanent_delegate: Option<&'b solana_account_info::AccountInfo<'a>>,
796    payer: Option<&'b solana_account_info::AccountInfo<'a>>,
797    mint_from: Option<&'b solana_account_info::AccountInfo<'a>>,
798    mint_to: Option<&'b solana_account_info::AccountInfo<'a>>,
799    token_account_from: Option<&'b solana_account_info::AccountInfo<'a>>,
800    token_account_to: Option<&'b solana_account_info::AccountInfo<'a>>,
801    rate_account: Option<&'b solana_account_info::AccountInfo<'a>>,
802    receipt_account: Option<&'b solana_account_info::AccountInfo<'a>>,
803    token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
804    system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
805    convert_args: Option<ConvertArgs>,
806    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
807    __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
808}