frequency_runtime/xcm/
barrier.rs

1use frame_support::traits::{ConstU32, Contains, Everything};
2
3use staging_xcm::latest::prelude::*;
4use staging_xcm_builder::{
5	AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom,
6	AllowTopLevelPaidExecutionFrom, DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry,
7	TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
8};
9
10use crate::{xcm::parameters::UniversalLocation, PolkadotXcm};
11use parachains_common::xcm_config::ParentRelayOrSiblingParachains;
12
13pub struct ParentOrParentsExecutivePlurality;
14impl Contains<Location> for ParentOrParentsExecutivePlurality {
15	fn contains(location: &Location) -> bool {
16		matches!(location.unpack(), (1, []) | (1, [Plurality { id: BodyId::Executive, .. }]))
17	}
18}
19
20pub type Barrier = TrailingSetTopicAsId<
21	DenyThenTry<
22		DenyRecursively<DenyReserveTransferToRelayChain>,
23		(
24			// Allow local users to buy weight credit.
25			TakeWeightCredit,
26			// Expected responses are OK.
27			AllowKnownQueryResponses<PolkadotXcm>,
28			WithComputedOrigin<
29				(
30					// If the message is one that immediately attempts to pay for execution, then
31					// allow it.
32					AllowTopLevelPaidExecutionFrom<Everything>,
33					// Parent and its pluralities (i.e. governance bodies) get free execution.
34					AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
35					// Subscriptions for version tracking are OK.
36					AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
37				),
38				UniversalLocation,
39				ConstU32<8>,
40			>,
41		),
42	>,
43>;