mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
* Update .gitignore and bring into line with XCM v2's SendError * type * Some work * Weighed responses * extra fields to xcm pallet * Fixes * Bump
This commit is contained in:
@@ -5,3 +5,5 @@
|
|||||||
/.cargo/config
|
/.cargo/config
|
||||||
polkadot_argument_parsing
|
polkadot_argument_parsing
|
||||||
**/node_modules
|
**/node_modules
|
||||||
|
**/chains/
|
||||||
|
*.iml
|
||||||
|
|||||||
Generated
+274
-293
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@ use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
|
|||||||
use cumulus_primitives_core::DmpMessageHandler;
|
use cumulus_primitives_core::DmpMessageHandler;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm, Error as XcmError}};
|
use xcm::{VersionedXcm, latest::prelude::*};
|
||||||
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
|
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
@@ -422,8 +422,8 @@ mod tests {
|
|||||||
weight_limit: Weight,
|
weight_limit: Weight,
|
||||||
_credit: Weight,
|
_credit: Weight,
|
||||||
) -> Outcome {
|
) -> Outcome {
|
||||||
let o = match &message {
|
let o = match (message.0.len(), &message.0.first()) {
|
||||||
Xcm::Transact { require_weight_at_most, .. } => {
|
(1, Some(Transact { require_weight_at_most, .. })) => {
|
||||||
if *require_weight_at_most <= weight_limit {
|
if *require_weight_at_most <= weight_limit {
|
||||||
Outcome::Complete(*require_weight_at_most)
|
Outcome::Complete(*require_weight_at_most)
|
||||||
} else {
|
} else {
|
||||||
@@ -466,11 +466,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn msg(weight: Weight) -> Xcm {
|
fn msg(weight: Weight) -> Xcm {
|
||||||
Xcm::Transact {
|
Xcm(vec![Transact {
|
||||||
origin_type: OriginKind::Native,
|
origin_type: OriginKind::Native,
|
||||||
require_weight_at_most: weight,
|
require_weight_at_most: weight,
|
||||||
call: vec![].into(),
|
call: vec![].into(),
|
||||||
}
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg_complete(weight: Weight) -> (Xcm, Outcome) {
|
fn msg_complete(weight: Weight) -> (Xcm, Outcome) {
|
||||||
|
|||||||
@@ -774,24 +774,24 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
|
|||||||
|
|
||||||
/// Xcm sender for sending to a sibling parachain.
|
/// Xcm sender for sending to a sibling parachain.
|
||||||
impl<T: Config> SendXcm for Pallet<T> {
|
impl<T: Config> SendXcm for Pallet<T> {
|
||||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
|
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
|
||||||
match &dest {
|
match &dest {
|
||||||
// An HRMP message for a sibling parachain.
|
// An HRMP message for a sibling parachain.
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
||||||
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
||||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
let hash = T::Hashing::hash_of(&versioned_xcm);
|
||||||
Self::send_fragment(
|
Self::send_fragment(
|
||||||
(*id).into(),
|
(*id).into(),
|
||||||
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
||||||
versioned_xcm,
|
versioned_xcm,
|
||||||
)
|
)
|
||||||
.map_err(|e| XcmError::SendFailed(<&'static str>::from(e)))?;
|
.map_err(|e| SendError::Transport(<&'static str>::from(e)))?;
|
||||||
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
// Anything else is unhandled. This includes a message this is meant for us.
|
// Anything else is unhandled. This includes a message this is meant for us.
|
||||||
_ => Err(XcmError::CannotReachDestination(dest, msg)),
|
_ => Err(SendError::CannotReachDestination(dest, msg)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ parameter_types! {
|
|||||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
||||||
pub Ancestry: MultiLocation = X1(Parachain(1u32.into())).into();
|
pub Ancestry: MultiLocation = X1(Parachain(1u32.into())).into();
|
||||||
pub UnitWeightCost: Weight = 1_000_000;
|
pub UnitWeightCost: Weight = 1_000_000;
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Means for transacting assets on this chain.
|
/// Means for transacting assets on this chain.
|
||||||
@@ -138,7 +139,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type IsTeleporter = NativeAsset;
|
type IsTeleporter = NativeAsset;
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = ();
|
type Barrier = ();
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type Trader = ();
|
type Trader = ();
|
||||||
type ResponseHandler = ();
|
type ResponseHandler = ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
use xcm::latest::prelude::*;
|
||||||
use sp_runtime::traits::Saturating;
|
use sp_runtime::traits::Saturating;
|
||||||
use frame_system::Config as SystemConfig;
|
use frame_system::Config as SystemConfig;
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para};
|
use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para};
|
||||||
use xcm::latest::{Xcm, Error as XcmError, SendXcm, OriginKind, Junction};
|
|
||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ pub mod pallet {
|
|||||||
Pinged(ParaId, u32, Vec<u8>),
|
Pinged(ParaId, u32, Vec<u8>),
|
||||||
PongSent(ParaId, u32, Vec<u8>),
|
PongSent(ParaId, u32, Vec<u8>),
|
||||||
Ponged(ParaId, u32, Vec<u8>, T::BlockNumber),
|
Ponged(ParaId, u32, Vec<u8>, T::BlockNumber),
|
||||||
ErrorSendingPing(XcmError, ParaId, u32, Vec<u8>),
|
ErrorSendingPing(SendError, ParaId, u32, Vec<u8>),
|
||||||
ErrorSendingPong(XcmError, ParaId, u32, Vec<u8>),
|
ErrorSendingPong(SendError, ParaId, u32, Vec<u8>),
|
||||||
UnknownPong(ParaId, u32, Vec<u8>),
|
UnknownPong(ParaId, u32, Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,11 +102,11 @@ pub mod pallet {
|
|||||||
let seq = PingCount::<T>::mutate(|seq| { *seq += 1; *seq });
|
let seq = PingCount::<T>::mutate(|seq| { *seq += 1; *seq });
|
||||||
match T::XcmSender::send_xcm(
|
match T::XcmSender::send_xcm(
|
||||||
(1, Junction::Parachain(para.into())).into(),
|
(1, Junction::Parachain(para.into())).into(),
|
||||||
Xcm::Transact {
|
Xcm(vec![Transact {
|
||||||
origin_type: OriginKind::Native,
|
origin_type: OriginKind::Native,
|
||||||
require_weight_at_most: 1_000,
|
require_weight_at_most: 1_000,
|
||||||
call: <T as Config>::Call::from(Call::<T>::ping(seq, payload.clone())).encode().into(),
|
call: <T as Config>::Call::from(Call::<T>::ping(seq, payload.clone())).encode().into(),
|
||||||
},
|
}]),
|
||||||
) {
|
) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
Pings::<T>::insert(seq, n);
|
Pings::<T>::insert(seq, n);
|
||||||
@@ -164,11 +164,11 @@ pub mod pallet {
|
|||||||
Self::deposit_event(Event::Pinged(para, seq, payload.clone()));
|
Self::deposit_event(Event::Pinged(para, seq, payload.clone()));
|
||||||
match T::XcmSender::send_xcm(
|
match T::XcmSender::send_xcm(
|
||||||
(1, Junction::Parachain(para.into())).into(),
|
(1, Junction::Parachain(para.into())).into(),
|
||||||
Xcm::Transact {
|
Xcm(vec![Transact {
|
||||||
origin_type: OriginKind::Native,
|
origin_type: OriginKind::Native,
|
||||||
require_weight_at_most: 1_000,
|
require_weight_at_most: 1_000,
|
||||||
call: <T as Config>::Call::from(Call::<T>::pong(seq, payload.clone())).encode().into(),
|
call: <T as Config>::Call::from(Call::<T>::pong(seq, payload.clone())).encode().into(),
|
||||||
},
|
}]),
|
||||||
) {
|
) {
|
||||||
Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)),
|
Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)),
|
||||||
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
|
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ parameter_types! {
|
|||||||
pub UnitWeightCost: Weight = 1_000_000;
|
pub UnitWeightCost: Weight = 1_000_000;
|
||||||
// One ROC buys 1 second of weight.
|
// One ROC buys 1 second of weight.
|
||||||
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), ROC);
|
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), ROC);
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_type! {
|
match_type! {
|
||||||
@@ -345,7 +346,7 @@ impl Config for XcmConfig {
|
|||||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
|
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
|
type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
|
||||||
type ResponseHandler = (); // Don't handle responses for now.
|
type ResponseHandler = (); // Don't handle responses for now.
|
||||||
}
|
}
|
||||||
@@ -371,8 +372,10 @@ impl pallet_xcm::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type XcmTeleportFilter = Everything;
|
type XcmTeleportFilter = Everything;
|
||||||
type XcmReserveTransferFilter = frame_support::traits::Nothing;
|
type XcmReserveTransferFilter = frame_support::traits::Nothing;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
|
type Origin = Origin;
|
||||||
|
type Call = Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_xcm::Config for Runtime {
|
impl cumulus_pallet_xcm::Config for Runtime {
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ match_type! {
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
|
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
|
||||||
pub UnitWeightCost: Weight = 1_000_000;
|
pub UnitWeightCost: Weight = 1_000_000;
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct XcmConfig;
|
pub struct XcmConfig;
|
||||||
@@ -209,7 +210,7 @@ impl Config for XcmConfig {
|
|||||||
type IsTeleporter = (); // balances not supported
|
type IsTeleporter = (); // balances not supported
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = AllowUnpaidExecutionFrom<JustTheParent>;
|
type Barrier = AllowUnpaidExecutionFrom<JustTheParent>;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; // balances not supported
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>; // balances not supported
|
||||||
type Trader = (); // balances not supported
|
type Trader = (); // balances not supported
|
||||||
type ResponseHandler = (); // Don't handle responses for now.
|
type ResponseHandler = (); // Don't handle responses for now.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
|
||||||
pub UnitWeightCost: Weight = 1_000_000_000;
|
pub UnitWeightCost: Weight = 1_000_000_000;
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_type! {
|
match_type! {
|
||||||
@@ -539,7 +540,7 @@ impl Config for XcmConfig {
|
|||||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of KSM
|
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of KSM
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type Trader = UsingComponents<IdentityFee<Balance>, KsmLocation, AccountId, Balances, ()>;
|
type Trader = UsingComponents<IdentityFee<Balance>, KsmLocation, AccountId, Balances, ()>;
|
||||||
type ResponseHandler = (); // Don't handle responses for now.
|
type ResponseHandler = (); // Don't handle responses for now.
|
||||||
}
|
}
|
||||||
@@ -569,8 +570,10 @@ impl pallet_xcm::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type XcmTeleportFilter = Everything;
|
type XcmTeleportFilter = Everything;
|
||||||
type XcmReserveTransferFilter = Everything;
|
type XcmReserveTransferFilter = Everything;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
|
type Origin = Origin;
|
||||||
|
type Call = Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_xcm::Config for Runtime {
|
impl cumulus_pallet_xcm::Config for Runtime {
|
||||||
|
|||||||
@@ -477,6 +477,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
|
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
|
||||||
pub UnitWeightCost: Weight = 1_000_000;
|
pub UnitWeightCost: Weight = 1_000_000;
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_type! {
|
match_type! {
|
||||||
@@ -504,7 +505,7 @@ impl Config for XcmConfig {
|
|||||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT
|
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type Trader = UsingComponents<IdentityFee<Balance>, DotLocation, AccountId, Balances, ()>;
|
type Trader = UsingComponents<IdentityFee<Balance>, DotLocation, AccountId, Balances, ()>;
|
||||||
type ResponseHandler = (); // Don't handle responses for now.
|
type ResponseHandler = (); // Don't handle responses for now.
|
||||||
}
|
}
|
||||||
@@ -534,8 +535,10 @@ impl pallet_xcm::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type XcmTeleportFilter = Everything;
|
type XcmTeleportFilter = Everything;
|
||||||
type XcmReserveTransferFilter = Everything;
|
type XcmReserveTransferFilter = Everything;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
|
type Origin = Origin;
|
||||||
|
type Call = Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_xcm::Config for Runtime {
|
impl cumulus_pallet_xcm::Config for Runtime {
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub UnitWeightCost: Weight = 1_000;
|
pub UnitWeightCost: Weight = 1_000;
|
||||||
|
pub const MaxInstructions: u32 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_type! {
|
match_type! {
|
||||||
@@ -502,7 +503,7 @@ impl Config for XcmConfig {
|
|||||||
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of WND
|
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of WND
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type Trader = UsingComponents<IdentityFee<Balance>, WestendLocation, AccountId, Balances, ()>;
|
type Trader = UsingComponents<IdentityFee<Balance>, WestendLocation, AccountId, Balances, ()>;
|
||||||
type ResponseHandler = (); // Don't handle responses for now.
|
type ResponseHandler = (); // Don't handle responses for now.
|
||||||
}
|
}
|
||||||
@@ -532,8 +533,10 @@ impl pallet_xcm::Config for Runtime {
|
|||||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||||
type XcmTeleportFilter = Everything;
|
type XcmTeleportFilter = Everything;
|
||||||
type XcmReserveTransferFilter = Everything;
|
type XcmReserveTransferFilter = Everything;
|
||||||
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
|
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
|
||||||
type LocationInverter = LocationInverter<Ancestry>;
|
type LocationInverter = LocationInverter<Ancestry>;
|
||||||
|
type Origin = Origin;
|
||||||
|
type Call = Call;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cumulus_pallet_xcm::Config for Runtime {
|
impl cumulus_pallet_xcm::Config for Runtime {
|
||||||
|
|||||||
@@ -33,20 +33,20 @@ use xcm::{WrapVersion, latest::prelude::*};
|
|||||||
/// for the `SendXcm` implementation.
|
/// for the `SendXcm` implementation.
|
||||||
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
|
||||||
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
|
||||||
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
|
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
|
||||||
if dest.contains_parents_only(1) {
|
if dest.contains_parents_only(1) {
|
||||||
// An upward message for the relay chain.
|
// An upward message for the relay chain.
|
||||||
let versioned_xcm = W::wrap_version(&dest, msg)
|
let versioned_xcm = W::wrap_version(&dest, msg)
|
||||||
.map_err(|()| XcmError::DestinationUnsupported)?;
|
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||||
let data = versioned_xcm.encode();
|
let data = versioned_xcm.encode();
|
||||||
|
|
||||||
T::send_upward_message(data)
|
T::send_upward_message(data)
|
||||||
.map_err(|e| XcmError::SendFailed(e.into()))?;
|
.map_err(|e| SendError::Transport(e.into()))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
// Anything else is unhandled. This includes a message this is meant for us.
|
// Anything else is unhandled. This includes a message this is meant for us.
|
||||||
Err(XcmError::CannotReachDestination(dest, msg))
|
Err(SendError::CannotReachDestination(dest, msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user