Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Add support to Aurora network #1535

Merged
merged 3 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
- Add `From<H160>` and From<Vec<H160>> traits to `ValueOrArray<H160>` [#1199](https://github.com/gakonst/ethers-rs/pull/1200)
- Fix handling of Websocket connection errors [#1287](https://github.com/gakonst/ethers-rs/pull/1287)
- Add Arithmetic Shift Right operation for I256 [#1323](https://github.com/gakonst/ethers-rs/issues/1323)
- [#1535](https://github.com/gakonst/ethers-rs/pull/1535) Add support to Aurora and Aurora testnet networks.

## ethers-contract-abigen

Expand Down
34 changes: 21 additions & 13 deletions ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub enum Chain {
EmeraldTestnet = 42261,
Evmos = 9001,
EvmosTestnet = 9000,
Aurora = 1313161554,
AuroraTestnet = 1313161555,
}

impl fmt::Display for Chain {
Expand Down Expand Up @@ -97,6 +99,8 @@ impl fmt::Display for Chain {
Chain::AnvilHardhat => "anvil-hardhat",
Chain::Evmos => "evmos",
Chain::EvmosTestnet => "evmos-testnet",
Chain::Aurora => "aurora",
Chain::AuroraTestnet => "aurora-testnet",
};

write!(formatter, "{}", chain)
Expand Down Expand Up @@ -162,6 +166,8 @@ impl TryFrom<u64> for Chain {
42261 => Chain::EmeraldTestnet,
9001 => Chain::Evmos,
9000 => Chain::EvmosTestnet,
1313161554 => Chain::Aurora,
1313161555 => Chain::AuroraTestnet,
_ => return Err(ParseChainError(chain.to_string())),
})
}
Expand All @@ -172,7 +178,7 @@ impl TryFrom<U256> for Chain {

fn try_from(chain: U256) -> Result<Chain, Self::Error> {
if chain.bits() > 64 {
return Err(ParseChainError(chain.to_string()))
return Err(ParseChainError(chain.to_string()));
}
chain.as_u64().try_into()
}
Expand Down Expand Up @@ -215,6 +221,8 @@ impl FromStr for Chain {
"oasis" => Chain::Oasis,
"emerald" => Chain::Emerald,
"emerald-testnet" => Chain::EmeraldTestnet,
"aurora" => Chain::Aurora,
"aurora-testnet" => Chain::AuroraTestnet,
_ => return Err(ParseChainError(chain.to_owned())),
})
}
Expand All @@ -227,18 +235,18 @@ impl Chain {
// TODO: Add other chains which do not support EIP1559.
matches!(
self,
Chain::Optimism |
Chain::OptimismKovan |
Chain::Fantom |
Chain::FantomTestnet |
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet |
Chain::Rsk |
Chain::Oasis |
Chain::Emerald |
Chain::EmeraldTestnet,
Chain::Optimism
| Chain::OptimismKovan
| Chain::Fantom
| Chain::FantomTestnet
| Chain::BinanceSmartChain
| Chain::BinanceSmartChainTestnet
| Chain::Arbitrum
| Chain::ArbitrumTestnet
| Chain::Rsk
| Chain::Oasis
| Chain::Emerald
| Chain::EmeraldTestnet,
)
}
}
Expand Down
54 changes: 28 additions & 26 deletions ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,35 @@ 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::Morden |
Chain::Ropsten |
Chain::Kovan |
Chain::Rinkeby |
Chain::Goerli |
Chain::Optimism |
Chain::OptimismKovan |
Chain::BinanceSmartChain |
Chain::BinanceSmartChainTestnet |
Chain::Arbitrum |
Chain::ArbitrumTestnet |
Chain::Cronos |
Chain::CronosTestnet => std::env::var("ETHERSCAN_API_KEY")?,
Chain::Mainnet
| Chain::Morden
| Chain::Ropsten
| Chain::Kovan
| Chain::Rinkeby
| Chain::Goerli
| Chain::Optimism
| Chain::OptimismKovan
| Chain::BinanceSmartChain
| Chain::BinanceSmartChainTestnet
| Chain::Arbitrum
| Chain::ArbitrumTestnet
| Chain::Cronos
| Chain::CronosTestnet
| Chain::Aurora
| Chain::AuroraTestnet => std::env::var("ETHERSCAN_API_KEY")?,
Chain::Fantom | Chain::FantomTestnet => {
std::env::var("FTMSCAN_API_KEY").or_else(|_| std::env::var("FANTOMSCAN_API_KEY"))?
}
Chain::XDai |
Chain::Sepolia |
Chain::Rsk |
Chain::Sokol |
Chain::Poa |
Chain::Oasis |
Chain::Emerald |
Chain::EmeraldTestnet |
Chain::Evmos |
Chain::EvmosTestnet => String::default(),
Chain::XDai
| Chain::Sepolia
| Chain::Rsk
| Chain::Sokol
| Chain::Poa
| Chain::Oasis
| Chain::Emerald
| Chain::EmeraldTestnet
| Chain::Evmos
| Chain::EvmosTestnet => String::default(),
Chain::Moonbeam | Chain::Moonbase | Chain::MoonbeamDev | Chain::Moonriver => {
std::env::var("MOONSCAN_API_KEY")?
}
Expand Down Expand Up @@ -440,10 +442,10 @@ impl Cache {
.checked_sub(Duration::from_secs(inner.expiry))
.is_some()
{
return None
return None;
}

return Some(inner.data)
return Some(inner.data);
}
None
}
Expand Down