referrerpolicy=no-referrer-when-downgrade

Trait polkadot_sdk_frame::traits::tokens::pay::Pay

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§

type Balance: Balance

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

type Beneficiary

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

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.

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

An identifier given to an individual payment.

type Error: Debug

An error which could be returned by the Pay type

Required Methods§

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).

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.

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.

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§

§

impl<A, F> Pay for PayFromAccount<F, A>
where A: TypedGet, F: Mutate<<A as TypedGet>::Type>, <A as TypedGet>::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

§

impl<A, F> Pay for PayAssetFromAccount<F, A>
where A: TypedGet, F: Mutate<<A as TypedGet>::Type> + Create<<A as TypedGet>::Type>, <A as TypedGet>::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