nautilus_blockchain/rpc/
mod.rs1use enum_dispatch::enum_dispatch;
17
18use crate::rpc::{
19 chains::{
20 arbitrum::ArbitrumRpcClient, base::BaseRpcClient, ethereum::EthereumRpcClient,
21 polygon::PolygonRpcClient,
22 },
23 error::BlockchainRpcClientError,
24 types::BlockchainMessage,
25};
26
27pub mod chains;
28pub mod core;
29pub mod error;
30pub mod http;
31pub mod types;
32pub mod utils;
33
34#[enum_dispatch(BlockchainRpcClient)]
35#[derive(Debug)]
36pub enum BlockchainRpcClientAny {
37 Ethereum(EthereumRpcClient),
38 Polygon(PolygonRpcClient),
39 Base(BaseRpcClient),
40 Arbitrum(ArbitrumRpcClient),
41}
42
43#[async_trait::async_trait]
44#[enum_dispatch]
45pub trait BlockchainRpcClient {
46 async fn connect(&mut self) -> anyhow::Result<()>;
47 async fn subscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
48 async fn unsubscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
49 async fn next_rpc_message(&mut self) -> Result<BlockchainMessage, BlockchainRpcClientError>;
50}