Trait governance_os_support::traits::Currencies[][src]

pub trait Currencies<AccountId> {
    type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + Default;
    type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
    fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance;
fn burn(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
fn mint(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
fn free_balance(
        currency_id: Self::CurrencyId,
        who: &AccountId
    ) -> Self::Balance;
fn total_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,
        source: &AccountId,
        dest: &AccountId,
        value: Self::Balance
    ) -> DispatchResult; }

Abstraction trait over a multiple currencies system, each currency type is identified by a CurrencyId, if it is set to None when calling a function the implementation should default to the native currency of the runtime.

Associated Types

type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + Default[src]

The type used to identify currencies

type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default[src]

The balance of an account.

Loading content...

Required methods

fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance[src]

The total amount of issuance in the system.

fn burn(
    currency_id: Self::CurrencyId,
    who: &AccountId,
    amount: Self::Balance
) -> DispatchResult
[src]

Remove amount tokens from who balance. If there are not enough tokens it will error.

fn mint(
    currency_id: Self::CurrencyId,
    who: &AccountId,
    amount: Self::Balance
) -> DispatchResult
[src]

Increase the balance of who by amount.

fn free_balance(currency_id: Self::CurrencyId, who: &AccountId) -> Self::Balance[src]

The ‘free’ balance of a given account.

fn total_balance(
    currency_id: Self::CurrencyId,
    who: &AccountId
) -> Self::Balance
[src]

The total balance of a given account. This may include non free funds.

fn ensure_can_withdraw(
    currency_id: Self::CurrencyId,
    who: &AccountId,
    amount: Self::Balance
) -> DispatchResult
[src]

Returns Ok if the account is able to make a withdrawal of the given amount. Basically, it’s just a dry-run of withdraw.

Err(...) with the reason why not otherwise.

fn transfer(
    currency_id: Self::CurrencyId,
    source: &AccountId,
    dest: &AccountId,
    value: Self::Balance
) -> DispatchResult
[src]

Transfer some liquid free balance to another account.

This is a very high-level function. It will ensure all appropriate fees are paid and no imbalance in the system remains.

Loading content...

Implementors

Loading content...