carbon-token-program-decoder 1.0.0

Token Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use solana_pubkey::Pubkey;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct Mint {
    /// Optional authority used to mint new tokens. The mint authority may only
    /// be provided during mint creation. If no mint authority is present
    /// then the mint has a fixed supply and no further tokens may be minted.
    pub mint_authority: Option<Pubkey>,
    /// Total supply of tokens.
    pub supply: u64,
    /// Number of base 10 digits to the right of the decimal place.
    pub decimals: u8,
    /// Is `true` if this structure has been initialized.
    pub is_initialized: bool,
    /// Optional authority to freeze token accounts.
    pub freeze_authority: Option<Pubkey>,
}

impl Mint {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() != 82 {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[0..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}