mod blocks;
mod transactions;
pub mod contract;
pub use blocks::{BlockEvent, BlockState};
pub use transactions::TransactionEvent;
#[derive(Clone, Debug)]
pub struct Event {
pub component: &'static str,
pub topic: &'static str,
pub entity: String,
pub data: Option<serde_json::Value>,
}
trait EventSource {
const COMPONENT: &'static str;
fn topic(&self) -> &'static str;
fn entity(&self) -> String;
fn data(&self) -> Option<serde_json::Value>;
}
impl<ES: EventSource> From<ES> for Event {
fn from(value: ES) -> Self {
Self {
data: value.data(),
topic: value.topic(),
entity: value.entity(),
component: ES::COMPONENT,
}
}
}