nautilus_blockchain/rpc/
mod.rs1use enum_dispatch::enum_dispatch;
24use nautilus_network::websocket::TransportBackend;
25
26use crate::rpc::{
27 chains::{
28 arbitrum::ArbitrumRpcClient, base::BaseRpcClient, bsc::BscRpcClient,
29 ethereum::EthereumRpcClient, polygon::PolygonRpcClient,
30 },
31 error::BlockchainRpcClientError,
32 types::BlockchainMessage,
33};
34
35pub mod chains;
36pub mod core;
37pub mod error;
38pub mod helpers;
39pub mod http;
40pub mod providers;
41pub mod types;
42pub mod utils;
43
44#[enum_dispatch(BlockchainRpcClient)]
45#[derive(Debug)]
46pub enum BlockchainRpcClientAny {
47 Arbitrum(ArbitrumRpcClient),
48 Base(BaseRpcClient),
49 Bsc(BscRpcClient),
50 Ethereum(EthereumRpcClient),
51 Polygon(PolygonRpcClient),
52}
53
54#[async_trait::async_trait]
55#[enum_dispatch]
56pub trait BlockchainRpcClient {
57 async fn connect(&mut self) -> anyhow::Result<()>;
58 async fn subscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
59 async fn subscribe_swaps(&mut self) -> Result<(), BlockchainRpcClientError> {
60 todo!("Not implemented")
61 }
62 async fn unsubscribe_blocks(&mut self) -> Result<(), BlockchainRpcClientError>;
63 async fn unsubscribe_swaps(&mut self) -> Result<(), BlockchainRpcClientError> {
64 todo!("Not implemented")
65 }
66 async fn next_rpc_message(&mut self) -> Result<BlockchainMessage, BlockchainRpcClientError>;
67 fn set_transport_backend(&mut self, backend: TransportBackend);
68}