From 0ed4ccd00057989690856e3c299837ebc78236b4 Mon Sep 17 00:00:00 2001 From: syahrul Date: Sun, 26 Mar 2023 11:56:27 +0800 Subject: [PATCH] chore: Add ZKSync into the Chain type --- ethers-core/src/types/chain.rs | 152 +++++++++++++++++---------------- 1 file changed, 80 insertions(+), 72 deletions(-) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index fd23c83b..24df078f 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -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)