Trait orml_traits::currency::BasicCurrency [−][src]
pub trait BasicCurrency<AccountId> {
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
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.
Associated Types
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default
The balance of an account.
Required methods
fn minimum_balance() -> Self::Balance
fn minimum_balance() -> Self::Balance
Existential deposit.
fn total_issuance() -> Self::Balance
fn total_issuance() -> Self::Balance
The total amount of issuance.
fn total_balance(who: &AccountId) -> Self::Balance
fn total_balance(who: &AccountId) -> Self::Balance
The combined balance of who
.
fn free_balance(who: &AccountId) -> Self::Balance
fn free_balance(who: &AccountId) -> Self::Balance
The free balance of who
.
fn 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.
Transfer some amount from one account to another.
fn 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.
fn 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.
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.