chore: add celo chain (#1932)
* add celo chain * add missing chain case * clippy & fmt
This commit is contained in:
parent
3dfc04f9fe
commit
92e726921a
|
@ -349,8 +349,7 @@ mod tests {
|
|||
assert_eq!(parsed, Source::String(src.to_owned()));
|
||||
|
||||
let hardhat_src = format!(
|
||||
r#"{{"_format": "hh-sol-artifact-1", "contractName": "Verifier", "sourceName": "contracts/verifier.sol", "abi": {}, "bytecode": "0x", "deployedBytecode": "0x", "linkReferences": {{}}, "deployedLinkReferences": {{}}}}"#,
|
||||
src,
|
||||
r#"{{"_format": "hh-sol-artifact-1", "contractName": "Verifier", "sourceName": "contracts/verifier.sol", "abi": {src}, "bytecode": "0x", "deployedBytecode": "0x", "linkReferences": {{}}, "deployedLinkReferences": {{}}}}"#,
|
||||
);
|
||||
let hardhat_parsed = Source::parse(&hardhat_src).unwrap();
|
||||
assert_eq!(hardhat_parsed, Source::String(hardhat_src));
|
||||
|
|
|
@ -69,6 +69,9 @@ pub enum Chain {
|
|||
Sepolia = 11155111,
|
||||
Aurora = 1313161554,
|
||||
AuroraTestnet = 1313161555,
|
||||
Celo = 42220,
|
||||
CeloAlfajores = 44787,
|
||||
CeloBaklava = 62320,
|
||||
}
|
||||
|
||||
// === impl Chain ===
|
||||
|
@ -117,6 +120,9 @@ impl fmt::Display for Chain {
|
|||
Chain::EvmosTestnet => "evmos-testnet",
|
||||
Chain::Aurora => "aurora",
|
||||
Chain::AuroraTestnet => "aurora-testnet",
|
||||
Chain::Celo => "celo",
|
||||
Chain::CeloAlfajores => "celo-alfajores",
|
||||
Chain::CeloBaklava => "celo-baklava",
|
||||
};
|
||||
|
||||
f.pad(chain)
|
||||
|
@ -195,6 +201,9 @@ impl TryFrom<u64> for Chain {
|
|||
9000 => Chain::EvmosTestnet,
|
||||
1313161554 => Chain::Aurora,
|
||||
1313161555 => Chain::AuroraTestnet,
|
||||
42220 => Chain::Celo,
|
||||
44787 => Chain::CeloAlfajores,
|
||||
62320 => Chain::CeloBaklava,
|
||||
_ => return Err(ParseChainError(chain.to_string())),
|
||||
})
|
||||
}
|
||||
|
@ -255,6 +264,9 @@ impl FromStr for Chain {
|
|||
"emerald-testnet" => Chain::EmeraldTestnet,
|
||||
"aurora" => Chain::Aurora,
|
||||
"aurora-testnet" => Chain::AuroraTestnet,
|
||||
"celo" => Chain::Celo,
|
||||
"celo-alfajores" => Chain::CeloAlfajores,
|
||||
"celo-baklava" => Chain::CeloBaklava,
|
||||
_ => return Err(ParseChainError(chain.to_owned())),
|
||||
})
|
||||
}
|
||||
|
@ -293,6 +305,7 @@ impl Chain {
|
|||
Chain::Oasis => 5_500,
|
||||
Chain::Emerald => 6_000,
|
||||
Chain::Dev | Chain::AnvilHardhat => 200,
|
||||
Chain::Celo | Chain::CeloAlfajores | Chain::CeloBaklava => 5_000,
|
||||
// Explictly handle all network to make it easier not to forget this match when new
|
||||
// networks are added.
|
||||
Chain::Morden |
|
||||
|
@ -411,6 +424,15 @@ impl Chain {
|
|||
}
|
||||
Chain::Evmos => ("https://evm.evmos.org/api", "https://evm.evmos.org/"),
|
||||
Chain::EvmosTestnet => ("https://evm.evmos.dev/api", "https://evm.evmos.dev/"),
|
||||
Chain::Celo => {
|
||||
("https://explorer.celo.org/mainnet", "https://explorer.celo.org/mainnet/api")
|
||||
}
|
||||
Chain::CeloAlfajores => {
|
||||
("https://explorer.celo.org/alfajores", "https://explorer.celo.org/alfajores/api")
|
||||
}
|
||||
Chain::CeloBaklava => {
|
||||
("https://explorer.celo.org/baklava", "https://explorer.celo.org/baklava/api")
|
||||
}
|
||||
Chain::AnvilHardhat | Chain::Dev | Chain::Morden | Chain::MoonbeamDev => {
|
||||
// this is explicitly exhaustive so we don't forget to add new urls when adding a
|
||||
// new chain
|
||||
|
@ -440,7 +462,10 @@ impl Chain {
|
|||
Chain::Rsk |
|
||||
Chain::Oasis |
|
||||
Chain::Emerald |
|
||||
Chain::EmeraldTestnet,
|
||||
Chain::EmeraldTestnet |
|
||||
Chain::Celo |
|
||||
Chain::CeloAlfajores |
|
||||
Chain::CeloBaklava,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ pub struct Eip1559TransactionRequest {
|
|||
/// Represents the maximum tx fee that will go to the miner as part of the user's
|
||||
/// fee payment. It serves 3 purposes:
|
||||
/// 1. Compensates miners for the uncle/ommer risk + fixed costs of including transaction in a
|
||||
/// block;
|
||||
/// block;
|
||||
/// 2. Allows users with high opportunity costs to pay a premium to miners;
|
||||
/// 3. In times where demand exceeds the available block space (i.e. 100% full, 30mm gas),
|
||||
/// this component allows first price auctions (i.e. the pre-1559 fee model) to happen on the
|
||||
|
|
|
@ -98,7 +98,10 @@ impl Client {
|
|||
Chain::Cronos |
|
||||
Chain::CronosTestnet |
|
||||
Chain::Aurora |
|
||||
Chain::AuroraTestnet => std::env::var("ETHERSCAN_API_KEY")?,
|
||||
Chain::AuroraTestnet |
|
||||
Chain::Celo |
|
||||
Chain::CeloAlfajores |
|
||||
Chain::CeloBaklava => std::env::var("ETHERSCAN_API_KEY")?,
|
||||
Chain::Fantom | Chain::FantomTestnet => {
|
||||
std::env::var("FTMSCAN_API_KEY").or_else(|_| std::env::var("FANTOMSCAN_API_KEY"))?
|
||||
}
|
||||
|
|
|
@ -39,10 +39,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
r#"
|
||||
Gas price
|
||||
---------------
|
||||
{:>10.2} gwei
|
||||
{:>10.8} usd
|
||||
"#,
|
||||
gwei, usd_per_gas
|
||||
{gwei:>10.2} gwei
|
||||
{usd_per_gas:>10.8} usd
|
||||
"#
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ethers::{abi::AbiDecode, prelude::*, providers::Middleware, utils::keccak256};
|
||||
use ethers::{abi::AbiDecode, prelude::*, providers::Middleware};
|
||||
use eyre::Result;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
// Note that `log` has type AnswerUpdatedFilter
|
||||
while let Some(Ok((log, meta))) = stream.next().await {
|
||||
println!("{:?}", log);
|
||||
println!("{:?}", meta)
|
||||
println!("{log:?}");
|
||||
println!("{meta:?}")
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ethers::{abi::AbiDecode, prelude::*, utils::keccak256};
|
||||
use ethers::{abi::AbiDecode, prelude::*};
|
||||
use eyre::Result;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
Loading…
Reference in New Issue