mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add method to fetch a block's events to the RPC
This commit is contained in:
@@ -132,15 +132,16 @@ pub mod pallet {
|
||||
|
||||
/// Fetch all of Serai's events.
|
||||
///
|
||||
/// This MUST only be used for testing purposes.
|
||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
|
||||
pub fn events() -> Vec<serai_abi::Event>
|
||||
/// This MUST NOT be called during a transaction/block's execution.
|
||||
pub fn events() -> Vec<Vec<u8>>
|
||||
where
|
||||
serai_abi::Event: TryFrom<T::RuntimeEvent>,
|
||||
T::RuntimeEvent: TryInto<Event<T>>,
|
||||
{
|
||||
frame_system::Pallet::<T>::events()
|
||||
.into_iter()
|
||||
.filter_map(|e| serai_abi::Event::try_from(e.event).ok())
|
||||
frame_system::Pallet::<T>::read_events_no_consensus()
|
||||
.filter_map(|e| match e.event.try_into() {
|
||||
Ok(Event::Event(bytes)) => Some(bytes),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user