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:
parent
ede6570567
commit
75fbec0706
|
@ -30,6 +30,7 @@
|
||||||
[#854](https://github.com/gakonst/ethers-rs/pull/852)
|
[#854](https://github.com/gakonst/ethers-rs/pull/852)
|
||||||
- Refactor `ethers-contract-abigen` to use `eyre` instead of `anyhow` via
|
- Refactor `ethers-contract-abigen` to use `eyre` instead of `anyhow` via
|
||||||
[#858](https://github.com/gakonst/ethers-rs/pull/858)
|
[#858](https://github.com/gakonst/ethers-rs/pull/858)
|
||||||
|
- Add Arbitrum mainnet and testnet to the list of known chains
|
||||||
|
|
||||||
## ethers-contract-abigen
|
## ethers-contract-abigen
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ pub enum Chain {
|
||||||
OptimismKovan = 69,
|
OptimismKovan = 69,
|
||||||
BinanceSmartChain = 56,
|
BinanceSmartChain = 56,
|
||||||
BinanceSmartChainTestnet = 97,
|
BinanceSmartChainTestnet = 97,
|
||||||
|
Arbitrum = 42161,
|
||||||
|
ArbitrumTestnet = 421611,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Chain {
|
impl fmt::Display for Chain {
|
||||||
|
@ -83,6 +85,8 @@ impl TryFrom<u64> for Chain {
|
||||||
69 => Chain::OptimismKovan,
|
69 => Chain::OptimismKovan,
|
||||||
56 => Chain::BinanceSmartChain,
|
56 => Chain::BinanceSmartChain,
|
||||||
97 => Chain::BinanceSmartChainTestnet,
|
97 => Chain::BinanceSmartChainTestnet,
|
||||||
|
42161 => Chain::Arbitrum,
|
||||||
|
421611 => Chain::ArbitrumTestnet,
|
||||||
_ => return Err(ParseChainError(chain.to_string())),
|
_ => return Err(ParseChainError(chain.to_string())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -112,6 +116,8 @@ impl FromStr for Chain {
|
||||||
"fantom-testnet" => Chain::FantomTestnet,
|
"fantom-testnet" => Chain::FantomTestnet,
|
||||||
"bsc" => Chain::BinanceSmartChain,
|
"bsc" => Chain::BinanceSmartChain,
|
||||||
"bsc-testnet" => Chain::BinanceSmartChainTestnet,
|
"bsc-testnet" => Chain::BinanceSmartChainTestnet,
|
||||||
|
"arbitrum" => Chain::Arbitrum,
|
||||||
|
"arbitrum-testnet" => Chain::ArbitrumTestnet,
|
||||||
_ => return Err(ParseChainError(chain.to_owned())),
|
_ => return Err(ParseChainError(chain.to_owned())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -129,7 +135,9 @@ impl Chain {
|
||||||
Chain::Fantom |
|
Chain::Fantom |
|
||||||
Chain::FantomTestnet |
|
Chain::FantomTestnet |
|
||||||
Chain::BinanceSmartChain |
|
Chain::BinanceSmartChain |
|
||||||
Chain::BinanceSmartChainTestnet
|
Chain::BinanceSmartChainTestnet |
|
||||||
|
Chain::Arbitrum |
|
||||||
|
Chain::ArbitrumTestnet,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,13 @@ impl Client {
|
||||||
Url::parse("https://api-testnet.bscscan.com/api"),
|
Url::parse("https://api-testnet.bscscan.com/api"),
|
||||||
Url::parse("https://testnet.bscscan.com"),
|
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)),
|
chain => return Err(EtherscanError::ChainNotSupported(chain)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,7 +114,9 @@ impl Client {
|
||||||
Chain::Fantom |
|
Chain::Fantom |
|
||||||
Chain::FantomTestnet |
|
Chain::FantomTestnet |
|
||||||
Chain::BinanceSmartChain |
|
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::XDai | Chain::Sepolia => String::default(),
|
||||||
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {
|
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {
|
||||||
|
|
Loading…
Reference in New Issue