From 1f96397aedbb993a6d3faaeed4b2f77929d81ef0 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 20 Dec 2024 16:39:29 +0000 Subject: [PATCH] Use register for all zksync networks and remove deprecated registerZksync method --- hardhat-setup/README.md | 2 -- hardhat-setup/networks.ts | 33 ++++++++------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/hardhat-setup/README.md b/hardhat-setup/README.md index 8bc4743a..837c7dd4 100644 --- a/hardhat-setup/README.md +++ b/hardhat-setup/README.md @@ -32,8 +32,6 @@ This class is your go-to assistant for setting up various blockchain networks fo 3. **`registerCustom(...)`**: Allows registering custom networks with custom parameters for Etherscan contract verifications. -4. **`registerZksync(...)`**: A specialized method for registering zkSync networks with additional parameters which specified for zksync network. - 5. **`registerAll()`**: Registers multiple standard networks using environment variables for configuration. ## Predefined environment variable names and their format diff --git a/hardhat-setup/networks.ts b/hardhat-setup/networks.ts index dd357854..92afd3d8 100644 --- a/hardhat-setup/networks.ts +++ b/hardhat-setup/networks.ts @@ -1,6 +1,6 @@ import dotenv from 'dotenv'; import { ChainConfig } from '@nomicfoundation/hardhat-verify/src/types'; -import { HardhatNetworkAccountsUserConfig, Network, NetworkUserConfig, NetworksUserConfig } from 'hardhat/types'; +import { HardhatNetworkAccountsUserConfig, Network, NetworksUserConfig } from 'hardhat/types'; /** * @category Hardhat-Setup @@ -121,27 +121,9 @@ export class Networks { } } - registerZksync(name: string, chainId: number, rpc?: string, ethNetwork?: string, privateKey?: string, verifyURL?: string, hardfork: string = 'paris') { - if (privateKey && rpc && ethNetwork) { - const { url, authKeyHttpHeader } = parseRpcEnv(rpc); - this.networks[name] = { - url, - httpHeaders: authKeyHttpHeader ? { 'auth-key': authKeyHttpHeader } : undefined, - zksync: true, - chainId, - accounts: [privateKey], - hardfork, - verifyURL, - ethNetwork, - } as NetworkUserConfig; - console.log(`Network '${name}' registered`); - } else { - console.log(`Network '${name}' not registered`); - } - } - registerAll(): { networks: NetworksUserConfig, etherscan: Etherscan } { const privateKey = process.env.PRIVATE_KEY; + /* eslint-disable max-len */ this.register('mainnet', 1, process.env.MAINNET_RPC_URL, process.env.MAINNET_PRIVATE_KEY || privateKey, 'mainnet', process.env.MAINNET_ETHERSCAN_KEY); this.register('bsc', 56, process.env.BSC_RPC_URL, process.env.BSC_PRIVATE_KEY || privateKey, 'bsc', process.env.BSC_ETHERSCAN_KEY); this.register('sepolia', 11155111, process.env.SEPOLIA_RPC_URL, process.env.SEPOLIA_PRIVATE_KEY || privateKey, 'sepolia', process.env.SEPOLIA_ETHERSCAN_KEY); @@ -153,13 +135,14 @@ export class Networks { this.register('fantom', 250, process.env.FANTOM_RPC_URL, process.env.FANTOM_PRIVATE_KEY || privateKey, 'opera', process.env.FANTOM_ETHERSCAN_KEY, 'paris'); this.register('aurora', 1313161554, process.env.AURORA_RPC_URL, process.env.AURORA_PRIVATE_KEY || privateKey, 'aurora', process.env.AURORA_ETHERSCAN_KEY); this.register('base', 8453, process.env.BASE_RPC_URL, process.env.BASE_PRIVATE_KEY || privateKey, 'base', process.env.BASE_ETHERSCAN_KEY); - this.registerCustom('klaytn', 8217, process.env.KLAYTN_RPC_URL, process.env.KLAYTN_PRIVATE_KEY || privateKey, process.env.KLAYTN_ETHERSCAN_KEY, 'https://scope.klaytn.com/', 'https://scope.klaytn.com/'); // eslint-disable-line max-len - this.registerCustom('linea', 59144, process.env.LINEA_RPC_URL, process.env.LINEA_PRIVATE_KEY || privateKey, process.env.LINEA_ETHERSCAN_KEY, 'https://api.lineascan.build/api', 'https://lineascan.build/', 'london'); // eslint-disable-line max-len + this.registerCustom('klaytn', 8217, process.env.KLAYTN_RPC_URL, process.env.KLAYTN_PRIVATE_KEY || privateKey, process.env.KLAYTN_ETHERSCAN_KEY, 'https://scope.klaytn.com/', 'https://scope.klaytn.com/'); + this.registerCustom('linea', 59144, process.env.LINEA_RPC_URL, process.env.LINEA_PRIVATE_KEY || privateKey, process.env.LINEA_ETHERSCAN_KEY, 'https://api.lineascan.build/api', 'https://lineascan.build/', 'london'); this.register('zksync', 324, process.env.ZKSYNC_RPC_URL, process.env.ZKSYNC_PRIVATE_KEY || privateKey, 'zksyncmainnet', process.env.ZKSYNC_ETHERSCAN_KEY, 'paris', 'mainnet'); - this.register('zksyncTest', 300, process.env.ZKSYNC_TEST_RPC_URL, process.env.ZKSYNC_TEST_PRIVATE_KEY || privateKey, 'zksyncsepolia', process.env.ZKSYNC_TEST_ETHERSCAN_KEY, 'paris', 'sepolia'); // eslint-disable-line max-len + this.register('zksyncTest', 300, process.env.ZKSYNC_TEST_RPC_URL, process.env.ZKSYNC_TEST_PRIVATE_KEY || privateKey, 'zksyncsepolia', process.env.ZKSYNC_TEST_ETHERSCAN_KEY, 'paris', 'sepolia'); // For 'zksyncFork' network you should use zksync fork node: https://github.com/matter-labs/era-test-node - this.registerZksync('zksyncFork', 260, process.env.ZKSYNC_FORK_RPC_URL, 'mainnet', process.env.ZKSYNC_FORK_PRIVATE_KEY || privateKey); - this.registerZksync('zksyncLocal', 270, process.env.ZKSYNC_LOCAL_RPC_URL, process.env.ZKSYNC_LOCAL_ETH_NETWORK, process.env.ZKSYNC_PRIVATE_KEY || privateKey); + this.register('zksyncFork', 260, process.env.ZKSYNC_FORK_RPC_URL, process.env.ZKSYNC_FORK_PRIVATE_KEY || privateKey, 'zksyncfork', 'none', 'paris', process.env.ZKSYNC_LOCAL_ETH_NETWORK || 'mainnet'); + this.register('zksyncLocal', 270, process.env.ZKSYNC_LOCAL_RPC_URL, process.env.ZKSYNC_PRIVATE_KEY || privateKey, 'zksynclocal', 'none', 'paris', process.env.ZKSYNC_LOCAL_ETH_NETWORK); + /* eslint-enable max-len */ return { networks: this.networks, etherscan: this.etherscan }; } }