orca_wavebreak/generated/instructions/
mint_config_update.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use crate::generated::types::MintConfigUpdateType;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub const MINT_CONFIG_UPDATE_DISCRIMINATOR: u8 = 26;
13
14/// Accounts.
15#[derive(Debug)]
16pub struct MintConfigUpdate {
17    /// The authority that is allowed to update a mint config
18    pub authority: solana_pubkey::Pubkey,
19    /// The mint config account
20    pub mint_config: solana_pubkey::Pubkey,
21    /// The authority config account
22    pub authority_config: solana_pubkey::Pubkey,
23}
24
25impl MintConfigUpdate {
26    pub fn instruction(
27        &self,
28        args: MintConfigUpdateInstructionArgs,
29    ) -> solana_instruction::Instruction {
30        self.instruction_with_remaining_accounts(args, &[])
31    }
32    #[allow(clippy::arithmetic_side_effects)]
33    #[allow(clippy::vec_init_then_push)]
34    pub fn instruction_with_remaining_accounts(
35        &self,
36        args: MintConfigUpdateInstructionArgs,
37        remaining_accounts: &[solana_instruction::AccountMeta],
38    ) -> solana_instruction::Instruction {
39        let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
40        accounts.push(solana_instruction::AccountMeta::new_readonly(
41            self.authority,
42            true,
43        ));
44        accounts.push(solana_instruction::AccountMeta::new(
45            self.mint_config,
46            false,
47        ));
48        accounts.push(solana_instruction::AccountMeta::new_readonly(
49            self.authority_config,
50            false,
51        ));
52        accounts.extend_from_slice(remaining_accounts);
53        let mut data = borsh::to_vec(&MintConfigUpdateInstructionData::new()).unwrap();
54        let mut args = borsh::to_vec(&args).unwrap();
55        data.append(&mut args);
56
57        solana_instruction::Instruction {
58            program_id: crate::WAVEBREAK_ID,
59            accounts,
60            data,
61        }
62    }
63}
64
65#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
66#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
67pub struct MintConfigUpdateInstructionData {
68    discriminator: u8,
69}
70
71impl MintConfigUpdateInstructionData {
72    pub fn new() -> Self {
73        Self { discriminator: 26 }
74    }
75}
76
77impl Default for MintConfigUpdateInstructionData {
78    fn default() -> Self {
79        Self::new()
80    }
81}
82
83#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
84#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
85pub struct MintConfigUpdateInstructionArgs {
86    pub update: MintConfigUpdateType,
87}
88
89/// Instruction builder for `MintConfigUpdate`.
90///
91/// ### Accounts:
92///
93///   0. `[signer]` authority
94///   1. `[writable]` mint_config
95///   2. `[]` authority_config
96#[derive(Clone, Debug, Default)]
97pub struct MintConfigUpdateBuilder {
98    authority: Option<solana_pubkey::Pubkey>,
99    mint_config: Option<solana_pubkey::Pubkey>,
100    authority_config: Option<solana_pubkey::Pubkey>,
101    update: Option<MintConfigUpdateType>,
102    __remaining_accounts: Vec<solana_instruction::AccountMeta>,
103}
104
105impl MintConfigUpdateBuilder {
106    pub fn new() -> Self {
107        Self::default()
108    }
109    /// The authority that is allowed to update a mint config
110    #[inline(always)]
111    pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
112        self.authority = Some(authority);
113        self
114    }
115    /// The mint config account
116    #[inline(always)]
117    pub fn mint_config(&mut self, mint_config: solana_pubkey::Pubkey) -> &mut Self {
118        self.mint_config = Some(mint_config);
119        self
120    }
121    /// The authority config account
122    #[inline(always)]
123    pub fn authority_config(&mut self, authority_config: solana_pubkey::Pubkey) -> &mut Self {
124        self.authority_config = Some(authority_config);
125        self
126    }
127    #[inline(always)]
128    pub fn update(&mut self, update: MintConfigUpdateType) -> &mut Self {
129        self.update = Some(update);
130        self
131    }
132    /// Add an additional account to the instruction.
133    #[inline(always)]
134    pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
135        self.__remaining_accounts.push(account);
136        self
137    }
138    /// Add additional accounts to the instruction.
139    #[inline(always)]
140    pub fn add_remaining_accounts(
141        &mut self,
142        accounts: &[solana_instruction::AccountMeta],
143    ) -> &mut Self {
144        self.__remaining_accounts.extend_from_slice(accounts);
145        self
146    }
147    #[allow(clippy::clone_on_copy)]
148    pub fn instruction(&self) -> solana_instruction::Instruction {
149        let accounts = MintConfigUpdate {
150            authority: self.authority.expect("authority is not set"),
151            mint_config: self.mint_config.expect("mint_config is not set"),
152            authority_config: self.authority_config.expect("authority_config is not set"),
153        };
154        let args = MintConfigUpdateInstructionArgs {
155            update: self.update.clone().expect("update is not set"),
156        };
157
158        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
159    }
160}
161
162/// `mint_config_update` CPI accounts.
163pub struct MintConfigUpdateCpiAccounts<'a, 'b> {
164    /// The authority that is allowed to update a mint config
165    pub authority: &'b solana_account_info::AccountInfo<'a>,
166    /// The mint config account
167    pub mint_config: &'b solana_account_info::AccountInfo<'a>,
168    /// The authority config account
169    pub authority_config: &'b solana_account_info::AccountInfo<'a>,
170}
171
172/// `mint_config_update` CPI instruction.
173pub struct MintConfigUpdateCpi<'a, 'b> {
174    /// The program to invoke.
175    pub __program: &'b solana_account_info::AccountInfo<'a>,
176    /// The authority that is allowed to update a mint config
177    pub authority: &'b solana_account_info::AccountInfo<'a>,
178    /// The mint config account
179    pub mint_config: &'b solana_account_info::AccountInfo<'a>,
180    /// The authority config account
181    pub authority_config: &'b solana_account_info::AccountInfo<'a>,
182    /// The arguments for the instruction.
183    pub __args: MintConfigUpdateInstructionArgs,
184}
185
186impl<'a, 'b> MintConfigUpdateCpi<'a, 'b> {
187    pub fn new(
188        program: &'b solana_account_info::AccountInfo<'a>,
189        accounts: MintConfigUpdateCpiAccounts<'a, 'b>,
190        args: MintConfigUpdateInstructionArgs,
191    ) -> Self {
192        Self {
193            __program: program,
194            authority: accounts.authority,
195            mint_config: accounts.mint_config,
196            authority_config: accounts.authority_config,
197            __args: args,
198        }
199    }
200    #[inline(always)]
201    pub fn invoke(&self) -> solana_program_error::ProgramResult {
202        self.invoke_signed_with_remaining_accounts(&[], &[])
203    }
204    #[inline(always)]
205    pub fn invoke_with_remaining_accounts(
206        &self,
207        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
208    ) -> solana_program_error::ProgramResult {
209        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
210    }
211    #[inline(always)]
212    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
213        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
214    }
215    #[allow(clippy::arithmetic_side_effects)]
216    #[allow(clippy::clone_on_copy)]
217    #[allow(clippy::vec_init_then_push)]
218    pub fn invoke_signed_with_remaining_accounts(
219        &self,
220        signers_seeds: &[&[&[u8]]],
221        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
222    ) -> solana_program_error::ProgramResult {
223        let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
224        accounts.push(solana_instruction::AccountMeta::new_readonly(
225            *self.authority.key,
226            true,
227        ));
228        accounts.push(solana_instruction::AccountMeta::new(
229            *self.mint_config.key,
230            false,
231        ));
232        accounts.push(solana_instruction::AccountMeta::new_readonly(
233            *self.authority_config.key,
234            false,
235        ));
236        remaining_accounts.iter().for_each(|remaining_account| {
237            accounts.push(solana_instruction::AccountMeta {
238                pubkey: *remaining_account.0.key,
239                is_signer: remaining_account.1,
240                is_writable: remaining_account.2,
241            })
242        });
243        let mut data = borsh::to_vec(&MintConfigUpdateInstructionData::new()).unwrap();
244        let mut args = borsh::to_vec(&self.__args).unwrap();
245        data.append(&mut args);
246
247        let instruction = solana_instruction::Instruction {
248            program_id: crate::WAVEBREAK_ID,
249            accounts,
250            data,
251        };
252        let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len());
253        account_infos.push(self.__program.clone());
254        account_infos.push(self.authority.clone());
255        account_infos.push(self.mint_config.clone());
256        account_infos.push(self.authority_config.clone());
257        remaining_accounts
258            .iter()
259            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
260
261        if signers_seeds.is_empty() {
262            solana_cpi::invoke(&instruction, &account_infos)
263        } else {
264            solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
265        }
266    }
267}
268
269/// Instruction builder for `MintConfigUpdate` via CPI.
270///
271/// ### Accounts:
272///
273///   0. `[signer]` authority
274///   1. `[writable]` mint_config
275///   2. `[]` authority_config
276#[derive(Clone, Debug)]
277pub struct MintConfigUpdateCpiBuilder<'a, 'b> {
278    instruction: Box<MintConfigUpdateCpiBuilderInstruction<'a, 'b>>,
279}
280
281impl<'a, 'b> MintConfigUpdateCpiBuilder<'a, 'b> {
282    pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
283        let instruction = Box::new(MintConfigUpdateCpiBuilderInstruction {
284            __program: program,
285            authority: None,
286            mint_config: None,
287            authority_config: None,
288            update: None,
289            __remaining_accounts: Vec::new(),
290        });
291        Self { instruction }
292    }
293    /// The authority that is allowed to update a mint config
294    #[inline(always)]
295    pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
296        self.instruction.authority = Some(authority);
297        self
298    }
299    /// The mint config account
300    #[inline(always)]
301    pub fn mint_config(
302        &mut self,
303        mint_config: &'b solana_account_info::AccountInfo<'a>,
304    ) -> &mut Self {
305        self.instruction.mint_config = Some(mint_config);
306        self
307    }
308    /// The authority config account
309    #[inline(always)]
310    pub fn authority_config(
311        &mut self,
312        authority_config: &'b solana_account_info::AccountInfo<'a>,
313    ) -> &mut Self {
314        self.instruction.authority_config = Some(authority_config);
315        self
316    }
317    #[inline(always)]
318    pub fn update(&mut self, update: MintConfigUpdateType) -> &mut Self {
319        self.instruction.update = Some(update);
320        self
321    }
322    /// Add an additional account to the instruction.
323    #[inline(always)]
324    pub fn add_remaining_account(
325        &mut self,
326        account: &'b solana_account_info::AccountInfo<'a>,
327        is_writable: bool,
328        is_signer: bool,
329    ) -> &mut Self {
330        self.instruction
331            .__remaining_accounts
332            .push((account, is_writable, is_signer));
333        self
334    }
335    /// Add additional accounts to the instruction.
336    ///
337    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
338    /// and a `bool` indicating whether the account is a signer or not.
339    #[inline(always)]
340    pub fn add_remaining_accounts(
341        &mut self,
342        accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
343    ) -> &mut Self {
344        self.instruction
345            .__remaining_accounts
346            .extend_from_slice(accounts);
347        self
348    }
349    #[inline(always)]
350    pub fn invoke(&self) -> solana_program_error::ProgramResult {
351        self.invoke_signed(&[])
352    }
353    #[allow(clippy::clone_on_copy)]
354    #[allow(clippy::vec_init_then_push)]
355    pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
356        let args = MintConfigUpdateInstructionArgs {
357            update: self.instruction.update.clone().expect("update is not set"),
358        };
359        let instruction = MintConfigUpdateCpi {
360            __program: self.instruction.__program,
361
362            authority: self.instruction.authority.expect("authority is not set"),
363
364            mint_config: self
365                .instruction
366                .mint_config
367                .expect("mint_config is not set"),
368
369            authority_config: self
370                .instruction
371                .authority_config
372                .expect("authority_config is not set"),
373            __args: args,
374        };
375        instruction.invoke_signed_with_remaining_accounts(
376            signers_seeds,
377            &self.instruction.__remaining_accounts,
378        )
379    }
380}
381
382#[derive(Clone, Debug)]
383struct MintConfigUpdateCpiBuilderInstruction<'a, 'b> {
384    __program: &'b solana_account_info::AccountInfo<'a>,
385    authority: Option<&'b solana_account_info::AccountInfo<'a>>,
386    mint_config: Option<&'b solana_account_info::AccountInfo<'a>>,
387    authority_config: Option<&'b solana_account_info::AccountInfo<'a>>,
388    update: Option<MintConfigUpdateType>,
389    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
390    __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
391}