feat(chain): add arbitrum support (#869)

* feat: add arbitrum chainid & block explorer

* chore: update changelog

* feat: add arbitrum to is_legacy

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
0xTomoyo 2022-02-06 01:36:21 +11:00 committed by GitHub
parent ede6570567
commit 75fbec0706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -30,6 +30,7 @@
[#854](https://github.com/gakonst/ethers-rs/pull/852)
- Refactor `ethers-contract-abigen` to use `eyre` instead of `anyhow` via
[#858](https://github.com/gakonst/ethers-rs/pull/858)
- Add Arbitrum mainnet and testnet to the list of known chains
## ethers-contract-abigen

View File

@ -34,6 +34,8 @@ pub enum Chain {
OptimismKovan = 69,
BinanceSmartChain = 56,
BinanceSmartChainTestnet = 97,
Arbitrum = 42161,
ArbitrumTestnet = 421611,
}
impl fmt::Display for Chain {
@ -83,6 +85,8 @@ impl TryFrom<u64> for Chain {
69 => Chain::OptimismKovan,
56 => Chain::BinanceSmartChain,
97 => Chain::BinanceSmartChainTestnet,
42161 => Chain::Arbitrum,
421611 => Chain::ArbitrumTestnet,
_ => return Err(ParseChainError(chain.to_string())),
})
}
@ -112,6 +116,8 @@ impl FromStr for Chain {
"fantom-testnet" => Chain::FantomTestnet,
"bsc" => Chain::BinanceSmartChain,
"bsc-testnet" => Chain::BinanceSmartChainTestnet,
"arbitrum" => Chain::Arbitrum,
"arbitrum-testnet" => Chain::ArbitrumTestnet,
_ => return Err(ParseChainError(chain.to_owned())),
})
}
@ -129,7 +135,9 @@ impl Chain {
Chain::Fantom |
Chain::FantomTestnet |
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet,
)
}
}

View File

@ -80,6 +80,13 @@ impl Client {
Url::parse("https://api-testnet.bscscan.com/api"),
Url::parse("https://testnet.bscscan.com"),
),
Chain::Arbitrum => {
(Url::parse("https://api.arbiscan.io/api"), Url::parse("https://arbiscan.io"))
}
Chain::ArbitrumTestnet => (
Url::parse("https://api-testnet.arbiscan.io/api"),
Url::parse("https://testnet.arbiscan.io"),
),
chain => return Err(EtherscanError::ChainNotSupported(chain)),
};
@ -107,7 +114,9 @@ impl Client {
Chain::Fantom |
Chain::FantomTestnet |
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet => std::env::var("ETHERSCAN_API_KEY")?,
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet => std::env::var("ETHERSCAN_API_KEY")?,
Chain::XDai | Chain::Sepolia => String::default(),
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {