mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 04:41:04 +00:00
Fixes
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::Encode;
|
||||
use cumulus_primitives_core::UpwardMessageSender;
|
||||
use cumulus_primitives_core::{MessageSendError, UpwardMessageSender};
|
||||
use sp_std::marker::PhantomData;
|
||||
use xcm::{latest::prelude::*, WrapVersion};
|
||||
|
||||
@@ -33,22 +33,37 @@ use xcm::{latest::prelude::*, WrapVersion};
|
||||
/// for the `SendXcm` implementation.
|
||||
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
||||
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
||||
fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> SendResult {
|
||||
let dest = dest.into();
|
||||
type Ticket = Vec<u8>;
|
||||
|
||||
if dest.contains_parents_only(1) {
|
||||
fn validate(
|
||||
dest: &mut Option<MultiLocation>,
|
||||
msg: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<Vec<u8>> {
|
||||
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
||||
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
||||
|
||||
if d.contains_parents_only(1) {
|
||||
// An upward message for the relay chain.
|
||||
let versioned_xcm =
|
||||
W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
|
||||
W::wrap_version(&d, msg).map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let data = versioned_xcm.encode();
|
||||
let hash = data.using_encoded(sp_io::hashing::blake2_256);
|
||||
|
||||
T::send_upward_message(data).map_err(|e| SendError::Transport(e.into()))?;
|
||||
|
||||
Ok(hash)
|
||||
Ok(data, MultiAssets::new())
|
||||
} else {
|
||||
*dest = Some(d.clone());
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
Err(SendError::CannotReachDestination(dest, msg))
|
||||
Err(SendError::NotApplicable(d, xcm))
|
||||
}
|
||||
}
|
||||
|
||||
fn deliver(blob: Vec<u8>) -> Result<XcmHash, SendError> {
|
||||
let hash = data.using_encoded(sp_io::hashing::blake2_256);
|
||||
|
||||
T::send_upward_message(data).map_err(|e| match e {
|
||||
MessageSendError::TooBig => SendError::ExceedsMaxMessageSize,
|
||||
e => SendError::Transport(e.into()),
|
||||
})?;
|
||||
|
||||
Ok(hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user