Trait frame_support::traits::tokens::fungibles::Unbalanced
source · pub trait Unbalanced<AccountId>: Inspect<AccountId> {
fn set_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult;
fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance);
fn decrease_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError> { ... }
fn decrease_balance_at_most(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance { ... }
fn increase_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError> { ... }
fn increase_balance_at_most(
asset: Self::AssetId,
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 inflation 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§
sourcefn set_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
fn set_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> DispatchResult
Set the asset
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.
sourcefn set_total_issuance(asset: Self::AssetId, amount: Self::Balance)
fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance)
Set the total issuance of asset
to amount
.
Provided Methods§
sourcefn decrease_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
fn decrease_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
Reduce the asset
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
.
sourcefn decrease_balance_at_most(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance
fn decrease_balance_at_most(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance
Reduce the asset
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.
sourcefn increase_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
fn increase_balance(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
Increase the asset
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.
sourcefn increase_balance_at_most(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance
fn increase_balance_at_most(
asset: Self::AssetId,
who: &AccountId,
amount: Self::Balance
) -> Self::Balance
Increase the asset
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.