-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more methods on XcmTransfer trait * Add Transferred for XcmTransfer * fix tests * fix clippy
- Loading branch information
Showing
2 changed files
with
104 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,67 @@ | ||
use frame_support::dispatch::DispatchResult; | ||
use frame_support::dispatch::DispatchError; | ||
use sp_std::vec::Vec; | ||
use xcm::v3::prelude::*; | ||
|
||
pub struct Transferred<AccountId> { | ||
pub sender: AccountId, | ||
pub assets: MultiAssets, | ||
pub fee: MultiAsset, | ||
pub dest: MultiLocation, | ||
} | ||
|
||
/// Abstraction over cross-chain token transfers. | ||
pub trait XcmTransfer<AccountId, Balance, CurrencyId> { | ||
/// Transfer native currencies. | ||
/// Transfer local assets with given `CurrencyId` and `Amount`. | ||
fn transfer( | ||
who: AccountId, | ||
currency_id: CurrencyId, | ||
amount: Balance, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> DispatchResult; | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
|
||
/// Transfer `MultiAsset` | ||
fn transfer_multi_asset( | ||
/// Transfer `MultiAsset` assets. | ||
fn transfer_multiasset( | ||
who: AccountId, | ||
asset: MultiAsset, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> DispatchResult; | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
|
||
/// Transfer `MultiAssetWithFee` | ||
/// Transfer native currencies specifying the fee and amount as separate. | ||
fn transfer_with_fee( | ||
who: AccountId, | ||
currency_id: CurrencyId, | ||
amount: Balance, | ||
fee: Balance, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
|
||
/// Transfer `MultiAsset` specifying the fee and amount as separate. | ||
fn transfer_multiasset_with_fee( | ||
who: AccountId, | ||
asset: MultiAsset, | ||
fee: MultiAsset, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> DispatchResult; | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
|
||
/// Transfer several currencies specifying the item to be used as fee. | ||
fn transfer_multicurrencies( | ||
who: AccountId, | ||
currencies: Vec<(CurrencyId, Balance)>, | ||
fee_item: u32, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
|
||
/// Transfer several `MultiAsset` specifying the item to be used as fee. | ||
fn transfer_multiassets( | ||
who: AccountId, | ||
assets: MultiAssets, | ||
fee: MultiAsset, | ||
dest: MultiLocation, | ||
dest_weight_limit: WeightLimit, | ||
) -> Result<Transferred<AccountId>, DispatchError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters