1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct VerifySizedCollectionItem {
13 pub metadata: solana_program::pubkey::Pubkey,
15 pub collection_authority: solana_program::pubkey::Pubkey,
17 pub payer: solana_program::pubkey::Pubkey,
19 pub collection_mint: solana_program::pubkey::Pubkey,
21 pub collection: solana_program::pubkey::Pubkey,
23 pub collection_master_edition_account: solana_program::pubkey::Pubkey,
25 pub collection_authority_record: Option<solana_program::pubkey::Pubkey>,
27}
28
29impl VerifySizedCollectionItem {
30 pub fn instruction(&self) -> solana_program::instruction::Instruction {
31 self.instruction_with_remaining_accounts(&[])
32 }
33 #[allow(clippy::vec_init_then_push)]
34 pub fn instruction_with_remaining_accounts(
35 &self,
36 remaining_accounts: &[solana_program::instruction::AccountMeta],
37 ) -> solana_program::instruction::Instruction {
38 let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
39 accounts.push(solana_program::instruction::AccountMeta::new(
40 self.metadata,
41 false,
42 ));
43 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
44 self.collection_authority,
45 true,
46 ));
47 accounts.push(solana_program::instruction::AccountMeta::new(
48 self.payer, true,
49 ));
50 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
51 self.collection_mint,
52 false,
53 ));
54 accounts.push(solana_program::instruction::AccountMeta::new(
55 self.collection,
56 false,
57 ));
58 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59 self.collection_master_edition_account,
60 false,
61 ));
62 if let Some(collection_authority_record) = self.collection_authority_record {
63 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
64 collection_authority_record,
65 false,
66 ));
67 }
68 accounts.extend_from_slice(remaining_accounts);
69 let data = VerifySizedCollectionItemInstructionData::new()
70 .try_to_vec()
71 .unwrap();
72
73 solana_program::instruction::Instruction {
74 program_id: crate::MPL_TOKEN_METADATA_ID,
75 accounts,
76 data,
77 }
78 }
79}
80
81#[derive(BorshDeserialize, BorshSerialize)]
82struct VerifySizedCollectionItemInstructionData {
83 discriminator: u8,
84}
85
86impl VerifySizedCollectionItemInstructionData {
87 fn new() -> Self {
88 Self { discriminator: 30 }
89 }
90}
91
92#[derive(Default)]
104pub struct VerifySizedCollectionItemBuilder {
105 metadata: Option<solana_program::pubkey::Pubkey>,
106 collection_authority: Option<solana_program::pubkey::Pubkey>,
107 payer: Option<solana_program::pubkey::Pubkey>,
108 collection_mint: Option<solana_program::pubkey::Pubkey>,
109 collection: Option<solana_program::pubkey::Pubkey>,
110 collection_master_edition_account: Option<solana_program::pubkey::Pubkey>,
111 collection_authority_record: Option<solana_program::pubkey::Pubkey>,
112 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
113}
114
115impl VerifySizedCollectionItemBuilder {
116 pub fn new() -> Self {
117 Self::default()
118 }
119 #[inline(always)]
121 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
122 self.metadata = Some(metadata);
123 self
124 }
125 #[inline(always)]
127 pub fn collection_authority(
128 &mut self,
129 collection_authority: solana_program::pubkey::Pubkey,
130 ) -> &mut Self {
131 self.collection_authority = Some(collection_authority);
132 self
133 }
134 #[inline(always)]
136 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
137 self.payer = Some(payer);
138 self
139 }
140 #[inline(always)]
142 pub fn collection_mint(
143 &mut self,
144 collection_mint: solana_program::pubkey::Pubkey,
145 ) -> &mut Self {
146 self.collection_mint = Some(collection_mint);
147 self
148 }
149 #[inline(always)]
151 pub fn collection(&mut self, collection: solana_program::pubkey::Pubkey) -> &mut Self {
152 self.collection = Some(collection);
153 self
154 }
155 #[inline(always)]
157 pub fn collection_master_edition_account(
158 &mut self,
159 collection_master_edition_account: solana_program::pubkey::Pubkey,
160 ) -> &mut Self {
161 self.collection_master_edition_account = Some(collection_master_edition_account);
162 self
163 }
164 #[inline(always)]
167 pub fn collection_authority_record(
168 &mut self,
169 collection_authority_record: Option<solana_program::pubkey::Pubkey>,
170 ) -> &mut Self {
171 self.collection_authority_record = collection_authority_record;
172 self
173 }
174 #[inline(always)]
176 pub fn add_remaining_account(
177 &mut self,
178 account: solana_program::instruction::AccountMeta,
179 ) -> &mut Self {
180 self.__remaining_accounts.push(account);
181 self
182 }
183 #[inline(always)]
185 pub fn add_remaining_accounts(
186 &mut self,
187 accounts: &[solana_program::instruction::AccountMeta],
188 ) -> &mut Self {
189 self.__remaining_accounts.extend_from_slice(accounts);
190 self
191 }
192 #[allow(clippy::clone_on_copy)]
193 pub fn instruction(&self) -> solana_program::instruction::Instruction {
194 let accounts = VerifySizedCollectionItem {
195 metadata: self.metadata.expect("metadata is not set"),
196 collection_authority: self
197 .collection_authority
198 .expect("collection_authority is not set"),
199 payer: self.payer.expect("payer is not set"),
200 collection_mint: self.collection_mint.expect("collection_mint is not set"),
201 collection: self.collection.expect("collection is not set"),
202 collection_master_edition_account: self
203 .collection_master_edition_account
204 .expect("collection_master_edition_account is not set"),
205 collection_authority_record: self.collection_authority_record,
206 };
207
208 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
209 }
210}
211
212pub struct VerifySizedCollectionItemCpiAccounts<'a, 'b> {
214 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
216 pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
218 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
220 pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
222 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
224 pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
226 pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
228}
229
230pub struct VerifySizedCollectionItemCpi<'a, 'b> {
232 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
234 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
236 pub collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
238 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
240 pub collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
242 pub collection: &'b solana_program::account_info::AccountInfo<'a>,
244 pub collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
246 pub collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
248}
249
250impl<'a, 'b> VerifySizedCollectionItemCpi<'a, 'b> {
251 pub fn new(
252 program: &'b solana_program::account_info::AccountInfo<'a>,
253 accounts: VerifySizedCollectionItemCpiAccounts<'a, 'b>,
254 ) -> Self {
255 Self {
256 __program: program,
257 metadata: accounts.metadata,
258 collection_authority: accounts.collection_authority,
259 payer: accounts.payer,
260 collection_mint: accounts.collection_mint,
261 collection: accounts.collection,
262 collection_master_edition_account: accounts.collection_master_edition_account,
263 collection_authority_record: accounts.collection_authority_record,
264 }
265 }
266 #[inline(always)]
267 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
268 self.invoke_signed_with_remaining_accounts(&[], &[])
269 }
270 #[inline(always)]
271 pub fn invoke_with_remaining_accounts(
272 &self,
273 remaining_accounts: &[(
274 &'b solana_program::account_info::AccountInfo<'a>,
275 bool,
276 bool,
277 )],
278 ) -> solana_program::entrypoint::ProgramResult {
279 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
280 }
281 #[inline(always)]
282 pub fn invoke_signed(
283 &self,
284 signers_seeds: &[&[&[u8]]],
285 ) -> solana_program::entrypoint::ProgramResult {
286 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
287 }
288 #[allow(clippy::clone_on_copy)]
289 #[allow(clippy::vec_init_then_push)]
290 pub fn invoke_signed_with_remaining_accounts(
291 &self,
292 signers_seeds: &[&[&[u8]]],
293 remaining_accounts: &[(
294 &'b solana_program::account_info::AccountInfo<'a>,
295 bool,
296 bool,
297 )],
298 ) -> solana_program::entrypoint::ProgramResult {
299 let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
300 accounts.push(solana_program::instruction::AccountMeta::new(
301 *self.metadata.key,
302 false,
303 ));
304 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
305 *self.collection_authority.key,
306 true,
307 ));
308 accounts.push(solana_program::instruction::AccountMeta::new(
309 *self.payer.key,
310 true,
311 ));
312 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
313 *self.collection_mint.key,
314 false,
315 ));
316 accounts.push(solana_program::instruction::AccountMeta::new(
317 *self.collection.key,
318 false,
319 ));
320 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
321 *self.collection_master_edition_account.key,
322 false,
323 ));
324 if let Some(collection_authority_record) = self.collection_authority_record {
325 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
326 *collection_authority_record.key,
327 false,
328 ));
329 }
330 remaining_accounts.iter().for_each(|remaining_account| {
331 accounts.push(solana_program::instruction::AccountMeta {
332 pubkey: *remaining_account.0.key,
333 is_signer: remaining_account.1,
334 is_writable: remaining_account.2,
335 })
336 });
337 let data = VerifySizedCollectionItemInstructionData::new()
338 .try_to_vec()
339 .unwrap();
340
341 let instruction = solana_program::instruction::Instruction {
342 program_id: crate::MPL_TOKEN_METADATA_ID,
343 accounts,
344 data,
345 };
346 let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len());
347 account_infos.push(self.__program.clone());
348 account_infos.push(self.metadata.clone());
349 account_infos.push(self.collection_authority.clone());
350 account_infos.push(self.payer.clone());
351 account_infos.push(self.collection_mint.clone());
352 account_infos.push(self.collection.clone());
353 account_infos.push(self.collection_master_edition_account.clone());
354 if let Some(collection_authority_record) = self.collection_authority_record {
355 account_infos.push(collection_authority_record.clone());
356 }
357 remaining_accounts
358 .iter()
359 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
360
361 if signers_seeds.is_empty() {
362 solana_program::program::invoke(&instruction, &account_infos)
363 } else {
364 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
365 }
366 }
367}
368
369pub struct VerifySizedCollectionItemCpiBuilder<'a, 'b> {
381 instruction: Box<VerifySizedCollectionItemCpiBuilderInstruction<'a, 'b>>,
382}
383
384impl<'a, 'b> VerifySizedCollectionItemCpiBuilder<'a, 'b> {
385 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
386 let instruction = Box::new(VerifySizedCollectionItemCpiBuilderInstruction {
387 __program: program,
388 metadata: None,
389 collection_authority: None,
390 payer: None,
391 collection_mint: None,
392 collection: None,
393 collection_master_edition_account: None,
394 collection_authority_record: None,
395 __remaining_accounts: Vec::new(),
396 });
397 Self { instruction }
398 }
399 #[inline(always)]
401 pub fn metadata(
402 &mut self,
403 metadata: &'b solana_program::account_info::AccountInfo<'a>,
404 ) -> &mut Self {
405 self.instruction.metadata = Some(metadata);
406 self
407 }
408 #[inline(always)]
410 pub fn collection_authority(
411 &mut self,
412 collection_authority: &'b solana_program::account_info::AccountInfo<'a>,
413 ) -> &mut Self {
414 self.instruction.collection_authority = Some(collection_authority);
415 self
416 }
417 #[inline(always)]
419 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
420 self.instruction.payer = Some(payer);
421 self
422 }
423 #[inline(always)]
425 pub fn collection_mint(
426 &mut self,
427 collection_mint: &'b solana_program::account_info::AccountInfo<'a>,
428 ) -> &mut Self {
429 self.instruction.collection_mint = Some(collection_mint);
430 self
431 }
432 #[inline(always)]
434 pub fn collection(
435 &mut self,
436 collection: &'b solana_program::account_info::AccountInfo<'a>,
437 ) -> &mut Self {
438 self.instruction.collection = Some(collection);
439 self
440 }
441 #[inline(always)]
443 pub fn collection_master_edition_account(
444 &mut self,
445 collection_master_edition_account: &'b solana_program::account_info::AccountInfo<'a>,
446 ) -> &mut Self {
447 self.instruction.collection_master_edition_account =
448 Some(collection_master_edition_account);
449 self
450 }
451 #[inline(always)]
454 pub fn collection_authority_record(
455 &mut self,
456 collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
457 ) -> &mut Self {
458 self.instruction.collection_authority_record = collection_authority_record;
459 self
460 }
461 #[inline(always)]
463 pub fn add_remaining_account(
464 &mut self,
465 account: &'b solana_program::account_info::AccountInfo<'a>,
466 is_writable: bool,
467 is_signer: bool,
468 ) -> &mut Self {
469 self.instruction
470 .__remaining_accounts
471 .push((account, is_writable, is_signer));
472 self
473 }
474 #[inline(always)]
479 pub fn add_remaining_accounts(
480 &mut self,
481 accounts: &[(
482 &'b solana_program::account_info::AccountInfo<'a>,
483 bool,
484 bool,
485 )],
486 ) -> &mut Self {
487 self.instruction
488 .__remaining_accounts
489 .extend_from_slice(accounts);
490 self
491 }
492 #[inline(always)]
493 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
494 self.invoke_signed(&[])
495 }
496 #[allow(clippy::clone_on_copy)]
497 #[allow(clippy::vec_init_then_push)]
498 pub fn invoke_signed(
499 &self,
500 signers_seeds: &[&[&[u8]]],
501 ) -> solana_program::entrypoint::ProgramResult {
502 let instruction = VerifySizedCollectionItemCpi {
503 __program: self.instruction.__program,
504
505 metadata: self.instruction.metadata.expect("metadata is not set"),
506
507 collection_authority: self
508 .instruction
509 .collection_authority
510 .expect("collection_authority is not set"),
511
512 payer: self.instruction.payer.expect("payer is not set"),
513
514 collection_mint: self
515 .instruction
516 .collection_mint
517 .expect("collection_mint is not set"),
518
519 collection: self.instruction.collection.expect("collection is not set"),
520
521 collection_master_edition_account: self
522 .instruction
523 .collection_master_edition_account
524 .expect("collection_master_edition_account is not set"),
525
526 collection_authority_record: self.instruction.collection_authority_record,
527 };
528 instruction.invoke_signed_with_remaining_accounts(
529 signers_seeds,
530 &self.instruction.__remaining_accounts,
531 )
532 }
533}
534
535struct VerifySizedCollectionItemCpiBuilderInstruction<'a, 'b> {
536 __program: &'b solana_program::account_info::AccountInfo<'a>,
537 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
538 collection_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
539 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
540 collection_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
541 collection: Option<&'b solana_program::account_info::AccountInfo<'a>>,
542 collection_master_edition_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
543 collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
544 __remaining_accounts: Vec<(
546 &'b solana_program::account_info::AccountInfo<'a>,
547 bool,
548 bool,
549 )>,
550}