-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from 0xcregis/142-feat-add-arbitrum-optimism-…
…and-avalanche-for-anychain-ethereum feat: AVAX, OP, ARB
- Loading branch information
Showing
7 changed files
with
191 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Arbitrum; | ||
|
||
impl Network for Arbitrum { | ||
const NAME: &'static str = "arbitrum"; | ||
} | ||
|
||
impl EthereumNetwork for Arbitrum { | ||
const CHAIN_ID: u32 = 42161; | ||
const NETWORK_ID: u32 = 42161; | ||
} | ||
|
||
impl FromStr for Arbitrum { | ||
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 Arbitrum { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", Self::NAME) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ArbitrumGoerli; | ||
|
||
impl Network for ArbitrumGoerli { | ||
const NAME: &'static str = "arbitrum goerli"; | ||
} | ||
|
||
impl EthereumNetwork for ArbitrumGoerli { | ||
const CHAIN_ID: u32 = 421613; | ||
const NETWORK_ID: u32 = 421613; | ||
} | ||
|
||
impl FromStr for ArbitrumGoerli { | ||
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 ArbitrumGoerli { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", Self::NAME) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Avalanche; | ||
|
||
impl Network for Avalanche { | ||
const NAME: &'static str = "avalanche"; | ||
} | ||
|
||
impl EthereumNetwork for Avalanche { | ||
const CHAIN_ID: u32 = 43114; | ||
const NETWORK_ID: u32 = 43114; | ||
} | ||
|
||
impl FromStr for Avalanche { | ||
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 Avalanche { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", Self::NAME) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 AvalancheTestnet; | ||
|
||
impl Network for AvalancheTestnet { | ||
const NAME: &'static str = "ethereum"; | ||
} | ||
|
||
impl EthereumNetwork for AvalancheTestnet { | ||
const CHAIN_ID: u32 = 1; | ||
const NETWORK_ID: u32 = 1; | ||
} | ||
|
||
impl FromStr for AvalancheTestnet { | ||
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 AvalancheTestnet { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", Self::NAME) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Op; | ||
|
||
impl Network for Op { | ||
const NAME: &'static str = "op"; | ||
} | ||
|
||
impl EthereumNetwork for Op { | ||
const CHAIN_ID: u32 = 10; | ||
const NETWORK_ID: u32 = 10; | ||
} | ||
|
||
impl FromStr for Op { | ||
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 Op { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", Self::NAME) | ||
} | ||
} |