espresso_api/v1/
explorer.rs1use async_trait::async_trait;
6use serde::Serialize;
7
8#[derive(Debug, Clone)]
9pub enum BlockIdent {
10 Height(u64),
11 Hash(String),
12 Latest,
13}
14
15#[derive(Debug, Clone)]
16pub enum TxIdent {
17 HeightAndOffset(u64, u64),
18 Hash(String),
19 Latest,
20}
21
22#[derive(Debug, Clone)]
23pub enum TxSummaryFilter {
24 None,
25 Block(u64),
26 Namespace(i64),
27}
28
29#[async_trait]
30pub trait ExplorerApi {
31 type BlockDetail: Serialize + Send + Sync + 'static;
32 type BlockSummaries: Serialize + Send + Sync + 'static;
33 type TransactionDetail: Serialize + Send + Sync + 'static;
34 type TransactionSummaries: Serialize + Send + Sync + 'static;
35 type ExplorerSummary: Serialize + Send + Sync + 'static;
36 type SearchResult: Serialize + Send + Sync + 'static;
37
38 async fn get_block_detail(&self, ident: BlockIdent) -> anyhow::Result<Self::BlockDetail>;
39
40 async fn get_block_summaries(
41 &self,
42 target: BlockIdent,
43 limit: u64,
44 ) -> anyhow::Result<Self::BlockSummaries>;
45
46 async fn get_transaction_detail(
47 &self,
48 ident: TxIdent,
49 ) -> anyhow::Result<Self::TransactionDetail>;
50
51 async fn get_transaction_summaries(
52 &self,
53 target: TxIdent,
54 limit: u64,
55 filter: TxSummaryFilter,
56 ) -> anyhow::Result<Self::TransactionSummaries>;
57
58 async fn get_explorer_summary(&self) -> anyhow::Result<Self::ExplorerSummary>;
59
60 async fn get_search_result(&self, query: String) -> anyhow::Result<Self::SearchResult>;
61}