referrerpolicy=no-referrer-when-downgrade

Trait polkadot_sdk_frame::traits::tokens::fungibles::Inspect

pub trait Inspect<AccountId>: Sized {
    type AssetId: AssetId;
    type Balance: Balance;

    // Required methods
    fn total_issuance(asset: Self::AssetId) -> Self::Balance;
    fn minimum_balance(asset: Self::AssetId) -> Self::Balance;
    fn total_balance(asset: Self::AssetId, who: &AccountId) -> Self::Balance;
    fn balance(asset: Self::AssetId, who: &AccountId) -> Self::Balance;
    fn reducible_balance(
        asset: Self::AssetId,
        who: &AccountId,
        preservation: Preservation,
        force: Fortitude,
    ) -> Self::Balance;
    fn can_deposit(
        asset: Self::AssetId,
        who: &AccountId,
        amount: Self::Balance,
        provenance: Provenance,
    ) -> DepositConsequence;
    fn can_withdraw(
        asset: Self::AssetId,
        who: &AccountId,
        amount: Self::Balance,
    ) -> WithdrawConsequence<Self::Balance>;
    fn asset_exists(asset: Self::AssetId) -> bool;

    // Provided method
    fn active_issuance(asset: Self::AssetId) -> Self::Balance { ... }
}
Expand description

Trait for providing balance-inspection access to a set of named fungible assets.

Required Associated Types§

type AssetId: AssetId

Means of identifying one asset class from another.

type Balance: Balance

Scalar type for representing balance of an account.

Required Methods§

fn total_issuance(asset: Self::AssetId) -> Self::Balance

The total amount of issuance in the system.

fn minimum_balance(asset: Self::AssetId) -> Self::Balance

The minimum balance any single account may have.

fn total_balance(asset: Self::AssetId, 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().

fn balance(asset: Self::AssetId, 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().

fn reducible_balance( asset: Self::AssetId, 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 transfer and potentially go below user-level restrictions on the minimum amount of the account.

Always less than free_balance().

fn can_deposit( asset: Self::AssetId, who: &AccountId, amount: Self::Balance, provenance: Provenance, ) -> DepositConsequence

Returns true if the asset balance of who may be increased by amount.

  • asset: The asset that should be deposited.
  • who: The account of which the balance should be increased by amount.
  • amount: How much should the balance be increased?
  • mint: Will amount be minted to deposit it into account?

fn can_withdraw( asset: Self::AssetId, who: &AccountId, amount: Self::Balance, ) -> WithdrawConsequence<Self::Balance>

Returns Failed if the asset balance of who may not be decreased by amount, otherwise the consequence.

fn asset_exists(asset: Self::AssetId) -> bool

Returns true if an asset exists.

Provided Methods§

fn active_issuance(asset: Self::AssetId) -> Self::Balance

The total amount of issuance in the system excluding those which are controlled by the system.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<AccountId> Inspect<AccountId> for ()

Dummy implementation of Inspect

§

type AssetId = u32

§

type Balance = u32

§

fn total_issuance( _: <() as Inspect<AccountId>>::AssetId, ) -> <() as Inspect<AccountId>>::Balance

§

fn minimum_balance( _: <() as Inspect<AccountId>>::AssetId, ) -> <() as Inspect<AccountId>>::Balance

§

fn total_balance( _: <() as Inspect<AccountId>>::AssetId, _: &AccountId, ) -> <() as Inspect<AccountId>>::Balance

§

fn balance( _: <() as Inspect<AccountId>>::AssetId, _: &AccountId, ) -> <() as Inspect<AccountId>>::Balance

§

fn reducible_balance( _: <() as Inspect<AccountId>>::AssetId, _: &AccountId, _: Preservation, _: Fortitude, ) -> <() as Inspect<AccountId>>::Balance

§

fn can_deposit( _: <() as Inspect<AccountId>>::AssetId, _: &AccountId, _: <() as Inspect<AccountId>>::Balance, _: Provenance, ) -> DepositConsequence

§

fn can_withdraw( _: <() as Inspect<AccountId>>::AssetId, _: &AccountId, _: <() as Inspect<AccountId>>::Balance, ) -> WithdrawConsequence<<() as Inspect<AccountId>>::Balance>

§

fn asset_exists(_: <() as Inspect<AccountId>>::AssetId) -> bool

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>, Criterion: Convert<AssetKind, Either<(), <Right as Inspect<AccountId>>::AssetId>>, AssetKind: AssetId,

§

type AssetId = AssetKind

§

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

§

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>, Criterion: Convert<AssetKind, Either<<Left as Inspect<AccountId>>::AssetId, <Right as Inspect<AccountId>>::AssetId>>, AssetKind: AssetId,

§

type AssetId = AssetKind

§

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