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§
Required Methods§
sourcefn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance
fn total_balance_on_hold(asset: Self::AssetId, who: &AccountId) -> Self::Balance
Amount of funds on hold (for all hold reasons) of who
.
sourcefn balance_on_hold(
asset: Self::AssetId,
reason: &Self::Reason,
who: &AccountId,
) -> Self::Balance
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§
sourcefn reducible_total_balance_on_hold(
asset: Self::AssetId,
who: &AccountId,
_force: Fortitude,
) -> Self::Balance
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()
.
sourcefn hold_available(
_asset: Self::AssetId,
_reason: &Self::Reason,
_who: &AccountId,
) -> bool
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.
sourcefn ensure_can_hold(
asset: Self::AssetId,
reason: &Self::Reason,
who: &AccountId,
amount: Self::Balance,
) -> DispatchResult
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.
sourcefn can_hold(
asset: Self::AssetId,
reason: &Self::Reason,
who: &AccountId,
amount: Self::Balance,
) -> bool
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.