[draft] Add Optimism & OptimismKovan chains (#737)
* core: Add Optimism & OptimismKovan chains * etherscan: Add ETHERSCAN_API_KEY to optimism network
This commit is contained in:
parent
47e188793b
commit
3f095f415f
|
@ -18,6 +18,8 @@ pub enum Chain {
|
|||
Moonbeam,
|
||||
MoonbeamDev,
|
||||
Moonriver,
|
||||
Optimism,
|
||||
OptimismKovan,
|
||||
}
|
||||
|
||||
impl fmt::Display for Chain {
|
||||
|
@ -43,6 +45,8 @@ impl From<Chain> for u32 {
|
|||
Chain::Moonbeam => 1287,
|
||||
Chain::MoonbeamDev => 1281,
|
||||
Chain::Moonriver => 1285,
|
||||
Chain::Optimism => 10,
|
||||
Chain::OptimismKovan => 69,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,14 @@ impl Client {
|
|||
Url::parse("https://api-testnet.snowtrace.io/api"),
|
||||
Url::parse("https://testnet.snowtrace.io"),
|
||||
),
|
||||
Chain::Optimism => (
|
||||
Url::parse("https://api-optimistic.etherscan.io/api"),
|
||||
Url::parse("https://optimistic.etherscan.io"),
|
||||
),
|
||||
Chain::OptimismKovan => (
|
||||
Url::parse("https://api-kovan-optimistic.etherscan.io/api"),
|
||||
Url::parse("https://kovan-optimistic.etherscan.io"),
|
||||
),
|
||||
chain => return Err(EtherscanError::ChainNotSupported(chain)),
|
||||
};
|
||||
|
||||
|
@ -75,9 +83,13 @@ impl Client {
|
|||
let api_key = match chain {
|
||||
Chain::Avalanche | Chain::AvalancheFuji => std::env::var("SNOWTRACE_API_KEY")?,
|
||||
Chain::Polygon | Chain::PolygonMumbai => std::env::var("POLYGONSCAN_API_KEY")?,
|
||||
Chain::Mainnet | Chain::Ropsten | Chain::Kovan | Chain::Rinkeby | Chain::Goerli => {
|
||||
std::env::var("ETHERSCAN_API_KEY")?
|
||||
}
|
||||
Chain::Mainnet
|
||||
| Chain::Ropsten
|
||||
| Chain::Kovan
|
||||
| Chain::Rinkeby
|
||||
| Chain::Goerli
|
||||
| Chain::Optimism
|
||||
| Chain::OptimismKovan => std::env::var("ETHERSCAN_API_KEY")?,
|
||||
|
||||
Chain::XDai | Chain::Sepolia => String::default(),
|
||||
Chain::Moonbeam | Chain::MoonbeamDev | Chain::Moonriver => {
|
||||
|
|
Loading…
Reference in New Issue