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 Beneficiary
type Beneficiary
The type by which we identify the beneficiaries to whom a payment may be made.
type AssetKind
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.
Required Methods§
fn pay(
who: &Self::Beneficiary,
asset_kind: Self::AssetKind,
amount: Self::Balance,
) -> Result<Self::Id, Self::Error>
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
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,
)
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)
fn ensure_concluded(id: Self::Id)
Ensure that a call to check_payment
with the given parameters will return either Success
or Failure
.