diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index 7dd6fefb..30b85093 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -18,6 +18,8 @@ pub enum Chain { Moonbeam, MoonbeamDev, Moonriver, + Optimism, + OptimismKovan, } impl fmt::Display for Chain { @@ -43,6 +45,8 @@ impl From for u32 { Chain::Moonbeam => 1287, Chain::MoonbeamDev => 1281, Chain::Moonriver => 1285, + Chain::Optimism => 10, + Chain::OptimismKovan => 69, } } } diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index 772e64ca..f7ba4be5 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -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 => {