pub trait Mutate<AccountId>: Inspect<AccountId> {
    // Required methods
    fn mint_into(who: &AccountId, amount: Self::Balance) -> DispatchResult;
    fn burn_from(
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError>;

    // Provided methods
    fn slash(
        who: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... }
    fn teleport(
        source: &AccountId,
        dest: &AccountId,
        amount: Self::Balance
    ) -> Result<Self::Balance, DispatchError> { ... }
}
Expand description

Trait for providing an ERC-20 style fungible asset.

Required Methods§

source

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

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.

source

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

Decrease the balance of who by at least amount, possibly slightly more in the case of minimum_balance requirements, burning the tokens. If that isn’t possible then an Err is returned and nothing is changed. If successful, the amount of tokens reduced is returned.

Provided Methods§

source

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

Attempt to reduce the balance of who by as much as possible up to amount, and possibly slightly more due to minimum_balance requirements. If no decrease is possible then an Err is returned and nothing is changed. If successful, the amount of tokens reduced is returned.

The default implementation just uses withdraw along with reducible_balance to ensure that it doesn’t fail.

source

fn teleport( source: &AccountId, dest: &AccountId, amount: Self::Balance ) -> Result<Self::Balance, DispatchError>

Transfer funds from one account into another. The default implementation uses mint_into and burn_from and may generate unwanted events.

Implementors§

source§

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