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