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()));
|
assert_eq!(parsed, Source::String(src.to_owned()));
|
||||||
|
|
||||||
let hardhat_src = format!(
|
let hardhat_src = format!(
|
||||||
r#"{{"_format": "hh-sol-artifact-1", "contractName": "Verifier", "sourceName": "contracts/verifier.sol", "abi": {}, "bytecode": "0x", "deployedBytecode": "0x", "linkReferences": {{}}, "deployedLinkReferences": {{}}}}"#,
|
r#"{{"_format": "hh-sol-artifact-1", "contractName": "Verifier", "sourceName": "contracts/verifier.sol", "abi": {src}, "bytecode": "0x", "deployedBytecode": "0x", "linkReferences": {{}}, "deployedLinkReferences": {{}}}}"#,
|
||||||
src,
|
|
||||||
);
|
);
|
||||||
let hardhat_parsed = Source::parse(&hardhat_src).unwrap();
|
let hardhat_parsed = Source::parse(&hardhat_src).unwrap();
|
||||||
assert_eq!(hardhat_parsed, Source::String(hardhat_src));
|
assert_eq!(hardhat_parsed, Source::String(hardhat_src));
|
||||||
|
|
|
@ -69,6 +69,9 @@ pub enum Chain {
|
||||||
Sepolia = 11155111,
|
Sepolia = 11155111,
|
||||||
Aurora = 1313161554,
|
Aurora = 1313161554,
|
||||||
AuroraTestnet = 1313161555,
|
AuroraTestnet = 1313161555,
|
||||||
|
Celo = 42220,
|
||||||
|
CeloAlfajores = 44787,
|
||||||
|
CeloBaklava = 62320,
|
||||||
}
|
}
|
||||||
|
|
||||||
// === impl Chain ===
|
// === impl Chain ===
|
||||||
|
@ -117,6 +120,9 @@ impl fmt::Display for Chain {
|
||||||
Chain::EvmosTestnet => "evmos-testnet",
|
Chain::EvmosTestnet => "evmos-testnet",
|
||||||
Chain::Aurora => "aurora",
|
Chain::Aurora => "aurora",
|
||||||
Chain::AuroraTestnet => "aurora-testnet",
|
Chain::AuroraTestnet => "aurora-testnet",
|
||||||
|
Chain::Celo => "celo",
|
||||||
|
Chain::CeloAlfajores => "celo-alfajores",
|
||||||
|
Chain::CeloBaklava => "celo-baklava",
|
||||||
};
|
};
|
||||||
|
|
||||||
f.pad(chain)
|
f.pad(chain)
|
||||||
|
@ -195,6 +201,9 @@ impl TryFrom<u64> for Chain {
|
||||||
9000 => Chain::EvmosTestnet,
|
9000 => Chain::EvmosTestnet,
|
||||||
1313161554 => Chain::Aurora,
|
1313161554 => Chain::Aurora,
|
||||||
1313161555 => Chain::AuroraTestnet,
|
1313161555 => Chain::AuroraTestnet,
|
||||||
|
42220 => Chain::Celo,
|
||||||
|
44787 => Chain::CeloAlfajores,
|
||||||
|
62320 => Chain::CeloBaklava,
|
||||||
_ => return Err(ParseChainError(chain.to_string())),
|
_ => return Err(ParseChainError(chain.to_string())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -255,6 +264,9 @@ impl FromStr for Chain {
|
||||||
"emerald-testnet" => Chain::EmeraldTestnet,
|
"emerald-testnet" => Chain::EmeraldTestnet,
|
||||||
"aurora" => Chain::Aurora,
|
"aurora" => Chain::Aurora,
|
||||||
"aurora-testnet" => Chain::AuroraTestnet,
|
"aurora-testnet" => Chain::AuroraTestnet,
|
||||||
|
"celo" => Chain::Celo,
|
||||||
|
"celo-alfajores" => Chain::CeloAlfajores,
|
||||||
|
"celo-baklava" => Chain::CeloBaklava,
|
||||||
_ => return Err(ParseChainError(chain.to_owned())),
|
_ => return Err(ParseChainError(chain.to_owned())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -293,6 +305,7 @@ impl Chain {
|
||||||
Chain::Oasis => 5_500,
|
Chain::Oasis => 5_500,
|
||||||
Chain::Emerald => 6_000,
|
Chain::Emerald => 6_000,
|
||||||
Chain::Dev | Chain::AnvilHardhat => 200,
|
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
|
// Explictly handle all network to make it easier not to forget this match when new
|
||||||
// networks are added.
|
// networks are added.
|
||||||
Chain::Morden |
|
Chain::Morden |
|
||||||
|
@ -411,6 +424,15 @@ impl Chain {
|
||||||
}
|
}
|
||||||
Chain::Evmos => ("https://evm.evmos.org/api", "https://evm.evmos.org/"),
|
Chain::Evmos => ("https://evm.evmos.org/api", "https://evm.evmos.org/"),
|
||||||
Chain::EvmosTestnet => ("https://evm.evmos.dev/api", "https://evm.evmos.dev/"),
|
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 => {
|
Chain::AnvilHardhat | Chain::Dev | Chain::Morden | Chain::MoonbeamDev => {
|
||||||
// this is explicitly exhaustive so we don't forget to add new urls when adding a
|
// this is explicitly exhaustive so we don't forget to add new urls when adding a
|
||||||
// new chain
|
// new chain
|
||||||
|
@ -440,7 +462,10 @@ impl Chain {
|
||||||
Chain::Rsk |
|
Chain::Rsk |
|
||||||
Chain::Oasis |
|
Chain::Oasis |
|
||||||
Chain::Emerald |
|
Chain::Emerald |
|
||||||
Chain::EmeraldTestnet,
|
Chain::EmeraldTestnet |
|
||||||
|
Chain::Celo |
|
||||||
|
Chain::CeloAlfajores |
|
||||||
|
Chain::CeloBaklava,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,10 @@ impl Client {
|
||||||
Chain::Cronos |
|
Chain::Cronos |
|
||||||
Chain::CronosTestnet |
|
Chain::CronosTestnet |
|
||||||
Chain::Aurora |
|
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 => {
|
Chain::Fantom | Chain::FantomTestnet => {
|
||||||
std::env::var("FTMSCAN_API_KEY").or_else(|_| std::env::var("FANTOMSCAN_API_KEY"))?
|
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#"
|
r#"
|
||||||
Gas price
|
Gas price
|
||||||
---------------
|
---------------
|
||||||
{:>10.2} gwei
|
{gwei:>10.2} gwei
|
||||||
{:>10.8} usd
|
{usd_per_gas:>10.8} usd
|
||||||
"#,
|
"#
|
||||||
gwei, usd_per_gas
|
|
||||||
);
|
);
|
||||||
Ok(())
|
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 eyre::Result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
// Note that `log` has type AnswerUpdatedFilter
|
// Note that `log` has type AnswerUpdatedFilter
|
||||||
while let Some(Ok((log, meta))) = stream.next().await {
|
while let Some(Ok((log, meta))) = stream.next().await {
|
||||||
println!("{:?}", log);
|
println!("{log:?}");
|
||||||
println!("{:?}", meta)
|
println!("{meta:?}")
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ethers::{abi::AbiDecode, prelude::*, utils::keccak256};
|
use ethers::{abi::AbiDecode, prelude::*};
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue