Trait PayWithSource
pub trait PayWithSource {
type Balance: Balance;
type Source;
type Beneficiary;
type AssetKind;
type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy;
type Error: Debug;
// Required methods
fn pay(
source: &Self::Source,
beneficiary: &Self::Beneficiary,
asset_kind: Self::AssetKind,
amount: Self::Balance,
) -> Result<Self::Id, Self::Error>;
fn check_payment(id: Self::Id) -> TransferStatus;
fn ensure_successful(
source: &Self::Source,
beneficiary: &Self::Beneficiary,
asset_kind: Self::AssetKind,
amount: Self::Balance,
);
fn ensure_concluded(id: Self::Id);
}Expand description
A variant of Pay that includes the payment Source.
Required Associated Types§
type Source
type Source
The type by which we identify the sources from whom a payment may be made.
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(
source: &Self::Source,
beneficiary: &Self::Beneficiary,
asset_kind: Self::AssetKind,
amount: Self::Balance,
) -> Result<Self::Id, Self::Error>
fn pay( source: &Self::Source, beneficiary: &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) -> TransferStatus
fn check_payment(id: Self::Id) -> TransferStatus
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(
source: &Self::Source,
beneficiary: &Self::Beneficiary,
asset_kind: Self::AssetKind,
amount: Self::Balance,
)
fn ensure_successful( source: &Self::Source, beneficiary: &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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.