Skip to main content

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