pub trait ChainClientFactory: Send + Sync {
// Required methods
fn create_chain_client(&self, chain: &str) -> Result<Box<dyn ChainClient>>;
fn create_dex_client(&self) -> Box<dyn DexDataSource>;
fn http(&self) -> Arc<dyn HttpClient> ⓘ;
}Expand description
Factory trait for creating chain clients and DEX data sources.
Bundles both chain and DEX client creation so CLI functions only need one injected dependency instead of two.
§Example
use scope::chains::{ChainClientFactory, DefaultClientFactory};
use scope::http::NativeHttpClient;
use scope::Config;
use std::sync::Arc;
let config = Config::default();
let http = Arc::new(NativeHttpClient::new().unwrap());
let factory = DefaultClientFactory { chains_config: config.chains.clone(), http };
let client = factory.create_chain_client("ethereum").unwrap();Required Methods§
Sourcefn create_chain_client(&self, chain: &str) -> Result<Box<dyn ChainClient>>
fn create_chain_client(&self, chain: &str) -> Result<Box<dyn ChainClient>>
Creates a chain client for the given blockchain network.
§Arguments
chain- The chain name (e.g., “ethereum”, “solana”, “tron”)
Sourcefn create_dex_client(&self) -> Box<dyn DexDataSource>
fn create_dex_client(&self) -> Box<dyn DexDataSource>
Creates a DEX data source client.
Sourcefn http(&self) -> Arc<dyn HttpClient> ⓘ
fn http(&self) -> Arc<dyn HttpClient> ⓘ
The HTTP transport for clients this factory does not create itself (exchange venues, compliance and contract lookups), so they use the same transport as the chain clients.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".