From 73edbf5dac1f1f028a6ee440fb774ea6157ab410 Mon Sep 17 00:00:00 2001 From: aya015757881 <2581015450@qq.com> Date: Tue, 2 Jul 2024 16:00:32 +0800 Subject: [PATCH 1/2] feat: add sepolia testnet --- anychain-ethereum/src/network/mod.rs | 3 ++ anychain-ethereum/src/network/sepolia.rs | 35 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 anychain-ethereum/src/network/sepolia.rs 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) + } +} From 4d74fb72d55ad20dbc620941e3363b594dd16748 Mon Sep 17 00:00:00 2001 From: aya015757881 <2581015450@qq.com> Date: Tue, 2 Jul 2024 16:01:38 +0800 Subject: [PATCH 2/2] refactor: version update --- Cargo.lock | 2 +- anychain-ethereum/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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