pub trait Inspect<AccountId>: Sized {
type Balance: Balance;
// Required methods
fn total_issuance() -> Self::Balance;
fn minimum_balance() -> Self::Balance;
fn total_balance(who: &AccountId) -> Self::Balance;
fn balance(who: &AccountId) -> Self::Balance;
fn reducible_balance(
who: &AccountId,
preservation: Preservation,
force: Fortitude
) -> Self::Balance;
fn can_deposit(
who: &AccountId,
amount: Self::Balance,
provenance: Provenance
) -> DepositConsequence;
fn can_withdraw(
who: &AccountId,
amount: Self::Balance
) -> WithdrawConsequence<Self::Balance>;
// Provided method
fn active_issuance() -> Self::Balance { ... }
}
Expand description
Trait for providing balance-inspection access to a fungible asset.
Required Associated Types§
Required Methods§
sourcefn total_issuance() -> Self::Balance
fn total_issuance() -> Self::Balance
The total amount of issuance in the system.
sourcefn minimum_balance() -> Self::Balance
fn minimum_balance() -> Self::Balance
The minimum balance any single account may have.
sourcefn total_balance(who: &AccountId) -> Self::Balance
fn total_balance(who: &AccountId) -> Self::Balance
Get the total amount of funds whose ultimate beneficial ownership can be determined as
who
.
This may include funds which are wholly inaccessible to who
, either temporarily or even
indefinitely.
For the amount of the balance which is currently free to be removed from the account without
error, use reducible_balance
.
For the amount of the balance which may eventually be free to be removed from the account,
use balance()
.
sourcefn balance(who: &AccountId) -> Self::Balance
fn balance(who: &AccountId) -> Self::Balance
Get the balance of who
which does not include funds which are exclusively allocated to
subsystems of the chain (“on hold” or “reserved”).
In general this isn’t especially useful outside of tests, and for practical purposes, you’ll
want to use reducible_balance()
.
sourcefn reducible_balance(
who: &AccountId,
preservation: Preservation,
force: Fortitude
) -> Self::Balance
fn reducible_balance( who: &AccountId, preservation: Preservation, force: Fortitude ) -> Self::Balance
Get the maximum amount that who
can withdraw/transfer successfully based on whether the
account should be kept alive (preservation
) or whether we are willing to force the
reduction and potentially go below user-level restrictions on the minimum amount of the
account.
Always less than or equal to balance()
.
sourcefn can_deposit(
who: &AccountId,
amount: Self::Balance,
provenance: Provenance
) -> DepositConsequence
fn can_deposit( who: &AccountId, amount: Self::Balance, provenance: Provenance ) -> DepositConsequence
Returns true
if the balance of who
may be increased by amount
.
who
: The account of which the balance should be increased byamount
.amount
: How much should the balance be increased?provenance
: Willamount
be minted to deposit it intoaccount
or is it already in the system?
sourcefn can_withdraw(
who: &AccountId,
amount: Self::Balance
) -> WithdrawConsequence<Self::Balance>
fn can_withdraw( who: &AccountId, amount: Self::Balance ) -> WithdrawConsequence<Self::Balance>
Returns Success
if the balance of who
may be decreased by amount
, otherwise
the consequence.
Provided Methods§
sourcefn active_issuance() -> Self::Balance
fn active_issuance() -> Self::Balance
The total amount of issuance in the system excluding those which are controlled by the system.