Trait orml_traits::currency::MultiCurrency
source · pub trait MultiCurrency<AccountId> {
type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + TypeInfo + MaxEncodedLen;
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo + MaxEncodedLen;
fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance;
fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance;
fn total_balance(
currency_id: Self::CurrencyId,
who: &AccountId
) -> Self::Balance;
fn free_balance(
currency_id: Self::CurrencyId,
who: &AccountId
) -> Self::Balance;
fn ensure_can_withdraw(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn transfer(
currency_id: Self::CurrencyId,
from: &AccountId,
to: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn deposit(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn withdraw(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn can_slash(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> bool;
fn slash(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance;
}
Expand description
Abstraction over a fungible multi-currency system.
Required Associated Types§
sourcetype CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + TypeInfo + MaxEncodedLen
type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + TypeInfo + MaxEncodedLen
The currency identifier.
sourcetype Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo + MaxEncodedLen
type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + TypeInfo + MaxEncodedLen
The balance of an account.
Required Methods§
sourcefn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance
fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance
Existential deposit of currency_id
.
sourcefn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance
fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance
The total amount of issuance of currency_id
.
fn total_balance(currency_id: Self::CurrencyId, who: &AccountId) -> Self::Balance
fn free_balance(currency_id: Self::CurrencyId, who: &AccountId) -> Self::Balance
sourcefn ensure_can_withdraw(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn ensure_can_withdraw(
currency_id: Self::CurrencyId,
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(
currency_id: Self::CurrencyId,
from: &AccountId,
to: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn transfer(
currency_id: Self::CurrencyId,
from: &AccountId,
to: &AccountId,
amount: Self::Balance
) -> DispatchResult
Transfer some amount from one account to another.
sourcefn deposit(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn deposit(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
Add amount
to the balance of who
under currency_id
and increase
total issuance.
sourcefn withdraw(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn withdraw(
currency_id: Self::CurrencyId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
Remove amount
from the balance of who
under currency_id
and reduce
total issuance.