nautilus_blockchain/rpc/
mod.rs1use alloy::primitives::Address;
24use enum_dispatch::enum_dispatch;
25use nautilus_live::SocketControl;
26use nautilus_network::websocket::TransportBackend;
27
28use crate::rpc::{
29 chains::{
30 arbitrum::ArbitrumRpcClient, base::BaseRpcClient, bsc::BscRpcClient,
31 ethereum::EthereumRpcClient, polygon::PolygonRpcClient,
32 },
33 error::BlockchainRpcClientError,
34 types::{BlockchainMessage, RpcEventType},
35};
36
37pub mod chains;
38pub mod core;
39pub mod error;
40pub mod helpers;
41pub mod http;
42pub mod providers;
43pub mod types;
44pub mod utils;
45
46#[cfg(feature = "hypersync")]
47pub(crate) mod verification;
48
49#[enum_dispatch(BlockchainRpcClient)]
50#[derive(Debug)]
51pub enum BlockchainRpcClientAny {
52 Arbitrum(ArbitrumRpcClient),
53 Base(BaseRpcClient),
54 Bsc(BscRpcClient),
55 Ethereum(EthereumRpcClient),
56 Polygon(PolygonRpcClient),
57}
58
59#[async_trait::async_trait]
60#[enum_dispatch]
61pub trait BlockchainRpcClient {
62 async fn connect(&mut self) -> anyhow::Result<()>;
63 async fn subscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
64 async fn subscribe_pool_events(
65 &mut self,
66 event_type: RpcEventType,
67 addresses: &[Address],
68 event_signature: String,
69 ) -> Result<(), BlockchainRpcClientError>;
70 async fn unsubscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
71 async fn next_rpc_message(&mut self) -> Result<BlockchainMessage, BlockchainRpcClientError>;
72 fn set_transport_backend(&mut self, backend: TransportBackend);
73 fn set_socket_control(&mut self, control: SocketControl);
74}