Skip to main content

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