From 48672a7342d21911f7913ee80494c7f3163f0d2c Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 11 Sep 2020 23:09:47 +0300 Subject: [PATCH] Make message-lane Event generic (#345) * make message-lane Event generic * cargo fmt --all * Update modules/message-lane/src/lib.rs Co-authored-by: Hernando Castano Co-authored-by: Hernando Castano --- modules/message-lane/src/lib.rs | 22 +++++++++++++++++----- modules/message-lane/src/mock.rs | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/message-lane/src/lib.rs b/modules/message-lane/src/lib.rs index 40517887e1579..0f581d0c659c3 100644 --- a/modules/message-lane/src/lib.rs +++ b/modules/message-lane/src/lib.rs @@ -49,7 +49,7 @@ mod mock; /// The module configuration trait pub trait Trait: frame_system::Trait { /// They overarching event type. - type Event: From + Into<::Event>; + type Event: From> + Into<::Event>; /// Message payload. type Payload: Parameter; /// Maximal number of messages that may be pruned during maintenance. Maintenance occurs @@ -75,13 +75,17 @@ decl_storage! { } decl_event!( - pub enum Event { + pub enum Event where + ::AccountId, + { /// Message has been accepted and is waiting to be delivered. MessageAccepted(LaneId, MessageNonce), /// Messages in the inclusive range have been delivered to the bridged chain. MessagesDelivered(LaneId, MessageNonce, MessageNonce), /// Messages in the inclusive range have been processed by the bridged chain. MessagesProcessed(LaneId, MessageNonce, MessageNonce), + /// Phantom member, never used. + Dummy(PhantomData<(AccountId, I)>), } ); @@ -102,7 +106,7 @@ decl_module! { let nonce = lane.send_message(payload); lane.prune_messages(T::MaxMessagesToPruneAtOnce::get()); - Self::deposit_event(Event::MessageAccepted(lane_id, nonce)); + Self::deposit_event(RawEvent::MessageAccepted(lane_id, nonce)); } } } @@ -153,7 +157,11 @@ impl, I: Instance> Module { let received_range = lane.confirm_receival(latest_received_nonce); if let Some(received_range) = received_range { - Self::deposit_event(Event::MessagesDelivered(*lane_id, received_range.0, received_range.1)); + Self::deposit_event(RawEvent::MessagesDelivered( + *lane_id, + received_range.0, + received_range.1, + )); } } @@ -166,7 +174,11 @@ impl, I: Instance> Module { let processed_range = lane.confirm_processing(latest_processed_nonce); if let Some(processed_range) = processed_range { - Self::deposit_event(Event::MessagesProcessed(*lane_id, processed_range.0, processed_range.1)); + Self::deposit_event(RawEvent::MessagesProcessed( + *lane_id, + processed_range.0, + processed_range.1, + )); } } } diff --git a/modules/message-lane/src/mock.rs b/modules/message-lane/src/mock.rs index 5512490751906..b56489c96a280 100644 --- a/modules/message-lane/src/mock.rs +++ b/modules/message-lane/src/mock.rs @@ -38,7 +38,7 @@ mod message_lane { impl_outer_event! { pub enum TestEvent for TestRuntime { frame_system, - message_lane, + message_lane, } }