Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Deposit XCM execution success and fail events. (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunxw authored Feb 23, 2021
1 parent da79d42 commit d8126cd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pallets/xcm-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,25 @@ impl<T: Config> DownwardMessageHandler for Module<T> {
fn handle_downward_message(msg: InboundDownwardMessage) {
let hash = msg.using_encoded(T::Hashing::hash);
frame_support::debug::print!("Processing Downward XCM: {:?}", &hash);
match VersionedXcm::decode(&mut &msg.msg[..]).map(Xcm::try_from) {
let event = match VersionedXcm::decode(&mut &msg.msg[..]).map(Xcm::try_from) {
Ok(Ok(xcm)) => {
match T::XcmExecutor::execute_xcm(Junction::Parent.into(), xcm) {
Ok(..) => RawEvent::Success(hash),
Err(e) => RawEvent::Fail(hash, e),
};
}
}
Ok(Err(..)) => Self::deposit_event(RawEvent::BadVersion(hash)),
Err(..) => Self::deposit_event(RawEvent::BadFormat(hash)),
}
Ok(Err(..)) => RawEvent::BadVersion(hash),
Err(..) => RawEvent::BadFormat(hash),
};
Self::deposit_event(event);
}
}

impl<T: Config> HrmpMessageHandler for Module<T> {
fn handle_hrmp_message(sender: ParaId, msg: InboundHrmpMessage) {
let hash = msg.using_encoded(T::Hashing::hash);
frame_support::debug::print!("Processing HRMP XCM: {:?}", &hash);
match VersionedXcm::decode(&mut &msg.data[..]).map(Xcm::try_from) {
let event = match VersionedXcm::decode(&mut &msg.data[..]).map(Xcm::try_from) {
Ok(Ok(xcm)) => {
let location = (
Junction::Parent,
Expand All @@ -129,11 +130,12 @@ impl<T: Config> HrmpMessageHandler for Module<T> {
match T::XcmExecutor::execute_xcm(location.into(), xcm) {
Ok(..) => RawEvent::Success(hash),
Err(e) => RawEvent::Fail(hash, e),
};
}
}
Ok(Err(..)) => Self::deposit_event(RawEvent::BadVersion(hash)),
Err(..) => Self::deposit_event(RawEvent::BadFormat(hash)),
}
Ok(Err(..)) => RawEvent::BadVersion(hash),
Err(..) => RawEvent::BadFormat(hash),
};
Self::deposit_event(event);
}
}

Expand Down

0 comments on commit d8126cd

Please sign in to comment.