sigil_client/generated/instructions/
close_mint.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct CloseMint {
13 pub mint: solana_program::pubkey::Pubkey,
15 pub authority: solana_program::pubkey::Pubkey,
17 pub recipient: Option<solana_program::pubkey::Pubkey>,
19}
20
21impl CloseMint {
22 pub fn instruction(&self) -> solana_program::instruction::Instruction {
23 self.instruction_with_remaining_accounts(&[])
24 }
25 #[allow(clippy::vec_init_then_push)]
26 pub fn instruction_with_remaining_accounts(
27 &self,
28 remaining_accounts: &[solana_program::instruction::AccountMeta],
29 ) -> solana_program::instruction::Instruction {
30 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
31 accounts.push(solana_program::instruction::AccountMeta::new(
32 self.mint, false,
33 ));
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.authority,
36 true,
37 ));
38 if let Some(recipient) = self.recipient {
39 accounts.push(solana_program::instruction::AccountMeta::new(
40 recipient, true,
41 ));
42 } else {
43 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
44 crate::SIGIL_ID,
45 false,
46 ));
47 }
48 accounts.extend_from_slice(remaining_accounts);
49 let data = CloseMintInstructionData::new().try_to_vec().unwrap();
50
51 solana_program::instruction::Instruction {
52 program_id: crate::SIGIL_ID,
53 accounts,
54 data,
55 }
56 }
57}
58
59#[derive(BorshDeserialize, BorshSerialize)]
60pub struct CloseMintInstructionData {
61 discriminator: u8,
62}
63
64impl CloseMintInstructionData {
65 pub fn new() -> Self {
66 Self { discriminator: 2 }
67 }
68}
69
70#[derive(Default)]
78pub struct CloseMintBuilder {
79 mint: Option<solana_program::pubkey::Pubkey>,
80 authority: Option<solana_program::pubkey::Pubkey>,
81 recipient: Option<solana_program::pubkey::Pubkey>,
82 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
83}
84
85impl CloseMintBuilder {
86 pub fn new() -> Self {
87 Self::default()
88 }
89 #[inline(always)]
91 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
92 self.mint = Some(mint);
93 self
94 }
95 #[inline(always)]
97 pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
98 self.authority = Some(authority);
99 self
100 }
101 #[inline(always)]
104 pub fn recipient(&mut self, recipient: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
105 self.recipient = recipient;
106 self
107 }
108 #[inline(always)]
110 pub fn add_remaining_account(
111 &mut self,
112 account: solana_program::instruction::AccountMeta,
113 ) -> &mut Self {
114 self.__remaining_accounts.push(account);
115 self
116 }
117 #[inline(always)]
119 pub fn add_remaining_accounts(
120 &mut self,
121 accounts: &[solana_program::instruction::AccountMeta],
122 ) -> &mut Self {
123 self.__remaining_accounts.extend_from_slice(accounts);
124 self
125 }
126 #[allow(clippy::clone_on_copy)]
127 pub fn instruction(&self) -> solana_program::instruction::Instruction {
128 let accounts = CloseMint {
129 mint: self.mint.expect("mint is not set"),
130 authority: self.authority.expect("authority is not set"),
131 recipient: self.recipient,
132 };
133
134 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
135 }
136}
137
138pub struct CloseMintCpiAccounts<'a, 'b> {
140 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
142 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
144 pub recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>,
146}
147
148pub struct CloseMintCpi<'a, 'b> {
150 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
152 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
154 pub authority: &'b solana_program::account_info::AccountInfo<'a>,
156 pub recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>,
158}
159
160impl<'a, 'b> CloseMintCpi<'a, 'b> {
161 pub fn new(
162 program: &'b solana_program::account_info::AccountInfo<'a>,
163 accounts: CloseMintCpiAccounts<'a, 'b>,
164 ) -> Self {
165 Self {
166 __program: program,
167 mint: accounts.mint,
168 authority: accounts.authority,
169 recipient: accounts.recipient,
170 }
171 }
172 #[inline(always)]
173 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
174 self.invoke_signed_with_remaining_accounts(&[], &[])
175 }
176 #[inline(always)]
177 pub fn invoke_with_remaining_accounts(
178 &self,
179 remaining_accounts: &[(
180 &'b solana_program::account_info::AccountInfo<'a>,
181 bool,
182 bool,
183 )],
184 ) -> solana_program::entrypoint::ProgramResult {
185 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
186 }
187 #[inline(always)]
188 pub fn invoke_signed(
189 &self,
190 signers_seeds: &[&[&[u8]]],
191 ) -> solana_program::entrypoint::ProgramResult {
192 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
193 }
194 #[allow(clippy::clone_on_copy)]
195 #[allow(clippy::vec_init_then_push)]
196 pub fn invoke_signed_with_remaining_accounts(
197 &self,
198 signers_seeds: &[&[&[u8]]],
199 remaining_accounts: &[(
200 &'b solana_program::account_info::AccountInfo<'a>,
201 bool,
202 bool,
203 )],
204 ) -> solana_program::entrypoint::ProgramResult {
205 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
206 accounts.push(solana_program::instruction::AccountMeta::new(
207 *self.mint.key,
208 false,
209 ));
210 accounts.push(solana_program::instruction::AccountMeta::new(
211 *self.authority.key,
212 true,
213 ));
214 if let Some(recipient) = self.recipient {
215 accounts.push(solana_program::instruction::AccountMeta::new(
216 *recipient.key,
217 true,
218 ));
219 } else {
220 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
221 crate::SIGIL_ID,
222 false,
223 ));
224 }
225 remaining_accounts.iter().for_each(|remaining_account| {
226 accounts.push(solana_program::instruction::AccountMeta {
227 pubkey: *remaining_account.0.key,
228 is_signer: remaining_account.1,
229 is_writable: remaining_account.2,
230 })
231 });
232 let data = CloseMintInstructionData::new().try_to_vec().unwrap();
233
234 let instruction = solana_program::instruction::Instruction {
235 program_id: crate::SIGIL_ID,
236 accounts,
237 data,
238 };
239 let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len());
240 account_infos.push(self.__program.clone());
241 account_infos.push(self.mint.clone());
242 account_infos.push(self.authority.clone());
243 if let Some(recipient) = self.recipient {
244 account_infos.push(recipient.clone());
245 }
246 remaining_accounts
247 .iter()
248 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
249
250 if signers_seeds.is_empty() {
251 solana_program::program::invoke(&instruction, &account_infos)
252 } else {
253 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
254 }
255 }
256}
257
258pub struct CloseMintCpiBuilder<'a, 'b> {
266 instruction: Box<CloseMintCpiBuilderInstruction<'a, 'b>>,
267}
268
269impl<'a, 'b> CloseMintCpiBuilder<'a, 'b> {
270 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
271 let instruction = Box::new(CloseMintCpiBuilderInstruction {
272 __program: program,
273 mint: None,
274 authority: None,
275 recipient: None,
276 __remaining_accounts: Vec::new(),
277 });
278 Self { instruction }
279 }
280 #[inline(always)]
282 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
283 self.instruction.mint = Some(mint);
284 self
285 }
286 #[inline(always)]
288 pub fn authority(
289 &mut self,
290 authority: &'b solana_program::account_info::AccountInfo<'a>,
291 ) -> &mut Self {
292 self.instruction.authority = Some(authority);
293 self
294 }
295 #[inline(always)]
298 pub fn recipient(
299 &mut self,
300 recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>,
301 ) -> &mut Self {
302 self.instruction.recipient = recipient;
303 self
304 }
305 #[inline(always)]
307 pub fn add_remaining_account(
308 &mut self,
309 account: &'b solana_program::account_info::AccountInfo<'a>,
310 is_writable: bool,
311 is_signer: bool,
312 ) -> &mut Self {
313 self.instruction
314 .__remaining_accounts
315 .push((account, is_writable, is_signer));
316 self
317 }
318 #[inline(always)]
323 pub fn add_remaining_accounts(
324 &mut self,
325 accounts: &[(
326 &'b solana_program::account_info::AccountInfo<'a>,
327 bool,
328 bool,
329 )],
330 ) -> &mut Self {
331 self.instruction
332 .__remaining_accounts
333 .extend_from_slice(accounts);
334 self
335 }
336 #[inline(always)]
337 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
338 self.invoke_signed(&[])
339 }
340 #[allow(clippy::clone_on_copy)]
341 #[allow(clippy::vec_init_then_push)]
342 pub fn invoke_signed(
343 &self,
344 signers_seeds: &[&[&[u8]]],
345 ) -> solana_program::entrypoint::ProgramResult {
346 let instruction = CloseMintCpi {
347 __program: self.instruction.__program,
348
349 mint: self.instruction.mint.expect("mint is not set"),
350
351 authority: self.instruction.authority.expect("authority is not set"),
352
353 recipient: self.instruction.recipient,
354 };
355 instruction.invoke_signed_with_remaining_accounts(
356 signers_seeds,
357 &self.instruction.__remaining_accounts,
358 )
359 }
360}
361
362struct CloseMintCpiBuilderInstruction<'a, 'b> {
363 __program: &'b solana_program::account_info::AccountInfo<'a>,
364 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
365 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
366 recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>,
367 __remaining_accounts: Vec<(
369 &'b solana_program::account_info::AccountInfo<'a>,
370 bool,
371 bool,
372 )>,
373}