o2_sdk/
config.rs

1/// Network configuration for O2 Exchange API endpoints.
2/// Supported O2 Exchange networks.
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum Network {
5    Testnet,
6    Devnet,
7    Mainnet,
8}
9
10/// Configuration holding API and RPC URLs for a specific network.
11#[derive(Debug, Clone)]
12pub struct NetworkConfig {
13    pub api_base: String,
14    pub ws_url: String,
15    pub fuel_rpc: String,
16    pub faucet_url: Option<String>,
17    pub whitelist_required: bool,
18}
19
20impl NetworkConfig {
21    pub fn from_network(network: Network) -> Self {
22        match network {
23            Network::Testnet => Self {
24                api_base: "https://api.testnet.o2.app".into(),
25                ws_url: "wss://api.testnet.o2.app/v1/ws".into(),
26                fuel_rpc: "https://testnet.fuel.network/v1/graphql".into(),
27                faucet_url: Some("https://fuel-o2-faucet.vercel.app/api/testnet/mint-v2".into()),
28                whitelist_required: true,
29            },
30            Network::Devnet => Self {
31                api_base: "https://api.devnet.o2.app".into(),
32                ws_url: "wss://api.devnet.o2.app/v1/ws".into(),
33                fuel_rpc: "https://devnet.fuel.network/v1/graphql".into(),
34                faucet_url: Some("https://fuel-o2-faucet.vercel.app/api/devnet/mint-v2".into()),
35                whitelist_required: false,
36            },
37            Network::Mainnet => Self {
38                api_base: "https://api.o2.app".into(),
39                ws_url: "wss://api.o2.app/v1/ws".into(),
40                fuel_rpc: "https://mainnet.fuel.network/v1/graphql".into(),
41                faucet_url: None,
42                whitelist_required: false,
43            },
44        }
45    }
46}
47
48impl Default for NetworkConfig {
49    fn default() -> Self {
50        Self::from_network(Network::Testnet)
51    }
52}