Skip to main content

mpl_token_metadata/generated/instructions/
delegate_collection_item_v1.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! [https://github.com/metaplex-foundation/kinobi]
6//!
7
8use crate::generated::types::AuthorizationData;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12/// Accounts.
13pub struct DelegateCollectionItemV1 {
14    /// Delegate record account
15    pub delegate_record: Option<solana_program::pubkey::Pubkey>,
16    /// Owner of the delegated account
17    pub delegate: solana_program::pubkey::Pubkey,
18    /// Metadata account
19    pub metadata: solana_program::pubkey::Pubkey,
20    /// Master Edition account
21    pub master_edition: Option<solana_program::pubkey::Pubkey>,
22    /// Token record account
23    pub token_record: Option<solana_program::pubkey::Pubkey>,
24    /// Mint of metadata
25    pub mint: solana_program::pubkey::Pubkey,
26    /// Token account of mint
27    pub token: Option<solana_program::pubkey::Pubkey>,
28    /// Update authority or token owner
29    pub authority: solana_program::pubkey::Pubkey,
30    /// Payer
31    pub payer: solana_program::pubkey::Pubkey,
32    /// System Program
33    pub system_program: solana_program::pubkey::Pubkey,
34    /// Instructions sysvar account
35    pub sysvar_instructions: solana_program::pubkey::Pubkey,
36    /// SPL Token Program
37    pub spl_token_program: Option<solana_program::pubkey::Pubkey>,
38    /// Token Authorization Rules Program
39    pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
40    /// Token Authorization Rules account
41    pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
42}
43
44impl DelegateCollectionItemV1 {
45    pub fn instruction(
46        &self,
47        args: DelegateCollectionItemV1InstructionArgs,
48    ) -> solana_program::instruction::Instruction {
49        self.instruction_with_remaining_accounts(args, &[])
50    }
51    #[allow(clippy::vec_init_then_push)]
52    pub fn instruction_with_remaining_accounts(
53        &self,
54        args: DelegateCollectionItemV1InstructionArgs,
55        remaining_accounts: &[solana_program::instruction::AccountMeta],
56    ) -> solana_program::instruction::Instruction {
57        let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
58        if let Some(delegate_record) = self.delegate_record {
59            accounts.push(solana_program::instruction::AccountMeta::new(
60                delegate_record,
61                false,
62            ));
63        } else {
64            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65                crate::MPL_TOKEN_METADATA_ID,
66                false,
67            ));
68        }
69        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
70            self.delegate,
71            false,
72        ));
73        accounts.push(solana_program::instruction::AccountMeta::new(
74            self.metadata,
75            false,
76        ));
77        if let Some(master_edition) = self.master_edition {
78            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
79                master_edition,
80                false,
81            ));
82        } else {
83            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
84                crate::MPL_TOKEN_METADATA_ID,
85                false,
86            ));
87        }
88        if let Some(token_record) = self.token_record {
89            accounts.push(solana_program::instruction::AccountMeta::new(
90                token_record,
91                false,
92            ));
93        } else {
94            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95                crate::MPL_TOKEN_METADATA_ID,
96                false,
97            ));
98        }
99        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
100            self.mint, false,
101        ));
102        if let Some(token) = self.token {
103            accounts.push(solana_program::instruction::AccountMeta::new(token, false));
104        } else {
105            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
106                crate::MPL_TOKEN_METADATA_ID,
107                false,
108            ));
109        }
110        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
111            self.authority,
112            true,
113        ));
114        accounts.push(solana_program::instruction::AccountMeta::new(
115            self.payer, true,
116        ));
117        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
118            self.system_program,
119            false,
120        ));
121        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
122            self.sysvar_instructions,
123            false,
124        ));
125        if let Some(spl_token_program) = self.spl_token_program {
126            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
127                spl_token_program,
128                false,
129            ));
130        } else {
131            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
132                crate::MPL_TOKEN_METADATA_ID,
133                false,
134            ));
135        }
136        if let Some(authorization_rules_program) = self.authorization_rules_program {
137            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
138                authorization_rules_program,
139                false,
140            ));
141        } else {
142            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
143                crate::MPL_TOKEN_METADATA_ID,
144                false,
145            ));
146        }
147        if let Some(authorization_rules) = self.authorization_rules {
148            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
149                authorization_rules,
150                false,
151            ));
152        } else {
153            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
154                crate::MPL_TOKEN_METADATA_ID,
155                false,
156            ));
157        }
158        accounts.extend_from_slice(remaining_accounts);
159        let mut data = DelegateCollectionItemV1InstructionData::new()
160            .try_to_vec()
161            .unwrap();
162        let mut args = args.try_to_vec().unwrap();
163        data.append(&mut args);
164
165        solana_program::instruction::Instruction {
166            program_id: crate::MPL_TOKEN_METADATA_ID,
167            accounts,
168            data,
169        }
170    }
171}
172
173#[derive(BorshDeserialize, BorshSerialize)]
174struct DelegateCollectionItemV1InstructionData {
175    discriminator: u8,
176    delegate_collection_item_v1_discriminator: u8,
177}
178
179impl DelegateCollectionItemV1InstructionData {
180    fn new() -> Self {
181        Self {
182            discriminator: 44,
183            delegate_collection_item_v1_discriminator: 11,
184        }
185    }
186}
187
188#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
189#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
190pub struct DelegateCollectionItemV1InstructionArgs {
191    pub authorization_data: Option<AuthorizationData>,
192}
193
194/// Instruction builder for `DelegateCollectionItemV1`.
195///
196/// ### Accounts:
197///
198///   0. `[writable, optional]` delegate_record
199///   1. `[]` delegate
200///   2. `[writable]` metadata
201///   3. `[optional]` master_edition
202///   4. `[writable, optional]` token_record
203///   5. `[]` mint
204///   6. `[writable, optional]` token
205///   7. `[signer]` authority
206///   8. `[writable, signer]` payer
207///   9. `[optional]` system_program (default to `11111111111111111111111111111111`)
208///   10. `[optional]` sysvar_instructions (default to `Sysvar1nstructions1111111111111111111111111`)
209///   11. `[optional]` spl_token_program
210///   12. `[optional]` authorization_rules_program
211///   13. `[optional]` authorization_rules
212#[derive(Default)]
213pub struct DelegateCollectionItemV1Builder {
214    delegate_record: Option<solana_program::pubkey::Pubkey>,
215    delegate: Option<solana_program::pubkey::Pubkey>,
216    metadata: Option<solana_program::pubkey::Pubkey>,
217    master_edition: Option<solana_program::pubkey::Pubkey>,
218    token_record: Option<solana_program::pubkey::Pubkey>,
219    mint: Option<solana_program::pubkey::Pubkey>,
220    token: Option<solana_program::pubkey::Pubkey>,
221    authority: Option<solana_program::pubkey::Pubkey>,
222    payer: Option<solana_program::pubkey::Pubkey>,
223    system_program: Option<solana_program::pubkey::Pubkey>,
224    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
225    spl_token_program: Option<solana_program::pubkey::Pubkey>,
226    authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
227    authorization_rules: Option<solana_program::pubkey::Pubkey>,
228    authorization_data: Option<AuthorizationData>,
229    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
230}
231
232impl DelegateCollectionItemV1Builder {
233    pub fn new() -> Self {
234        Self::default()
235    }
236    /// `[optional account]`
237    /// Delegate record account
238    #[inline(always)]
239    pub fn delegate_record(
240        &mut self,
241        delegate_record: Option<solana_program::pubkey::Pubkey>,
242    ) -> &mut Self {
243        self.delegate_record = delegate_record;
244        self
245    }
246    /// Owner of the delegated account
247    #[inline(always)]
248    pub fn delegate(&mut self, delegate: solana_program::pubkey::Pubkey) -> &mut Self {
249        self.delegate = Some(delegate);
250        self
251    }
252    /// Metadata account
253    #[inline(always)]
254    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
255        self.metadata = Some(metadata);
256        self
257    }
258    /// `[optional account]`
259    /// Master Edition account
260    #[inline(always)]
261    pub fn master_edition(
262        &mut self,
263        master_edition: Option<solana_program::pubkey::Pubkey>,
264    ) -> &mut Self {
265        self.master_edition = master_edition;
266        self
267    }
268    /// `[optional account]`
269    /// Token record account
270    #[inline(always)]
271    pub fn token_record(
272        &mut self,
273        token_record: Option<solana_program::pubkey::Pubkey>,
274    ) -> &mut Self {
275        self.token_record = token_record;
276        self
277    }
278    /// Mint of metadata
279    #[inline(always)]
280    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
281        self.mint = Some(mint);
282        self
283    }
284    /// `[optional account]`
285    /// Token account of mint
286    #[inline(always)]
287    pub fn token(&mut self, token: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
288        self.token = token;
289        self
290    }
291    /// Update authority or token owner
292    #[inline(always)]
293    pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self {
294        self.authority = Some(authority);
295        self
296    }
297    /// Payer
298    #[inline(always)]
299    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
300        self.payer = Some(payer);
301        self
302    }
303    /// `[optional account, default to '11111111111111111111111111111111']`
304    /// System Program
305    #[inline(always)]
306    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
307        self.system_program = Some(system_program);
308        self
309    }
310    /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']`
311    /// Instructions sysvar account
312    #[inline(always)]
313    pub fn sysvar_instructions(
314        &mut self,
315        sysvar_instructions: solana_program::pubkey::Pubkey,
316    ) -> &mut Self {
317        self.sysvar_instructions = Some(sysvar_instructions);
318        self
319    }
320    /// `[optional account]`
321    /// SPL Token Program
322    #[inline(always)]
323    pub fn spl_token_program(
324        &mut self,
325        spl_token_program: Option<solana_program::pubkey::Pubkey>,
326    ) -> &mut Self {
327        self.spl_token_program = spl_token_program;
328        self
329    }
330    /// `[optional account]`
331    /// Token Authorization Rules Program
332    #[inline(always)]
333    pub fn authorization_rules_program(
334        &mut self,
335        authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
336    ) -> &mut Self {
337        self.authorization_rules_program = authorization_rules_program;
338        self
339    }
340    /// `[optional account]`
341    /// Token Authorization Rules account
342    #[inline(always)]
343    pub fn authorization_rules(
344        &mut self,
345        authorization_rules: Option<solana_program::pubkey::Pubkey>,
346    ) -> &mut Self {
347        self.authorization_rules = authorization_rules;
348        self
349    }
350    /// `[optional argument]`
351    #[inline(always)]
352    pub fn authorization_data(&mut self, authorization_data: AuthorizationData) -> &mut Self {
353        self.authorization_data = Some(authorization_data);
354        self
355    }
356    /// Add an aditional account to the instruction.
357    #[inline(always)]
358    pub fn add_remaining_account(
359        &mut self,
360        account: solana_program::instruction::AccountMeta,
361    ) -> &mut Self {
362        self.__remaining_accounts.push(account);
363        self
364    }
365    /// Add additional accounts to the instruction.
366    #[inline(always)]
367    pub fn add_remaining_accounts(
368        &mut self,
369        accounts: &[solana_program::instruction::AccountMeta],
370    ) -> &mut Self {
371        self.__remaining_accounts.extend_from_slice(accounts);
372        self
373    }
374    #[allow(clippy::clone_on_copy)]
375    pub fn instruction(&self) -> solana_program::instruction::Instruction {
376        let accounts = DelegateCollectionItemV1 {
377            delegate_record: self.delegate_record,
378            delegate: self.delegate.expect("delegate is not set"),
379            metadata: self.metadata.expect("metadata is not set"),
380            master_edition: self.master_edition,
381            token_record: self.token_record,
382            mint: self.mint.expect("mint is not set"),
383            token: self.token,
384            authority: self.authority.expect("authority is not set"),
385            payer: self.payer.expect("payer is not set"),
386            system_program: self
387                .system_program
388                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
389            sysvar_instructions: self.sysvar_instructions.unwrap_or(solana_program::pubkey!(
390                "Sysvar1nstructions1111111111111111111111111"
391            )),
392            spl_token_program: self.spl_token_program,
393            authorization_rules_program: self.authorization_rules_program,
394            authorization_rules: self.authorization_rules,
395        };
396        let args = DelegateCollectionItemV1InstructionArgs {
397            authorization_data: self.authorization_data.clone(),
398        };
399
400        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
401    }
402}
403
404/// `delegate_collection_item_v1` CPI accounts.
405pub struct DelegateCollectionItemV1CpiAccounts<'a, 'b> {
406    /// Delegate record account
407    pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
408    /// Owner of the delegated account
409    pub delegate: &'b solana_program::account_info::AccountInfo<'a>,
410    /// Metadata account
411    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
412    /// Master Edition account
413    pub master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
414    /// Token record account
415    pub token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
416    /// Mint of metadata
417    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
418    /// Token account of mint
419    pub token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
420    /// Update authority or token owner
421    pub authority: &'b solana_program::account_info::AccountInfo<'a>,
422    /// Payer
423    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
424    /// System Program
425    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
426    /// Instructions sysvar account
427    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
428    /// SPL Token Program
429    pub spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
430    /// Token Authorization Rules Program
431    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
432    /// Token Authorization Rules account
433    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
434}
435
436/// `delegate_collection_item_v1` CPI instruction.
437pub struct DelegateCollectionItemV1Cpi<'a, 'b> {
438    /// The program to invoke.
439    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
440    /// Delegate record account
441    pub delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
442    /// Owner of the delegated account
443    pub delegate: &'b solana_program::account_info::AccountInfo<'a>,
444    /// Metadata account
445    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
446    /// Master Edition account
447    pub master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
448    /// Token record account
449    pub token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
450    /// Mint of metadata
451    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
452    /// Token account of mint
453    pub token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
454    /// Update authority or token owner
455    pub authority: &'b solana_program::account_info::AccountInfo<'a>,
456    /// Payer
457    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
458    /// System Program
459    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
460    /// Instructions sysvar account
461    pub sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
462    /// SPL Token Program
463    pub spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
464    /// Token Authorization Rules Program
465    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
466    /// Token Authorization Rules account
467    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
468    /// The arguments for the instruction.
469    pub __args: DelegateCollectionItemV1InstructionArgs,
470}
471
472impl<'a, 'b> DelegateCollectionItemV1Cpi<'a, 'b> {
473    pub fn new(
474        program: &'b solana_program::account_info::AccountInfo<'a>,
475        accounts: DelegateCollectionItemV1CpiAccounts<'a, 'b>,
476        args: DelegateCollectionItemV1InstructionArgs,
477    ) -> Self {
478        Self {
479            __program: program,
480            delegate_record: accounts.delegate_record,
481            delegate: accounts.delegate,
482            metadata: accounts.metadata,
483            master_edition: accounts.master_edition,
484            token_record: accounts.token_record,
485            mint: accounts.mint,
486            token: accounts.token,
487            authority: accounts.authority,
488            payer: accounts.payer,
489            system_program: accounts.system_program,
490            sysvar_instructions: accounts.sysvar_instructions,
491            spl_token_program: accounts.spl_token_program,
492            authorization_rules_program: accounts.authorization_rules_program,
493            authorization_rules: accounts.authorization_rules,
494            __args: args,
495        }
496    }
497    #[inline(always)]
498    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
499        self.invoke_signed_with_remaining_accounts(&[], &[])
500    }
501    #[inline(always)]
502    pub fn invoke_with_remaining_accounts(
503        &self,
504        remaining_accounts: &[(
505            &'b solana_program::account_info::AccountInfo<'a>,
506            bool,
507            bool,
508        )],
509    ) -> solana_program::entrypoint::ProgramResult {
510        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
511    }
512    #[inline(always)]
513    pub fn invoke_signed(
514        &self,
515        signers_seeds: &[&[&[u8]]],
516    ) -> solana_program::entrypoint::ProgramResult {
517        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
518    }
519    #[allow(clippy::clone_on_copy)]
520    #[allow(clippy::vec_init_then_push)]
521    pub fn invoke_signed_with_remaining_accounts(
522        &self,
523        signers_seeds: &[&[&[u8]]],
524        remaining_accounts: &[(
525            &'b solana_program::account_info::AccountInfo<'a>,
526            bool,
527            bool,
528        )],
529    ) -> solana_program::entrypoint::ProgramResult {
530        let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
531        if let Some(delegate_record) = self.delegate_record {
532            accounts.push(solana_program::instruction::AccountMeta::new(
533                *delegate_record.key,
534                false,
535            ));
536        } else {
537            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
538                crate::MPL_TOKEN_METADATA_ID,
539                false,
540            ));
541        }
542        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
543            *self.delegate.key,
544            false,
545        ));
546        accounts.push(solana_program::instruction::AccountMeta::new(
547            *self.metadata.key,
548            false,
549        ));
550        if let Some(master_edition) = self.master_edition {
551            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
552                *master_edition.key,
553                false,
554            ));
555        } else {
556            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
557                crate::MPL_TOKEN_METADATA_ID,
558                false,
559            ));
560        }
561        if let Some(token_record) = self.token_record {
562            accounts.push(solana_program::instruction::AccountMeta::new(
563                *token_record.key,
564                false,
565            ));
566        } else {
567            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
568                crate::MPL_TOKEN_METADATA_ID,
569                false,
570            ));
571        }
572        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
573            *self.mint.key,
574            false,
575        ));
576        if let Some(token) = self.token {
577            accounts.push(solana_program::instruction::AccountMeta::new(
578                *token.key, false,
579            ));
580        } else {
581            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
582                crate::MPL_TOKEN_METADATA_ID,
583                false,
584            ));
585        }
586        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
587            *self.authority.key,
588            true,
589        ));
590        accounts.push(solana_program::instruction::AccountMeta::new(
591            *self.payer.key,
592            true,
593        ));
594        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
595            *self.system_program.key,
596            false,
597        ));
598        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
599            *self.sysvar_instructions.key,
600            false,
601        ));
602        if let Some(spl_token_program) = self.spl_token_program {
603            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
604                *spl_token_program.key,
605                false,
606            ));
607        } else {
608            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
609                crate::MPL_TOKEN_METADATA_ID,
610                false,
611            ));
612        }
613        if let Some(authorization_rules_program) = self.authorization_rules_program {
614            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
615                *authorization_rules_program.key,
616                false,
617            ));
618        } else {
619            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
620                crate::MPL_TOKEN_METADATA_ID,
621                false,
622            ));
623        }
624        if let Some(authorization_rules) = self.authorization_rules {
625            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
626                *authorization_rules.key,
627                false,
628            ));
629        } else {
630            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
631                crate::MPL_TOKEN_METADATA_ID,
632                false,
633            ));
634        }
635        remaining_accounts.iter().for_each(|remaining_account| {
636            accounts.push(solana_program::instruction::AccountMeta {
637                pubkey: *remaining_account.0.key,
638                is_signer: remaining_account.1,
639                is_writable: remaining_account.2,
640            })
641        });
642        let mut data = DelegateCollectionItemV1InstructionData::new()
643            .try_to_vec()
644            .unwrap();
645        let mut args = self.__args.try_to_vec().unwrap();
646        data.append(&mut args);
647
648        let instruction = solana_program::instruction::Instruction {
649            program_id: crate::MPL_TOKEN_METADATA_ID,
650            accounts,
651            data,
652        };
653        let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len());
654        account_infos.push(self.__program.clone());
655        if let Some(delegate_record) = self.delegate_record {
656            account_infos.push(delegate_record.clone());
657        }
658        account_infos.push(self.delegate.clone());
659        account_infos.push(self.metadata.clone());
660        if let Some(master_edition) = self.master_edition {
661            account_infos.push(master_edition.clone());
662        }
663        if let Some(token_record) = self.token_record {
664            account_infos.push(token_record.clone());
665        }
666        account_infos.push(self.mint.clone());
667        if let Some(token) = self.token {
668            account_infos.push(token.clone());
669        }
670        account_infos.push(self.authority.clone());
671        account_infos.push(self.payer.clone());
672        account_infos.push(self.system_program.clone());
673        account_infos.push(self.sysvar_instructions.clone());
674        if let Some(spl_token_program) = self.spl_token_program {
675            account_infos.push(spl_token_program.clone());
676        }
677        if let Some(authorization_rules_program) = self.authorization_rules_program {
678            account_infos.push(authorization_rules_program.clone());
679        }
680        if let Some(authorization_rules) = self.authorization_rules {
681            account_infos.push(authorization_rules.clone());
682        }
683        remaining_accounts
684            .iter()
685            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
686
687        if signers_seeds.is_empty() {
688            solana_program::program::invoke(&instruction, &account_infos)
689        } else {
690            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
691        }
692    }
693}
694
695/// Instruction builder for `DelegateCollectionItemV1` via CPI.
696///
697/// ### Accounts:
698///
699///   0. `[writable, optional]` delegate_record
700///   1. `[]` delegate
701///   2. `[writable]` metadata
702///   3. `[optional]` master_edition
703///   4. `[writable, optional]` token_record
704///   5. `[]` mint
705///   6. `[writable, optional]` token
706///   7. `[signer]` authority
707///   8. `[writable, signer]` payer
708///   9. `[]` system_program
709///   10. `[]` sysvar_instructions
710///   11. `[optional]` spl_token_program
711///   12. `[optional]` authorization_rules_program
712///   13. `[optional]` authorization_rules
713pub struct DelegateCollectionItemV1CpiBuilder<'a, 'b> {
714    instruction: Box<DelegateCollectionItemV1CpiBuilderInstruction<'a, 'b>>,
715}
716
717impl<'a, 'b> DelegateCollectionItemV1CpiBuilder<'a, 'b> {
718    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
719        let instruction = Box::new(DelegateCollectionItemV1CpiBuilderInstruction {
720            __program: program,
721            delegate_record: None,
722            delegate: None,
723            metadata: None,
724            master_edition: None,
725            token_record: None,
726            mint: None,
727            token: None,
728            authority: None,
729            payer: None,
730            system_program: None,
731            sysvar_instructions: None,
732            spl_token_program: None,
733            authorization_rules_program: None,
734            authorization_rules: None,
735            authorization_data: None,
736            __remaining_accounts: Vec::new(),
737        });
738        Self { instruction }
739    }
740    /// `[optional account]`
741    /// Delegate record account
742    #[inline(always)]
743    pub fn delegate_record(
744        &mut self,
745        delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
746    ) -> &mut Self {
747        self.instruction.delegate_record = delegate_record;
748        self
749    }
750    /// Owner of the delegated account
751    #[inline(always)]
752    pub fn delegate(
753        &mut self,
754        delegate: &'b solana_program::account_info::AccountInfo<'a>,
755    ) -> &mut Self {
756        self.instruction.delegate = Some(delegate);
757        self
758    }
759    /// Metadata account
760    #[inline(always)]
761    pub fn metadata(
762        &mut self,
763        metadata: &'b solana_program::account_info::AccountInfo<'a>,
764    ) -> &mut Self {
765        self.instruction.metadata = Some(metadata);
766        self
767    }
768    /// `[optional account]`
769    /// Master Edition account
770    #[inline(always)]
771    pub fn master_edition(
772        &mut self,
773        master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
774    ) -> &mut Self {
775        self.instruction.master_edition = master_edition;
776        self
777    }
778    /// `[optional account]`
779    /// Token record account
780    #[inline(always)]
781    pub fn token_record(
782        &mut self,
783        token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
784    ) -> &mut Self {
785        self.instruction.token_record = token_record;
786        self
787    }
788    /// Mint of metadata
789    #[inline(always)]
790    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
791        self.instruction.mint = Some(mint);
792        self
793    }
794    /// `[optional account]`
795    /// Token account of mint
796    #[inline(always)]
797    pub fn token(
798        &mut self,
799        token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
800    ) -> &mut Self {
801        self.instruction.token = token;
802        self
803    }
804    /// Update authority or token owner
805    #[inline(always)]
806    pub fn authority(
807        &mut self,
808        authority: &'b solana_program::account_info::AccountInfo<'a>,
809    ) -> &mut Self {
810        self.instruction.authority = Some(authority);
811        self
812    }
813    /// Payer
814    #[inline(always)]
815    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
816        self.instruction.payer = Some(payer);
817        self
818    }
819    /// System Program
820    #[inline(always)]
821    pub fn system_program(
822        &mut self,
823        system_program: &'b solana_program::account_info::AccountInfo<'a>,
824    ) -> &mut Self {
825        self.instruction.system_program = Some(system_program);
826        self
827    }
828    /// Instructions sysvar account
829    #[inline(always)]
830    pub fn sysvar_instructions(
831        &mut self,
832        sysvar_instructions: &'b solana_program::account_info::AccountInfo<'a>,
833    ) -> &mut Self {
834        self.instruction.sysvar_instructions = Some(sysvar_instructions);
835        self
836    }
837    /// `[optional account]`
838    /// SPL Token Program
839    #[inline(always)]
840    pub fn spl_token_program(
841        &mut self,
842        spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
843    ) -> &mut Self {
844        self.instruction.spl_token_program = spl_token_program;
845        self
846    }
847    /// `[optional account]`
848    /// Token Authorization Rules Program
849    #[inline(always)]
850    pub fn authorization_rules_program(
851        &mut self,
852        authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
853    ) -> &mut Self {
854        self.instruction.authorization_rules_program = authorization_rules_program;
855        self
856    }
857    /// `[optional account]`
858    /// Token Authorization Rules account
859    #[inline(always)]
860    pub fn authorization_rules(
861        &mut self,
862        authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
863    ) -> &mut Self {
864        self.instruction.authorization_rules = authorization_rules;
865        self
866    }
867    /// `[optional argument]`
868    #[inline(always)]
869    pub fn authorization_data(&mut self, authorization_data: AuthorizationData) -> &mut Self {
870        self.instruction.authorization_data = Some(authorization_data);
871        self
872    }
873    /// Add an additional account to the instruction.
874    #[inline(always)]
875    pub fn add_remaining_account(
876        &mut self,
877        account: &'b solana_program::account_info::AccountInfo<'a>,
878        is_writable: bool,
879        is_signer: bool,
880    ) -> &mut Self {
881        self.instruction
882            .__remaining_accounts
883            .push((account, is_writable, is_signer));
884        self
885    }
886    /// Add additional accounts to the instruction.
887    ///
888    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
889    /// and a `bool` indicating whether the account is a signer or not.
890    #[inline(always)]
891    pub fn add_remaining_accounts(
892        &mut self,
893        accounts: &[(
894            &'b solana_program::account_info::AccountInfo<'a>,
895            bool,
896            bool,
897        )],
898    ) -> &mut Self {
899        self.instruction
900            .__remaining_accounts
901            .extend_from_slice(accounts);
902        self
903    }
904    #[inline(always)]
905    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
906        self.invoke_signed(&[])
907    }
908    #[allow(clippy::clone_on_copy)]
909    #[allow(clippy::vec_init_then_push)]
910    pub fn invoke_signed(
911        &self,
912        signers_seeds: &[&[&[u8]]],
913    ) -> solana_program::entrypoint::ProgramResult {
914        let args = DelegateCollectionItemV1InstructionArgs {
915            authorization_data: self.instruction.authorization_data.clone(),
916        };
917        let instruction = DelegateCollectionItemV1Cpi {
918            __program: self.instruction.__program,
919
920            delegate_record: self.instruction.delegate_record,
921
922            delegate: self.instruction.delegate.expect("delegate is not set"),
923
924            metadata: self.instruction.metadata.expect("metadata is not set"),
925
926            master_edition: self.instruction.master_edition,
927
928            token_record: self.instruction.token_record,
929
930            mint: self.instruction.mint.expect("mint is not set"),
931
932            token: self.instruction.token,
933
934            authority: self.instruction.authority.expect("authority is not set"),
935
936            payer: self.instruction.payer.expect("payer is not set"),
937
938            system_program: self
939                .instruction
940                .system_program
941                .expect("system_program is not set"),
942
943            sysvar_instructions: self
944                .instruction
945                .sysvar_instructions
946                .expect("sysvar_instructions is not set"),
947
948            spl_token_program: self.instruction.spl_token_program,
949
950            authorization_rules_program: self.instruction.authorization_rules_program,
951
952            authorization_rules: self.instruction.authorization_rules,
953            __args: args,
954        };
955        instruction.invoke_signed_with_remaining_accounts(
956            signers_seeds,
957            &self.instruction.__remaining_accounts,
958        )
959    }
960}
961
962struct DelegateCollectionItemV1CpiBuilderInstruction<'a, 'b> {
963    __program: &'b solana_program::account_info::AccountInfo<'a>,
964    delegate_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
965    delegate: Option<&'b solana_program::account_info::AccountInfo<'a>>,
966    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
967    master_edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
968    token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
969    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
970    token: Option<&'b solana_program::account_info::AccountInfo<'a>>,
971    authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
972    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
973    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
974    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
975    spl_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
976    authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
977    authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
978    authorization_data: Option<AuthorizationData>,
979    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
980    __remaining_accounts: Vec<(
981        &'b solana_program::account_info::AccountInfo<'a>,
982        bool,
983        bool,
984    )>,
985}