1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crate::constants::{ BNB_TESTNET_RPC_URL, FUJI_RPC_URL, GOERLI_RPC_URL, MUMBAI_RPC_URL };

use serde::{ Deserialize, Serialize };

use strum::{ EnumIter, EnumString };

#[derive(
    Clone,
    Copy,
    Debug,
    Deserialize,
    EnumIter,
    Hash,
    Eq,
    PartialEq,
    Serialize,
    Default,
    PartialOrd,
    Ord,
    EnumString
)]
pub enum Chains {
    #[serde(rename = "ETHEREUM")]
    #[strum(serialize = "ETHEREUM")]
    #[default]
    Ethereum,
    #[serde(rename = "POLYGON")]
    #[strum(serialize = "POLYGON")]
    Polygon,
    #[serde(rename = "BNBCHAIN")]
    #[strum(serialize = "BNBCHAIN")]
    BnbChain,
    #[serde(rename = "AVALANCHE")]
    #[strum(serialize = "AVALANCHE")]
    Avalanche,
}

impl Chains {
    #[must_use]
    pub fn get_rpc_url(&self) -> String {
        let rpc_url = match self {
            Self::Ethereum => GOERLI_RPC_URL,
            Self::Polygon => MUMBAI_RPC_URL,
            Self::Avalanche => FUJI_RPC_URL,
            Self::BnbChain => BNB_TESTNET_RPC_URL,
        };

        rpc_url.to_string()
    }
    #[must_use]
    pub fn get_testnets(&self) -> String {
        let webhook_url = match self {
            Self::Ethereum => "GOERLI",
            Self::Polygon => "MUMBAI",
            Self::Avalanche => "FUJI",
            Self::BnbChain => "BNBCHAIN_TESTNET",
        };

        webhook_url.to_string()
    }
}