Use new MultiLocation syntax everywhere (#570)

* Use new MultiLocation syntax everywhere

* Make tests compile
This commit is contained in:
Keith Yeung
2021-08-12 11:26:49 +02:00
committed by Bastian Köcher
parent e36689ffc8
commit 7d473c1c11
13 changed files with 442 additions and 423 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
use cumulus_primitives_core::DmpMessageHandler;
use codec::{Encode, Decode};
use sp_runtime::RuntimeDebug;
use xcm::{VersionedXcm, latest::{Xcm, Junction, Outcome, ExecuteXcm, Error as XcmError}};
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm, Error as XcmError}};
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
pub use pallet::*;
@@ -245,7 +245,7 @@ pub mod pallet {
Ok(0)
},
Ok(Ok(x)) => {
let outcome = T::XcmExecutor::execute_xcm(Junction::Parent.into(), x, limit);
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit);
match outcome {
Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)),
outcome => {
+3 -3
View File
@@ -25,7 +25,7 @@ use cumulus_primitives_core::{ParaId, DmpMessageHandler};
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
use codec::{Encode, Decode};
use sp_runtime::traits::BadOrigin;
use xcm::{VersionedXcm, latest::{Xcm, Junction, Outcome, ExecuteXcm}};
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm}};
use frame_support::dispatch::Weight;
pub use pallet::*;
@@ -118,7 +118,7 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)),
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
Ok(Ok(x)) => {
let outcome = T::XcmExecutor::execute_xcm(Junction::Parent.into(), x, limit);
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit);
used += outcome.weight_used();
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
}
@@ -149,7 +149,7 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
Ok(Ok(x)) => {
let weight_limit = limit.saturating_sub(used);
let outcome = T::XcmExecutor::execute_xcm(Junction::Parent.into(), x, weight_limit);
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, weight_limit);
used += outcome.weight_used();
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
}
+2 -2
View File
@@ -351,7 +351,7 @@ impl<T: Config> Pallet<T> {
log::debug!("Processing XCMP-XCM: {:?}", &hash);
let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
Ok(xcm) => {
let location = (Parent, Parachain(sender.into()));
let location = (1, Parachain(sender.into()));
match T::XcmExecutor::execute_xcm(location.into(), xcm, max_weight) {
Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)),
Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))),
@@ -777,7 +777,7 @@ impl<T: Config> SendXcm for Pallet<T> {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
match &dest {
// An HRMP message for a sibling parachain.
X2(Parent, Parachain(id)) => {
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
.map_err(|()| XcmError::DestinationUnsupported)?;
let hash = T::Hashing::hash_of(&versioned_xcm);
+2 -2
View File
@@ -104,8 +104,8 @@ impl cumulus_pallet_parachain_system::Config for Test {
}
parameter_types! {
pub const RelayChain: MultiLocation = X1(Parent);
pub Ancestry: MultiLocation = X1(Parachain(1u32.into()));
pub const RelayChain: MultiLocation = MultiLocation::parent();
pub Ancestry: MultiLocation = X1(Parachain(1u32.into())).into();
pub UnitWeightCost: Weight = 1_000_000;
}