staging_xcm_executor/traits/
drop_assets.rs1use crate::AssetsInHolding;
18use core::marker::PhantomData;
19use frame_support::traits::Contains;
20use xcm::latest::{Assets, Location, Weight, XcmContext};
21
22pub trait DropAssets {
24 fn drop_assets(origin: &Location, assets: AssetsInHolding, context: &XcmContext) -> Weight;
26}
27impl DropAssets for () {
28 fn drop_assets(_origin: &Location, _assets: AssetsInHolding, _context: &XcmContext) -> Weight {
29 Weight::zero()
30 }
31}
32
33pub struct FilterAssets<D, A>(PhantomData<(D, A)>);
36
37impl<D: DropAssets, A: Contains<AssetsInHolding>> DropAssets for FilterAssets<D, A> {
38 fn drop_assets(origin: &Location, assets: AssetsInHolding, context: &XcmContext) -> Weight {
39 if A::contains(&assets) {
40 D::drop_assets(origin, assets, context)
41 } else {
42 Weight::zero()
43 }
44 }
45}
46
47pub struct FilterOrigin<D, O>(PhantomData<(D, O)>);
51
52impl<D: DropAssets, O: Contains<Location>> DropAssets for FilterOrigin<D, O> {
53 fn drop_assets(origin: &Location, assets: AssetsInHolding, context: &XcmContext) -> Weight {
54 if O::contains(origin) {
55 D::drop_assets(origin, assets, context)
56 } else {
57 Weight::zero()
58 }
59 }
60}
61
62pub trait ClaimAssets {
64 fn claim_assets(
67 origin: &Location,
68 ticket: &Location,
69 what: &Assets,
70 context: &XcmContext,
71 ) -> bool;
72}
73
74#[impl_trait_for_tuples::impl_for_tuples(30)]
75impl ClaimAssets for Tuple {
76 fn claim_assets(
77 origin: &Location,
78 ticket: &Location,
79 what: &Assets,
80 context: &XcmContext,
81 ) -> bool {
82 for_tuples!( #(
83 if Tuple::claim_assets(origin, ticket, what, context) {
84 return true;
85 }
86 )* );
87 false
88 }
89}