-
Notifications
You must be signed in to change notification settings - Fork 300
Expand file tree
/
Copy pathxcm_transfer.rs
More file actions
84 lines (76 loc) · 2.54 KB
/
Copy pathxcm_transfer.rs
File metadata and controls
84 lines (76 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{DispatchError, RuntimeDebug};
use sp_std::vec::Vec;
use xcm::{
v5::{prelude::*, Weight},
VersionedAsset, VersionedAssets, VersionedLocation,
};
#[derive(Encode, Decode, Clone, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct Transferred<AccountId> {
pub sender: AccountId,
pub assets: Assets,
pub fee: Asset,
pub dest: Location,
}
/// Abstraction over cross-chain token transfers.
pub trait XcmTransfer<AccountId, Balance, CurrencyId> {
/// Transfer local assets with given `CurrencyId` and `Amount`.
fn transfer(
who: AccountId,
currency_id: CurrencyId,
amount: Balance,
dest: Location,
dest_weight_limit: WeightLimit,
) -> Result<Transferred<AccountId>, DispatchError>;
/// Transfer `Asset` assets.
fn transfer_multiasset(
who: AccountId,
asset: Asset,
dest: Location,
dest_weight_limit: WeightLimit,
) -> Result<Transferred<AccountId>, DispatchError>;
/// Transfer native currencies specifying the fee and amount as separate.
fn transfer_with_fee(
who: AccountId,
currency_id: CurrencyId,
amount: Balance,
fee: Balance,
dest: Location,
dest_weight_limit: WeightLimit,
) -> Result<Transferred<AccountId>, DispatchError>;
/// Transfer `Asset` specifying the fee and amount as separate.
fn transfer_multiasset_with_fee(
who: AccountId,
asset: Asset,
fee: Asset,
dest: Location,
dest_weight_limit: WeightLimit,
) -> 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: Location,
dest_weight_limit: WeightLimit,
) -> Result<Transferred<AccountId>, DispatchError>;
/// Transfer several `Asset` specifying the item to be used as fee.
fn transfer_multiassets(
who: AccountId,
assets: Assets,
fee: Asset,
dest: Location,
dest_weight_limit: WeightLimit,
) -> Result<Transferred<AccountId>, DispatchError>;
}
pub trait XtokensWeightInfo<AccountId, Balance, CurrencyId> {
fn weight_of_transfer_multiasset(asset: &VersionedAsset, dest: &VersionedLocation) -> Weight;
fn weight_of_transfer(currency_id: CurrencyId, amount: Balance, dest: &VersionedLocation) -> Weight;
fn weight_of_transfer_multicurrencies(
currencies: &[(CurrencyId, Balance)],
fee_item: &u32,
dest: &VersionedLocation,
) -> Weight;
fn weight_of_transfer_multiassets(assets: &VersionedAssets, fee_item: &u32, dest: &VersionedLocation) -> Weight;
}