Skip to main content

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