diff --git a/pallets/xcm-handler/src/lib.rs b/pallets/xcm-handler/src/lib.rs index e64576cedbf..9b34e0a47ef 100644 --- a/pallets/xcm-handler/src/lib.rs +++ b/pallets/xcm-handler/src/lib.rs @@ -103,16 +103,17 @@ impl DownwardMessageHandler for Module { 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); } } @@ -120,7 +121,7 @@ impl HrmpMessageHandler for Module { 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, @@ -129,11 +130,12 @@ impl HrmpMessageHandler for Module { 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); } }