carbon_token_2022_decoder/instructions/
mint_to.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/// Mints new tokens to an account. The native mint does not support minting.
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
16pub struct MintTo {
17    /// The amount of new tokens to mint.
18    pub amount: u64,
19}
20
21#[derive(Debug, Clone, PartialEq)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23pub struct MintToInstructionAccounts {
24    pub mint: solana_pubkey::Pubkey,
25    pub token: solana_pubkey::Pubkey,
26    pub mint_authority: solana_pubkey::Pubkey,
27    pub remaining: Vec<solana_instruction::AccountMeta>,
28}
29
30impl MintTo {
31    pub fn decode(data: &[u8]) -> Option<Self> {
32        if data.is_empty() {
33            return None;
34        }
35        let discriminator = &data[0..1];
36        if discriminator != [7] {
37            return None;
38        }
39
40        let data_slice = data;
41
42        let data_slice = &data_slice[1..];
43
44        Self::deserialize(data_slice)
45    }
46}
47
48impl ArrangeAccounts for MintTo {
49    type ArrangedAccounts = MintToInstructionAccounts;
50
51    fn arrange_accounts(
52        accounts: &[solana_instruction::AccountMeta],
53    ) -> Option<Self::ArrangedAccounts> {
54        let mut iter = accounts.iter();
55
56        let mint = next_account(&mut iter)?;
57        let token = next_account(&mut iter)?;
58        let mint_authority = next_account(&mut iter)?;
59
60        let remaining = iter.as_slice();
61
62        Some(MintToInstructionAccounts {
63            mint,
64            token,
65            mint_authority,
66            remaining: remaining.to_vec(),
67        })
68    }
69}