Skip to main content

carbon_token_program_decoder/instructions/
mint_to.rs

1//! This code was AUTOGENERATED using the Codama library.
2use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3/// Mints new tokens to an account. The native mint does not support minting.
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
6pub struct MintTo {
7    /// The amount of new tokens to mint.
8    pub amount: u64,
9}
10
11#[derive(Debug, Clone, PartialEq)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13pub struct MintToInstructionAccounts {
14    pub mint: solana_pubkey::Pubkey,
15    pub token: solana_pubkey::Pubkey,
16    pub mint_authority: solana_pubkey::Pubkey,
17    pub remaining: Vec<solana_instruction::AccountMeta>,
18}
19
20impl MintTo {
21    pub fn decode(data: &[u8]) -> Option<Self> {
22        if data.is_empty() {
23            return None;
24        }
25        let discriminator = &data[0..1];
26        if discriminator != [7] {
27            return None;
28        }
29
30        let mut data_slice = data;
31
32        data_slice = &data_slice[1..];
33
34        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
35    }
36}
37
38impl ArrangeAccounts for MintTo {
39    type ArrangedAccounts = MintToInstructionAccounts;
40
41    fn arrange_accounts(
42        accounts: &[solana_instruction::AccountMeta],
43    ) -> Option<Self::ArrangedAccounts> {
44        let mut iter = accounts.iter();
45
46        let mint = next_account(&mut iter)?;
47        let token = next_account(&mut iter)?;
48        let mint_authority = next_account(&mut iter)?;
49
50        let remaining = iter.as_slice();
51
52        Some(MintToInstructionAccounts {
53            mint,
54            token,
55            mint_authority,
56            remaining: remaining.to_vec(),
57        })
58    }
59}