Add XCM Handler (#267)

* initial mock

* integrate xcm-handler into runtime

* expose xcm send error

* oops

* better comment
This commit is contained in:
Shawn Tabrizi
2020-12-17 09:42:00 -08:00
committed by GitHub
parent 8226063135
commit afc50e8ade
8 changed files with 349 additions and 3 deletions
+15 -3
View File
@@ -34,7 +34,7 @@ use sp_std::{cmp, prelude::*};
use cumulus_primitives::{
inherents::{MessageIngestionType, MESSAGE_INGESTION_IDENTIFIER},
well_known_keys, DownwardMessageHandler, HrmpMessageHandler, OutboundHrmpMessage, ParaId,
UpwardMessage,
UpwardMessage, UpwardMessageSender, HrmpMessageSender,
};
// TODO: these should be not a constant, but sourced from the relay-chain configuration.
@@ -201,7 +201,7 @@ pub enum SendUpErr {
}
/// An error that can be raised upon sending a horizontal message.
pub enum SendHorizonalErr {
pub enum SendHorizontalErr {
/// The message sent is too big.
TooBig,
/// There is no channel to the specified destination.
@@ -216,7 +216,7 @@ impl<T: Config> Module<T> {
Ok(())
}
pub fn send_hrmp_message(message: OutboundHrmpMessage) -> Result<(), SendHorizonalErr> {
pub fn send_hrmp_message(message: OutboundHrmpMessage) -> Result<(), SendHorizontalErr> {
// TODO:
// (a) check against the size limit sourced from the relay-chain configuration
// (b) check if the channel to the recipient is actually opened.
@@ -234,6 +234,18 @@ impl<T: Config> Module<T> {
}
}
impl<T: Config> UpwardMessageSender for Module<T> {
fn send_upward_message(message: UpwardMessage) -> Result<(), ()> {
Self::send_upward_message(message).map_err(|_| ())
}
}
impl<T: Config> HrmpMessageSender for Module<T> {
fn send_hrmp_message(message: OutboundHrmpMessage) -> Result<(), ()> {
Self::send_hrmp_message(message).map_err(|_| ())
}
}
impl<T: Config> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = MakeFatalError<()>;