mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
[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:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ use frame_support::{
|
||||
use pallet_xcm::XcmPassthrough;
|
||||
use parachains_common::{
|
||||
impls::ToStakingPot,
|
||||
xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry},
|
||||
xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry},
|
||||
};
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
|
||||
FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser,
|
||||
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsPreset,
|
||||
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
};
|
||||
@@ -140,7 +140,8 @@ impl xcm_executor::Config for XcmConfig {
|
||||
// Collectives does not recognize a reserve location for any asset. Users must teleport DOT
|
||||
// where allowed (e.g. with the Relay Chain).
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT
|
||||
/// Only allow teleportation of DOT.
|
||||
type IsTeleporter = ConcreteNativeAssetFrom<DotLocation>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||
|
||||
Reference in New Issue
Block a user