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