referrerpolicy=no-referrer-when-downgrade
pub trait InspectHold<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,
    ) -> Result<(), DispatchError> { ... }
    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§

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§

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

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

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§

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().

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.

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

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.

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§

§

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

§

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

§

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

§

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