pub struct WalletBalance {
pub native_currency: Option<Money>,
pub token_balances: Vec<TokenBalance>,
pub token_universe: HashSet<Address>,
}Expand description
Represents the complete balance state of a blockchain wallet.
Tracks both the native currency balance (e.g., ETH, ARB) and ERC-20 token
balances for a wallet address. The token_universe defines which tokens
should be tracked for balance fetching.
Fields§
§native_currency: Option<Money>The balance of the chain’s native currency
token_balances: Vec<TokenBalance>Collection of ERC-20 token balances held in the wallet.
token_universe: HashSet<Address>Set of token addresses to track for balance updates.
Implementations§
Source§impl WalletBalance
impl WalletBalance
Sourcepub const fn new(token_universe: HashSet<Address>) -> Self
pub const fn new(token_universe: HashSet<Address>) -> Self
Creates a new WalletBalance with the specified token universe.
Sourcepub fn is_token_universe_initialized(&self) -> bool
pub fn is_token_universe_initialized(&self) -> bool
Returns true if the token universe has been initialized with token addresses.
Sourcepub fn set_native_currency_balance(&mut self, balance: Money)
pub fn set_native_currency_balance(&mut self, balance: Money)
Sets the native currency balance for the wallet.
Sourcepub fn add_token_balance(&mut self, token_balance: TokenBalance)
pub fn add_token_balance(&mut self, token_balance: TokenBalance)
Adds an ERC-20 token balance to the wallet.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WalletBalance
impl RefUnwindSafe for WalletBalance
impl Send for WalletBalance
impl Sync for WalletBalance
impl Unpin for WalletBalance
impl UnwindSafe for WalletBalance
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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