1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct UnverifyCollection {
13 pub metadata: solana_program::pubkey::Pubkey,
15 pub collection_authority: solana_program::pubkey::Pubkey,
17 pub collection_mint: solana_program::pubkey::Pubkey,
19 pub collection: solana_program::pubkey::Pubkey,
21 pub collection_master_edition_account: solana_program::pubkey::Pubkey,
23 pub collection_authority_record: Option<solana_program::pubkey::Pubkey>,
25}
26
27impl UnverifyCollection {
28 pub fn instruction(&self) -> solana_program::instruction::Instruction {
29 self.instruction_with_remaining_accounts(&[])
30 }
31 #[allow(clippy::vec_init_then_push)]
32 pub fn instruction_with_remaining_accounts(
33 &self,
34 remaining_accounts: &[solana_program::instruction::AccountMeta],
35 ) -> solana_program::instruction::Instruction {
36 let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
37 accounts.push(solana_program::instruction::AccountMeta::new(
38 self.metadata,
39 false,
40 ));
41 accounts.push(solana_program::instruction::AccountMeta::new(
42 self.collection_authority,
43 true,
44 ));
45 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
46 self.collection_mint,
47 false,
48 ));
49 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
50 self.collection,
51 false,
52 ));
53 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
54 self.collection_master_edition_account,
55 false,
56 ));
57 if let Some(collection_authority_record) = self.collection_authority_record {
58 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59 collection_authority_record,
60 false,
61 ));
62 }
63 accounts.extend_from_slice(remaining_accounts);
64 let data = UnverifyCollectionInstructionData::new()
65 .try_to_vec()
66 .unwrap();
67
68 solana_program::instruction::Instruction {
69 program_id: crate::MPL_TOKEN_METADATA_ID,
70 accounts,
71 data,
72 }
73 }
74}
75
76#[derive(BorshDeserialize, BorshSerialize)]
77struct UnverifyCollectionInstructionData {
78 discriminator: u8,
79}
80
81impl UnverifyCollectionInstructionData {
82 fn new() -> Self {
83 Self { discriminator: 22 }
84 }
85}
86
87#[derive(Default)]
98pub struct UnverifyCollectionBuilder {
99 metadata: Option<solana_program::pubkey::Pubkey>,
100 collection_authority: Option<solana_program::pubkey::Pubkey>,
101 collection_mint: Option<solana_program::pubkey::Pubkey>,
102 collection: Option<solana_program::pubkey::Pubkey>,
103 collection_master_edition_account: Option<solana_program::pubkey::Pubkey>,
104 collection_authority_record: Option<solana_program::pubkey::Pubkey>,
105 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
106}
107
108impl UnverifyCollectionBuilder {
109 pub fn new() -> Self {
110 Self::default()
111 }
112 #[inline(always)]
114 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
115 self.metadata = Some(metadata);
116 self
117 }
118 #[inline(always)]
120 pub fn collection_authority(
121 &mut self,
122 collection_authority: solana_program::pubkey::Pubkey,
123 ) -> &mut Self {
124 self.collection_authority = Some(collection_authority);
125 self
126 }
127 #[inline(always)]
129 pub fn collection_mint(
130 &mut self,
131 collection_mint: solana_program::pubkey::Pubkey,
132 ) -> &mut Self {
133 self.collection_mint = Some(collection_mint);
134 self
135 }
136 #[inline(always)]
138 pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self {
139 self.collection = Some(collection);
140 self
141 }
142 #[inline(always)]
144 pub fn collection_master_edition_account(
145 &mut self,
146 collection_master_edition_account: solana_program::pubkey::Pubkey,
147 ) -> &mut Self {
148 self.collection_master_edition_account = Some(collection_master_edition_account);
149 self
150 }
151 #[inline(always)]
154 pub fn collection_authority_record(
155 &mut self,
156 collection_authority_record: Option<solana_program::pubkey::Pubkey>,
157 ) -> &mut Self {
158 self.collection_authority_record = collection_authority_record;
159 self
160 }
161 #[inline(always)]
163 pub fn add_remaining_account(
164 &mut self,
165 account: solana_program::instruction::AccountMeta,
166 ) -> &mut Self {
167 self.__remaining_accounts.push(account);
168 self
169 }
170 #[inline(always)]
172 pub fn add_remaining_accounts(
173 &mut self,
174 accounts: &[solana_program::instruction::AccountMeta],
175 ) -> &mut Self {
176 self.__remaining_accounts.extend_from_slice(accounts);
177 self
178 }
179 #[allow(clippy::clone_on_copy)]
180 pub fn instruction(&self) -> solana_program::instruction::Instruction {
181 let accounts = UnverifyCollection {
182 metadata: self.metadata.expect("metadata is not set"),
183 collection_authority: self
184 .collection_authority
185 .expect("collection_authority is not set"),
186 collection_mint: self.collection_mint.expect("collection_mint is not set"),
187 collection: self.collection.expect("collection is not set"),
188 collection_master_edition_account: self
189 .collection_master_edition_account
190 .expect("collection_master_edition_account is not set"),
191 collection_authority_record: self.collection_authority_record,
192 };
193
194 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
195 }
196}
197
198pub struct UnverifyCollectionCpiAccounts<'a, 'b> {
200 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
202 pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
204 pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
206 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
208 pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
210 pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
212}
213
214pub struct UnverifyCollectionCpi<'a, 'b> {
216 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
218 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
220 pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
222 pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
224 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
226 pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
228 pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
230}
231
232impl<'a, 'b> UnverifyCollectionCpi<'a, 'b> {
233 pub fn new(
234 program: &'b solana_program::account_info::AccountInfo<'a>,
235 accounts: UnverifyCollectionCpiAccounts<'a, 'b>,
236 ) -> Self {
237 Self {
238 __program: program,
239 metadata: accounts.metadata,
240 collection_authority: accounts.collection_authority,
241 collection_mint: accounts.collection_mint,
242 collection: accounts.collection,
243 collection_master_edition_account: accounts.collection_master_edition_account,
244 collection_authority_record: accounts.collection_authority_record,
245 }
246 }
247 #[inline(always)]
248 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
249 self.invoke_signed_with_remaining_accounts(&[], &[])
250 }
251 #[inline(always)]
252 pub fn invoke_with_remaining_accounts(
253 &self,
254 remaining_accounts: &[(
255 &'b solana_program::account_info::AccountInfo<'a>,
256 bool,
257 bool,
258 )],
259 ) -> solana_program::entrypoint::ProgramResult {
260 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
261 }
262 #[inline(always)]
263 pub fn invoke_signed(
264 &self,
265 signers_seeds: &[&[&[u8]]],
266 ) -> solana_program::entrypoint::ProgramResult {
267 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
268 }
269 #[allow(clippy::clone_on_copy)]
270 #[allow(clippy::vec_init_then_push)]
271 pub fn invoke_signed_with_remaining_accounts(
272 &self,
273 signers_seeds: &[&[&[u8]]],
274 remaining_accounts: &[(
275 &'b solana_program::account_info::AccountInfo<'a>,
276 bool,
277 bool,
278 )],
279 ) -> solana_program::entrypoint::ProgramResult {
280 let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
281 accounts.push(solana_program::instruction::AccountMeta::new(
282 *self.metadata.key,
283 false,
284 ));
285 accounts.push(solana_program::instruction::AccountMeta::new(
286 *self.collection_authority.key,
287 true,
288 ));
289 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
290 *self.collection_mint.key,
291 false,
292 ));
293 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
294 *self.collection.key,
295 false,
296 ));
297 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
298 *self.collection_master_edition_account.key,
299 false,
300 ));
301 if let Some(collection_authority_record) = self.collection_authority_record {
302 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
303 *collection_authority_record.key,
304 false,
305 ));
306 }
307 remaining_accounts.iter().for_each(|remaining_account| {
308 accounts.push(solana_program::instruction::AccountMeta {
309 pubkey: *remaining_account.0.key,
310 is_signer: remaining_account.1,
311 is_writable: remaining_account.2,
312 })
313 });
314 let data = UnverifyCollectionInstructionData::new()
315 .try_to_vec()
316 .unwrap();
317
318 let instruction = solana_program::instruction::Instruction {
319 program_id: crate::MPL_TOKEN_METADATA_ID,
320 accounts,
321 data,
322 };
323 let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len());
324 account_infos.push(self.__program.clone());
325 account_infos.push(self.metadata.clone());
326 account_infos.push(self.collection_authority.clone());
327 account_infos.push(self.collection_mint.clone());
328 account_infos.push(self.collection.clone());
329 account_infos.push(self.collection_master_edition_account.clone());
330 if let Some(collection_authority_record) = self.collection_authority_record {
331 account_infos.push(collection_authority_record.clone());
332 }
333 remaining_accounts
334 .iter()
335 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
336
337 if signers_seeds.is_empty() {
338 solana_program::program::invoke(&instruction, &account_infos)
339 } else {
340 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
341 }
342 }
343}
344
345pub struct UnverifyCollectionCpiBuilder<'a, 'b> {
356 instruction: Box<UnverifyCollectionCpiBuilderInstruction<'a, 'b>>,
357}
358
359impl<'a, 'b> UnverifyCollectionCpiBuilder<'a, 'b> {
360 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
361 let instruction = Box::new(UnverifyCollectionCpiBuilderInstruction {
362 __program: program,
363 metadata: None,
364 collection_authority: None,
365 collection_mint: None,
366 collection: None,
367 collection_master_edition_account: None,
368 collection_authority_record: None,
369 __remaining_accounts: Vec::new(),
370 });
371 Self { instruction }
372 }
373 #[inline(always)]
375 pub fn metadata(
376 &mut self,
377 metadata: &'b solana_program::account_info::AccountInfo<'a>,
378 ) -> &mut Self {
379 self.instruction.metadata = Some(metadata);
380 self
381 }
382 #[inline(always)]
384 pub fn collection_authority(
385 &mut self,
386 collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
387 ) -> &mut Self {
388 self.instruction.collection_authority = Some(collection_authority);
389 self
390 }
391 #[inline(always)]
393 pub fn collection_mint(
394 &mut self,
395 collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
396 ) -> &mut Self {
397 self.instruction.collection_mint = Some(collection_mint);
398 self
399 }
400 #[inline(always)]
402 pub fn collection(
403 &mut self,
404 collection: &'b solana_program::account_info::AccountInfo<'a>,
405 ) -> &mut Self {
406 self.instruction.collection = Some(collection);
407 self
408 }
409 #[inline(always)]
411 pub fn collection_master_edition_account(
412 &mut self,
413 collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
414 ) -> &mut Self {
415 self.instruction.collection_master_edition_account =
416 Some(collection_master_edition_account);
417 self
418 }
419 #[inline(always)]
422 pub fn collection_authority_record(
423 &mut self,
424 collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
425 ) -> &mut Self {
426 self.instruction.collection_authority_record = collection_authority_record;
427 self
428 }
429 #[inline(always)]
431 pub fn add_remaining_account(
432 &mut self,
433 account: &'b solana_program::account_info::AccountInfo<'a>,
434 is_writable: bool,
435 is_signer: bool,
436 ) -> &mut Self {
437 self.instruction
438 .__remaining_accounts
439 .push((account, is_writable, is_signer));
440 self
441 }
442 #[inline(always)]
447 pub fn add_remaining_accounts(
448 &mut self,
449 accounts: &[(
450 &'b solana_program::account_info::AccountInfo<'a>,
451 bool,
452 bool,
453 )],
454 ) -> &mut Self {
455 self.instruction
456 .__remaining_accounts
457 .extend_from_slice(accounts);
458 self
459 }
460 #[inline(always)]
461 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
462 self.invoke_signed(&[])
463 }
464 #[allow(clippy::clone_on_copy)]
465 #[allow(clippy::vec_init_then_push)]
466 pub fn invoke_signed(
467 &self,
468 signers_seeds: &[&[&[u8]]],
469 ) -> solana_program::entrypoint::ProgramResult {
470 let instruction = UnverifyCollectionCpi {
471 __program: self.instruction.__program,
472
473 metadata: self.instruction.metadata.expect("metadata is not set"),
474
475 collection_authority: self
476 .instruction
477 .collection_authority
478 .expect("collection_authority is not set"),
479
480 collection_mint: self
481 .instruction
482 .collection_mint
483 .expect("collection_mint is not set"),
484
485 collection: self.instruction.collection.expect("collection is not set"),
486
487 collection_master_edition_account: self
488 .instruction
489 .collection_master_edition_account
490 .expect("collection_master_edition_account is not set"),
491
492 collection_authority_record: self.instruction.collection_authority_record,
493 };
494 instruction.invoke_signed_with_remaining_accounts(
495 signers_seeds,
496 &self.instruction.__remaining_accounts,
497 )
498 }
499}
500
501struct UnverifyCollectionCpiBuilderInstruction<'a, 'b> {
502 __program: &'b solana_program::account_info::AccountInfo<'a>,
503 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
504 collection_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
505 collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
506 collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
507 collection_master_edition_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
508 collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
509 __remaining_accounts: Vec<(
511 &'b solana_program::account_info::AccountInfo<'a>,
512 bool,
513 bool,
514 )>,
515}