Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Companion for paritytech/polkadot#7098
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed Apr 20, 2023
1 parent eced0cb commit b868e1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
16 changes: 8 additions & 8 deletions parachain-template/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
use core::{marker::PhantomData, ops::ControlFlow};
use frame_support::{
log, match_types, parameter_types,
traits::{ConstU32, Everything, Nothing},
traits::{ConstU32, Everything, Nothing, ProcessMessageError},
weights::Weight,
};
use frame_system::EnsureRoot;
Expand All @@ -15,10 +15,10 @@ use polkadot_runtime_common::impls::ToAuthor;
use xcm::{latest::prelude::*, CreateMatcher, MatchXcm};
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents, WithComputedOrigin,
CreateMatcher, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, MatchXcm,
NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin,
};
use xcm_executor::{traits::ShouldExecute, XcmExecutor};

Expand Down Expand Up @@ -108,7 +108,7 @@ where
message: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
) -> Result<(), ProcessMessageError> {
Deny::should_execute(origin, message, max_weight, weight_credit)?;
Allow::should_execute(origin, message, max_weight, weight_credit)
}
Expand All @@ -122,7 +122,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
message: &mut [Instruction<RuntimeCall>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
) -> Result<(), ProcessMessageError> {
message.matcher().match_next_inst_while(
|_| true,
|inst| match inst {
Expand All @@ -136,7 +136,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
TransferReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} => {
Err(()) // Deny
Err(ProcessMessageError::Unsupported) // Deny
},
// An unexpected reserve transfer has arrived from the Relay Chain. Generally,
// `IsReserve` should not allow this, but we just log it here.
Expand Down
13 changes: 8 additions & 5 deletions parachains/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ use crate::impls::AccountIdOf;
use core::{marker::PhantomData, ops::ControlFlow};
use frame_support::{
log,
traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair},
traits::{
fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair, ProcessMessageError,
},
weights::Weight,
};
use sp_runtime::traits::Get;
use xcm::{latest::prelude::*, CreateMatcher, MatchXcm};
use xcm::latest::prelude::*;
use xcm_builder::{CreateMatcher, MatchXcm};
use xcm_executor::traits::ShouldExecute;

//TODO: move DenyThenTry to polkadot's xcm module.
Expand All @@ -27,7 +30,7 @@ where
message: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
) -> Result<(), ProcessMessageError> {
Deny::should_execute(origin, message, max_weight, weight_credit)?;
Allow::should_execute(origin, message, max_weight, weight_credit)
}
Expand All @@ -41,7 +44,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
message: &mut [Instruction<RuntimeCall>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
) -> Result<(), ProcessMessageError> {
message.matcher().match_next_inst_while(
|_| true,
|inst| match inst {
Expand All @@ -55,7 +58,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
TransferReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} => {
Err(()) // Deny
Err(ProcessMessageError::Unsupported) // Deny
},

// An unexpected reserve transfer has arrived from the Relay Chain. Generally,
Expand Down

0 comments on commit b868e1d

Please sign in to comment.