Skip to main content

quicknode_sdk/admin/
chains.rs

1#[cfg(feature = "node")]
2use napi_derive::napi;
3#[cfg(feature = "python")]
4use pyo3::pyclass;
5#[cfg(feature = "python")]
6use pyo3_stub_gen::derive::gen_stub_pyclass;
7use serde::{Deserialize, Serialize};
8
9/// A network within a supported chain.
10#[cfg_attr(feature = "python", gen_stub_pyclass)]
11#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
12#[cfg_attr(feature = "node", napi(object))]
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct ChainNetwork {
15    /// Network slug (e.g. `mainnet`).
16    pub slug: String,
17    /// Human-readable network name.
18    pub name: String,
19    /// Numeric chain id, when applicable.
20    pub chain_id: Option<i64>,
21}
22
23/// A blockchain supported by QuickNode along with its networks.
24#[cfg_attr(feature = "python", gen_stub_pyclass)]
25#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
26#[cfg_attr(feature = "node", napi(object))]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct Chain {
29    /// Chain slug (e.g. `ethereum`).
30    pub slug: String,
31    /// Networks available on this chain.
32    #[serde(default)]
33    pub networks: Vec<ChainNetwork>,
34    /// Whether the chain is shown in selection UIs.
35    pub is_select_chain: Option<bool>,
36}
37
38/// Response from `list_chains`.
39#[cfg_attr(feature = "python", gen_stub_pyclass)]
40#[cfg_attr(feature = "python", pyclass(get_all, set_all))]
41#[cfg_attr(feature = "node", napi(object))]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct ListChainsResponse {
44    /// Supported chains and their networks.
45    #[serde(default)]
46    pub data: Vec<Chain>,
47    /// Error message when the request did not succeed.
48    pub error: Option<String>,
49}