carbon_token_2022_decoder/instructions/
create_native_mint.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//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12
13/// Creates the native mint.
14///
15/// This instruction only needs to be invoked once after deployment and is
16/// permissionless. Wrapped SOL (`native_mint::id()`) will not be
17/// available until this instruction is successfully executed.
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
20pub struct CreateNativeMint {}
21
22#[derive(Debug, Clone, PartialEq)]
23#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
24pub struct CreateNativeMintInstructionAccounts {
25    pub payer: solana_pubkey::Pubkey,
26    pub native_mint: solana_pubkey::Pubkey,
27    pub system_program: solana_pubkey::Pubkey,
28    pub remaining: Vec<solana_instruction::AccountMeta>,
29}
30
31impl CreateNativeMint {
32    pub fn decode(data: &[u8]) -> Option<Self> {
33        if data.is_empty() {
34            return None;
35        }
36        let discriminator = &data[0..1];
37        if discriminator != [31] {
38            return None;
39        }
40
41        let data_slice = data;
42
43        let data_slice = &data_slice[1..];
44
45        Self::deserialize(data_slice)
46    }
47}
48
49impl ArrangeAccounts for CreateNativeMint {
50    type ArrangedAccounts = CreateNativeMintInstructionAccounts;
51
52    fn arrange_accounts(
53        accounts: &[solana_instruction::AccountMeta],
54    ) -> Option<Self::ArrangedAccounts> {
55        let mut iter = accounts.iter();
56
57        let payer = next_account(&mut iter)?;
58        let native_mint = next_account(&mut iter)?;
59        let system_program = next_account(&mut iter)?;
60
61        let remaining = iter.as_slice();
62
63        Some(CreateNativeMintInstructionAccounts {
64            payer,
65            native_mint,
66            system_program,
67            remaining: remaining.to_vec(),
68        })
69    }
70}