referrerpolicy=no-referrer-when-downgrade

Trait frame_support::traits::tokens::pay::Pay

source ·
pub trait Pay {
    type Balance: Balance;
    type Beneficiary;
    type AssetKind;
    type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy;
    type Error: Debug;

    // Required methods
    fn pay(
        who: &Self::Beneficiary,
        asset_kind: Self::AssetKind,
        amount: Self::Balance,
    ) -> Result<Self::Id, Self::Error>;
    fn check_payment(id: Self::Id) -> PaymentStatus;
    fn ensure_successful(
        who: &Self::Beneficiary,
        asset_kind: Self::AssetKind,
        amount: Self::Balance,
    );
    fn ensure_concluded(id: Self::Id);
}
Expand description

Can be implemented by PayFromAccount using a fungible impl, but can also be implemented with XCM/Asset and made generic over assets.

Required Associated Types§

source

type Balance: Balance

The type by which we measure units of the currency in which we make payments.

source

type Beneficiary

The type by which we identify the beneficiaries to whom a payment may be made.

source

type AssetKind

The type for the kinds of asset that are going to be paid.

The unit type can be used here to indicate there’s only one kind of asset to do payments with. When implementing, it should be clear from the context what that asset is.

source

type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy

An identifier given to an individual payment.

source

type Error: Debug

An error which could be returned by the Pay type

Required Methods§

source

fn pay( who: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, ) -> Result<Self::Id, Self::Error>

Make a payment and return an identifier for later evaluation of success in some off-chain mechanism (likely an event, but possibly not on this chain).

source

fn check_payment(id: Self::Id) -> PaymentStatus

Check how a payment has proceeded. id must have been previously returned by pay for the result of this call to be meaningful. Once this returns anything other than InProgress for some id it must return Unknown rather than the actual result value.

source

fn ensure_successful( who: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, )

Ensure that a call to pay with the given parameters will be successful if done immediately after this call. Used in benchmarking code.

source

fn ensure_concluded(id: Self::Id)

Ensure that a call to check_payment with the given parameters will return either Success or Failure.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<A, F> Pay for PayAssetFromAccount<F, A>
where A: TypedGet, F: Mutate<A::Type> + Create<A::Type>, A::Type: Eq,

§

type Balance = <F as Inspect<<A as TypedGet>::Type>>::Balance

§

type Beneficiary = <A as TypedGet>::Type

§

type AssetKind = <F as Inspect<<A as TypedGet>::Type>>::AssetId

§

type Id = ()

§

type Error = DispatchError

source§

impl<A, F> Pay for PayFromAccount<F, A>
where A: TypedGet, F: Mutate<A::Type>, A::Type: Eq,

§

type Balance = <F as Inspect<<A as TypedGet>::Type>>::Balance

§

type Beneficiary = <A as TypedGet>::Type

§

type AssetKind = ()

§

type Id = ()

§

type Error = DispatchError