token_acl_client/generated/instructions/
freeze.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub const FREEZE_DISCRIMINATOR: u8 = 5;
12
13#[derive(Debug)]
15pub struct Freeze {
16 pub authority: solana_pubkey::Pubkey,
17
18 pub mint: solana_pubkey::Pubkey,
19
20 pub token_account: solana_pubkey::Pubkey,
21
22 pub mint_config: solana_pubkey::Pubkey,
23
24 pub token_program: solana_pubkey::Pubkey,
25}
26
27impl Freeze {
28 pub fn instruction(&self) -> solana_instruction::Instruction {
29 self.instruction_with_remaining_accounts(&[])
30 }
31 #[allow(clippy::arithmetic_side_effects)]
32 #[allow(clippy::vec_init_then_push)]
33 pub fn instruction_with_remaining_accounts(
34 &self,
35 remaining_accounts: &[solana_instruction::AccountMeta],
36 ) -> solana_instruction::Instruction {
37 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
38 accounts.push(solana_instruction::AccountMeta::new_readonly(
39 self.authority,
40 true,
41 ));
42 accounts.push(solana_instruction::AccountMeta::new_readonly(
43 self.mint, false,
44 ));
45 accounts.push(solana_instruction::AccountMeta::new(
46 self.token_account,
47 false,
48 ));
49 accounts.push(solana_instruction::AccountMeta::new_readonly(
50 self.mint_config,
51 false,
52 ));
53 accounts.push(solana_instruction::AccountMeta::new_readonly(
54 self.token_program,
55 false,
56 ));
57 accounts.extend_from_slice(remaining_accounts);
58 let data = FreezeInstructionData::new().try_to_vec().unwrap();
59
60 solana_instruction::Instruction {
61 program_id: crate::TOKEN_ACL_ID,
62 accounts,
63 data,
64 }
65 }
66}
67
68#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
69#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
70pub struct FreezeInstructionData {
71 discriminator: u8,
72}
73
74impl FreezeInstructionData {
75 pub fn new() -> Self {
76 Self { discriminator: 5 }
77 }
78
79 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
80 borsh::to_vec(self)
81 }
82}
83
84impl Default for FreezeInstructionData {
85 fn default() -> Self {
86 Self::new()
87 }
88}
89
90#[derive(Clone, Debug, Default)]
100pub struct FreezeBuilder {
101 authority: Option<solana_pubkey::Pubkey>,
102 mint: Option<solana_pubkey::Pubkey>,
103 token_account: Option<solana_pubkey::Pubkey>,
104 mint_config: Option<solana_pubkey::Pubkey>,
105 token_program: Option<solana_pubkey::Pubkey>,
106 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
107}
108
109impl FreezeBuilder {
110 pub fn new() -> Self {
111 Self::default()
112 }
113 #[inline(always)]
114 pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
115 self.authority = Some(authority);
116 self
117 }
118 #[inline(always)]
119 pub fn mint(&mut self, mint: solana_pubkey::Pubkey) -> &mut Self {
120 self.mint = Some(mint);
121 self
122 }
123 #[inline(always)]
124 pub fn token_account(&mut self, token_account: solana_pubkey::Pubkey) -> &mut Self {
125 self.token_account = Some(token_account);
126 self
127 }
128 #[inline(always)]
129 pub fn mint_config(&mut self, mint_config: solana_pubkey::Pubkey) -> &mut Self {
130 self.mint_config = Some(mint_config);
131 self
132 }
133 #[inline(always)]
135 pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
136 self.token_program = Some(token_program);
137 self
138 }
139 #[inline(always)]
141 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
142 self.__remaining_accounts.push(account);
143 self
144 }
145 #[inline(always)]
147 pub fn add_remaining_accounts(
148 &mut self,
149 accounts: &[solana_instruction::AccountMeta],
150 ) -> &mut Self {
151 self.__remaining_accounts.extend_from_slice(accounts);
152 self
153 }
154 #[allow(clippy::clone_on_copy)]
155 pub fn instruction(&self) -> solana_instruction::Instruction {
156 let accounts = Freeze {
157 authority: self.authority.expect("authority is not set"),
158 mint: self.mint.expect("mint is not set"),
159 token_account: self.token_account.expect("token_account is not set"),
160 mint_config: self.mint_config.expect("mint_config is not set"),
161 token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
162 "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
163 )),
164 };
165
166 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
167 }
168}
169
170pub struct FreezeCpiAccounts<'a, 'b> {
172 pub authority: &'b solana_account_info::AccountInfo<'a>,
173
174 pub mint: &'b solana_account_info::AccountInfo<'a>,
175
176 pub token_account: &'b solana_account_info::AccountInfo<'a>,
177
178 pub mint_config: &'b solana_account_info::AccountInfo<'a>,
179
180 pub token_program: &'b solana_account_info::AccountInfo<'a>,
181}
182
183pub struct FreezeCpi<'a, 'b> {
185 pub __program: &'b solana_account_info::AccountInfo<'a>,
187
188 pub authority: &'b solana_account_info::AccountInfo<'a>,
189
190 pub mint: &'b solana_account_info::AccountInfo<'a>,
191
192 pub token_account: &'b solana_account_info::AccountInfo<'a>,
193
194 pub mint_config: &'b solana_account_info::AccountInfo<'a>,
195
196 pub token_program: &'b solana_account_info::AccountInfo<'a>,
197}
198
199impl<'a, 'b> FreezeCpi<'a, 'b> {
200 pub fn new(
201 program: &'b solana_account_info::AccountInfo<'a>,
202 accounts: FreezeCpiAccounts<'a, 'b>,
203 ) -> Self {
204 Self {
205 __program: program,
206 authority: accounts.authority,
207 mint: accounts.mint,
208 token_account: accounts.token_account,
209 mint_config: accounts.mint_config,
210 token_program: accounts.token_program,
211 }
212 }
213 #[inline(always)]
214 pub fn invoke(&self) -> solana_program_error::ProgramResult {
215 self.invoke_signed_with_remaining_accounts(&[], &[])
216 }
217 #[inline(always)]
218 pub fn invoke_with_remaining_accounts(
219 &self,
220 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
221 ) -> solana_program_error::ProgramResult {
222 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
223 }
224 #[inline(always)]
225 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
226 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
227 }
228 #[allow(clippy::arithmetic_side_effects)]
229 #[allow(clippy::clone_on_copy)]
230 #[allow(clippy::vec_init_then_push)]
231 pub fn invoke_signed_with_remaining_accounts(
232 &self,
233 signers_seeds: &[&[&[u8]]],
234 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
235 ) -> solana_program_error::ProgramResult {
236 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
237 accounts.push(solana_instruction::AccountMeta::new_readonly(
238 *self.authority.key,
239 true,
240 ));
241 accounts.push(solana_instruction::AccountMeta::new_readonly(
242 *self.mint.key,
243 false,
244 ));
245 accounts.push(solana_instruction::AccountMeta::new(
246 *self.token_account.key,
247 false,
248 ));
249 accounts.push(solana_instruction::AccountMeta::new_readonly(
250 *self.mint_config.key,
251 false,
252 ));
253 accounts.push(solana_instruction::AccountMeta::new_readonly(
254 *self.token_program.key,
255 false,
256 ));
257 remaining_accounts.iter().for_each(|remaining_account| {
258 accounts.push(solana_instruction::AccountMeta {
259 pubkey: *remaining_account.0.key,
260 is_signer: remaining_account.1,
261 is_writable: remaining_account.2,
262 })
263 });
264 let data = FreezeInstructionData::new().try_to_vec().unwrap();
265
266 let instruction = solana_instruction::Instruction {
267 program_id: crate::TOKEN_ACL_ID,
268 accounts,
269 data,
270 };
271 let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len());
272 account_infos.push(self.__program.clone());
273 account_infos.push(self.authority.clone());
274 account_infos.push(self.mint.clone());
275 account_infos.push(self.token_account.clone());
276 account_infos.push(self.mint_config.clone());
277 account_infos.push(self.token_program.clone());
278 remaining_accounts
279 .iter()
280 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
281
282 if signers_seeds.is_empty() {
283 solana_cpi::invoke(&instruction, &account_infos)
284 } else {
285 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
286 }
287 }
288}
289
290#[derive(Clone, Debug)]
300pub struct FreezeCpiBuilder<'a, 'b> {
301 instruction: Box<FreezeCpiBuilderInstruction<'a, 'b>>,
302}
303
304impl<'a, 'b> FreezeCpiBuilder<'a, 'b> {
305 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
306 let instruction = Box::new(FreezeCpiBuilderInstruction {
307 __program: program,
308 authority: None,
309 mint: None,
310 token_account: None,
311 mint_config: None,
312 token_program: None,
313 __remaining_accounts: Vec::new(),
314 });
315 Self { instruction }
316 }
317 #[inline(always)]
318 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
319 self.instruction.authority = Some(authority);
320 self
321 }
322 #[inline(always)]
323 pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
324 self.instruction.mint = Some(mint);
325 self
326 }
327 #[inline(always)]
328 pub fn token_account(
329 &mut self,
330 token_account: &'b solana_account_info::AccountInfo<'a>,
331 ) -> &mut Self {
332 self.instruction.token_account = Some(token_account);
333 self
334 }
335 #[inline(always)]
336 pub fn mint_config(
337 &mut self,
338 mint_config: &'b solana_account_info::AccountInfo<'a>,
339 ) -> &mut Self {
340 self.instruction.mint_config = Some(mint_config);
341 self
342 }
343 #[inline(always)]
344 pub fn token_program(
345 &mut self,
346 token_program: &'b solana_account_info::AccountInfo<'a>,
347 ) -> &mut Self {
348 self.instruction.token_program = Some(token_program);
349 self
350 }
351 #[inline(always)]
353 pub fn add_remaining_account(
354 &mut self,
355 account: &'b solana_account_info::AccountInfo<'a>,
356 is_writable: bool,
357 is_signer: bool,
358 ) -> &mut Self {
359 self.instruction
360 .__remaining_accounts
361 .push((account, is_writable, is_signer));
362 self
363 }
364 #[inline(always)]
369 pub fn add_remaining_accounts(
370 &mut self,
371 accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
372 ) -> &mut Self {
373 self.instruction
374 .__remaining_accounts
375 .extend_from_slice(accounts);
376 self
377 }
378 #[inline(always)]
379 pub fn invoke(&self) -> solana_program_error::ProgramResult {
380 self.invoke_signed(&[])
381 }
382 #[allow(clippy::clone_on_copy)]
383 #[allow(clippy::vec_init_then_push)]
384 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
385 let instruction = FreezeCpi {
386 __program: self.instruction.__program,
387
388 authority: self.instruction.authority.expect("authority is not set"),
389
390 mint: self.instruction.mint.expect("mint is not set"),
391
392 token_account: self
393 .instruction
394 .token_account
395 .expect("token_account is not set"),
396
397 mint_config: self
398 .instruction
399 .mint_config
400 .expect("mint_config is not set"),
401
402 token_program: self
403 .instruction
404 .token_program
405 .expect("token_program is not set"),
406 };
407 instruction.invoke_signed_with_remaining_accounts(
408 signers_seeds,
409 &self.instruction.__remaining_accounts,
410 )
411 }
412}
413
414#[derive(Clone, Debug)]
415struct FreezeCpiBuilderInstruction<'a, 'b> {
416 __program: &'b solana_account_info::AccountInfo<'a>,
417 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
418 mint: Option<&'b solana_account_info::AccountInfo<'a>>,
419 token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
420 mint_config: Option<&'b solana_account_info::AccountInfo<'a>>,
421 token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
422 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
424}