[Feature] Limit collectives teleports to DOT (#1579)

* [Feature] Limit collectives teleports to DOT

* Update pallets/xcm/src/lib.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* fix review comments

* Update parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* [ci] Apply cargo-fmt

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: paritytech-ci <paritytech-ci@parity.io>
This commit is contained in:
Roman Useinov
2022-08-31 13:27:14 +02:00
committed by GitHub
parent 8fbecbf9bc
commit 1ab196df49
2 changed files with 18 additions and 5 deletions
+13 -1
View File
@@ -5,8 +5,9 @@ use frame_support::{
traits::{fungibles::Inspect, tokens::BalanceConversion},
weights::{Weight, WeightToFee, WeightToFeePolynomial},
};
use sp_runtime::traits::Get;
use xcm::latest::prelude::*;
use xcm_executor::traits::ShouldExecute;
use xcm_executor::traits::{FilterAssetLocation, ShouldExecute};
//TODO: move DenyThenTry to polkadot's xcm module.
/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
@@ -107,3 +108,14 @@ where
Ok(asset_amount)
}
}
/// Accepts an asset if it is a native asset from a particular `MultiLocation`.
pub struct ConcreteNativeAssetFrom<Location>(PhantomData<Location>);
impl<Location: Get<MultiLocation>> FilterAssetLocation for ConcreteNativeAssetFrom<Location> {
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
log::trace!(target: "xcm::filter_asset_location",
"ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}",
asset, origin, Location::get());
matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get())
}
}