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

add support for Emerald (from Oasis) #1236

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Unreleased

- Add support for Emerald Mainnet and Testnet chains (the Oasis Paratimes)
- Fix RLP decoding of `from` field for `Eip1559TransactionRequest` and
`Eip2930TransactionRequest`, remove `Eip1559TransactionRequest` `sighash`
method [1180](https://github.com/gakonst/ethers-rs/pull/1180)
Expand Down
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 => String::default(),
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",
),
Comment on lines +268 to +274
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this compatible with etherscan API?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsse This project is using the fork for a small POC: https://gunix.codeberg.page/sycamore-metamask-example/
However that's only getting the balance and nothing else.

The explorer is blockscout. According to the docs, it supports ETH RPC

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're using our own fork of the blockscout: https://github.com/oasisprotocol/emerald-blockscout

Let us know, if you require any assistance.

Chain::Dev => return Err(EtherscanError::LocalNetworksNotSupported),
chain => return Err(EtherscanError::ChainNotSupported(chain)),
};
Expand Down