lit_rust_sdk/
config.rs

1use alloy::primitives::Address;
2use eyre::Result;
3use serde::{Deserialize, Serialize};
4use std::time::Duration;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "kebab-case")]
8pub enum LitNetwork {
9    DatilDev,
10    DatilTest,
11    Datil,
12}
13
14impl LitNetwork {
15    pub fn staking_contract_address(&self) -> Result<Address> {
16        match self {
17            LitNetwork::DatilDev => {
18                Ok("0xD4507CD392Af2c80919219d7896508728f6A623F".parse::<Address>()?)
19            }
20            LitNetwork::DatilTest => {
21                Ok("0x5758aDa5a1dC05e659eF0B5062fbcF093Ec572D1".parse::<Address>()?)
22            }
23            LitNetwork::Datil => {
24                Ok("0x21d636d95eE71150c0c3Ffa79268c989a329d1CE".parse::<Address>()?)
25            }
26        }
27    }
28
29    pub fn contract_resolver_address(&self) -> Result<Address> {
30        match self {
31            LitNetwork::DatilDev => {
32                Ok("0xCF5d7074c722Dd044Dd45EC791942b881366627c".parse::<Address>()?)
33            }
34            LitNetwork::DatilTest => {
35                Ok("0xCf908e1E4Ee79fb540e144C3EDB2796E8D413548".parse::<Address>()?)
36            }
37            LitNetwork::Datil => {
38                Ok("0x5326a59fF2c41bCdA7E64F9afB9C313d0342117B".parse::<Address>()?)
39            }
40        }
41    }
42
43    pub fn rpc_url(&self) -> &'static str {
44        match self {
45            LitNetwork::DatilDev => "https://yellowstone-rpc.litprotocol.com/",
46            LitNetwork::DatilTest => "https://yellowstone-rpc.litprotocol.com/",
47            LitNetwork::Datil => "https://yellowstone-rpc.litprotocol.com/",
48        }
49    }
50
51    pub fn env(&self) -> u8 {
52        match self {
53            LitNetwork::DatilDev => 0,
54            LitNetwork::DatilTest => 0,
55            LitNetwork::Datil => 2,
56        }
57    }
58}
59
60#[derive(Debug, Clone)]
61pub struct LitNodeClientConfig {
62    pub lit_network: LitNetwork,
63    pub alert_when_unauthorized: bool,
64    pub debug: bool,
65    pub connect_timeout: Duration,
66    pub check_node_attestation: bool,
67}
68
69impl Default for LitNodeClientConfig {
70    fn default() -> Self {
71        Self {
72            lit_network: LitNetwork::DatilDev,
73            alert_when_unauthorized: true,
74            debug: false,
75            connect_timeout: Duration::from_millis(20000),
76            check_node_attestation: false,
77        }
78    }
79}