pub trait Unbalanced<AccountId>: Inspect<AccountId> {
    // Required methods
    fn set_balance(who: &AccountId, amount: Self::Balance) -> DispatchResult;
    fn set_total_issuance(amount: Self::Balance);

    // Provided methods
    fn decrease_balance(
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... }
    fn decrease_balance_at_most(
        who: &AccountId,
        amount: Self::Balance
    ) -> Self::Balance { ... }
    fn increase_balance(
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... }
    fn increase_balance_at_most(
        who: &AccountId,
        amount: Self::Balance
    ) -> Self::Balance { ... }
}
Expand description

A fungible token class where the balance can be set arbitrarily.

WARNING Do not use this directly unless you want trouble, since it allows you to alter account balances without keeping the issuance up to date. It has no safeguards against accidentally creating token imbalances in your system leading to accidental imflation or deflation. It’s really just for the underlying datatype to implement so the user gets the much safer Balanced trait to use.

Required Methods§

source

fn set_balance(who: &AccountId, amount: Self::Balance) -> DispatchResult

Set the balance of who to amount. If this cannot be done for some reason (e.g. because the account cannot be created or an overflow) then an Err is returned.

source

fn set_total_issuance(amount: Self::Balance)

Set the total issuance to amount.

Provided Methods§

source

fn decrease_balance( who: &AccountId, amount: Self::Balance ) -> Result<Self::Balance, DispatchError>

Reduce the balance of who by amount. If it cannot be reduced by that amount for some reason, return Err and don’t reduce it at all. If Ok, return the imbalance.

Minimum balance will be respected and the returned imbalance may be up to Self::minimum_balance() - 1 greater than amount.

source

fn decrease_balance_at_most( who: &AccountId, amount: Self::Balance ) -> Self::Balance

Reduce the balance of who by the most that is possible, up to amount.

Minimum balance will be respected and the returned imbalance may be up to Self::minimum_balance() - 1 greater than amount.

Return the imbalance by which the account was reduced.

source

fn increase_balance( who: &AccountId, amount: Self::Balance ) -> Result<Self::Balance, DispatchError>

Increase the balance of who by amount. If it cannot be increased by that amount for some reason, return Err and don’t increase it at all. If Ok, return the imbalance.

Minimum balance will be respected and an error will be returned if amount < Self::minimum_balance() when the account of who is zero.

source

fn increase_balance_at_most( who: &AccountId, amount: Self::Balance ) -> Self::Balance

Increase the balance of who by the most that is possible, up to amount.

Minimum balance will be respected and the returned imbalance will be zero in the case that amount < Self::minimum_balance().

Return the imbalance by which the account was increased.

Implementors§

source§

impl<F: Unbalanced<AccountId>, A: Get<<F as Inspect<AccountId>>::AssetId>, AccountId> Unbalanced<AccountId> for ItemOf<F, A, AccountId>