Skip to content

Commit

Permalink
backport named events PR (paritytech#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent e31a260 commit fd80f8a
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub mod pallet {
) -> DispatchResult {
Self::ensure_owner_or_root(origin)?;
parameter.save();
Self::deposit_event(Event::ParameterUpdated(parameter));
Self::deposit_event(Event::ParameterUpdated { parameter });
Ok(())
}

Expand Down Expand Up @@ -623,7 +623,10 @@ pub mod pallet {

// emit 'delivered' event
let received_range = confirmed_messages.begin..=confirmed_messages.end;
Self::deposit_event(Event::MessagesDelivered(lane_id, confirmed_messages));
Self::deposit_event(Event::MessagesDelivered {
lane_id,
messages: confirmed_messages,
});

// if some new messages have been confirmed, reward relayers
let relayer_fund_account =
Expand Down Expand Up @@ -652,11 +655,11 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
/// Pallet parameter has been updated.
ParameterUpdated(T::Parameter),
ParameterUpdated { parameter: T::Parameter },
/// Message has been accepted and is waiting to be delivered.
MessageAccepted(LaneId, MessageNonce),
MessageAccepted { lane_id: LaneId, nonce: MessageNonce },
/// Messages in the inclusive range have been delivered to the bridged chain.
MessagesDelivered(LaneId, DeliveredMessages),
MessagesDelivered { lane_id: LaneId, messages: DeliveredMessages },
}

#[pallet::error]
Expand Down Expand Up @@ -942,7 +945,7 @@ fn send_message<T: Config<I>, I: 'static>(
encoded_payload_len,
);

Pallet::<T, I>::deposit_event(Event::MessageAccepted(lane_id, nonce));
Pallet::<T, I>::deposit_event(Event::MessageAccepted { lane_id, nonce });

Ok(SendMessageArtifacts { nonce, weight: actual_weight })
}
Expand Down Expand Up @@ -1188,7 +1191,10 @@ mod tests {
System::<TestRuntime>::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: TestEvent::Messages(Event::MessageAccepted(TEST_LANE_ID, message_nonce)),
event: TestEvent::Messages(Event::MessageAccepted {
lane_id: TEST_LANE_ID,
nonce: message_nonce
}),
topics: vec![],
}],
);
Expand Down Expand Up @@ -1232,10 +1238,10 @@ mod tests {
System::<TestRuntime>::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: TestEvent::Messages(Event::MessagesDelivered(
TEST_LANE_ID,
DeliveredMessages::new(1, true),
)),
event: TestEvent::Messages(Event::MessagesDelivered {
lane_id: TEST_LANE_ID,
messages: DeliveredMessages::new(1, true),
}),
topics: vec![],
}],
);
Expand All @@ -1257,7 +1263,7 @@ mod tests {
System::<TestRuntime>::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: TestEvent::Messages(Event::ParameterUpdated(parameter)),
event: TestEvent::Messages(Event::ParameterUpdated { parameter }),
topics: vec![],
}],
);
Expand All @@ -1281,7 +1287,7 @@ mod tests {
System::<TestRuntime>::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: TestEvent::Messages(Event::ParameterUpdated(parameter)),
event: TestEvent::Messages(Event::ParameterUpdated { parameter }),
topics: vec![],
}],
);
Expand Down

0 comments on commit fd80f8a

Please sign in to comment.