Is there any clue on how to correctly compare whether event got from frame_system::Module::events() is equal to a specific one from current pallets decl_event!?
I've tried to match the event from the list with inner PostCreated event:
let events: Vec<EventRecord<<T as system::Trait>::Event, T::Hash>> = SystemModule::<T>::events();
events.iter().filter(|EventRecord { event, .. }| {
matches!(event, RawEvent::PostCreated(_, _))
});
But, got an error:
428 | matches!(event, RawEvent::PostCreated(_, _))
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found enum `RawEvent`
| |
| this expression has type `&<T as frame_system::Trait>::Event`
|
= note: expected associated type `<T as frame_system::Trait>::Event`
found enum `RawEvent<_>`
= help: consider constraining the associated type `<T as frame_system::Trait>::Event` to `RawEvent<_>`
Furthermore, if I add .into() to the event, I'm getting another error:
428 | matches!(event.into(), RawEvent::PostCreated(_, _))
| ^^^^ the trait `std::convert::From<&<T as frame_system::Trait>::Event>` is not implemented for `RawEvent<_>`
|
= note: required because of the requirements on the impl of `std::convert::Into<RawEvent<_>>` for `&<T as frame_system::Trait>::Event`
I will appreciate any help. Sure that something is wrong with exactly this lines of code.
Your "generic" event type should be defined like this in your configuration trait:
This means that we support the
Fromtrait from theEventenum defined in the pallet, and theIntotrait forEventenum in theframe_systempallet.So the conversion can be the following:
So:
You can then compare this
system_eventto the events you get back fromframe_system::Module::<T>::events().