1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use mpl_utils::assert_signer;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use crate::{
assertions::{
assert_owned_by, collection::assert_has_collection_authority,
metadata::assert_metadata_derivation,
},
error::MetadataError,
state::{Metadata, TokenMetadataAccount},
utils::clean_write_metadata,
};
pub fn unverify_collection(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let metadata_info = next_account_info(account_info_iter)?;
let collection_authority_info = next_account_info(account_info_iter)?;
let collection_mint_info = next_account_info(account_info_iter)?;
let collection_metadata_info = next_account_info(account_info_iter)?;
let _edition_account_info = next_account_info(account_info_iter)?;
let using_delegated_collection_authority = accounts.len() == 6;
assert_owned_by(metadata_info, program_id)?;
assert_signer(collection_authority_info)?;
assert_owned_by(collection_mint_info, &spl_token::id())?;
let mut metadata = Metadata::from_account_info(metadata_info)?;
let collection = match metadata.collection.as_mut() {
Some(collection) => collection,
None => return Ok(()),
};
if !collection.verified {
return Ok(());
}
if collection.key != *collection_mint_info.key {
return Err(MetadataError::NotAMemberOfCollection.into());
}
assert_metadata_derivation(program_id, collection_metadata_info, collection_mint_info)?;
let parent_burned = collection_metadata_info.data_is_empty();
if parent_burned {
if metadata.update_authority != *collection_authority_info.key {
return Err(MetadataError::UpdateAuthorityIncorrect.into());
}
} else {
assert_owned_by(collection_metadata_info, program_id)?;
let collection_metadata = Metadata::from_account_info(collection_metadata_info)?;
if collection_metadata.collection_details.is_some() {
return Err(MetadataError::SizedCollection.into());
}
if using_delegated_collection_authority {
let collection_authority_record = next_account_info(account_info_iter)?;
assert_has_collection_authority(
collection_authority_info,
&collection_metadata,
collection_mint_info.key,
Some(collection_authority_record),
)?;
} else {
assert_has_collection_authority(
collection_authority_info,
&collection_metadata,
collection_mint_info.key,
None,
)?;
}
}
collection.verified = false;
clean_write_metadata(&mut metadata, metadata_info)?;
Ok(())
}