Skip to main content

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