1use crate::generated::types::CompressionProof;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub struct BurnV1 {
14 pub asset: solana_program::pubkey::Pubkey,
16 pub collection: Option<solana_program::pubkey::Pubkey>,
18 pub payer: solana_program::pubkey::Pubkey,
20 pub authority: Option<solana_program::pubkey::Pubkey>,
22 pub system_program: Option<solana_program::pubkey::Pubkey>,
24 pub log_wrapper: Option<solana_program::pubkey::Pubkey>,
26}
27
28impl BurnV1 {
29 pub fn instruction(
30 &self,
31 args: BurnV1InstructionArgs,
32 ) -> solana_program::instruction::Instruction {
33 self.instruction_with_remaining_accounts(args, &[])
34 }
35 #[allow(clippy::vec_init_then_push)]
36 pub fn instruction_with_remaining_accounts(
37 &self,
38 args: BurnV1InstructionArgs,
39 remaining_accounts: &[solana_program::instruction::AccountMeta],
40 ) -> solana_program::instruction::Instruction {
41 let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
42 accounts.push(solana_program::instruction::AccountMeta::new(
43 self.asset, false,
44 ));
45 if let Some(collection) = self.collection {
46 accounts.push(solana_program::instruction::AccountMeta::new(
47 collection, false,
48 ));
49 } else {
50 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
51 crate::MPL_CORE_ID,
52 false,
53 ));
54 }
55 accounts.push(solana_program::instruction::AccountMeta::new(
56 self.payer, true,
57 ));
58 if let Some(authority) = self.authority {
59 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
60 authority, true,
61 ));
62 } else {
63 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
64 crate::MPL_CORE_ID,
65 false,
66 ));
67 }
68 if let Some(system_program) = self.system_program {
69 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
70 system_program,
71 false,
72 ));
73 } else {
74 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
75 crate::MPL_CORE_ID,
76 false,
77 ));
78 }
79 if let Some(log_wrapper) = self.log_wrapper {
80 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
81 log_wrapper,
82 false,
83 ));
84 } else {
85 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
86 crate::MPL_CORE_ID,
87 false,
88 ));
89 }
90 accounts.extend_from_slice(remaining_accounts);
91 let mut data = BurnV1InstructionData::new().try_to_vec().unwrap();
92 let mut args = args.try_to_vec().unwrap();
93 data.append(&mut args);
94
95 solana_program::instruction::Instruction {
96 program_id: crate::MPL_CORE_ID,
97 accounts,
98 data,
99 }
100 }
101}
102
103#[derive(BorshDeserialize, BorshSerialize)]
104struct BurnV1InstructionData {
105 discriminator: u8,
106}
107
108impl BurnV1InstructionData {
109 fn new() -> Self {
110 Self { discriminator: 12 }
111 }
112}
113
114#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
115#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
116pub struct BurnV1InstructionArgs {
117 pub compression_proof: Option<CompressionProof>,
118}
119
120#[derive(Default)]
131pub struct BurnV1Builder {
132 asset: Option<solana_program::pubkey::Pubkey>,
133 collection: Option<solana_program::pubkey::Pubkey>,
134 payer: Option<solana_program::pubkey::Pubkey>,
135 authority: Option<solana_program::pubkey::Pubkey>,
136 system_program: Option<solana_program::pubkey::Pubkey>,
137 log_wrapper: Option<solana_program::pubkey::Pubkey>,
138 compression_proof: Option<CompressionProof>,
139 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
140}
141
142impl BurnV1Builder {
143 pub fn new() -> Self {
144 Self::default()
145 }
146 #[inline(always)]
148 pub fn asset(&mut self, asset: solana_program::pubkey::Pubkey) -> &mut Self {
149 self.asset = Some(asset);
150 self
151 }
152 #[inline(always)]
155 pub fn collection(&mut self, collection: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
156 self.collection = collection;
157 self
158 }
159 #[inline(always)]
161 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
162 self.payer = Some(payer);
163 self
164 }
165 #[inline(always)]
168 pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
169 self.authority = authority;
170 self
171 }
172 #[inline(always)]
175 pub fn system_program(
176 &mut self,
177 system_program: Option<solana_program::pubkey::Pubkey>,
178 ) -> &mut Self {
179 self.system_program = system_program;
180 self
181 }
182 #[inline(always)]
185 pub fn log_wrapper(
186 &mut self,
187 log_wrapper: Option<solana_program::pubkey::Pubkey>,
188 ) -> &mut Self {
189 self.log_wrapper = log_wrapper;
190 self
191 }
192 #[inline(always)]
194 pub fn compression_proof(&mut self, compression_proof: CompressionProof) -> &mut Self {
195 self.compression_proof = Some(compression_proof);
196 self
197 }
198 #[inline(always)]
200 pub fn add_remaining_account(
201 &mut self,
202 account: solana_program::instruction::AccountMeta,
203 ) -> &mut Self {
204 self.__remaining_accounts.push(account);
205 self
206 }
207 #[inline(always)]
209 pub fn add_remaining_accounts(
210 &mut self,
211 accounts: &[solana_program::instruction::AccountMeta],
212 ) -> &mut Self {
213 self.__remaining_accounts.extend_from_slice(accounts);
214 self
215 }
216 #[allow(clippy::clone_on_copy)]
217 pub fn instruction(&self) -> solana_program::instruction::Instruction {
218 let accounts = BurnV1 {
219 asset: self.asset.expect("asset is not set"),
220 collection: self.collection,
221 payer: self.payer.expect("payer is not set"),
222 authority: self.authority,
223 system_program: self.system_program,
224 log_wrapper: self.log_wrapper,
225 };
226 let args = BurnV1InstructionArgs {
227 compression_proof: self.compression_proof.clone(),
228 };
229
230 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
231 }
232}
233
234pub struct BurnV1CpiAccounts<'a, 'b> {
236 pub asset: &'b solana_program::account_info::AccountInfo<'a>,
238 pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
240 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
242 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
244 pub system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
246 pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
248}
249
250pub struct BurnV1Cpi<'a, 'b> {
252 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
254 pub asset: &'b solana_program::account_info::AccountInfo<'a>,
256 pub collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
258 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
260 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
262 pub system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
264 pub log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
266 pub __args: BurnV1InstructionArgs,
268}
269
270impl<'a, 'b> BurnV1Cpi<'a, 'b> {
271 pub fn new(
272 program: &'b solana_program::account_info::AccountInfo<'a>,
273 accounts: BurnV1CpiAccounts<'a, 'b>,
274 args: BurnV1InstructionArgs,
275 ) -> Self {
276 Self {
277 __program: program,
278 asset: accounts.asset,
279 collection: accounts.collection,
280 payer: accounts.payer,
281 authority: accounts.authority,
282 system_program: accounts.system_program,
283 log_wrapper: accounts.log_wrapper,
284 __args: args,
285 }
286 }
287 #[inline(always)]
288 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
289 self.invoke_signed_with_remaining_accounts(&[], &[])
290 }
291 #[inline(always)]
292 pub fn invoke_with_remaining_accounts(
293 &self,
294 remaining_accounts: &[(
295 &'b solana_program::account_info::AccountInfo<'a>,
296 bool,
297 bool,
298 )],
299 ) -> solana_program::entrypoint::ProgramResult {
300 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
301 }
302 #[inline(always)]
303 pub fn invoke_signed(
304 &self,
305 signers_seeds: &[&[&[u8]]],
306 ) -> solana_program::entrypoint::ProgramResult {
307 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
308 }
309 #[allow(clippy::clone_on_copy)]
310 #[allow(clippy::vec_init_then_push)]
311 pub fn invoke_signed_with_remaining_accounts(
312 &self,
313 signers_seeds: &[&[&[u8]]],
314 remaining_accounts: &[(
315 &'b solana_program::account_info::AccountInfo<'a>,
316 bool,
317 bool,
318 )],
319 ) -> solana_program::entrypoint::ProgramResult {
320 let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
321 accounts.push(solana_program::instruction::AccountMeta::new(
322 *self.asset.key,
323 false,
324 ));
325 if let Some(collection) = self.collection {
326 accounts.push(solana_program::instruction::AccountMeta::new(
327 *collection.key,
328 false,
329 ));
330 } else {
331 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
332 crate::MPL_CORE_ID,
333 false,
334 ));
335 }
336 accounts.push(solana_program::instruction::AccountMeta::new(
337 *self.payer.key,
338 true,
339 ));
340 if let Some(authority) = self.authority {
341 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
342 *authority.key,
343 true,
344 ));
345 } else {
346 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
347 crate::MPL_CORE_ID,
348 false,
349 ));
350 }
351 if let Some(system_program) = self.system_program {
352 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
353 *system_program.key,
354 false,
355 ));
356 } else {
357 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
358 crate::MPL_CORE_ID,
359 false,
360 ));
361 }
362 if let Some(log_wrapper) = self.log_wrapper {
363 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
364 *log_wrapper.key,
365 false,
366 ));
367 } else {
368 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
369 crate::MPL_CORE_ID,
370 false,
371 ));
372 }
373 remaining_accounts.iter().for_each(|remaining_account| {
374 accounts.push(solana_program::instruction::AccountMeta {
375 pubkey: *remaining_account.0.key,
376 is_signer: remaining_account.1,
377 is_writable: remaining_account.2,
378 })
379 });
380 let mut data = BurnV1InstructionData::new().try_to_vec().unwrap();
381 let mut args = self.__args.try_to_vec().unwrap();
382 data.append(&mut args);
383
384 let instruction = solana_program::instruction::Instruction {
385 program_id: crate::MPL_CORE_ID,
386 accounts,
387 data,
388 };
389 let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len());
390 account_infos.push(self.__program.clone());
391 account_infos.push(self.asset.clone());
392 if let Some(collection) = self.collection {
393 account_infos.push(collection.clone());
394 }
395 account_infos.push(self.payer.clone());
396 if let Some(authority) = self.authority {
397 account_infos.push(authority.clone());
398 }
399 if let Some(system_program) = self.system_program {
400 account_infos.push(system_program.clone());
401 }
402 if let Some(log_wrapper) = self.log_wrapper {
403 account_infos.push(log_wrapper.clone());
404 }
405 remaining_accounts
406 .iter()
407 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
408
409 if signers_seeds.is_empty() {
410 solana_program::program::invoke(&instruction, &account_infos)
411 } else {
412 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
413 }
414 }
415}
416
417pub struct BurnV1CpiBuilder<'a, 'b> {
428 instruction: Box<BurnV1CpiBuilderInstruction<'a, 'b>>,
429}
430
431impl<'a, 'b> BurnV1CpiBuilder<'a, 'b> {
432 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
433 let instruction = Box::new(BurnV1CpiBuilderInstruction {
434 __program: program,
435 asset: None,
436 collection: None,
437 payer: None,
438 authority: None,
439 system_program: None,
440 log_wrapper: None,
441 compression_proof: None,
442 __remaining_accounts: Vec::new(),
443 });
444 Self { instruction }
445 }
446 #[inline(always)]
448 pub fn asset(&mut self, asset: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
449 self.instruction.asset = Some(asset);
450 self
451 }
452 #[inline(always)]
455 pub fn collection(
456 &mut self,
457 collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
458 ) -> &mut Self {
459 self.instruction.collection = collection;
460 self
461 }
462 #[inline(always)]
464 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
465 self.instruction.payer = Some(payer);
466 self
467 }
468 #[inline(always)]
471 pub fn authority(
472 &mut self,
473 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
474 ) -> &mut Self {
475 self.instruction.authority = authority;
476 self
477 }
478 #[inline(always)]
481 pub fn system_program(
482 &mut self,
483 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
484 ) -> &mut Self {
485 self.instruction.system_program = system_program;
486 self
487 }
488 #[inline(always)]
491 pub fn log_wrapper(
492 &mut self,
493 log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
494 ) -> &mut Self {
495 self.instruction.log_wrapper = log_wrapper;
496 self
497 }
498 #[inline(always)]
500 pub fn compression_proof(&mut self, compression_proof: CompressionProof) -> &mut Self {
501 self.instruction.compression_proof = Some(compression_proof);
502 self
503 }
504 #[inline(always)]
506 pub fn add_remaining_account(
507 &mut self,
508 account: &'b solana_program::account_info::AccountInfo<'a>,
509 is_writable: bool,
510 is_signer: bool,
511 ) -> &mut Self {
512 self.instruction
513 .__remaining_accounts
514 .push((account, is_writable, is_signer));
515 self
516 }
517 #[inline(always)]
522 pub fn add_remaining_accounts(
523 &mut self,
524 accounts: &[(
525 &'b solana_program::account_info::AccountInfo<'a>,
526 bool,
527 bool,
528 )],
529 ) -> &mut Self {
530 self.instruction
531 .__remaining_accounts
532 .extend_from_slice(accounts);
533 self
534 }
535 #[inline(always)]
536 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
537 self.invoke_signed(&[])
538 }
539 #[allow(clippy::clone_on_copy)]
540 #[allow(clippy::vec_init_then_push)]
541 pub fn invoke_signed(
542 &self,
543 signers_seeds: &[&[&[u8]]],
544 ) -> solana_program::entrypoint::ProgramResult {
545 let args = BurnV1InstructionArgs {
546 compression_proof: self.instruction.compression_proof.clone(),
547 };
548 let instruction = BurnV1Cpi {
549 __program: self.instruction.__program,
550
551 asset: self.instruction.asset.expect("asset is not set"),
552
553 collection: self.instruction.collection,
554
555 payer: self.instruction.payer.expect("payer is not set"),
556
557 authority: self.instruction.authority,
558
559 system_program: self.instruction.system_program,
560
561 log_wrapper: self.instruction.log_wrapper,
562 __args: args,
563 };
564 instruction.invoke_signed_with_remaining_accounts(
565 signers_seeds,
566 &self.instruction.__remaining_accounts,
567 )
568 }
569}
570
571struct BurnV1CpiBuilderInstruction<'a, 'b> {
572 __program: &'b solana_program::account_info::AccountInfo<'a>,
573 asset: Option<&'b solana_program::account_info::AccountInfo<'a>>,
574 collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
575 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
576 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
577 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
578 log_wrapper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
579 compression_proof: Option<CompressionProof>,
580 __remaining_accounts: Vec<(
582 &'b solana_program::account_info::AccountInfo<'a>,
583 bool,
584 bool,
585 )>,
586}