git.delta.rocks / unique-network / refs/commits / 8d26c7374833

difftreelog

feat allow xcm transact for sys,gov and utility

Daniel Shiposha2023-09-26parent: #61fc26e.patch.diff
in: master

1 file changed

modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
15// 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/>.
1616
17use 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;
162162
163pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;163pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
164
165pub 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 }
182
183 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}
204
205impl 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}
164210
165pub 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;
194
195 // Deny all XCM Transacts.
196 type SafeCallFilter = Nothing;240 type SafeCallFilter = XcmCallFilter;
197}241}
198242
199#[cfg(feature = "runtime-benchmarks")]243#[cfg(feature = "runtime-benchmarks")]