chore: Add ZKSync into the Chain type

This commit is contained in:
syahrul 2023-03-26 11:56:27 +08:00
parent 36dac5864c
commit 0ed4ccd000
1 changed files with 80 additions and 72 deletions

View File

@ -140,6 +140,8 @@ pub enum Chain {
CantoTestnet = 740,
Boba = 288,
ZKSync = 324,
}
// === impl Chain ===
@ -270,9 +272,9 @@ impl Chain {
FilecoinHyperspaceTestnet | FilecoinMainnet => 30_000,
// Explicitly exhaustive. See NB above.
Morden | Ropsten | Rinkeby | Goerli | Kovan | XDai | Chiado | Sepolia | Moonbase |
MoonbeamDev | Optimism | OptimismGoerli | OptimismKovan | Poa | Sokol | Rsk |
EmeraldTestnet | Boba => return None,
Morden | Ropsten | Rinkeby | Goerli | Kovan | XDai | Chiado | Sepolia | Moonbase
| MoonbeamDev | Optimism | OptimismGoerli | OptimismKovan | Poa | Sokol | Rsk
| EmeraldTestnet | Boba | ZKSync => return None,
};
Some(Duration::from_millis(ms))
@ -293,41 +295,42 @@ impl Chain {
match self {
// Known legacy chains / non EIP-1559 compliant
Optimism |
OptimismGoerli |
OptimismKovan |
Fantom |
FantomTestnet |
BinanceSmartChain |
BinanceSmartChainTestnet |
Arbitrum |
ArbitrumTestnet |
ArbitrumGoerli |
ArbitrumNova |
Rsk |
Oasis |
Emerald |
EmeraldTestnet |
Celo |
CeloAlfajores |
CeloBaklava |
Boba => true,
Optimism
| OptimismGoerli
| OptimismKovan
| Fantom
| FantomTestnet
| BinanceSmartChain
| BinanceSmartChainTestnet
| Arbitrum
| ArbitrumTestnet
| ArbitrumGoerli
| ArbitrumNova
| Rsk
| Oasis
| Emerald
| EmeraldTestnet
| Celo
| CeloAlfajores
| CeloBaklava
| Boba
| ZKSync => true,
// Known EIP-1559 chains
Mainnet |
Goerli |
Sepolia |
Polygon |
PolygonMumbai |
Avalanche |
AvalancheFuji |
FilecoinHyperspaceTestnet => false,
Mainnet
| Goerli
| Sepolia
| Polygon
| PolygonMumbai
| Avalanche
| AvalancheFuji
| FilecoinHyperspaceTestnet => false,
// Unknown / not applicable, default to false for backwards compatibility
Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan |
Sokol | Poa | XDai | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos |
EvmosTestnet | Chiado | Aurora | AuroraTestnet | Canto | CantoTestnet |
FilecoinMainnet => false,
Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan
| Sokol | Poa | XDai | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos
| EvmosTestnet | Chiado | Aurora | AuroraTestnet | Canto | CantoTestnet
| FilecoinMainnet => false,
}
}
@ -460,10 +463,14 @@ impl Chain {
Boba => ("https://api.bobascan.com/api", "https://bobascan.com"),
ZKSync => {
("https://zksync2-mainnet-explorer.zksync.io/", "https://explorer.zksync.io/")
}
AnvilHardhat | Dev | Morden | MoonbeamDev | FilecoinMainnet => {
// this is explicitly exhaustive so we don't forget to add new urls when adding a
// new chain
return None
return None;
}
};
@ -484,28 +491,28 @@ impl Chain {
use Chain::*;
let api_key_name = match self {
Mainnet |
Morden |
Ropsten |
Kovan |
Rinkeby |
Goerli |
Optimism |
OptimismGoerli |
OptimismKovan |
BinanceSmartChain |
BinanceSmartChainTestnet |
Arbitrum |
ArbitrumTestnet |
ArbitrumGoerli |
ArbitrumNova |
Cronos |
CronosTestnet |
Aurora |
AuroraTestnet |
Celo |
CeloAlfajores |
CeloBaklava => "ETHERSCAN_API_KEY",
Mainnet
| Morden
| Ropsten
| Kovan
| Rinkeby
| Goerli
| Optimism
| OptimismGoerli
| OptimismKovan
| BinanceSmartChain
| BinanceSmartChainTestnet
| Arbitrum
| ArbitrumTestnet
| ArbitrumGoerli
| ArbitrumNova
| Cronos
| CronosTestnet
| Aurora
| AuroraTestnet
| Celo
| CeloAlfajores
| CeloBaklava => "ETHERSCAN_API_KEY",
Avalanche | AvalancheFuji => "SNOWTRACE_API_KEY",
@ -520,21 +527,22 @@ impl Chain {
Boba => "BOBASCAN_API_KEY",
// Explicitly exhaustive. See NB above.
XDai |
Chiado |
Sepolia |
Rsk |
Sokol |
Poa |
Oasis |
Emerald |
EmeraldTestnet |
Evmos |
EvmosTestnet |
AnvilHardhat |
Dev |
FilecoinMainnet |
FilecoinHyperspaceTestnet => return None,
XDai
| Chiado
| Sepolia
| Rsk
| Sokol
| Poa
| Oasis
| Emerald
| EmeraldTestnet
| Evmos
| EvmosTestnet
| AnvilHardhat
| Dev
| FilecoinMainnet
| FilecoinHyperspaceTestnet
| ZKSync => return None,
};
Some(api_key_name)