referrerpolicy=no-referrer-when-downgrade

Trait Transfer

pub trait Transfer {
    type Balance;
    type Sender;
    type Beneficiary;
    type AssetKind;
    type RemoteFeeAsset;
    type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy;
    type Error: Debug;

    // Required methods
    fn transfer(
        from: &Self::Sender,
        to: &Self::Beneficiary,
        asset_kind: Self::AssetKind,
        amount: Self::Balance,
        remote_fee: Option<Self::RemoteFeeAsset>,
    ) -> Result<Self::Id, Self::Error>;
    fn check_transfer(id: Self::Id) -> TransferStatus;
    fn ensure_successful(
        to: &Self::Beneficiary,
        asset_kind: Self::AssetKind,
        amount: Self::Balance,
    );
    fn ensure_concluded(id: Self::Id);
}
Expand description

Is intended to be implemented using a fungible impl, but can also be implemented with XCM/Asset and made generic over assets.

It is similar to the frame_support::traits::tokens::Pay, but it offers a variable source account for the payment.

Required Associated Types§

type Balance

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

type Sender

The type by which identify the payer involved in the transfer.

This is usually and AccountId or a Location.

type Beneficiary

The type by which we identify the beneficiary involved in the transfer.

This is usually and AccountId or a Location.

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 RemoteFeeAsset

Asset that is used to pay the xcm execution fees on the remote chain.

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 transfer( from: &Self::Sender, to: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, remote_fee: Option<Self::RemoteFeeAsset>, ) -> 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_transfer(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.

fn ensure_successful( to: &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.

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.

Implementors§