Skip to main content

ChainClientFactory

Trait ChainClientFactory 

Source
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>;
}
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::Config;

let config = Config::default();
let factory = DefaultClientFactory { chains_config: config.chains.clone() };
let client = factory.create_chain_client("ethereum").unwrap();

Required Methods§

Source

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”)
Source

fn create_dex_client(&self) -> Box<dyn DexDataSource>

Creates a DEX data source client.

Implementors§