mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 14:07:58 +00:00
* support for XCM v1 * Fixes * Fix. * Use `xcm::latest` * Bump Polkadot Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
committed by
Bastian Köcher
parent
fd80849dde
commit
e36689ffc8
@@ -42,11 +42,8 @@ use rand_chacha::{
|
||||
ChaChaRng,
|
||||
};
|
||||
use sp_runtime::{traits::Hash, RuntimeDebug};
|
||||
use sp_std::{convert::TryFrom, prelude::*};
|
||||
use xcm::{
|
||||
v0::{Error as XcmError, ExecuteXcm, Junction, MultiLocation, Outcome, SendXcm, Xcm},
|
||||
VersionedXcm,
|
||||
};
|
||||
use sp_std::{prelude::*, convert::TryFrom};
|
||||
use xcm::{latest::prelude::*, WrapVersion, VersionedXcm};
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
@@ -69,6 +66,9 @@ pub mod pallet {
|
||||
|
||||
/// Information on the avaialble XCMP channels.
|
||||
type ChannelInfo: GetChannelInfo;
|
||||
|
||||
/// Means of converting an `Xcm` into a `VersionedXcm`.
|
||||
type VersionWrapper: WrapVersion;
|
||||
}
|
||||
|
||||
impl Default for QueueConfigData {
|
||||
@@ -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 = (Junction::Parent, Junction::Parachain(sender.into()));
|
||||
let location = (Parent, 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,13 +777,14 @@ 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.
|
||||
MultiLocation::X2(Junction::Parent, Junction::Parachain(id)) => {
|
||||
let msg = VersionedXcm::<()>::from(msg);
|
||||
let hash = T::Hashing::hash_of(&msg);
|
||||
X2(Parent, Parachain(id)) => {
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
||||
Self::send_fragment(
|
||||
(*id).into(),
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
||||
msg,
|
||||
versioned_xcm,
|
||||
)
|
||||
.map_err(|e| XcmError::SendFailed(<&'static str>::from(e)))?;
|
||||
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
||||
|
||||
@@ -17,10 +17,7 @@ use super::*;
|
||||
use crate as xcmp_queue;
|
||||
use sp_core::H256;
|
||||
use frame_support::parameter_types;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
testing::{Header},
|
||||
};
|
||||
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
|
||||
use xcm_builder::{
|
||||
FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, CurrencyAdapter,
|
||||
ParentIsDefault,
|
||||
@@ -107,10 +104,8 @@ impl cumulus_pallet_parachain_system::Config for Test {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayChain: MultiLocation = MultiLocation::X1(Junction::Parent);
|
||||
pub Ancestry: MultiLocation = MultiLocation::X1(
|
||||
Junction::Parachain(1u32.into())
|
||||
);
|
||||
pub const RelayChain: MultiLocation = X1(Parent);
|
||||
pub Ancestry: MultiLocation = X1(Parachain(1u32.into()));
|
||||
pub UnitWeightCost: Weight = 1_000_000;
|
||||
}
|
||||
|
||||
@@ -157,6 +152,7 @@ impl Config for Test {
|
||||
type Event = Event;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type ChannelInfo = ParachainSystem;
|
||||
type VersionWrapper = ();
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
|
||||
Reference in New Issue
Block a user