Skip to main content

security_token_client/generated/instructions/
close_claim_receipt_account.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::CloseClaimReceiptArgs;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub const CLOSE_CLAIM_RECEIPT_ACCOUNT_DISCRIMINATOR: u8 = 23;
13
14/// Accounts.
15#[derive(Debug)]
16pub struct CloseClaimReceiptAccount {
17    pub mint: solana_pubkey::Pubkey,
18
19    pub verification_config_or_mint_authority: solana_pubkey::Pubkey,
20
21    pub instructions_sysvar_or_creator: solana_pubkey::Pubkey,
22
23    pub receipt_account: solana_pubkey::Pubkey,
24
25    pub destination: solana_pubkey::Pubkey,
26
27    pub mint_account: solana_pubkey::Pubkey,
28
29    pub eligible_token_account: solana_pubkey::Pubkey,
30
31    pub proof_account: Option<solana_pubkey::Pubkey>,
32}
33
34impl CloseClaimReceiptAccount {
35    pub fn instruction(
36        &self,
37        args: CloseClaimReceiptAccountInstructionArgs,
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: CloseClaimReceiptAccountInstructionArgs,
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_or_mint_authority,
54            false,
55        ));
56        accounts.push(solana_instruction::AccountMeta::new_readonly(
57            self.instructions_sysvar_or_creator,
58            false,
59        ));
60        accounts.push(solana_instruction::AccountMeta::new(
61            self.receipt_account,
62            false,
63        ));
64        accounts.push(solana_instruction::AccountMeta::new(
65            self.destination,
66            false,
67        ));
68        accounts.push(solana_instruction::AccountMeta::new_readonly(
69            self.mint_account,
70            false,
71        ));
72        accounts.push(solana_instruction::AccountMeta::new_readonly(
73            self.eligible_token_account,
74            false,
75        ));
76        if let Some(proof_account) = self.proof_account {
77            accounts.push(solana_instruction::AccountMeta::new_readonly(
78                proof_account,
79                false,
80            ));
81        } else {
82            accounts.push(solana_instruction::AccountMeta::new_readonly(
83                crate::SECURITY_TOKEN_PROGRAM_ID,
84                false,
85            ));
86        }
87        accounts.extend_from_slice(remaining_accounts);
88        let mut data = borsh::to_vec(&CloseClaimReceiptAccountInstructionData::new()).unwrap();
89        let mut args = borsh::to_vec(&args).unwrap();
90        data.append(&mut args);
91
92        solana_instruction::Instruction {
93            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
94            accounts,
95            data,
96        }
97    }
98}
99
100#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
101#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
102pub struct CloseClaimReceiptAccountInstructionData {
103    discriminator: u8,
104}
105
106impl CloseClaimReceiptAccountInstructionData {
107    pub fn new() -> Self {
108        Self { discriminator: 23 }
109    }
110}
111
112impl Default for CloseClaimReceiptAccountInstructionData {
113    fn default() -> Self {
114        Self::new()
115    }
116}
117
118#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
119#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
120pub struct CloseClaimReceiptAccountInstructionArgs {
121    pub close_claim_receipt_args: CloseClaimReceiptArgs,
122}
123
124/// Instruction builder for `CloseClaimReceiptAccount`.
125///
126/// ### Accounts:
127///
128///   0. `[]` mint
129///   1. `[]` verification_config_or_mint_authority
130///   2. `[]` instructions_sysvar_or_creator
131///   3. `[writable]` receipt_account
132///   4. `[writable]` destination
133///   5. `[]` mint_account
134///   6. `[]` eligible_token_account
135///   7. `[optional]` proof_account
136#[derive(Clone, Debug, Default)]
137pub struct CloseClaimReceiptAccountBuilder {
138    mint: Option<solana_pubkey::Pubkey>,
139    verification_config_or_mint_authority: Option<solana_pubkey::Pubkey>,
140    instructions_sysvar_or_creator: Option<solana_pubkey::Pubkey>,
141    receipt_account: Option<solana_pubkey::Pubkey>,
142    destination: Option<solana_pubkey::Pubkey>,
143    mint_account: Option<solana_pubkey::Pubkey>,
144    eligible_token_account: Option<solana_pubkey::Pubkey>,
145    proof_account: Option<solana_pubkey::Pubkey>,
146    close_claim_receipt_args: Option<CloseClaimReceiptArgs>,
147    __remaining_accounts: Vec<solana_instruction::AccountMeta>,
148}
149
150impl CloseClaimReceiptAccountBuilder {
151    pub fn new() -> Self {
152        Self::default()
153    }
154    #[inline(always)]
155    pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
156        self.mint = Some(mint);
157        self
158    }
159    #[inline(always)]
160    pub fn verification_config_or_mint_authority(
161        &mut self,
162        verification_config_or_mint_authority: solana_pubkey::Pubkey,
163    ) -> &mut Self {
164        self.verification_config_or_mint_authority = Some(verification_config_or_mint_authority);
165        self
166    }
167    #[inline(always)]
168    pub fn instructions_sysvar_or_creator(
169        &mut self,
170        instructions_sysvar_or_creator: solana_pubkey::Pubkey,
171    ) -> &mut Self {
172        self.instructions_sysvar_or_creator = Some(instructions_sysvar_or_creator);
173        self
174    }
175    #[inline(always)]
176    pub fn receipt_account(&mut self, receipt_account: solana_pubkey::Pubkey) -> &mut Self {
177        self.receipt_account = Some(receipt_account);
178        self
179    }
180    #[inline(always)]
181    pub fn destination(&mut self, destination: solana_pubkey::Pubkey) -> &mut Self {
182        self.destination = Some(destination);
183        self
184    }
185    #[inline(always)]
186    pub fn mint_account(&mut self, mint_account: solana_pubkey::Pubkey) -> &mut Self {
187        self.mint_account = Some(mint_account);
188        self
189    }
190    #[inline(always)]
191    pub fn eligible_token_account(
192        &mut self,
193        eligible_token_account: solana_pubkey::Pubkey,
194    ) -> &mut Self {
195        self.eligible_token_account = Some(eligible_token_account);
196        self
197    }
198    /// `[optional account]`
199    #[inline(always)]
200    pub fn proof_account(&mut self, proof_account: Option<solana_pubkey::Pubkey>) -> &mut Self {
201        self.proof_account = proof_account;
202        self
203    }
204    #[inline(always)]
205    pub fn close_claim_receipt_args(
206        &mut self,
207        close_claim_receipt_args: CloseClaimReceiptArgs,
208    ) -> &mut Self {
209        self.close_claim_receipt_args = Some(close_claim_receipt_args);
210        self
211    }
212    /// Add an additional account to the instruction.
213    #[inline(always)]
214    pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
215        self.__remaining_accounts.push(account);
216        self
217    }
218    /// Add additional accounts to the instruction.
219    #[inline(always)]
220    pub fn add_remaining_accounts(
221        &mut self,
222        accounts: &[solana_instruction::AccountMeta],
223    ) -> &mut Self {
224        self.__remaining_accounts.extend_from_slice(accounts);
225        self
226    }
227    #[allow(clippy::clone_on_copy)]
228    pub fn instruction(&self) -> solana_instruction::Instruction {
229        let accounts = CloseClaimReceiptAccount {
230            mint: self.mint.expect("mint is not set"),
231            verification_config_or_mint_authority: self
232                .verification_config_or_mint_authority
233                .expect("verification_config_or_mint_authority is not set"),
234            instructions_sysvar_or_creator: self
235                .instructions_sysvar_or_creator
236                .expect("instructions_sysvar_or_creator is not set"),
237            receipt_account: self.receipt_account.expect("receipt_account is not set"),
238            destination: self.destination.expect("destination is not set"),
239            mint_account: self.mint_account.expect("mint_account is not set"),
240            eligible_token_account: self
241                .eligible_token_account
242                .expect("eligible_token_account is not set"),
243            proof_account: self.proof_account,
244        };
245        let args = CloseClaimReceiptAccountInstructionArgs {
246            close_claim_receipt_args: self
247                .close_claim_receipt_args
248                .clone()
249                .expect("close_claim_receipt_args is not set"),
250        };
251
252        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
253    }
254}
255
256/// `close_claim_receipt_account` CPI accounts.
257pub struct CloseClaimReceiptAccountCpiAccounts<'a, 'b> {
258    pub mint: &'b solana_account_info::AccountInfo<'a>,
259
260    pub verification_config_or_mint_authority: &'b solana_account_info::AccountInfo<'a>,
261
262    pub instructions_sysvar_or_creator: &'b solana_account_info::AccountInfo<'a>,
263
264    pub receipt_account: &'b solana_account_info::AccountInfo<'a>,
265
266    pub destination: &'b solana_account_info::AccountInfo<'a>,
267
268    pub mint_account: &'b solana_account_info::AccountInfo<'a>,
269
270    pub eligible_token_account: &'b solana_account_info::AccountInfo<'a>,
271
272    pub proof_account: Option<&'b solana_account_info::AccountInfo<'a>>,
273}
274
275/// `close_claim_receipt_account` CPI instruction.
276pub struct CloseClaimReceiptAccountCpi<'a, 'b> {
277    /// The program to invoke.
278    pub __program: &'b solana_account_info::AccountInfo<'a>,
279
280    pub mint: &'b solana_account_info::AccountInfo<'a>,
281
282    pub verification_config_or_mint_authority: &'b solana_account_info::AccountInfo<'a>,
283
284    pub instructions_sysvar_or_creator: &'b solana_account_info::AccountInfo<'a>,
285
286    pub receipt_account: &'b solana_account_info::AccountInfo<'a>,
287
288    pub destination: &'b solana_account_info::AccountInfo<'a>,
289
290    pub mint_account: &'b solana_account_info::AccountInfo<'a>,
291
292    pub eligible_token_account: &'b solana_account_info::AccountInfo<'a>,
293
294    pub proof_account: Option<&'b solana_account_info::AccountInfo<'a>>,
295    /// The arguments for the instruction.
296    pub __args: CloseClaimReceiptAccountInstructionArgs,
297}
298
299impl<'a, 'b> CloseClaimReceiptAccountCpi<'a, 'b> {
300    pub fn new(
301        program: &'b solana_account_info::AccountInfo<'a>,
302        accounts: CloseClaimReceiptAccountCpiAccounts<'a, 'b>,
303        args: CloseClaimReceiptAccountInstructionArgs,
304    ) -> Self {
305        Self {
306            __program: program,
307            mint: accounts.mint,
308            verification_config_or_mint_authority: accounts.verification_config_or_mint_authority,
309            instructions_sysvar_or_creator: accounts.instructions_sysvar_or_creator,
310            receipt_account: accounts.receipt_account,
311            destination: accounts.destination,
312            mint_account: accounts.mint_account,
313            eligible_token_account: accounts.eligible_token_account,
314            proof_account: accounts.proof_account,
315            __args: args,
316        }
317    }
318    #[inline(always)]
319    pub fn invoke(&self) -> solana_program_error::ProgramResult {
320        self.invoke_signed_with_remaining_accounts(&[], &[])
321    }
322    #[inline(always)]
323    pub fn invoke_with_remaining_accounts(
324        &self,
325        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
326    ) -> solana_program_error::ProgramResult {
327        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
328    }
329    #[inline(always)]
330    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
331        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
332    }
333    #[allow(clippy::arithmetic_side_effects)]
334    #[allow(clippy::clone_on_copy)]
335    #[allow(clippy::vec_init_then_push)]
336    pub fn invoke_signed_with_remaining_accounts(
337        &self,
338        signers_seeds: &[&[&[u8]]],
339        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
340    ) -> solana_program_error::ProgramResult {
341        let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
342        accounts.push(solana_instruction::AccountMeta::new_readonly(
343            *self.mint.key,
344            false,
345        ));
346        accounts.push(solana_instruction::AccountMeta::new_readonly(
347            *self.verification_config_or_mint_authority.key,
348            false,
349        ));
350        accounts.push(solana_instruction::AccountMeta::new_readonly(
351            *self.instructions_sysvar_or_creator.key,
352            false,
353        ));
354        accounts.push(solana_instruction::AccountMeta::new(
355            *self.receipt_account.key,
356            false,
357        ));
358        accounts.push(solana_instruction::AccountMeta::new(
359            *self.destination.key,
360            false,
361        ));
362        accounts.push(solana_instruction::AccountMeta::new_readonly(
363            *self.mint_account.key,
364            false,
365        ));
366        accounts.push(solana_instruction::AccountMeta::new_readonly(
367            *self.eligible_token_account.key,
368            false,
369        ));
370        if let Some(proof_account) = self.proof_account {
371            accounts.push(solana_instruction::AccountMeta::new_readonly(
372                *proof_account.key,
373                false,
374            ));
375        } else {
376            accounts.push(solana_instruction::AccountMeta::new_readonly(
377                crate::SECURITY_TOKEN_PROGRAM_ID,
378                false,
379            ));
380        }
381        remaining_accounts.iter().for_each(|remaining_account| {
382            accounts.push(solana_instruction::AccountMeta {
383                pubkey: *remaining_account.0.key,
384                is_signer: remaining_account.1,
385                is_writable: remaining_account.2,
386            })
387        });
388        let mut data = borsh::to_vec(&CloseClaimReceiptAccountInstructionData::new()).unwrap();
389        let mut args = borsh::to_vec(&self.__args).unwrap();
390        data.append(&mut args);
391
392        let instruction = solana_instruction::Instruction {
393            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
394            accounts,
395            data,
396        };
397        let mut account_infos = Vec::with_capacity(9 + remaining_accounts.len());
398        account_infos.push(self.__program.clone());
399        account_infos.push(self.mint.clone());
400        account_infos.push(self.verification_config_or_mint_authority.clone());
401        account_infos.push(self.instructions_sysvar_or_creator.clone());
402        account_infos.push(self.receipt_account.clone());
403        account_infos.push(self.destination.clone());
404        account_infos.push(self.mint_account.clone());
405        account_infos.push(self.eligible_token_account.clone());
406        if let Some(proof_account) = self.proof_account {
407            account_infos.push(proof_account.clone());
408        }
409        remaining_accounts
410            .iter()
411            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
412
413        if signers_seeds.is_empty() {
414            solana_cpi::invoke(&instruction, &account_infos)
415        } else {
416            solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
417        }
418    }
419}
420
421/// Instruction builder for `CloseClaimReceiptAccount` via CPI.
422///
423/// ### Accounts:
424///
425///   0. `[]` mint
426///   1. `[]` verification_config_or_mint_authority
427///   2. `[]` instructions_sysvar_or_creator
428///   3. `[writable]` receipt_account
429///   4. `[writable]` destination
430///   5. `[]` mint_account
431///   6. `[]` eligible_token_account
432///   7. `[optional]` proof_account
433#[derive(Clone, Debug)]
434pub struct CloseClaimReceiptAccountCpiBuilder<'a, 'b> {
435    instruction: Box<CloseClaimReceiptAccountCpiBuilderInstruction<'a, 'b>>,
436}
437
438impl<'a, 'b> CloseClaimReceiptAccountCpiBuilder<'a, 'b> {
439    pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
440        let instruction = Box::new(CloseClaimReceiptAccountCpiBuilderInstruction {
441            __program: program,
442            mint: None,
443            verification_config_or_mint_authority: None,
444            instructions_sysvar_or_creator: None,
445            receipt_account: None,
446            destination: None,
447            mint_account: None,
448            eligible_token_account: None,
449            proof_account: None,
450            close_claim_receipt_args: None,
451            __remaining_accounts: Vec::new(),
452        });
453        Self { instruction }
454    }
455    #[inline(always)]
456    pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
457        self.instruction.mint = Some(mint);
458        self
459    }
460    #[inline(always)]
461    pub fn verification_config_or_mint_authority(
462        &mut self,
463        verification_config_or_mint_authority: &'b solana_account_info::AccountInfo<'a>,
464    ) -> &mut Self {
465        self.instruction.verification_config_or_mint_authority =
466            Some(verification_config_or_mint_authority);
467        self
468    }
469    #[inline(always)]
470    pub fn instructions_sysvar_or_creator(
471        &mut self,
472        instructions_sysvar_or_creator: &'b solana_account_info::AccountInfo<'a>,
473    ) -> &mut Self {
474        self.instruction.instructions_sysvar_or_creator = Some(instructions_sysvar_or_creator);
475        self
476    }
477    #[inline(always)]
478    pub fn receipt_account(
479        &mut self,
480        receipt_account: &'b solana_account_info::AccountInfo<'a>,
481    ) -> &mut Self {
482        self.instruction.receipt_account = Some(receipt_account);
483        self
484    }
485    #[inline(always)]
486    pub fn destination(
487        &mut self,
488        destination: &'b solana_account_info::AccountInfo<'a>,
489    ) -> &mut Self {
490        self.instruction.destination = Some(destination);
491        self
492    }
493    #[inline(always)]
494    pub fn mint_account(
495        &mut self,
496        mint_account: &'b solana_account_info::AccountInfo<'a>,
497    ) -> &mut Self {
498        self.instruction.mint_account = Some(mint_account);
499        self
500    }
501    #[inline(always)]
502    pub fn eligible_token_account(
503        &mut self,
504        eligible_token_account: &'b solana_account_info::AccountInfo<'a>,
505    ) -> &mut Self {
506        self.instruction.eligible_token_account = Some(eligible_token_account);
507        self
508    }
509    /// `[optional account]`
510    #[inline(always)]
511    pub fn proof_account(
512        &mut self,
513        proof_account: Option<&'b solana_account_info::AccountInfo<'a>>,
514    ) -> &mut Self {
515        self.instruction.proof_account = proof_account;
516        self
517    }
518    #[inline(always)]
519    pub fn close_claim_receipt_args(
520        &mut self,
521        close_claim_receipt_args: CloseClaimReceiptArgs,
522    ) -> &mut Self {
523        self.instruction.close_claim_receipt_args = Some(close_claim_receipt_args);
524        self
525    }
526    /// Add an additional account to the instruction.
527    #[inline(always)]
528    pub fn add_remaining_account(
529        &mut self,
530        account: &'b solana_account_info::AccountInfo<'a>,
531        is_writable: bool,
532        is_signer: bool,
533    ) -> &mut Self {
534        self.instruction
535            .__remaining_accounts
536            .push((account, is_writable, is_signer));
537        self
538    }
539    /// Add additional accounts to the instruction.
540    ///
541    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
542    /// and a `bool` indicating whether the account is a signer or not.
543    #[inline(always)]
544    pub fn add_remaining_accounts(
545        &mut self,
546        accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
547    ) -> &mut Self {
548        self.instruction
549            .__remaining_accounts
550            .extend_from_slice(accounts);
551        self
552    }
553    #[inline(always)]
554    pub fn invoke(&self) -> solana_program_error::ProgramResult {
555        self.invoke_signed(&[])
556    }
557    #[allow(clippy::clone_on_copy)]
558    #[allow(clippy::vec_init_then_push)]
559    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
560        let args = CloseClaimReceiptAccountInstructionArgs {
561            close_claim_receipt_args: self
562                .instruction
563                .close_claim_receipt_args
564                .clone()
565                .expect("close_claim_receipt_args is not set"),
566        };
567        let instruction = CloseClaimReceiptAccountCpi {
568            __program: self.instruction.__program,
569
570            mint: self.instruction.mint.expect("mint is not set"),
571
572            verification_config_or_mint_authority: self
573                .instruction
574                .verification_config_or_mint_authority
575                .expect("verification_config_or_mint_authority is not set"),
576
577            instructions_sysvar_or_creator: self
578                .instruction
579                .instructions_sysvar_or_creator
580                .expect("instructions_sysvar_or_creator is not set"),
581
582            receipt_account: self
583                .instruction
584                .receipt_account
585                .expect("receipt_account is not set"),
586
587            destination: self
588                .instruction
589                .destination
590                .expect("destination is not set"),
591
592            mint_account: self
593                .instruction
594                .mint_account
595                .expect("mint_account is not set"),
596
597            eligible_token_account: self
598                .instruction
599                .eligible_token_account
600                .expect("eligible_token_account is not set"),
601
602            proof_account: self.instruction.proof_account,
603            __args: args,
604        };
605        instruction.invoke_signed_with_remaining_accounts(
606            signers_seeds,
607            &self.instruction.__remaining_accounts,
608        )
609    }
610}
611
612#[derive(Clone, Debug)]
613struct CloseClaimReceiptAccountCpiBuilderInstruction<'a, 'b> {
614    __program: &'b solana_account_info::AccountInfo<'a>,
615    mint: Option<&'b solana_account_info::AccountInfo<'a>>,
616    verification_config_or_mint_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
617    instructions_sysvar_or_creator: Option<&'b solana_account_info::AccountInfo<'a>>,
618    receipt_account: Option<&'b solana_account_info::AccountInfo<'a>>,
619    destination: Option<&'b solana_account_info::AccountInfo<'a>>,
620    mint_account: Option<&'b solana_account_info::AccountInfo<'a>>,
621    eligible_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
622    proof_account: Option<&'b solana_account_info::AccountInfo<'a>>,
623    close_claim_receipt_args: Option<CloseClaimReceiptArgs>,
624    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
625    __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
626}