1use borsh::{BorshDeserialize, BorshSerialize};
2#[cfg(feature = "serde-feature")]
3use serde::{Deserialize, Serialize};
4use solana_program::{
5 instruction::{AccountMeta, Instruction},
6 pubkey::Pubkey,
7};
8
9use crate::instruction::MetadataInstruction;
10
11#[allow(clippy::too_many_arguments)]
26pub fn approve_collection_authority(
27 program_id: Pubkey,
28 collection_authority_record: Pubkey,
29 new_collection_authority: Pubkey,
30 update_authority: Pubkey,
31 payer: Pubkey,
32 metadata: Pubkey,
33 mint: Pubkey,
34) -> Instruction {
35 Instruction {
36 program_id,
37 accounts: vec![
38 AccountMeta::new(collection_authority_record, false),
39 AccountMeta::new_readonly(new_collection_authority, false),
40 AccountMeta::new(update_authority, true),
41 AccountMeta::new(payer, true),
42 AccountMeta::new_readonly(metadata, false),
43 AccountMeta::new_readonly(mint, false),
44 AccountMeta::new_readonly(solana_program::system_program::ID, false),
45 ],
46 data: MetadataInstruction::ApproveCollectionAuthority
47 .try_to_vec()
48 .unwrap(),
49 }
50}
51
52#[allow(clippy::too_many_arguments)]
64pub fn revoke_collection_authority(
65 program_id: Pubkey,
66 collection_authority_record: Pubkey,
67 delegate_authority: Pubkey,
68 revoke_authority: Pubkey,
69 metadata: Pubkey,
70 mint: Pubkey,
71) -> Instruction {
72 Instruction {
73 program_id,
74 accounts: vec![
75 AccountMeta::new(collection_authority_record, false),
76 AccountMeta::new_readonly(delegate_authority, false),
77 AccountMeta::new(revoke_authority, true),
78 AccountMeta::new_readonly(metadata, false),
79 AccountMeta::new_readonly(mint, false),
80 ],
81 data: MetadataInstruction::RevokeCollectionAuthority
82 .try_to_vec()
83 .unwrap(),
84 }
85}
86
87#[allow(clippy::too_many_arguments)]
103pub fn set_and_verify_collection(
104 program_id: Pubkey,
105 metadata: Pubkey,
106 collection_authority: Pubkey,
107 payer: Pubkey,
108 update_authority: Pubkey,
109 collection_mint: Pubkey,
110 collection: Pubkey,
111 collection_master_edition_account: Pubkey,
112 collection_authority_record: Option<Pubkey>,
113) -> Instruction {
114 let mut accounts = vec![
115 AccountMeta::new(metadata, false),
116 AccountMeta::new(collection_authority, true),
117 AccountMeta::new(payer, true),
118 AccountMeta::new_readonly(update_authority, false),
119 AccountMeta::new_readonly(collection_mint, false),
120 AccountMeta::new_readonly(collection, false),
121 AccountMeta::new_readonly(collection_master_edition_account, false),
122 ];
123
124 if let Some(collection_authority_record) = collection_authority_record {
125 accounts.push(AccountMeta::new_readonly(
126 collection_authority_record,
127 false,
128 ));
129 }
130
131 Instruction {
132 program_id,
133 accounts,
134 data: MetadataInstruction::SetAndVerifyCollection
135 .try_to_vec()
136 .unwrap(),
137 }
138}
139
140#[allow(clippy::too_many_arguments)]
154pub fn set_and_verify_sized_collection_item(
155 program_id: Pubkey,
156 metadata: Pubkey,
157 collection_authority: Pubkey,
158 payer: Pubkey,
159 update_authority: Pubkey,
160 collection_mint: Pubkey,
161 collection: Pubkey,
162 collection_master_edition_account: Pubkey,
163 collection_authority_record: Option<Pubkey>,
164) -> Instruction {
165 let mut accounts = vec![
166 AccountMeta::new(metadata, false),
167 AccountMeta::new(collection_authority, true),
168 AccountMeta::new(payer, true),
169 AccountMeta::new_readonly(update_authority, false),
170 AccountMeta::new_readonly(collection_mint, false),
171 AccountMeta::new(collection, false),
172 AccountMeta::new_readonly(collection_master_edition_account, false),
173 ];
174
175 if let Some(collection_authority_record) = collection_authority_record {
176 accounts.push(AccountMeta::new_readonly(
177 collection_authority_record,
178 false,
179 ));
180 }
181
182 Instruction {
183 program_id,
184 accounts,
185 data: MetadataInstruction::SetAndVerifySizedCollectionItem
186 .try_to_vec()
187 .unwrap(),
188 }
189}
190
191#[repr(C)]
192#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
193#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
194pub struct SetCollectionSizeArgs {
195 pub size: u64,
196}
197
198pub fn set_collection_size(
199 program_id: Pubkey,
200 metadata_account: Pubkey,
201 update_authority: Pubkey,
202 mint: Pubkey,
203 collection_authority_record: Option<Pubkey>,
204 size: u64,
205) -> Instruction {
206 let mut accounts = vec![
207 AccountMeta::new(metadata_account, false),
208 AccountMeta::new_readonly(update_authority, true),
209 AccountMeta::new_readonly(mint, false),
210 ];
211
212 if let Some(record) = collection_authority_record {
213 accounts.push(AccountMeta::new_readonly(record, false));
214 }
215
216 Instruction {
217 program_id,
218 accounts,
219 data: MetadataInstruction::SetCollectionSize(SetCollectionSizeArgs { size })
220 .try_to_vec()
221 .unwrap(),
222 }
223}
224
225#[allow(clippy::too_many_arguments)]
238pub fn unverify_collection(
239 program_id: Pubkey,
240 metadata: Pubkey,
241 collection_authority: Pubkey,
242 collection_mint: Pubkey,
243 collection: Pubkey,
244 collection_master_edition_account: Pubkey,
245 collection_authority_record: Option<Pubkey>,
246) -> Instruction {
247 let mut accounts = vec![
248 AccountMeta::new(metadata, false),
249 AccountMeta::new(collection_authority, true),
250 AccountMeta::new_readonly(collection_mint, false),
251 AccountMeta::new_readonly(collection, false),
252 AccountMeta::new_readonly(collection_master_edition_account, false),
253 ];
254
255 if let Some(collection_authority_record) = collection_authority_record {
256 accounts.push(AccountMeta::new_readonly(
257 collection_authority_record,
258 false,
259 ));
260 }
261
262 Instruction {
263 program_id,
264 accounts,
265 data: MetadataInstruction::UnverifyCollection
266 .try_to_vec()
267 .unwrap(),
268 }
269}
270
271#[allow(clippy::too_many_arguments)]
284pub fn unverify_sized_collection_item(
285 program_id: Pubkey,
286 metadata: Pubkey,
287 collection_authority: Pubkey,
288 payer: Pubkey,
289 collection_mint: Pubkey,
290 collection: Pubkey,
291 collection_master_edition_account: Pubkey,
292 collection_authority_record: Option<Pubkey>,
293) -> Instruction {
294 let mut accounts = vec![
295 AccountMeta::new(metadata, false),
296 AccountMeta::new_readonly(collection_authority, true),
297 AccountMeta::new(payer, true),
298 AccountMeta::new_readonly(collection_mint, false),
299 AccountMeta::new(collection, false),
300 AccountMeta::new_readonly(collection_master_edition_account, false),
301 ];
302
303 if let Some(collection_authority_record) = collection_authority_record {
304 accounts.push(AccountMeta::new_readonly(
305 collection_authority_record,
306 false,
307 ));
308 }
309
310 Instruction {
311 program_id,
312 accounts,
313 data: MetadataInstruction::UnverifySizedCollectionItem
314 .try_to_vec()
315 .unwrap(),
316 }
317}
318
319#[allow(clippy::too_many_arguments)]
332pub fn verify_collection(
333 program_id: Pubkey,
334 metadata: Pubkey,
335 collection_authority: Pubkey,
336 payer: Pubkey,
337 collection_mint: Pubkey,
338 collection: Pubkey,
339 collection_master_edition_account: Pubkey,
340 collection_authority_record: Option<Pubkey>,
341) -> Instruction {
342 let mut accounts = vec![
343 AccountMeta::new(metadata, false),
344 AccountMeta::new(collection_authority, true),
345 AccountMeta::new(payer, true),
346 AccountMeta::new_readonly(collection_mint, false),
347 AccountMeta::new_readonly(collection, false),
348 AccountMeta::new_readonly(collection_master_edition_account, false),
349 ];
350
351 if let Some(collection_authority_record) = collection_authority_record {
352 accounts.push(AccountMeta::new_readonly(
353 collection_authority_record,
354 false,
355 ));
356 }
357
358 Instruction {
359 program_id,
360 accounts,
361 data: MetadataInstruction::VerifyCollection.try_to_vec().unwrap(),
362 }
363}
364
365#[allow(clippy::too_many_arguments)]
378pub fn verify_sized_collection_item(
379 program_id: Pubkey,
380 metadata: Pubkey,
381 collection_authority: Pubkey,
382 payer: Pubkey,
383 collection_mint: Pubkey,
384 collection: Pubkey,
385 collection_master_edition_account: Pubkey,
386 collection_authority_record: Option<Pubkey>,
387) -> Instruction {
388 let mut accounts = vec![
389 AccountMeta::new(metadata, false),
390 AccountMeta::new_readonly(collection_authority, true),
391 AccountMeta::new(payer, true),
392 AccountMeta::new_readonly(collection_mint, false),
393 AccountMeta::new(collection, false),
394 AccountMeta::new_readonly(collection_master_edition_account, false),
395 ];
396
397 if let Some(record) = collection_authority_record {
398 accounts.push(AccountMeta::new_readonly(record, false));
399 }
400
401 Instruction {
402 program_id,
403 accounts,
404 data: MetadataInstruction::VerifySizedCollectionItem
405 .try_to_vec()
406 .unwrap(),
407 }
408}