Trait frame_support::traits::tokens::fungibles::hold::Inspect

source ·
pub trait Inspect<AccountId>: Inspect<AccountId> {
    type Reason: Encode + TypeInfo + 'static;

    // Required methods
    fn total_balance_on_hold(
        asset: Self::AssetId,
        who: &AccountId,
    ) -> Self::Balance;
    fn balance_on_hold(
        asset: Self::AssetId,
        reason: &Self::Reason,
        who: &AccountId,
    ) -> Self::Balance;

    // Provided methods
    fn reducible_total_balance_on_hold(
        asset: Self::AssetId,
        who: &AccountId,
        _force: Fortitude,
    ) -> Self::Balance { ... }
    fn hold_available(
        _asset: Self::AssetId,
        _reason: &Self::Reason,
        _who: &AccountId,
    ) -> bool { ... }
    fn ensure_can_hold(
        asset: Self::AssetId,
        reason: &Self::Reason,
        who: &AccountId,
        amount: Self::Balance,
    ) -> DispatchResult { ... }
    fn can_hold(
        asset: Self::AssetId,
        reason: &Self::Reason,
        who: &AccountId,
        amount: Self::Balance,
    ) -> bool { ... }
}
Expand description

Trait for inspecting a fungible asset whose accounts support partitioning and slashing.

Required Associated Types§

source

type Reason: Encode + TypeInfo + 'static

An identifier for a hold. Used for disambiguating different holds so that they can be individually replaced or removed and funds from one hold don’t accidentally become unreserved or slashed for another.

Required Methods§

source

fn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance

Amount of funds on hold (for all hold reasons) of who.

source

fn balance_on_hold( asset: Self::AssetId, reason: &Self::Reason, who: &AccountId, ) -> Self::Balance

Amount of funds on hold (for the given reason) of who.

Provided Methods§

source

fn reducible_total_balance_on_hold( asset: Self::AssetId, who: &AccountId, _force: Fortitude, ) -> Self::Balance

Get the maximum amount that the total_balance_on_hold of who can be reduced successfully based on whether we are willing to force the reduction and potentially go below user-level restrictions on the minimum amount of the account. Note: This cannot bring the account into an inconsistent state with regards any required existential deposit.

Never more than total_balance_on_hold().

source

fn hold_available( _asset: Self::AssetId, _reason: &Self::Reason, _who: &AccountId, ) -> bool

Returns true if it’s possible to place (additional) funds under a hold of a given reason. This may fail if the account has exhausted a limited number of concurrent holds or if it cannot be made to exist (e.g. there is no provider reference).

NOTE: This does not take into account changes which could be made to the account of who (such as removing a provider reference) after this call is made. Any usage of this should therefore ensure the account is already in the appropriate state prior to calling it.

source

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

Check to see if some amount of funds of who may be placed on hold with the given reason. Reasons why this may not be true:

  • The implementor supports only a limited number of concurrent holds on an account which is the possible values of reason;
  • The total balance of the account is less than amount;
  • Removing amount from the total balance would kill the account and remove the only provider reference.

Note: we pass Fortitude::Force as the last argument to reducible_balance since we assume that if needed the balance can slashed. If we are using a simple non-forcing reserve-transfer, then we really ought to check that we are not reducing the funds below the freeze-limit (if any).

NOTE: This does not take into account changes which could be made to the account of who (such as removing a provider reference) after this call is made. Any usage of this should therefore ensure the account is already in the appropriate state prior to calling it.

source

fn can_hold( asset: Self::AssetId, reason: &Self::Reason, who: &AccountId, amount: Self::Balance, ) -> bool

Check to see if some amount of funds of who may be placed on hold for the given reason. Reasons why this may not be true:

  • The implementor supports only a limited number of concurrent holds on an account which is the possible values of reason;
  • The main balance of the account is less than amount;
  • Removing amount from the main balance would kill the account and remove the only provider reference.

NOTE: This does not take into account changes which could be made to the account of who (such as removing a provider reference) after this call is made. Any usage of this should therefore ensure the account is already in the appropriate state prior to calling it.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Left: InspectHold<AccountId>, Right: InspectHold<AccountId, Balance = Left::Balance, Reason = Left::Reason>, Criterion: Convert<AssetKind, Either<(), Right::AssetId>>, AssetKind: AssetId, AccountId> Inspect<AccountId> for frame_support::traits::tokens::fungible::UnionOf<Left, Right, Criterion, AssetKind, AccountId>

§

type Reason = <Left as Inspect<AccountId>>::Reason

source§

impl<Left: InspectHold<AccountId>, Right: InspectHold<AccountId, Balance = Left::Balance, Reason = Left::Reason>, Criterion: Convert<AssetKind, Either<Left::AssetId, Right::AssetId>>, AssetKind: AssetId, AccountId> Inspect<AccountId> for frame_support::traits::tokens::fungibles::UnionOf<Left, Right, Criterion, AssetKind, AccountId>

§

type Reason = <Left as Inspect<AccountId>>::Reason