diff --git a/Cargo.lock b/Cargo.lock index 81f6ead..0c0c366 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "anychain-ethereum" -version = "0.1.12" +version = "0.1.13" dependencies = [ "anychain-core", "ethabi", diff --git a/anychain-ethereum/Cargo.toml b/anychain-ethereum/Cargo.toml index 10d821a..781019b 100644 --- a/anychain-ethereum/Cargo.toml +++ b/anychain-ethereum/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anychain-ethereum" description = "A Rust library for Ethereum-focused cryptocurrency wallets, enabling seamless transactions on the Ethereum blockchain" -version = "0.1.12" +version = "0.1.13" keywords = ["blockchain", "crypto", "cryptocurrencies", "ethereum", "wallet"] # Workspace inherited keys diff --git a/anychain-ethereum/src/network/mod.rs b/anychain-ethereum/src/network/mod.rs index 52a8bca..3de339b 100644 --- a/anychain-ethereum/src/network/mod.rs +++ b/anychain-ethereum/src/network/mod.rs @@ -6,6 +6,9 @@ pub use self::ethereum::*; pub mod goerli; pub use self::goerli::*; +pub mod sepolia; +pub use self::sepolia::*; + pub mod ethereum_classic; pub use self::ethereum_classic::*; diff --git a/anychain-ethereum/src/network/sepolia.rs b/anychain-ethereum/src/network/sepolia.rs new file mode 100644 index 0000000..2c9e10e --- /dev/null +++ b/anychain-ethereum/src/network/sepolia.rs @@ -0,0 +1,35 @@ +use crate::network::EthereumNetwork; +use anychain_core::{Network, NetworkError}; + +use serde::Serialize; +use std::{fmt, str::FromStr}; + +/// Represents an ETH testnet +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] +pub struct Sepolia; + +impl Network for Sepolia { + const NAME: &'static str = "sepolia"; +} + +impl EthereumNetwork for Sepolia { + const CHAIN_ID: u32 = 11155111; + const NETWORK_ID: u32 = 11155111; +} + +impl FromStr for Sepolia { + type Err = NetworkError; + + fn from_str(s: &str) -> Result { + match s { + Self::NAME => Ok(Self), + _ => Err(NetworkError::InvalidNetwork(s.into())), + } + } +} + +impl fmt::Display for Sepolia { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", Self::NAME) + } +}