Struct light_compressed_token::token_data::TokenData
source · pub struct TokenData {
pub mint: Pubkey,
pub owner: Pubkey,
pub amount: u64,
pub delegate: Option<Pubkey>,
pub state: AccountState,
pub is_native: Option<u64>,
pub delegated_amount: u64,
}Fields§
§mint: PubkeyThe mint associated with this account
owner: PubkeyThe owner of this account.
amount: u64The amount of tokens this account holds.
delegate: Option<Pubkey>If delegate is Some then delegated_amount represents
the amount authorized by the delegate
state: AccountStateThe account’s state
is_native: Option<u64>If 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.
delegated_amount: u64The amount delegated
Implementations§
source§impl TokenData
impl TokenData
Hashing schema: H(mint, owner, amount, delegate, delegated_amount, is_native, state)
delegate, delegated_amount, is_native and state have dynamic positions. Always hash mint, owner and amount If delegate hash delegate and delegated_amount together. If is native hash is_native. If frozen hash is frozen.
Security: to prevent the possibility that different fields with the same value result in the same hash we add a prefix to the delegated amount, is native and state fields. This way we can have a dynamic hashing schema and hash only used values.
sourcepub fn hash_with_hashed_values<H: Hasher>(
mint: &[u8; 32],
owner: &[u8; 32],
amount_bytes: &[u8; 8],
native_amount: &Option<u64>
) -> Result<[u8; 32], HasherError>
pub fn hash_with_hashed_values<H: Hasher>( mint: &[u8; 32], owner: &[u8; 32], amount_bytes: &[u8; 8], native_amount: &Option<u64> ) -> Result<[u8; 32], HasherError>
We should not hash pubkeys multiple times. For all we can assume mints are equal. For all input compressed accounts we can assume owners are equal.
pub fn hash_with_delegate_hashed_values<H: Hasher>( mint: &[u8; 32], owner: &[u8; 32], amount_bytes: &[u8; 8], native_amount: Option<u64>, hashed_delegate: &[u8; 32], delegated_amount: &[u8; 8] ) -> Result<[u8; 32], HasherError>
Trait Implementations§
source§impl BorshDeserialize for TokenData
impl BorshDeserialize for TokenData
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSerialize for TokenDatawhere
Pubkey: BorshSerialize,
u64: BorshSerialize,
Option<Pubkey>: BorshSerialize,
AccountState: BorshSerialize,
Option<u64>: BorshSerialize,
impl BorshSerialize for TokenDatawhere
Pubkey: BorshSerialize,
u64: BorshSerialize,
Option<Pubkey>: BorshSerialize,
AccountState: BorshSerialize,
Option<u64>: BorshSerialize,
source§impl DataHasher for TokenData
impl DataHasher for TokenData
source§impl PartialEq for TokenData
impl PartialEq for TokenData
impl Copy for TokenData
impl Eq for TokenData
impl StructuralPartialEq for TokenData
Auto Trait Implementations§
impl Freeze for TokenData
impl RefUnwindSafe for TokenData
impl Send for TokenData
impl Sync for TokenData
impl Unpin for TokenData
impl UnwindSafe for TokenData
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more