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