Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
add support for Emerald (from Oasis)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiram-abif committed May 8, 2022
1 parent fd994d7 commit a092b16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub enum Chain {
ArbitrumTestnet = 421611,
Cronos = 25,
CronosTestnet = 338,
Emerald = 42262,
EmeraldTestnet = 42261,
}

impl fmt::Display for Chain {
Expand Down Expand Up @@ -69,6 +71,8 @@ impl fmt::Display for Chain {
Chain::ArbitrumTestnet => "arbitrum-testnet",
Chain::Cronos => "cronos",
Chain::CronosTestnet => "cronos-testnet",
Chain::Emerald => "emerald",
Chain::EmeraldTestnet => "emerald-testnet",
};

write!(formatter, "{}", chain)
Expand Down Expand Up @@ -123,6 +127,8 @@ impl TryFrom<u64> for Chain {
421611 => Chain::ArbitrumTestnet,
25 => Chain::Cronos,
338 => Chain::CronosTestnet,
42262 => Chain::Emerald,
42261 => Chain::EmeraldTestnet,
_ => return Err(ParseChainError(chain.to_string())),
})
}
Expand Down
8 changes: 8 additions & 0 deletions ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl Client {
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {
std::env::var("MOONSCAN_API_KEY")?
}
Chain::Emerald | Chain::EmeraldTestnet => std::env::var("OASIS_API_KEY")?,
Chain::Dev => return Err(EtherscanError::LocalNetworksNotSupported),
};
Self::new(chain, api_key)
Expand Down Expand Up @@ -263,6 +264,13 @@ impl ClientBuilder {
Chain::Moonriver => {
urls("https://api-moonriver.moonscan.io/api", "https://moonriver.moonscan.io")
}
Chain::Emerald => {
urls("https://explorer.emerald.oasis.dev/api", "https://explorer.emerald.oasis.dev")
}
Chain::EmeraldTestnet => urls(
"https://testnet.explorer.emerald.oasis.dev/api",
"https://testnet.explorer.emerald.oasis.dev",
),
Chain::Dev => return Err(EtherscanError::LocalNetworksNotSupported),
chain => return Err(EtherscanError::ChainNotSupported(chain)),
};
Expand Down

0 comments on commit a092b16

Please sign in to comment.