pub trait Inspect<AccountId>: Inspect<AccountId> {
type Reason: Encode + TypeInfo + 'static;
// Required methods
fn total_balance_on_hold(who: &AccountId) -> Self::Balance;
fn balance_on_hold(reason: &Self::Reason, who: &AccountId) -> Self::Balance;
// Provided methods
fn reducible_total_balance_on_hold(
who: &AccountId,
_force: Fortitude,
) -> Self::Balance { ... }
fn hold_available(_reason: &Self::Reason, _who: &AccountId) -> bool { ... }
fn ensure_can_hold(
reason: &Self::Reason,
who: &AccountId,
amount: Self::Balance,
) -> Result<(), DispatchError> { ... }
fn can_hold(
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§
fn total_balance_on_hold(who: &AccountId) -> Self::Balance
fn total_balance_on_hold(who: &AccountId) -> Self::Balance
Amount of funds on hold (for all hold reasons) of who
.
fn balance_on_hold(reason: &Self::Reason, who: &AccountId) -> Self::Balance
fn balance_on_hold(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(
who: &AccountId,
_force: Fortitude,
) -> Self::Balance
fn reducible_total_balance_on_hold( 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(_reason: &Self::Reason, _who: &AccountId) -> bool
fn hold_available(_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(
reason: &Self::Reason,
who: &AccountId,
amount: Self::Balance,
) -> Result<(), DispatchError>
fn ensure_can_hold( 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 true
as the third 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(
reason: &Self::Reason,
who: &AccountId,
amount: Self::Balance,
) -> bool
fn can_hold( 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.