Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OptimismGoerli #147

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.5"
keywords = ["blockchain", "crypto", "cryptocurrency", "ethereum", "wallet"]

# Workspace inherited keys
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)
}
}
Loading