Fantom chain (#806)

* feat(core): add fantom and fantom-testnet chains

* feat(etherscan): add fantom chains support

* chore: lint
This commit is contained in:
Meet Mangukiya 2022-01-18 16:30:27 +05:30 committed by GitHub
parent 6c7b6d1e49
commit 91ff71ec62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -21,6 +21,8 @@ pub enum Chain {
Kovan = 42, Kovan = 42,
XDai = 100, XDai = 100,
Polygon = 137, Polygon = 137,
Fantom = 250,
FantomTestnet = 4002,
PolygonMumbai = 80001, PolygonMumbai = 80001,
Avalanche = 43114, Avalanche = 43114,
AvalancheFuji = 43113, AvalancheFuji = 43113,
@ -102,6 +104,8 @@ impl FromStr for Chain {
"moonriver" => Chain::Moonriver, "moonriver" => Chain::Moonriver,
"optimism" => Chain::Optimism, "optimism" => Chain::Optimism,
"optimism-kovan" => Chain::OptimismKovan, "optimism-kovan" => Chain::OptimismKovan,
"fantom" => Chain::Fantom,
"fantom-testnet" => Chain::FantomTestnet,
_ => return Err(ParseChainError(chain.to_owned())), _ => return Err(ParseChainError(chain.to_owned())),
}) })
} }

View File

@ -66,6 +66,13 @@ impl Client {
Url::parse("https://api-kovan-optimistic.etherscan.io/api"), Url::parse("https://api-kovan-optimistic.etherscan.io/api"),
Url::parse("https://kovan-optimistic.etherscan.io"), Url::parse("https://kovan-optimistic.etherscan.io"),
), ),
Chain::Fantom => {
(Url::parse("https://api.ftmscan.com"), Url::parse("https://ftmscan.com"))
}
Chain::FantomTestnet => (
Url::parse("https://api-testnet.ftmscan.com"),
Url::parse("https://testnet.ftmscan.com"),
),
chain => return Err(EtherscanError::ChainNotSupported(chain)), chain => return Err(EtherscanError::ChainNotSupported(chain)),
}; };
@ -89,7 +96,9 @@ impl Client {
Chain::Rinkeby | Chain::Rinkeby |
Chain::Goerli | Chain::Goerli |
Chain::Optimism | Chain::Optimism |
Chain::OptimismKovan => std::env::var("ETHERSCAN_API_KEY")?, Chain::OptimismKovan |
Chain::Fantom |
Chain::FantomTestnet => 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 => {