Trait stp258_traits::stp258::Stp258Currency[][src]

pub trait Stp258Currency<AccountId> {
    type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug;
    type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
    fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance;
fn base_unit(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; }

Abstraction over a fungible multi-stable-currency system.

Associated Types

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

The currency identifier.

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

The balance of an account.

Loading content...

Required methods

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

Existential deposit of currency_id.

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

base_unit of currency_id.

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

The total amount of issuance of currency_id.

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

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

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

A dry-run of withdraw. Returns Ok iff the account is able to make a withdrawal of the given amount.

fn transfer(
    currency_id: Self::CurrencyId,
    from: &AccountId,
    to: &AccountId,
    amount: Self::Balance
) -> DispatchResult
[src]

Transfer some amount from one account to another.

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

Add amount to the balance of who under currency_id and increase total issuance.

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

Remove amount from the balance of who under currency_id and reduce total issuance.

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

Same result as slash(currency_id, 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.

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

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 value will be returned.

Loading content...

Implementors

Loading content...