wagyu_ethereum/network/
rinkeby.rs

1use crate::network::EthereumNetwork;
2use wagyu_model::{ChildIndex, Network, NetworkError};
3
4use serde::Serialize;
5use std::{fmt, str::FromStr};
6
7/// Represents an Ethereum test network (PoA).
8#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
9pub struct Rinkeby;
10
11impl Network for Rinkeby {
12    const NAME: &'static str = "rinkeby";
13}
14
15impl EthereumNetwork for Rinkeby {
16    const CHAIN_ID: u32 = 4;
17    const NETWORK_ID: u32 = 4;
18    const HD_COIN_TYPE: ChildIndex = ChildIndex::Hardened(1);
19}
20
21impl FromStr for Rinkeby {
22    type Err = NetworkError;
23
24    fn from_str(s: &str) -> Result<Self, Self::Err> {
25        match s {
26            Self::NAME => Ok(Self),
27            _ => Err(NetworkError::InvalidNetwork(s.into())),
28        }
29    }
30}
31
32impl fmt::Display for Rinkeby {
33    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34        write!(f, "{}", Self::NAME)
35    }
36}