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

Commit

Permalink
feat(chain): add Cronos and Cronos testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtau committed Feb 18, 2022
1 parent 16b9de5 commit 1729ace
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Unreleased

- Add Cronos mainnet beta and testnet to the list of known chains
[926](https://github.com/gakonst/ethers-rs/pull/926)
- `Chain::to_string` will return the same chain name as `Chain::from_str`
- Add `eth_syncing` [848](https://github.com/gakonst/ethers-rs/pull/848)
- Fix overflow and possible divide-by-zero in `estimate_priority_fee`
Expand Down
7 changes: 6 additions & 1 deletion ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub enum Chain {
BinanceSmartChainTestnet = 97,
Arbitrum = 42161,
ArbitrumTestnet = 421611,
Cronos = 25,
CronosTestnet = 338,
}

impl fmt::Display for Chain {
Expand Down Expand Up @@ -63,6 +65,8 @@ impl fmt::Display for Chain {
Chain::BinanceSmartChainTestnet => "bsc-testnet",
Chain::Arbitrum => "arbitrum",
Chain::ArbitrumTestnet => "arbitrum-testnet",
Chain::Cronos => "cronos",
Chain::CronosTestnet => "cronos-testnet",
};

write!(formatter, "{}", chain)
Expand Down Expand Up @@ -162,7 +166,8 @@ impl Chain {
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet,
Chain::ArbitrumTestnet |
Chain::Cronos,
)
}
}
8 changes: 6 additions & 2 deletions ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ impl Client {
Url::parse("https://api-testnet.arbiscan.io/api"),
Url::parse("https://testnet.arbiscan.io"),
),
Chain::Cronos => {
(Url::parse("https://api.cronoscan.com/api"), Url::parse("https://cronoscan.com"))
}
chain => return Err(EtherscanError::ChainNotSupported(chain)),
};

Expand Down Expand Up @@ -116,9 +119,10 @@ impl Client {
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet => std::env::var("ETHERSCAN_API_KEY")?,
Chain::ArbitrumTestnet |
Chain::Cronos => std::env::var("ETHERSCAN_API_KEY")?,

Chain::XDai | Chain::Sepolia => String::default(),
Chain::XDai | Chain::Sepolia | Chain::CronosTestnet => String::default(),
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {
std::env::var("MOONSCAN_API_KEY")?
}
Expand Down

0 comments on commit 1729ace

Please sign in to comment.