hopr_chain_indexer/
traits.rs1use async_trait::async_trait;
2use ethers::types::TxHash;
3
4use hopr_chain_rpc::BlockWithLogs;
5use hopr_chain_types::chain_events::SignificantChainEvent;
6use hopr_primitive_types::prelude::*;
7
8use crate::errors::Result;
9
10#[async_trait]
11pub trait ChainLogHandler {
12 fn contract_addresses(&self) -> Vec<Address>;
13
14 fn contract_address_topics(&self, contract: Address) -> Vec<TxHash>;
15
16 async fn collect_block_events(&self, block_with_logs: BlockWithLogs) -> Result<Vec<SignificantChainEvent>>;
17}
18
19#[cfg(test)]
20use mockall::mock;
21
22#[cfg(test)]
23mock! {
24 pub ChainLogHandler {}
34
35 impl Clone for ChainLogHandler {
36 fn clone(&self) -> Self;
37 }
38
39 #[async_trait]
40 impl ChainLogHandler for ChainLogHandler {
41 fn contract_addresses(&self) -> Vec<Address>;
42 fn contract_address_topics(&self, contract: Address) -> Vec<TxHash>;
43 async fn collect_block_events(&self, block_with_logs: BlockWithLogs) -> Result<Vec<SignificantChainEvent>>;
44 }
45}