I need to get a list of all events of a specific custom type. In the documentation, it said that I can query the System pallet's storage for events. I am looking for an example (in Rust) of how to get a list of specific events. I am planning to do this in an OCW and I need this for the current block but also need it for all blocks.
Listening to events The Substrate RPC does not directly expose an endpoint for querying events. If you used the default implementation, you can see the list of events for the current block by querying the storage of the System pallet. Otherwise, the Polkadot-JS API supports a WebSocket subscription on runtime events.
I tried this:
let evts = <frame_system::Pallet<T>>::read_events_no_consensus();
for evt in evts {
frame_support::log::info!("evt={:?}", evt.event);
}
which works BUT it prints:
evt=<wasm:stripped>
evt=<wasm:stripped>
evt=<wasm:stripped>
evt=<wasm:stripped>
evt=<wasm:stripped>
evt=<wasm:stripped>
How can I dump the fields of each event so I can understand what events occurred?
For efficiency, how can I get just the events for the current block?
<wasm:stripped>
is because of the node was started using--execution=wasm
. If I change it to--execution=Native
, it works!