Skip to main content

security_token_client/generated/instructions/
resume.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 borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub const RESUME_DISCRIMINATOR: u8 = 9;
12
13/// Accounts.
14#[derive(Debug)]
15pub struct Resume {
16    pub mint: solana_pubkey::Pubkey,
17
18    pub verification_config: solana_pubkey::Pubkey,
19
20    pub instructions_sysvar: solana_pubkey::Pubkey,
21
22    pub pause_authority: solana_pubkey::Pubkey,
23
24    pub mint_account: solana_pubkey::Pubkey,
25
26    pub token_program: solana_pubkey::Pubkey,
27}
28
29impl Resume {
30    pub fn instruction(&self) -> solana_instruction::Instruction {
31        self.instruction_with_remaining_accounts(&[])
32    }
33    #[allow(clippy::arithmetic_side_effects)]
34    #[allow(clippy::vec_init_then_push)]
35    pub fn instruction_with_remaining_accounts(
36        &self,
37        remaining_accounts: &[solana_instruction::AccountMeta],
38    ) -> solana_instruction::Instruction {
39        let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
40        accounts.push(solana_instruction::AccountMeta::new_readonly(
41            self.mint, false,
42        ));
43        accounts.push(solana_instruction::AccountMeta::new_readonly(
44            self.verification_config,
45            false,
46        ));
47        accounts.push(solana_instruction::AccountMeta::new_readonly(
48            self.instructions_sysvar,
49            false,
50        ));
51        accounts.push(solana_instruction::AccountMeta::new_readonly(
52            self.pause_authority,
53            false,
54        ));
55        accounts.push(solana_instruction::AccountMeta::new(
56            self.mint_account,
57            false,
58        ));
59        accounts.push(solana_instruction::AccountMeta::new_readonly(
60            self.token_program,
61            false,
62        ));
63        accounts.extend_from_slice(remaining_accounts);
64        let data = borsh::to_vec(&ResumeInstructionData::new()).unwrap();
65
66        solana_instruction::Instruction {
67            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
68            accounts,
69            data,
70        }
71    }
72}
73
74#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76pub struct ResumeInstructionData {
77    discriminator: u8,
78}
79
80impl ResumeInstructionData {
81    pub fn new() -> Self {
82        Self { discriminator: 9 }
83    }
84}
85
86impl Default for ResumeInstructionData {
87    fn default() -> Self {
88        Self::new()
89    }
90}
91
92/// Instruction builder for `Resume`.
93///
94/// ### Accounts:
95///
96///   0. `[]` mint
97///   1. `[]` verification_config
98///   2. `[optional]` instructions_sysvar (default to `Sysvar1nstructions1111111111111111111111111`)
99///   3. `[]` pause_authority
100///   4. `[writable]` mint_account
101///   5. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`)
102#[derive(Clone, Debug, Default)]
103pub struct ResumeBuilder {
104    mint: Option<solana_pubkey::Pubkey>,
105    verification_config: Option<solana_pubkey::Pubkey>,
106    instructions_sysvar: Option<solana_pubkey::Pubkey>,
107    pause_authority: Option<solana_pubkey::Pubkey>,
108    mint_account: Option<solana_pubkey::Pubkey>,
109    token_program: Option<solana_pubkey::Pubkey>,
110    __remaining_accounts: Vec<solana_instruction::AccountMeta>,
111}
112
113impl ResumeBuilder {
114    pub fn new() -> Self {
115        Self::default()
116    }
117    #[inline(always)]
118    pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
119        self.mint = Some(mint);
120        self
121    }
122    #[inline(always)]
123    pub fn verification_config(&mut self, verification_config: solana_pubkey::Pubkey) -> &mut Self {
124        self.verification_config = Some(verification_config);
125        self
126    }
127    /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']`
128    #[inline(always)]
129    pub fn instructions_sysvar(&mut self, instructions_sysvar: solana_pubkey::Pubkey) -> &mut Self {
130        self.instructions_sysvar = Some(instructions_sysvar);
131        self
132    }
133    #[inline(always)]
134    pub fn pause_authority(&mut self, pause_authority: solana_pubkey::Pubkey) -> &mut Self {
135        self.pause_authority = Some(pause_authority);
136        self
137    }
138    #[inline(always)]
139    pub fn mint_account(&mut self, mint_account: solana_pubkey::Pubkey) -> &mut Self {
140        self.mint_account = Some(mint_account);
141        self
142    }
143    /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']`
144    #[inline(always)]
145    pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
146        self.token_program = Some(token_program);
147        self
148    }
149    /// Add an additional account to the instruction.
150    #[inline(always)]
151    pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
152        self.__remaining_accounts.push(account);
153        self
154    }
155    /// Add additional accounts to the instruction.
156    #[inline(always)]
157    pub fn add_remaining_accounts(
158        &mut self,
159        accounts: &[solana_instruction::AccountMeta],
160    ) -> &mut Self {
161        self.__remaining_accounts.extend_from_slice(accounts);
162        self
163    }
164    #[allow(clippy::clone_on_copy)]
165    pub fn instruction(&self) -> solana_instruction::Instruction {
166        let accounts = Resume {
167            mint: self.mint.expect("mint is not set"),
168            verification_config: self
169                .verification_config
170                .expect("verification_config is not set"),
171            instructions_sysvar: self.instructions_sysvar.unwrap_or(solana_pubkey::pubkey!(
172                "Sysvar1nstructions1111111111111111111111111"
173            )),
174            pause_authority: self.pause_authority.expect("pause_authority is not set"),
175            mint_account: self.mint_account.expect("mint_account is not set"),
176            token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
177                "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
178            )),
179        };
180
181        accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
182    }
183}
184
185/// `resume` CPI accounts.
186pub struct ResumeCpiAccounts<'a, 'b> {
187    pub mint: &'b solana_account_info::AccountInfo<'a>,
188
189    pub verification_config: &'b solana_account_info::AccountInfo<'a>,
190
191    pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
192
193    pub pause_authority: &'b solana_account_info::AccountInfo<'a>,
194
195    pub mint_account: &'b solana_account_info::AccountInfo<'a>,
196
197    pub token_program: &'b solana_account_info::AccountInfo<'a>,
198}
199
200/// `resume` CPI instruction.
201pub struct ResumeCpi<'a, 'b> {
202    /// The program to invoke.
203    pub __program: &'b solana_account_info::AccountInfo<'a>,
204
205    pub mint: &'b solana_account_info::AccountInfo<'a>,
206
207    pub verification_config: &'b solana_account_info::AccountInfo<'a>,
208
209    pub instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
210
211    pub pause_authority: &'b solana_account_info::AccountInfo<'a>,
212
213    pub mint_account: &'b solana_account_info::AccountInfo<'a>,
214
215    pub token_program: &'b solana_account_info::AccountInfo<'a>,
216}
217
218impl<'a, 'b> ResumeCpi<'a, 'b> {
219    pub fn new(
220        program: &'b solana_account_info::AccountInfo<'a>,
221        accounts: ResumeCpiAccounts<'a, 'b>,
222    ) -> Self {
223        Self {
224            __program: program,
225            mint: accounts.mint,
226            verification_config: accounts.verification_config,
227            instructions_sysvar: accounts.instructions_sysvar,
228            pause_authority: accounts.pause_authority,
229            mint_account: accounts.mint_account,
230            token_program: accounts.token_program,
231        }
232    }
233    #[inline(always)]
234    pub fn invoke(&self) -> solana_program_error::ProgramResult {
235        self.invoke_signed_with_remaining_accounts(&[], &[])
236    }
237    #[inline(always)]
238    pub fn invoke_with_remaining_accounts(
239        &self,
240        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
241    ) -> solana_program_error::ProgramResult {
242        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
243    }
244    #[inline(always)]
245    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
246        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
247    }
248    #[allow(clippy::arithmetic_side_effects)]
249    #[allow(clippy::clone_on_copy)]
250    #[allow(clippy::vec_init_then_push)]
251    pub fn invoke_signed_with_remaining_accounts(
252        &self,
253        signers_seeds: &[&[&[u8]]],
254        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
255    ) -> solana_program_error::ProgramResult {
256        let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
257        accounts.push(solana_instruction::AccountMeta::new_readonly(
258            *self.mint.key,
259            false,
260        ));
261        accounts.push(solana_instruction::AccountMeta::new_readonly(
262            *self.verification_config.key,
263            false,
264        ));
265        accounts.push(solana_instruction::AccountMeta::new_readonly(
266            *self.instructions_sysvar.key,
267            false,
268        ));
269        accounts.push(solana_instruction::AccountMeta::new_readonly(
270            *self.pause_authority.key,
271            false,
272        ));
273        accounts.push(solana_instruction::AccountMeta::new(
274            *self.mint_account.key,
275            false,
276        ));
277        accounts.push(solana_instruction::AccountMeta::new_readonly(
278            *self.token_program.key,
279            false,
280        ));
281        remaining_accounts.iter().for_each(|remaining_account| {
282            accounts.push(solana_instruction::AccountMeta {
283                pubkey: *remaining_account.0.key,
284                is_signer: remaining_account.1,
285                is_writable: remaining_account.2,
286            })
287        });
288        let data = borsh::to_vec(&ResumeInstructionData::new()).unwrap();
289
290        let instruction = solana_instruction::Instruction {
291            program_id: crate::SECURITY_TOKEN_PROGRAM_ID,
292            accounts,
293            data,
294        };
295        let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len());
296        account_infos.push(self.__program.clone());
297        account_infos.push(self.mint.clone());
298        account_infos.push(self.verification_config.clone());
299        account_infos.push(self.instructions_sysvar.clone());
300        account_infos.push(self.pause_authority.clone());
301        account_infos.push(self.mint_account.clone());
302        account_infos.push(self.token_program.clone());
303        remaining_accounts
304            .iter()
305            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
306
307        if signers_seeds.is_empty() {
308            solana_cpi::invoke(&instruction, &account_infos)
309        } else {
310            solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
311        }
312    }
313}
314
315/// Instruction builder for `Resume` via CPI.
316///
317/// ### Accounts:
318///
319///   0. `[]` mint
320///   1. `[]` verification_config
321///   2. `[]` instructions_sysvar
322///   3. `[]` pause_authority
323///   4. `[writable]` mint_account
324///   5. `[]` token_program
325#[derive(Clone, Debug)]
326pub struct ResumeCpiBuilder<'a, 'b> {
327    instruction: Box<ResumeCpiBuilderInstruction<'a, 'b>>,
328}
329
330impl<'a, 'b> ResumeCpiBuilder<'a, 'b> {
331    pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
332        let instruction = Box::new(ResumeCpiBuilderInstruction {
333            __program: program,
334            mint: None,
335            verification_config: None,
336            instructions_sysvar: None,
337            pause_authority: None,
338            mint_account: None,
339            token_program: None,
340            __remaining_accounts: Vec::new(),
341        });
342        Self { instruction }
343    }
344    #[inline(always)]
345    pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
346        self.instruction.mint = Some(mint);
347        self
348    }
349    #[inline(always)]
350    pub fn verification_config(
351        &mut self,
352        verification_config: &'b solana_account_info::AccountInfo<'a>,
353    ) -> &mut Self {
354        self.instruction.verification_config = Some(verification_config);
355        self
356    }
357    #[inline(always)]
358    pub fn instructions_sysvar(
359        &mut self,
360        instructions_sysvar: &'b solana_account_info::AccountInfo<'a>,
361    ) -> &mut Self {
362        self.instruction.instructions_sysvar = Some(instructions_sysvar);
363        self
364    }
365    #[inline(always)]
366    pub fn pause_authority(
367        &mut self,
368        pause_authority: &'b solana_account_info::AccountInfo<'a>,
369    ) -> &mut Self {
370        self.instruction.pause_authority = Some(pause_authority);
371        self
372    }
373    #[inline(always)]
374    pub fn mint_account(
375        &mut self,
376        mint_account: &'b solana_account_info::AccountInfo<'a>,
377    ) -> &mut Self {
378        self.instruction.mint_account = Some(mint_account);
379        self
380    }
381    #[inline(always)]
382    pub fn token_program(
383        &mut self,
384        token_program: &'b solana_account_info::AccountInfo<'a>,
385    ) -> &mut Self {
386        self.instruction.token_program = Some(token_program);
387        self
388    }
389    /// Add an additional account to the instruction.
390    #[inline(always)]
391    pub fn add_remaining_account(
392        &mut self,
393        account: &'b solana_account_info::AccountInfo<'a>,
394        is_writable: bool,
395        is_signer: bool,
396    ) -> &mut Self {
397        self.instruction
398            .__remaining_accounts
399            .push((account, is_writable, is_signer));
400        self
401    }
402    /// Add additional accounts to the instruction.
403    ///
404    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
405    /// and a `bool` indicating whether the account is a signer or not.
406    #[inline(always)]
407    pub fn add_remaining_accounts(
408        &mut self,
409        accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
410    ) -> &mut Self {
411        self.instruction
412            .__remaining_accounts
413            .extend_from_slice(accounts);
414        self
415    }
416    #[inline(always)]
417    pub fn invoke(&self) -> solana_program_error::ProgramResult {
418        self.invoke_signed(&[])
419    }
420    #[allow(clippy::clone_on_copy)]
421    #[allow(clippy::vec_init_then_push)]
422    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
423        let instruction = ResumeCpi {
424            __program: self.instruction.__program,
425
426            mint: self.instruction.mint.expect("mint is not set"),
427
428            verification_config: self
429                .instruction
430                .verification_config
431                .expect("verification_config is not set"),
432
433            instructions_sysvar: self
434                .instruction
435                .instructions_sysvar
436                .expect("instructions_sysvar is not set"),
437
438            pause_authority: self
439                .instruction
440                .pause_authority
441                .expect("pause_authority is not set"),
442
443            mint_account: self
444                .instruction
445                .mint_account
446                .expect("mint_account is not set"),
447
448            token_program: self
449                .instruction
450                .token_program
451                .expect("token_program is not set"),
452        };
453        instruction.invoke_signed_with_remaining_accounts(
454            signers_seeds,
455            &self.instruction.__remaining_accounts,
456        )
457    }
458}
459
460#[derive(Clone, Debug)]
461struct ResumeCpiBuilderInstruction<'a, 'b> {
462    __program: &'b solana_account_info::AccountInfo<'a>,
463    mint: Option<&'b solana_account_info::AccountInfo<'a>>,
464    verification_config: Option<&'b solana_account_info::AccountInfo<'a>>,
465    instructions_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>,
466    pause_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
467    mint_account: Option<&'b solana_account_info::AccountInfo<'a>>,
468    token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
469    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
470    __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
471}