Skip to main content

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