Trait common::SwapAction

source ·
pub trait SwapAction<SourceAccountId, TargetAccountId, AssetId, T: Config> {
    // Required methods
    fn reserve(
        &self,
        source: &SourceAccountId,
        base_asset_id: &AssetId
    ) -> DispatchResult;
    fn claim(&self, source: &SourceAccountId) -> bool;
    fn weight(&self) -> Weight;
    fn cancel(&self, source: &SourceAccountId);
}
Expand description

Definition of a pending atomic swap action. It contains the following three phrases:

  • Reserve: reserve the resources needed for a swap. This is to make sure that Claim succeeds with best efforts.
  • Claim: claim any resources reserved in the first phrase.
  • Cancel: cancel any resources reserved in the first phrase.

Required Methods§

source

fn reserve( &self, source: &SourceAccountId, base_asset_id: &AssetId ) -> DispatchResult

Reserve the resources needed for the swap, from the given source. The reservation is allowed to fail. If that is the case, the the full swap creation operation is cancelled.

source

fn claim(&self, source: &SourceAccountId) -> bool

Claim the reserved resources, with source. Returns whether the claim succeeds.

source

fn weight(&self) -> Weight

Weight for executing the operation.

source

fn cancel(&self, source: &SourceAccountId)

Cancel the resources reserved in source.

Implementations on Foreign Types§

source§

impl<SourceAccountId, TargetAccountId, AssetId, T: Config> SwapAction<SourceAccountId, TargetAccountId, AssetId, T> for ()

Dummy implementation for cases then () used in runtime as empty SwapAction.

source§

fn reserve( &self, _source: &SourceAccountId, _base_asset_id: &AssetId ) -> DispatchResult

source§

fn claim(&self, _source: &SourceAccountId) -> bool

source§

fn weight(&self) -> Weight

source§

fn cancel(&self, _source: &SourceAccountId)

Implementors§