difftreelog
feat allow xcm transact for sys,gov and utility
in: master
1 file changed
runtime/common/config/xcm/mod.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_support::{17use frame_support::{18 traits::{Everything, Nothing, Get, ConstU32, ProcessMessageError},18 traits::{Everything, Nothing, Get, ConstU32, ProcessMessageError, Contains},19 parameter_types,19 parameter_types,20};20};21use frame_system::EnsureRoot;21use frame_system::EnsureRoot;162162163pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;163pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;164165pub struct XcmCallFilter;166impl XcmCallFilter {167 fn allow_gov_and_sys_call(call: &RuntimeCall) -> bool {168 match call {169 RuntimeCall::System(..)170 | RuntimeCall::Identity(..)171 | RuntimeCall::Preimage(..)172 | RuntimeCall::Democracy(..)173 | RuntimeCall::Council(..)174 | RuntimeCall::TechnicalCommittee(..)175 | RuntimeCall::CouncilMembership(..)176 | RuntimeCall::TechnicalCommitteeMembership(..)177 | RuntimeCall::FellowshipCollective(..)178 | RuntimeCall::FellowshipReferenda(..) => true,179 _ => false,180 }181 }182183 fn allow_utility_call(call: &RuntimeCall) -> bool {184 match call {185 RuntimeCall::Utility(pallet_utility::Call::batch { calls, .. }) => {186 calls.iter().all(|call| Self::allow_gov_and_sys_call(call))187 }188 RuntimeCall::Utility(pallet_utility::Call::batch_all { calls, .. }) => {189 calls.iter().all(|call| Self::allow_gov_and_sys_call(call))190 }191 RuntimeCall::Utility(pallet_utility::Call::as_derivative { call, .. }) => {192 Self::allow_gov_and_sys_call(call)193 }194 RuntimeCall::Utility(pallet_utility::Call::dispatch_as { call, .. }) => {195 Self::allow_gov_and_sys_call(call)196 }197 RuntimeCall::Utility(pallet_utility::Call::force_batch { calls, .. }) => {198 calls.iter().all(|call| Self::allow_gov_and_sys_call(call))199 }200 _ => false,201 }202 }203}204205impl Contains<RuntimeCall> for XcmCallFilter {206 fn contains(call: &RuntimeCall) -> bool {207 Self::allow_gov_and_sys_call(call) || Self::allow_utility_call(call)208 }209}164210165pub struct XcmExecutorConfig<T>(PhantomData<T>);211pub struct XcmExecutorConfig<T>(PhantomData<T>);166impl<T> xcm_executor::Config for XcmExecutorConfig<T>212impl<T> xcm_executor::Config for XcmExecutorConfig<T>192 type UniversalAliases = Nothing;238 type UniversalAliases = Nothing;193 type CallDispatcher = RuntimeCall;239 type CallDispatcher = RuntimeCall;194195 // Deny all XCM Transacts.196 type SafeCallFilter = Nothing;240 type SafeCallFilter = XcmCallFilter;197}241}198242199#[cfg(feature = "runtime-benchmarks")]243#[cfg(feature = "runtime-benchmarks")]