Skip to main content

nautilus_blockchain/python/
factories.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Python bindings for blockchain factories.
17
18use nautilus_common::factories::DataClientFactory;
19use pyo3::prelude::*;
20
21use crate::factories::{BlockchainDataClientFactory, BlockchainExecutionClientFactory};
22
23#[pymethods]
24#[pyo3_stub_gen::derive::gen_stub_pymethods]
25impl BlockchainDataClientFactory {
26    /// Factory for creating blockchain data clients.
27    ///
28    /// This factory creates `BlockchainDataClient` instances configured for different blockchain networks
29    /// (Ethereum, Arbitrum, Base, Polygon) with appropriate RPC and HyperSync configurations.
30    #[new]
31    const fn py_new() -> Self {
32        Self::new()
33    }
34
35    /// Returns the factory name.
36    fn name(&self) -> &str {
37        DataClientFactory::name(self)
38    }
39
40    /// Returns the configuration type.
41    fn config_type(&self) -> &str {
42        DataClientFactory::config_type(self)
43    }
44
45    /// Returns a string representation of the factory.
46    fn __repr__(&self) -> String {
47        format!("BlockchainDataClientFactory(name={})", self.name())
48    }
49}
50
51#[pymethods]
52impl BlockchainExecutionClientFactory {
53    /// Factory for creating blockchain execution clients.
54    #[new]
55    const fn py_new() -> Self {
56        Self::new()
57    }
58}