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