Skip to main content

carbon_token_program_decoder/accounts/
token.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {crate::types::AccountState, solana_pubkey::Pubkey};
3
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
6pub struct Token {
7    /// The mint associated with this account.
8    pub mint: Pubkey,
9    /// The owner of this account.
10    pub owner: Pubkey,
11    /// The amount of tokens this account holds.
12    pub amount: u64,
13    /// If `delegate` is `Some` then `delegated_amount` represents
14    /// the amount authorized by the delegate.
15    pub delegate: Option<Pubkey>,
16    /// The account's state.
17    pub state: AccountState,
18    /// If is_native.is_some, this is a native token, and the value logs the
19    /// rent-exempt reserve. An Account is required to be rent-exempt, so
20    /// the value is used by the Processor to ensure that wrapped SOL
21    /// accounts do not drop below this threshold.
22    pub is_native: Option<u64>,
23    /// The amount delegated.
24    pub delegated_amount: u64,
25    /// Optional authority to close the account.
26    pub close_authority: Option<Pubkey>,
27}
28
29impl Token {
30    pub fn decode(data: &[u8]) -> Option<Self> {
31        if data.len() != 165 {
32            return None;
33        }
34
35        let mut data_slice = data;
36
37        data_slice = &data_slice[0..];
38
39        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
40    }
41}