Trait Mutate
pub trait Mutate<AccountId>: Inspect<AccountId> + Unbalanced<AccountId>where
AccountId: Eq,{
// Provided methods
fn mint_into(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError> { ... }
fn burn_from(
who: &AccountId,
amount: Self::Balance,
preservation: Preservation,
precision: Precision,
force: Fortitude,
) -> Result<Self::Balance, DispatchError> { ... }
fn shelve(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError> { ... }
fn restore(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError> { ... }
fn transfer(
source: &AccountId,
dest: &AccountId,
amount: Self::Balance,
preservation: Preservation,
) -> Result<Self::Balance, DispatchError> { ... }
fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance { ... }
fn done_mint_into(_who: &AccountId, _amount: Self::Balance) { ... }
fn done_burn_from(_who: &AccountId, _amount: Self::Balance) { ... }
fn done_shelve(_who: &AccountId, _amount: Self::Balance) { ... }
fn done_restore(_who: &AccountId, _amount: Self::Balance) { ... }
fn done_transfer(
_source: &AccountId,
_dest: &AccountId,
_amount: Self::Balance,
) { ... }
}Expand description
Trait for providing a basic fungible asset.
Provided Methods§
fn mint_into(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError>
fn mint_into( who: &AccountId, amount: Self::Balance, ) -> Result<Self::Balance, DispatchError>
Increase the balance of who by exactly amount, minting new tokens. If that isn’t
possible then an Err is returned and nothing is changed.
fn burn_from(
who: &AccountId,
amount: Self::Balance,
preservation: Preservation,
precision: Precision,
force: Fortitude,
) -> Result<Self::Balance, DispatchError>
fn burn_from( who: &AccountId, amount: Self::Balance, preservation: Preservation, precision: Precision, force: Fortitude, ) -> Result<Self::Balance, DispatchError>
Attempt to decrease the balance of who, burning the tokens.
The actual amount burned is derived from the amount, preservation, precision and
force, and might end up being more, less or equal to the amount specified.
If the burn isn’t possible then an Err is returned and nothing is changed.
If successful, the amount of tokens reduced is returned.
fn shelve(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError>
fn shelve( who: &AccountId, amount: Self::Balance, ) -> Result<Self::Balance, DispatchError>
Attempt to decrease the asset balance of who by amount.
Equivalent to Mutate::burn_from, except with an expectation that within the bounds of
some universal issuance, the total assets suspended and resumed will be equivalent. The
implementation may be configured such that the total assets suspended may never be less than
the total assets resumed (which is the invariant for an issuing system), or the reverse
(which the invariant in a non-issuing system).
Because of this expectation, any metadata associated with the asset is expected to survive the suspect-resume cycle.
fn restore(
who: &AccountId,
amount: Self::Balance,
) -> Result<Self::Balance, DispatchError>
fn restore( who: &AccountId, amount: Self::Balance, ) -> Result<Self::Balance, DispatchError>
Attempt to increase the asset balance of who by amount.
Equivalent to Mutate::mint_into, except with an expectation that within the bounds of
some universal issuance, the total assets suspended and resumed will be equivalent. The
implementation may be configured such that the total assets suspended may never be less than
the total assets resumed (which is the invariant for an issuing system), or the reverse
(which the invariant in a non-issuing system).
Because of this expectation, any metadata associated with the asset is expected to survive the suspect-resume cycle.
fn transfer(
source: &AccountId,
dest: &AccountId,
amount: Self::Balance,
preservation: Preservation,
) -> Result<Self::Balance, DispatchError>
fn transfer( source: &AccountId, dest: &AccountId, amount: Self::Balance, preservation: Preservation, ) -> Result<Self::Balance, DispatchError>
Transfer funds from one account into another.
Returns the amount credited to dest. With the default implementation this is amount
unless Unbalanced::decrease_balance folded a sub-minimum remainder of source into
its return, as pallet-assets does, in which case it exceeds amount by up to
minimum_balance() - 1 and that remainder is credited to dest as well. Adapters such as
ItemOf and UnionOf forward that figure.
source may be debited by more than is returned, e.g. when a reaped remainder is passed to
handle_dust as pallet-balances does.
A transfer where the source and destination account are identical, or where amount is
zero, is treated as No-OP after checking the preconditions.
fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance
fn set_balance(who: &AccountId, amount: Self::Balance) -> Self::Balance
Simple infallible function to force an account to have a particular balance, good for use in tests and benchmarks but not recommended for production code owing to the lack of error reporting.
Returns the new balance.
fn done_mint_into(_who: &AccountId, _amount: Self::Balance)
fn done_burn_from(_who: &AccountId, _amount: Self::Balance)
fn done_shelve(_who: &AccountId, _amount: Self::Balance)
fn done_restore(_who: &AccountId, _amount: Self::Balance)
fn done_transfer(_source: &AccountId, _dest: &AccountId, _amount: Self::Balance)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl<AccountId> Mutate<AccountId> for ()where
AccountId: Eq,
std only.Dummy implementation of Mutate