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()
}
}