mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Fixes
This commit is contained in:
@@ -67,13 +67,13 @@ pub mod pallet {
|
||||
pub enum Event<T: Config> {
|
||||
/// Downward message is invalid XCM.
|
||||
/// \[ id \]
|
||||
InvalidFormat([u8; 8]),
|
||||
InvalidFormat([u8; 32]),
|
||||
/// Downward message is unsupported version of XCM.
|
||||
/// \[ id \]
|
||||
UnsupportedVersion([u8; 8]),
|
||||
UnsupportedVersion([u8; 32]),
|
||||
/// Downward message executed with the given outcome.
|
||||
/// \[ id, outcome \]
|
||||
ExecutedDownward([u8; 8], Outcome),
|
||||
ExecutedDownward([u8; 32], Outcome),
|
||||
}
|
||||
|
||||
/// Origin for the parachains module.
|
||||
|
||||
@@ -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