Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 138-feat-anychain-neo
Browse files Browse the repository at this point in the history
  • Loading branch information
shuimuliang committed Oct 26, 2023
2 parents 1bc84f9 + fe4d226 commit ba58665
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion anychain-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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.4"
version = "0.1.6"
keywords = ["blockchain", "crypto", "cryptocurrency", "ethereum", "wallet"]

# Workspace inherited keys
Expand Down
6 changes: 3 additions & 3 deletions anychain-ethereum/src/network/avalanche_testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use std::{fmt, str::FromStr};
pub struct AvalancheTestnet;

impl Network for AvalancheTestnet {
const NAME: &'static str = "ethereum";
const NAME: &'static str = "avalanche testnet";
}

impl EthereumNetwork for AvalancheTestnet {
const CHAIN_ID: u32 = 1;
const NETWORK_ID: u32 = 1;
const CHAIN_ID: u32 = 43113;
const NETWORK_ID: u32 = 43113;
}

impl FromStr for AvalancheTestnet {
Expand Down
7 changes: 5 additions & 2 deletions anychain-ethereum/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ pub use self::arbitrum::*;
pub mod arbitrum_goerli;
pub use self::arbitrum_goerli::*;

pub mod op_mainnet;
pub use self::op_mainnet::*;
pub mod optimism;
pub use self::optimism::*;

pub mod optimism_goerli;
pub use self::optimism_goerli::*;

pub mod huobi_eco;
pub use self::huobi_eco::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ use std::{fmt, str::FromStr};

/// Represents an ETH mainnet
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Op;
pub struct Optimism;

impl Network for Op {
const NAME: &'static str = "op";
impl Network for Optimism {
const NAME: &'static str = "optimism";
}

impl EthereumNetwork for Op {
impl EthereumNetwork for Optimism {
const CHAIN_ID: u32 = 10;
const NETWORK_ID: u32 = 10;
}

impl FromStr for Op {
impl FromStr for Optimism {
type Err = NetworkError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand All @@ -28,7 +28,7 @@ impl FromStr for Op {
}
}

impl fmt::Display for Op {
impl fmt::Display for Optimism {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
Expand Down
35 changes: 35 additions & 0 deletions anychain-ethereum/src/network/optimism_goerli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use crate::network::EthereumNetwork;
use anychain_core::{Network, NetworkError};

use serde::Serialize;
use std::{fmt, str::FromStr};

/// Represents an ETH mainnet
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct OptimismGoerli;

impl Network for OptimismGoerli {
const NAME: &'static str = "optimism goerli";
}

impl EthereumNetwork for OptimismGoerli {
const CHAIN_ID: u32 = 420;
const NETWORK_ID: u32 = 420;
}

impl FromStr for OptimismGoerli {
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 OptimismGoerli {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}

0 comments on commit ba58665

Please sign in to comment.