Trait orml_traits::currency::BasicCurrency
source · pub trait BasicCurrency<AccountId> {
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + MaxEncodedLen;
// Required methods
fn minimum_balance() -> Self::Balance;
fn total_issuance() -> Self::Balance;
fn total_balance(who: &AccountId) -> Self::Balance;
fn free_balance(who: &AccountId) -> Self::Balance;
fn ensure_can_withdraw(
who: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn transfer(
from: &AccountId,
to: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn deposit(who: &AccountId, amount: Self::Balance) -> DispatchResult;
fn withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult;
fn can_slash(who: &AccountId, value: Self::Balance) -> bool;
fn slash(who: &AccountId, amount: Self::Balance) -> Self::Balance;
}Expand description
Abstraction over a fungible (single) currency system.
Required Associated Types§
sourcetype Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + MaxEncodedLen
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + MaxEncodedLen
The balance of an account.
Required Methods§
sourcefn minimum_balance() -> Self::Balance
fn minimum_balance() -> Self::Balance
Existential deposit.
sourcefn total_issuance() -> Self::Balance
fn total_issuance() -> Self::Balance
The total amount of issuance.
sourcefn total_balance(who: &AccountId) -> Self::Balance
fn total_balance(who: &AccountId) -> Self::Balance
The combined balance of who.
sourcefn free_balance(who: &AccountId) -> Self::Balance
fn free_balance(who: &AccountId) -> Self::Balance
The free balance of who.
sourcefn ensure_can_withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult
fn ensure_can_withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult
A dry-run of withdraw. Returns Ok iff the account is able to make a
withdrawal of the given amount.
sourcefn transfer(
from: &AccountId,
to: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn transfer( from: &AccountId, to: &AccountId, amount: Self::Balance ) -> DispatchResult
Transfer some amount from one account to another.
sourcefn deposit(who: &AccountId, amount: Self::Balance) -> DispatchResult
fn deposit(who: &AccountId, amount: Self::Balance) -> DispatchResult
Add amount to the balance of who and increase total issuance.
sourcefn withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult
fn withdraw(who: &AccountId, amount: Self::Balance) -> DispatchResult
Remove amount from the balance of who and reduce total issuance.
sourcefn can_slash(who: &AccountId, value: Self::Balance) -> bool
fn can_slash(who: &AccountId, value: Self::Balance) -> bool
Same result as slash(who, value) (but without the side-effects)
assuming there are no balance changes in the meantime and only the
reserved balance is not taken into account.
sourcefn slash(who: &AccountId, amount: Self::Balance) -> Self::Balance
fn slash(who: &AccountId, amount: Self::Balance) -> Self::Balance
Deduct the balance of who by up to amount.
As much funds up to amount will be deducted as possible. If this is
less than amount, then a non-zero excess value will be returned.