Skip to main content

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