Use new MultiLocation syntax everywhere (#570)

* Use new MultiLocation syntax everywhere

* Make tests compile
This commit is contained in:
Keith Yeung
2021-08-12 11:26:49 +02:00
committed by GitHub
parent 38f7e93d82
commit da5634a712
13 changed files with 358 additions and 324 deletions
+9 -10
View File
@@ -34,20 +34,19 @@ use xcm::{WrapVersion, latest::prelude::*};
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 {
if dest.contains_parents_only(1) {
// An upward message for the relay chain.
X1(Parent) => {
let versioned_xcm = W::wrap_version(&dest, msg)
.map_err(|()| XcmError::DestinationUnsupported)?;
let data = versioned_xcm.encode();
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()))?;
T::send_upward_message(data)
.map_err(|e| XcmError::SendFailed(e.into()))?;
Ok(())
}
Ok(())
} else {
// Anything else is unhandled. This includes a message this is meant for us.
_ => Err(XcmError::CannotReachDestination(dest, msg)),
Err(XcmError::CannotReachDestination(dest, msg))
}
}
}