From the following function I can read the frame_system
events:
let events = frame_system::Pallet::<T>::read_events_no_consensus();
the above provides me the following example array:
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::Balances(Event::Withdraw {
who: d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d(5 GrwvaEF...),
amount: 125000107
}),
topics: []
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::SubstrateKitties(Event::Created {
kitty: [177, 185, 56, 80, 240, 56, 24, 57, 112, 17, 186, 6, 89, 221, 25, 98],
owner: d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d(5 GrwvaEF...)
}),
topics: []
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::System(Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo {
weight: 0,
class: DispatchClass::Normal,
pays_fee: Pays::Yes
}
}),
topics: []
}
I would like to be able to parse/match ONLY the Event::SubstrateKitties(Event::Created)
events.
I also reviewed the link below and Shawn Tabrizi
recommendation related to assert_last_event
use cases:
https://stackoverflow.com/questions/64199998/converting-between-event-types
However, I still haven't found a proper way to do this. Below is a simplify example of my latest code so far:
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
/// Block finalization
fn on_finalize(_n: BlockNumberFor<T>) {
let events = frame_system::Pallet::<T>::read_events_no_consensus();
events.iter().for_each(|EventRecord { event, .. }| {
match event {
// What should I write here?? => {
log::info("SubstrateKitties event: {:?}", event);
},
_ => {
log::info!("Ignoring system events.");
},
}
});
}
}
```