mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +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
@@ -22,7 +22,7 @@
|
||||
use sp_std::marker::PhantomData;
|
||||
use codec::Encode;
|
||||
use cumulus_primitives_core::UpwardMessageSender;
|
||||
use xcm::{VersionedXcm, v0::{Xcm, MultiLocation, Junction, SendXcm, Error as XcmError}};
|
||||
use xcm::{WrapVersion, latest::prelude::*};
|
||||
|
||||
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into
|
||||
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
|
||||
@@ -31,13 +31,15 @@ use xcm::{VersionedXcm, v0::{Xcm, MultiLocation, Junction, SendXcm, Error as Xcm
|
||||
/// NOTE: This is a pretty dumb "just send it" router; we will probably want to introduce queuing
|
||||
/// to UMP eventually and when we do, the pallet which implements the queuing will be responsible
|
||||
/// for the `SendXcm` implementation.
|
||||
pub struct ParentAsUmp<T>(PhantomData<T>);
|
||||
impl<T: UpwardMessageSender> SendXcm for ParentAsUmp<T> {
|
||||
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
||||
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
|
||||
match &dest {
|
||||
// An upward message for the relay chain.
|
||||
MultiLocation::X1(Junction::Parent) => {
|
||||
let data = VersionedXcm::<()>::from(msg).encode();
|
||||
MultiLocation::X1(Parent) => {
|
||||
let versioned_xcm = W::wrap_version(&dest, msg)
|
||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
||||
let data = versioned_xcm.encode();
|
||||
|
||||
T::send_upward_message(data)
|
||||
.map_err(|e| XcmError::SendFailed(e.into()))?;
|
||||
|
||||
Reference in New Issue
Block a user