1234567891011121314151617use cumulus_pallet_xcm;18use frame_support::{19 {match_types, parameter_types, weights::Weight},20 pallet_prelude::Get,21 traits::{Contains, Everything, fungibles},22};23use frame_system::EnsureRoot;24use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};25use pallet_xcm::XcmPassthrough;26use polkadot_parachain::primitives::Sibling;27use sp_runtime::traits::{AccountIdConversion, CheckedConversion, Convert, Zero};28use sp_std::{borrow::Borrow, marker::PhantomData, vec, vec::Vec};29use xcm::{30 latest::{MultiAsset, Xcm},31 prelude::{Concrete, Fungible as XcmFungible},32 v1::{BodyId, Junction::*, Junctions::*, MultiLocation, NetworkId},33};34use xcm_builder::{35 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,36 EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentAsSuperuser,37 ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,38 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,39 ConvertedConcreteAssetId,40};41use xcm_executor::{42 {Config, XcmExecutor},43 traits::{Convert as ConvertXcm, FilterAssetLocation, JustTry, MatchesFungible, ShouldExecute},44};4546use up_common::{47 constants::{MAXIMUM_BLOCK_WEIGHT, UNIQUE},48 types::{AccountId, Balance},49};5051use crate::{52 Balances, Call, DmpQueue, Event, Origin, ParachainInfo,53 ParachainSystem, PolkadotXcm, Runtime, XcmpQueue,54};55use crate::runtime_common::config::substrate::{TreasuryModuleId, MaxLocks, MaxReserves};56use crate::runtime_common::config::pallets::TreasuryAccountId;57use crate::runtime_common::config::xcm::*;58use crate::*;596061pub type Amount = i128;6263match_types! {64 pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {65 MultiLocation { parents: 1, interior: Here } |66 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }67 };68 pub type ParentOrSiblings: impl Contains<MultiLocation> = {69 MultiLocation { parents: 1, interior: Here } |70 MultiLocation { parents: 1, interior: X1(_) }71 };72}73747576pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)77 where78 Deny: ShouldExecute,79 Allow: ShouldExecute;8081impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>82 where83 Deny: ShouldExecute,84 Allow: ShouldExecute,85{86 fn should_execute<Call>(87 origin: &MultiLocation,88 message: &mut Xcm<Call>,89 max_weight: Weight,90 weight_credit: &mut Weight,91 ) -> Result<(), ()> {92 Deny::should_execute(origin, message, max_weight, weight_credit)?;93 Allow::should_execute(origin, message, max_weight, weight_credit)94 }95}9697pub type Barrier = DenyThenTry<98 DenyExchangeWithUnknownLocation,99 (100 TakeWeightCredit,101 AllowTopLevelPaidExecutionFrom<Everything>,102 103 AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,104 105 AllowKnownQueryResponses<PolkadotXcm>,106 107 AllowSubscriptionsFrom<ParentOrSiblings>,108 ),109>;