1use crate::generated::types::CompressionProof;
9#[cfg(feature = "anchor")]
10use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
11#[cfg(not(feature = "anchor"))]
12use borsh::{BorshDeserialize, BorshSerialize};
13
14pub struct BurnCollectionV1 {
16 pub collection: solana_program::pubkey::Pubkey,
18 pub payer: solana_program::pubkey::Pubkey,
20 pub authority: Option<solana_program::pubkey::Pubkey>,
22 pub log_wrapper: Option<solana_program::pubkey::Pubkey>,
24}
25
26impl BurnCollectionV1 {
27 pub fn instruction(
28 &self,
29 args: BurnCollectionV1InstructionArgs,
30 ) -> solana_program::instruction::Instruction {
31 self.instruction_with_remaining_accounts(args, &[])
32 }
33 #[allow(clippy::vec_init_then_push)]
34 pub fn instruction_with_remaining_accounts(
35 &self,
36 args: BurnCollectionV1InstructionArgs,
37 remaining_accounts: &[solana_program::instruction::AccountMeta],
38 ) -> solana_program::instruction::Instruction {
39 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
40 accounts.push(solana_program::instruction::AccountMeta::new(
41 self.collection,
42 false,
43 ));
44 accounts.push(solana_program::instruction::AccountMeta::new(
45 self.payer, true,
46 ));
47 if let Some(authority) = self.authority {
48 accounts.push(solana_program::instruction::AccountMeta::new(
49 authority, true,
50 ));
51 } else {
52 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
53 crate::MPL_CORE_ID,
54 false,
55 ));
56 }
57 if let Some(log_wrapper) = self.log_wrapper {
58 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59 log_wrapper,
60 false,
61 ));
62 } else {
63 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
64 crate::MPL_CORE_ID,
65 false,
66 ));
67 }
68 accounts.extend_from_slice(remaining_accounts);
69 let mut data = BurnCollectionV1InstructionData::new().try_to_vec().unwrap();
70 let mut args = args.try_to_vec().unwrap();
71 data.append(&mut args);
72
73 solana_program::instruction::Instruction {
74 program_id: crate::MPL_CORE_ID,
75 accounts,
76 data,
77 }
78 }
79}
80
81#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
82#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
83pub struct BurnCollectionV1InstructionData {
84 discriminator: u8,
85}
86
87impl BurnCollectionV1InstructionData {
88 pub fn new() -> Self {
89 Self { discriminator: 13 }
90 }
91}
92
93#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
94#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
95#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
96#[derive(Clone, Debug, Eq, PartialEq)]
97pub struct BurnCollectionV1InstructionArgs {
98 pub compression_proof: Option<CompressionProof>,
99}
100
101#[derive(Default)]
110pub struct BurnCollectionV1Builder {
111 collection: Option<solana_program::pubkey::Pubkey>,
112 payer: Option<solana_program::pubkey::Pubkey>,
113 authority: Option<solana_program::pubkey::Pubkey>,
114 log_wrapper: Option<solana_program::pubkey::Pubkey>,
115 compression_proof: Option<CompressionProof>,
116 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
117}
118
119impl BurnCollectionV1Builder {
120 pub fn new() -> Self {
121 Self::default()
122 }
123 #[inline(always)]
125 pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self {
126 self.collection = Some(collection);
127 self
128 }
129 #[inline(always)]
131 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
132 self.payer = Some(payer);
133 self
134 }
135 #[inline(always)]
138 pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
139 self.authority = authority;
140 self
141 }
142 #[inline(always)]
145 pub fn log_wrapper(
146 &mut self,
147 log_wrapper: Option<solana_program::pubkey::Pubkey>,
148 ) -> &mut Self {
149 self.log_wrapper = log_wrapper;
150 self
151 }
152 #[inline(always)]
154 pub fn compression_proof(&mut self, compression_proof: CompressionProof) -> &mut Self {
155 self.compression_proof = Some(compression_proof);
156 self
157 }
158 #[inline(always)]
160 pub fn add_remaining_account(
161 &mut self,
162 account: solana_program::instruction::AccountMeta,
163 ) -> &mut Self {
164 self.__remaining_accounts.push(account);
165 self
166 }
167 #[inline(always)]
169 pub fn add_remaining_accounts(
170 &mut self,
171 accounts: &[solana_program::instruction::AccountMeta],
172 ) -> &mut Self {
173 self.__remaining_accounts.extend_from_slice(accounts);
174 self
175 }
176 #[allow(clippy::clone_on_copy)]
177 pub fn instruction(&self) -> solana_program::instruction::Instruction {
178 let accounts = BurnCollectionV1 {
179 collection: self.collection.expect("collection is not set"),
180 payer: self.payer.expect("payer is not set"),
181 authority: self.authority,
182 log_wrapper: self.log_wrapper,
183 };
184 let args = BurnCollectionV1InstructionArgs {
185 compression_proof: self.compression_proof.clone(),
186 };
187
188 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
189 }
190}
191
192pub struct BurnCollectionV1CpiAccounts<'a, 'b> {
194 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
196 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
198 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
200 pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
202}
203
204pub struct BurnCollectionV1Cpi<'a, 'b> {
206 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
208 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
210 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
212 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
214 pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
216 pub __args: BurnCollectionV1InstructionArgs,
218}
219
220impl<'a, 'b> BurnCollectionV1Cpi<'a, 'b> {
221 pub fn new(
222 program: &'b solana_program::account_info::AccountInfo<'a>,
223 accounts: BurnCollectionV1CpiAccounts<'a, 'b>,
224 args: BurnCollectionV1InstructionArgs,
225 ) -> Self {
226 Self {
227 __program: program,
228 collection: accounts.collection,
229 payer: accounts.payer,
230 authority: accounts.authority,
231 log_wrapper: accounts.log_wrapper,
232 __args: args,
233 }
234 }
235 #[inline(always)]
236 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
237 self.invoke_signed_with_remaining_accounts(&[], &[])
238 }
239 #[inline(always)]
240 pub fn invoke_with_remaining_accounts(
241 &self,
242 remaining_accounts: &[(
243 &'b solana_program::account_info::AccountInfo<'a>,
244 bool,
245 bool,
246 )],
247 ) -> solana_program::entrypoint::ProgramResult {
248 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
249 }
250 #[inline(always)]
251 pub fn invoke_signed(
252 &self,
253 signers_seeds: &[&[&[u8]]],
254 ) -> solana_program::entrypoint::ProgramResult {
255 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
256 }
257 #[allow(clippy::clone_on_copy)]
258 #[allow(clippy::vec_init_then_push)]
259 pub fn invoke_signed_with_remaining_accounts(
260 &self,
261 signers_seeds: &[&[&[u8]]],
262 remaining_accounts: &[(
263 &'b solana_program::account_info::AccountInfo<'a>,
264 bool,
265 bool,
266 )],
267 ) -> solana_program::entrypoint::ProgramResult {
268 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
269 accounts.push(solana_program::instruction::AccountMeta::new(
270 *self.collection.key,
271 false,
272 ));
273 accounts.push(solana_program::instruction::AccountMeta::new(
274 *self.payer.key,
275 true,
276 ));
277 if let Some(authority) = self.authority {
278 accounts.push(solana_program::instruction::AccountMeta::new(
279 *authority.key,
280 true,
281 ));
282 } else {
283 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
284 crate::MPL_CORE_ID,
285 false,
286 ));
287 }
288 if let Some(log_wrapper) = self.log_wrapper {
289 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
290 *log_wrapper.key,
291 false,
292 ));
293 } else {
294 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
295 crate::MPL_CORE_ID,
296 false,
297 ));
298 }
299 remaining_accounts.iter().for_each(|remaining_account| {
300 accounts.push(solana_program::instruction::AccountMeta {
301 pubkey: *remaining_account.0.key,
302 is_signer: remaining_account.1,
303 is_writable: remaining_account.2,
304 })
305 });
306 let mut data = BurnCollectionV1InstructionData::new().try_to_vec().unwrap();
307 let mut args = self.__args.try_to_vec().unwrap();
308 data.append(&mut args);
309
310 let instruction = solana_program::instruction::Instruction {
311 program_id: crate::MPL_CORE_ID,
312 accounts,
313 data,
314 };
315 let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len());
316 account_infos.push(self.__program.clone());
317 account_infos.push(self.collection.clone());
318 account_infos.push(self.payer.clone());
319 if let Some(authority) = self.authority {
320 account_infos.push(authority.clone());
321 }
322 if let Some(log_wrapper) = self.log_wrapper {
323 account_infos.push(log_wrapper.clone());
324 }
325 remaining_accounts
326 .iter()
327 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
328
329 if signers_seeds.is_empty() {
330 solana_program::program::invoke(&instruction, &account_infos)
331 } else {
332 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
333 }
334 }
335}
336
337pub struct BurnCollectionV1CpiBuilder<'a, 'b> {
346 instruction: Box<BurnCollectionV1CpiBuilderInstruction<'a, 'b>>,
347}
348
349impl<'a, 'b> BurnCollectionV1CpiBuilder<'a, 'b> {
350 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
351 let instruction = Box::new(BurnCollectionV1CpiBuilderInstruction {
352 __program: program,
353 collection: None,
354 payer: None,
355 authority: None,
356 log_wrapper: None,
357 compression_proof: None,
358 __remaining_accounts: Vec::new(),
359 });
360 Self { instruction }
361 }
362 #[inline(always)]
364 pub fn collection(
365 &mut self,
366 collection: &'b solana_program::account_info::AccountInfo<'a>,
367 ) -> &mut Self {
368 self.instruction.collection = Some(collection);
369 self
370 }
371 #[inline(always)]
373 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
374 self.instruction.payer = Some(payer);
375 self
376 }
377 #[inline(always)]
380 pub fn authority(
381 &mut self,
382 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
383 ) -> &mut Self {
384 self.instruction.authority = authority;
385 self
386 }
387 #[inline(always)]
390 pub fn log_wrapper(
391 &mut self,
392 log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
393 ) -> &mut Self {
394 self.instruction.log_wrapper = log_wrapper;
395 self
396 }
397 #[inline(always)]
399 pub fn compression_proof(&mut self, compression_proof: CompressionProof) -> &mut Self {
400 self.instruction.compression_proof = Some(compression_proof);
401 self
402 }
403 #[inline(always)]
405 pub fn add_remaining_account(
406 &mut self,
407 account: &'b solana_program::account_info::AccountInfo<'a>,
408 is_writable: bool,
409 is_signer: bool,
410 ) -> &mut Self {
411 self.instruction
412 .__remaining_accounts
413 .push((account, is_writable, is_signer));
414 self
415 }
416 #[inline(always)]
421 pub fn add_remaining_accounts(
422 &mut self,
423 accounts: &[(
424 &'b solana_program::account_info::AccountInfo<'a>,
425 bool,
426 bool,
427 )],
428 ) -> &mut Self {
429 self.instruction
430 .__remaining_accounts
431 .extend_from_slice(accounts);
432 self
433 }
434 #[inline(always)]
435 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
436 self.invoke_signed(&[])
437 }
438 #[allow(clippy::clone_on_copy)]
439 #[allow(clippy::vec_init_then_push)]
440 pub fn invoke_signed(
441 &self,
442 signers_seeds: &[&[&[u8]]],
443 ) -> solana_program::entrypoint::ProgramResult {
444 let args = BurnCollectionV1InstructionArgs {
445 compression_proof: self.instruction.compression_proof.clone(),
446 };
447 let instruction = BurnCollectionV1Cpi {
448 __program: self.instruction.__program,
449
450 collection: self.instruction.collection.expect("collection is not set"),
451
452 payer: self.instruction.payer.expect("payer is not set"),
453
454 authority: self.instruction.authority,
455
456 log_wrapper: self.instruction.log_wrapper,
457 __args: args,
458 };
459 instruction.invoke_signed_with_remaining_accounts(
460 signers_seeds,
461 &self.instruction.__remaining_accounts,
462 )
463 }
464}
465
466struct BurnCollectionV1CpiBuilderInstruction<'a, 'b> {
467 __program: &'b solana_program::account_info::AccountInfo<'a>,
468 collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
469 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
470 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
471 log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
472 compression_proof: Option<CompressionProof>,
473 __remaining_accounts: Vec<(
475 &'b solana_program::account_info::AccountInfo<'a>,
476 bool,
477 bool,
478 )>,
479}