Skip to main content

mpl_token_metadata/generated/instructions/
lock_v1.rs

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