Skip to main content

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