use crate::network::EthereumNetwork;
use anychain_core::{Network, NetworkError};
use serde::Serialize;
use std::{fmt, str::FromStr};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Ethereum;
impl Network for Ethereum {
const NAME: &'static str = "ethereum";
}
impl EthereumNetwork for Ethereum {
const CHAIN_ID: u32 = 1;
const NETWORK_ID: u32 = 1;
}
impl FromStr for Ethereum {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for Ethereum {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}