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
use crate::Assets;
use core::marker::PhantomData;
use frame_support::traits::Contains;
use sp_runtime::traits::Zero;
use xcm::latest::{MultiAssets, MultiLocation, Weight};
pub trait DropAssets {
fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight;
}
impl DropAssets for () {
fn drop_assets(_origin: &MultiLocation, _assets: Assets) -> Weight {
Weight::zero()
}
}
pub struct FilterAssets<D, A>(PhantomData<(D, A)>);
impl<D: DropAssets, A: Contains<Assets>> DropAssets for FilterAssets<D, A> {
fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight {
if A::contains(&assets) {
D::drop_assets(origin, assets)
} else {
Weight::zero()
}
}
}
pub struct FilterOrigin<D, O>(PhantomData<(D, O)>);
impl<D: DropAssets, O: Contains<MultiLocation>> DropAssets for FilterOrigin<D, O> {
fn drop_assets(origin: &MultiLocation, assets: Assets) -> Weight {
if O::contains(origin) {
D::drop_assets(origin, assets)
} else {
Weight::zero()
}
}
}
pub trait ClaimAssets {
fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, what: &MultiAssets) -> bool;
}
#[impl_trait_for_tuples::impl_for_tuples(30)]
impl ClaimAssets for Tuple {
fn claim_assets(origin: &MultiLocation, ticket: &MultiLocation, what: &MultiAssets) -> bool {
for_tuples!( #(
if Tuple::claim_assets(origin, ticket, what) {
return true;
}
)* );
false
}
}