Trait frame_support::traits::tokens::fungible::hold::Mutate

source ·
pub trait Mutate<AccountId>: Inspect<AccountId> + Unbalanced<AccountId> + Unbalanced<AccountId> {
Show 13 methods // Provided methods fn hold( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, ) -> DispatchResult { ... } fn release( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, precision: Precision, ) -> Result<Self::Balance, DispatchError> { ... } fn set_on_hold( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, ) -> DispatchResult { ... } fn release_all( reason: &Self::Reason, who: &AccountId, precision: Precision, ) -> Result<Self::Balance, DispatchError> { ... } fn burn_held( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, precision: Precision, force: Fortitude, ) -> Result<Self::Balance, DispatchError> { ... } fn burn_all_held( reason: &Self::Reason, who: &AccountId, precision: Precision, force: Fortitude, ) -> Result<Self::Balance, DispatchError> { ... } fn transfer_on_hold( reason: &Self::Reason, source: &AccountId, dest: &AccountId, amount: Self::Balance, precision: Precision, mode: Restriction, force: Fortitude, ) -> Result<Self::Balance, DispatchError> { ... } fn transfer_and_hold( reason: &Self::Reason, source: &AccountId, dest: &AccountId, amount: Self::Balance, precision: Precision, expendability: Preservation, force: Fortitude, ) -> Result<Self::Balance, DispatchError> { ... } fn done_hold( _reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance, ) { ... } fn done_release( _reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance, ) { ... } fn done_burn_held( _reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance, ) { ... } fn done_transfer_on_hold( _reason: &Self::Reason, _source: &AccountId, _dest: &AccountId, _amount: Self::Balance, ) { ... } fn done_transfer_and_hold( _reason: &Self::Reason, _source: &AccountId, _dest: &AccountId, _transferred: Self::Balance, ) { ... }
}
Expand description

Trait for mutating a fungible asset which can be placed on hold.

Provided Methods§

source

fn hold( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, ) -> DispatchResult

Hold some funds in an account. If a hold for reason is already in place, then this will increase it.

source

fn release( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, precision: Precision, ) -> Result<Self::Balance, DispatchError>

Release up to amount held funds in an account.

The actual amount released is returned with Ok.

If precision is Precision::BestEffort, then the amount actually unreserved and returned as the inner value of Ok may be smaller than the amount passed.

NOTE! The inner of the Ok result variant returns the actual amount released. This is the opposite of the ReservableCurrency::unreserve() result, which gives the amount not able to be released!

source

fn set_on_hold( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, ) -> DispatchResult

Hold or release funds in the account of who to bring the balance on hold for reason to exactly amount.

source

fn release_all( reason: &Self::Reason, who: &AccountId, precision: Precision, ) -> Result<Self::Balance, DispatchError>

Release all funds in the account of who on hold for reason.

The actual amount released is returned with Ok.

If precision is BestEffort, then the amount actually unreserved and returned as the inner value of Ok may be smaller than the amount passed.

NOTE! The inner of the Ok result variant returns the actual amount released. This is the opposite of the ReservableCurrency::unreserve() result, which gives the amount not able to be released!

source

fn burn_held( reason: &Self::Reason, who: &AccountId, amount: Self::Balance, precision: Precision, force: Fortitude, ) -> Result<Self::Balance, DispatchError>

Attempt to decrease the balance of who which is held for the given reason by amount.

If precision is BestEffort, then as much as possible is reduced, up to amount, and the amount of tokens reduced is returned. Otherwise, if the total amount can be reduced, then it is and the amount returned, and if not, then nothing changes and Err is returned.

If force is Force, then locks/freezes will be ignored. This should only be used when conducting slashing or other activity which materially disadvantages the account holder since it could provide a means of circumventing freezes.

source

fn burn_all_held( reason: &Self::Reason, who: &AccountId, precision: Precision, force: Fortitude, ) -> Result<Self::Balance, DispatchError>

Attempt to decrease the balance of who which is held for the given reason to zero.

If precision is BestEffort, then as much as possible is reduced, up to amount, and the amount of tokens reduced is returned. Otherwise, if the total amount can be reduced, then it is and the amount returned, and if not, then nothing changes and Err is returned.

If force is Force, then locks/freezes will be ignored. This should only be used when conducting slashing or other activity which materially disadvantages the account holder since it could provide a means of circumventing freezes.

source

fn transfer_on_hold( reason: &Self::Reason, source: &AccountId, dest: &AccountId, amount: Self::Balance, precision: Precision, mode: Restriction, force: Fortitude, ) -> Result<Self::Balance, DispatchError>

Transfer held funds into a destination account.

If mode is OnHold, then the destination account must already exist and the assets transferred will still be on hold in the destination account. If not, then the destination account need not already exist, but must be creatable.

If precision is BestEffort, then an amount less than amount may be transferred without error.

If force is Force, then other fund-locking mechanisms may be disregarded. It should be left as Polite in most circumstances, but when you want the same power as a slash, it may be Force.

The actual amount transferred is returned, or Err in the case of error and nothing is changed.

source

fn transfer_and_hold( reason: &Self::Reason, source: &AccountId, dest: &AccountId, amount: Self::Balance, precision: Precision, expendability: Preservation, force: Fortitude, ) -> Result<Self::Balance, DispatchError>

Transfer some amount of free balance from source to become owned by dest but on hold for reason.

If precision is BestEffort, then an amount less than amount may be transferred without error.

source must obey the requirements of keep_alive.

If force is Force, then other fund-locking mechanisms may be disregarded. It should be left as Polite in most circumstances, but when you want the same power as a slash, it may be Force.

The amount placed on hold is returned or Err in the case of error and nothing is changed.

WARNING: This may return an error after a partial storage mutation. It should be used only inside a transactional storage context and an Err result must imply a storage rollback.

source

fn done_hold(_reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance)

source

fn done_release( _reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance, )

source

fn done_burn_held( _reason: &Self::Reason, _who: &AccountId, _amount: Self::Balance, )

source

fn done_transfer_on_hold( _reason: &Self::Reason, _source: &AccountId, _dest: &AccountId, _amount: Self::Balance, )

source

fn done_transfer_and_hold( _reason: &Self::Reason, _source: &AccountId, _dest: &AccountId, _transferred: Self::Balance, )

Object Safety§

This trait is not object safe.

Implementors§

source§

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