Skip to main content

mpl_token_metadata/generated/instructions/
remove_creator_verification.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 borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11/// Accounts.
12pub struct RemoveCreatorVerification {
13    /// Metadata (pda of ['metadata', program id, mint id])
14    pub metadata: solana_program::pubkey::Pubkey,
15    /// Creator
16    pub creator: solana_program::pubkey::Pubkey,
17}
18
19impl RemoveCreatorVerification {
20    pub fn instruction(&self) -> solana_program::instruction::Instruction {
21        self.instruction_with_remaining_accounts(&[])
22    }
23    #[allow(clippy::vec_init_then_push)]
24    pub fn instruction_with_remaining_accounts(
25        &self,
26        remaining_accounts: &[solana_program::instruction::AccountMeta],
27    ) -> solana_program::instruction::Instruction {
28        let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
29        accounts.push(solana_program::instruction::AccountMeta::new(
30            self.metadata,
31            false,
32        ));
33        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
34            self.creator,
35            true,
36        ));
37        accounts.extend_from_slice(remaining_accounts);
38        let data = RemoveCreatorVerificationInstructionData::new()
39            .try_to_vec()
40            .unwrap();
41
42        solana_program::instruction::Instruction {
43            program_id: crate::MPL_TOKEN_METADATA_ID,
44            accounts,
45            data,
46        }
47    }
48}
49
50#[derive(BorshDeserialize, BorshSerialize)]
51struct RemoveCreatorVerificationInstructionData {
52    discriminator: u8,
53}
54
55impl RemoveCreatorVerificationInstructionData {
56    fn new() -> Self {
57        Self { discriminator: 28 }
58    }
59}
60
61/// Instruction builder for `RemoveCreatorVerification`.
62///
63/// ### Accounts:
64///
65///   0. `[writable]` metadata
66///   1. `[signer]` creator
67#[derive(Default)]
68pub struct RemoveCreatorVerificationBuilder {
69    metadata: Option<solana_program::pubkey::Pubkey>,
70    creator: Option<solana_program::pubkey::Pubkey>,
71    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
72}
73
74impl RemoveCreatorVerificationBuilder {
75    pub fn new() -> Self {
76        Self::default()
77    }
78    /// Metadata (pda of ['metadata', program id, mint id])
79    #[inline(always)]
80    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
81        self.metadata = Some(metadata);
82        self
83    }
84    /// Creator
85    #[inline(always)]
86    pub fn creator(&mut self, creator: solana_program::pubkey::Pubkey) -> &mut Self {
87        self.creator = Some(creator);
88        self
89    }
90    /// Add an aditional account to the instruction.
91    #[inline(always)]
92    pub fn add_remaining_account(
93        &mut self,
94        account: solana_program::instruction::AccountMeta,
95    ) -> &mut Self {
96        self.__remaining_accounts.push(account);
97        self
98    }
99    /// Add additional accounts to the instruction.
100    #[inline(always)]
101    pub fn add_remaining_accounts(
102        &mut self,
103        accounts: &[solana_program::instruction::AccountMeta],
104    ) -> &mut Self {
105        self.__remaining_accounts.extend_from_slice(accounts);
106        self
107    }
108    #[allow(clippy::clone_on_copy)]
109    pub fn instruction(&self) -> solana_program::instruction::Instruction {
110        let accounts = RemoveCreatorVerification {
111            metadata: self.metadata.expect("metadata is not set"),
112            creator: self.creator.expect("creator is not set"),
113        };
114
115        accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
116    }
117}
118
119/// `remove_creator_verification` CPI accounts.
120pub struct RemoveCreatorVerificationCpiAccounts<'a, 'b> {
121    /// Metadata (pda of ['metadata', program id, mint id])
122    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
123    /// Creator
124    pub creator: &'b solana_program::account_info::AccountInfo<'a>,
125}
126
127/// `remove_creator_verification` CPI instruction.
128pub struct RemoveCreatorVerificationCpi<'a, 'b> {
129    /// The program to invoke.
130    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
131    /// Metadata (pda of ['metadata', program id, mint id])
132    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
133    /// Creator
134    pub creator: &'b solana_program::account_info::AccountInfo<'a>,
135}
136
137impl<'a, 'b> RemoveCreatorVerificationCpi<'a, 'b> {
138    pub fn new(
139        program: &'b solana_program::account_info::AccountInfo<'a>,
140        accounts: RemoveCreatorVerificationCpiAccounts<'a, 'b>,
141    ) -> Self {
142        Self {
143            __program: program,
144            metadata: accounts.metadata,
145            creator: accounts.creator,
146        }
147    }
148    #[inline(always)]
149    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
150        self.invoke_signed_with_remaining_accounts(&[], &[])
151    }
152    #[inline(always)]
153    pub fn invoke_with_remaining_accounts(
154        &self,
155        remaining_accounts: &[(
156            &'b solana_program::account_info::AccountInfo<'a>,
157            bool,
158            bool,
159        )],
160    ) -> solana_program::entrypoint::ProgramResult {
161        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
162    }
163    #[inline(always)]
164    pub fn invoke_signed(
165        &self,
166        signers_seeds: &[&[&[u8]]],
167    ) -> solana_program::entrypoint::ProgramResult {
168        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
169    }
170    #[allow(clippy::clone_on_copy)]
171    #[allow(clippy::vec_init_then_push)]
172    pub fn invoke_signed_with_remaining_accounts(
173        &self,
174        signers_seeds: &[&[&[u8]]],
175        remaining_accounts: &[(
176            &'b solana_program::account_info::AccountInfo<'a>,
177            bool,
178            bool,
179        )],
180    ) -> solana_program::entrypoint::ProgramResult {
181        let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
182        accounts.push(solana_program::instruction::AccountMeta::new(
183            *self.metadata.key,
184            false,
185        ));
186        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
187            *self.creator.key,
188            true,
189        ));
190        remaining_accounts.iter().for_each(|remaining_account| {
191            accounts.push(solana_program::instruction::AccountMeta {
192                pubkey: *remaining_account.0.key,
193                is_signer: remaining_account.1,
194                is_writable: remaining_account.2,
195            })
196        });
197        let data = RemoveCreatorVerificationInstructionData::new()
198            .try_to_vec()
199            .unwrap();
200
201        let instruction = solana_program::instruction::Instruction {
202            program_id: crate::MPL_TOKEN_METADATA_ID,
203            accounts,
204            data,
205        };
206        let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len());
207        account_infos.push(self.__program.clone());
208        account_infos.push(self.metadata.clone());
209        account_infos.push(self.creator.clone());
210        remaining_accounts
211            .iter()
212            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
213
214        if signers_seeds.is_empty() {
215            solana_program::program::invoke(&instruction, &account_infos)
216        } else {
217            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
218        }
219    }
220}
221
222/// Instruction builder for `RemoveCreatorVerification` via CPI.
223///
224/// ### Accounts:
225///
226///   0. `[writable]` metadata
227///   1. `[signer]` creator
228pub struct RemoveCreatorVerificationCpiBuilder<'a, 'b> {
229    instruction: Box<RemoveCreatorVerificationCpiBuilderInstruction<'a, 'b>>,
230}
231
232impl<'a, 'b> RemoveCreatorVerificationCpiBuilder<'a, 'b> {
233    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
234        let instruction = Box::new(RemoveCreatorVerificationCpiBuilderInstruction {
235            __program: program,
236            metadata: None,
237            creator: None,
238            __remaining_accounts: Vec::new(),
239        });
240        Self { instruction }
241    }
242    /// Metadata (pda of ['metadata', program id, mint id])
243    #[inline(always)]
244    pub fn metadata(
245        &mut self,
246        metadata: &'b solana_program::account_info::AccountInfo<'a>,
247    ) -> &mut Self {
248        self.instruction.metadata = Some(metadata);
249        self
250    }
251    /// Creator
252    #[inline(always)]
253    pub fn creator(
254        &mut self,
255        creator: &'b solana_program::account_info::AccountInfo<'a>,
256    ) -> &mut Self {
257        self.instruction.creator = Some(creator);
258        self
259    }
260    /// Add an additional account to the instruction.
261    #[inline(always)]
262    pub fn add_remaining_account(
263        &mut self,
264        account: &'b solana_program::account_info::AccountInfo<'a>,
265        is_writable: bool,
266        is_signer: bool,
267    ) -> &mut Self {
268        self.instruction
269            .__remaining_accounts
270            .push((account, is_writable, is_signer));
271        self
272    }
273    /// Add additional accounts to the instruction.
274    ///
275    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
276    /// and a `bool` indicating whether the account is a signer or not.
277    #[inline(always)]
278    pub fn add_remaining_accounts(
279        &mut self,
280        accounts: &[(
281            &'b solana_program::account_info::AccountInfo<'a>,
282            bool,
283            bool,
284        )],
285    ) -> &mut Self {
286        self.instruction
287            .__remaining_accounts
288            .extend_from_slice(accounts);
289        self
290    }
291    #[inline(always)]
292    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
293        self.invoke_signed(&[])
294    }
295    #[allow(clippy::clone_on_copy)]
296    #[allow(clippy::vec_init_then_push)]
297    pub fn invoke_signed(
298        &self,
299        signers_seeds: &[&[&[u8]]],
300    ) -> solana_program::entrypoint::ProgramResult {
301        let instruction = RemoveCreatorVerificationCpi {
302            __program: self.instruction.__program,
303
304            metadata: self.instruction.metadata.expect("metadata is not set"),
305
306            creator: self.instruction.creator.expect("creator is not set"),
307        };
308        instruction.invoke_signed_with_remaining_accounts(
309            signers_seeds,
310            &self.instruction.__remaining_accounts,
311        )
312    }
313}
314
315struct RemoveCreatorVerificationCpiBuilderInstruction<'a, 'b> {
316    __program: &'b solana_program::account_info::AccountInfo<'a>,
317    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
318    creator: Option<&'b solana_program::account_info::AccountInfo<'a>>,
319    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
320    __remaining_accounts: Vec<(
321        &'b solana_program::account_info::AccountInfo<'a>,
322        bool,
323        bool,
324    )>,
325}