pub trait TransactAsset {
    fn can_check_in(
        _origin: &MultiLocation,
        _what: &MultiAsset
    ) -> Result<(), Error> { ... } fn check_in(_origin: &MultiLocation, _what: &MultiAsset) { ... } fn check_out(_dest: &MultiLocation, _what: &MultiAsset) { ... } fn deposit_asset(
        _what: &MultiAsset,
        _who: &MultiLocation
    ) -> Result<(), Error> { ... } fn withdraw_asset(
        _what: &MultiAsset,
        _who: &MultiLocation
    ) -> Result<Assets, Error> { ... } fn internal_transfer_asset(
        _asset: &MultiAsset,
        _from: &MultiLocation,
        _to: &MultiLocation
    ) -> Result<Assets, Error> { ... } fn transfer_asset(
        asset: &MultiAsset,
        from: &MultiLocation,
        to: &MultiLocation
    ) -> Result<Assets, Error> { ... } }
Expand description

Facility for asset transacting.

This should work with as many asset/location combinations as possible. Locations to support may include non-account locations such as a MultiLocation::X1(Junction::Parachain). Different chains may handle them in different ways.

Can be amalgamated as a tuple of items that implement this trait. In such executions, if any of the transactors returns Ok(()), then it will short circuit. Else, execution is passed to the next transactor.

Provided Methods§

Ensure that check_in will result in Ok.

When composed as a tuple, all type-items are called and at least one must result in Ok.

An asset has been teleported in from the given origin. This should do whatever housekeeping is needed.

NOTE: This will make only a best-effort at bookkeeping. The caller should ensure that can_check_in has returned with Ok in order to guarantee that this operation proceeds properly.

Implementation note: In general this will do one of two things: On chains where the asset is native, it will reduce the assets from a special “teleported” account so that a) total-issuance is preserved; and b) to ensure that no more assets can be teleported in than were teleported out overall (this should not be needed if the teleporting chains are to be trusted, but better to be safe than sorry). On chains where the asset is not native then it will generally just be a no-op.

When composed as a tuple, all type-items are called. It is up to the implementer that there exists no value for _what which can cause side-effects for more than one of the type-items.

An asset has been teleported out to the given destination. This should do whatever housekeeping is needed.

Implementation note: In general this will do one of two things: On chains where the asset is native, it will increase the assets in a special “teleported” account so that a) total-issuance is preserved; and b) to ensure that no more assets can be teleported in than were teleported out overall (this should not be needed if the teleporting chains are to be trusted, but better to be safe than sorry). On chains where the asset is not native then it will generally just be a no-op.

When composed as a tuple, all type-items are called. It is up to the implementer that there exists no value for _what which can cause side-effects for more than one of the type-items.

Deposit the what asset into the account of who.

Implementations should return XcmError::FailedToTransactAsset if deposit failed.

Withdraw the given asset from the consensus system. Return the actual asset(s) withdrawn, which should always be equal to _what.

Implementations should return XcmError::FailedToTransactAsset if withdraw failed.

Move an asset from one location in to another location.

Returns XcmError::FailedToTransactAsset if transfer failed.

Notes

This function is meant to only be implemented by the type implementing TransactAsset, and not be called directly. Most common API usages will instead call transfer_asset, which in turn has a default implementation that calls internal_transfer_asset. As such, please do not call this method directly unless you know what you’re doing.

Move an asset from one location in to another location.

Attempts to use internal_transfer_asset and if not available then falls back to using a two-part withdraw/deposit.

Implementations on Foreign Types§

Implementors§