From 61259a9f4e738506b7951776e782774e44d83127 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 12 Dec 2024 21:21:39 +0000 Subject: [PATCH 1/6] Change zksync and zksyncTest verify to etherscan-like explorer --- hardhat-setup/networks.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hardhat-setup/networks.ts b/hardhat-setup/networks.ts index 8b7c4095..46aeffe6 100644 --- a/hardhat-setup/networks.ts +++ b/hardhat-setup/networks.ts @@ -96,7 +96,7 @@ export class Networks { } } - register(name: string, chainId: number, rpc?: string, privateKey?: string, etherscanNetworkName?: string, etherscanKey?: string, hardfork: string = 'shanghai') { + register(name: string, chainId: number, rpc?: string, privateKey?: string, etherscanNetworkName?: string, etherscanKey?: string, hardfork: string = 'shanghai', zksync: boolean = false) { if (rpc && privateKey && etherscanNetworkName && etherscanKey) { const { url, authKeyHttpHeader } = parseRpcEnv(rpc); this.networks[name] = { @@ -105,6 +105,7 @@ export class Networks { chainId, accounts: [privateKey], hardfork, + zksync, }; this.etherscan.apiKey[etherscanNetworkName] = etherscanKey; console.log(`Network '${name}' registered`); @@ -154,11 +155,11 @@ export class Networks { 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.registerZksync('zksync', 324, process.env.ZKSYNC_RPC_URL, 'mainnet', process.env.ZKSYNC_PRIVATE_KEY || privateKey, process.env.ZKSYNC_VERIFY_URL); + this.register('zksync', 324, process.env.ZKSYNC_RPC_URL, process.env.ZKSYNC_PRIVATE_KEY || privateKey, 'zksyncmainnet', process.env.ZKSYNC_ETHERSCAN_KEY, 'paris', true); + 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', true); // 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.registerZksync('zksyncTest', 300, process.env.ZKSYNC_TEST_RPC_URL, 'sepolia', process.env.ZKSYNC_TEST_PRIVATE_KEY || privateKey, process.env.ZKSYNC_TEST_VERIFY_URL); return { networks: this.networks, etherscan: this.etherscan }; } } From 4ba64149c768ac0bdfc7d50349637bfb3b702d7f Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 13 Dec 2024 13:25:31 +0000 Subject: [PATCH 2/6] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90eeca62..6e2699e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@1inch/solidity-utils", - "version": "6.2.1", + "version": "6.3.0", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "exports": { From 860afd12dc13fc2c007327ef5c5d460d6c1d1dee Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 17 Dec 2024 22:27:24 +0000 Subject: [PATCH 3/6] patch register method for zksync --- hardhat-setup/networks.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hardhat-setup/networks.ts b/hardhat-setup/networks.ts index 46aeffe6..0376cb92 100644 --- a/hardhat-setup/networks.ts +++ b/hardhat-setup/networks.ts @@ -96,7 +96,7 @@ export class Networks { } } - register(name: string, chainId: number, rpc?: string, privateKey?: string, etherscanNetworkName?: string, etherscanKey?: string, hardfork: string = 'shanghai', zksync: boolean = false) { + register(name: string, chainId: number, rpc?: string, privateKey?: string, etherscanNetworkName?: string, etherscanKey?: string, hardfork: string = 'shanghai', l1Network?: string) { if (rpc && privateKey && etherscanNetworkName && etherscanKey) { const { url, authKeyHttpHeader } = parseRpcEnv(rpc); this.networks[name] = { @@ -105,7 +105,7 @@ export class Networks { chainId, accounts: [privateKey], hardfork, - zksync, + ...(l1Network && { ethNetwork: l1Network, zksync: true }), }; this.etherscan.apiKey[etherscanNetworkName] = etherscanKey; console.log(`Network '${name}' registered`); @@ -155,8 +155,8 @@ export class Networks { 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.register('zksync', 324, process.env.ZKSYNC_RPC_URL, process.env.ZKSYNC_PRIVATE_KEY || privateKey, 'zksyncmainnet', process.env.ZKSYNC_ETHERSCAN_KEY, 'paris', true); - 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', true); + 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'); // 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); From 3d5e5fd292e3b61a4e38b1085f1a2dea322c8b4c Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 17 Dec 2024 22:28:16 +0000 Subject: [PATCH 4/6] Remove info about zksync verification in era block explorer --- hardhat-setup/README.md | 13 ++----------- hardhat-setup/networks.ts | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hardhat-setup/README.md b/hardhat-setup/README.md index 9e4c39c2..8bc4743a 100644 --- a/hardhat-setup/README.md +++ b/hardhat-setup/README.md @@ -62,7 +62,7 @@ This class is your go-to assistant for setting up various blockchain networks fo - `PRIVATE_KEY=f040ec294d83b8abf0803b713ebdac7e6ef8c104bd644a45d32114e7a210ce74` - `MAINNET_PRIVATE_KEY=f040ec294d83b8abf0803b713ebdac7e6ef8c104bd644a45d32114e7a210ce74` -4. **`etherscan key`** +3. **`etherscan key`** `_ETHERSCAN_KEY` - The Etherscan's key to verify contracts for the specific network with ``. @@ -70,16 +70,7 @@ This class is your go-to assistant for setting up various blockchain networks fo - Just a string with Etherscan API KEY - Example: `MAINNET_ETHERSCAN_KEY=UFAPYWUQYZMR1NTER4G0BKB52WIOE6LKD9` -4. **`verify url in zksync`** - - `_VERIFY_URL` - The veridy url to verify contracts for the specific network with ``. - - Format: - - Just a link to verification service - - Example: `ZKSYNC_VERIFY_URL=https://zksync2-mainnet-explorer.zksync.io/contract_verification` - - Default value (**only for mainnet**): `https://zksync2-mainnet-explorer.zksync.io/contract_verification` - -5. **`eth network in zksync`** +4. **`eth network in zksync`** `ZKSYNC_LOCAL_ETH_NETWORK` - rpc or name of ethNetwork for local zksync node. diff --git a/hardhat-setup/networks.ts b/hardhat-setup/networks.ts index 0376cb92..dd357854 100644 --- a/hardhat-setup/networks.ts +++ b/hardhat-setup/networks.ts @@ -156,7 +156,7 @@ export class Networks { 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.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'); + 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 // 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); From 1f96397aedbb993a6d3faaeed4b2f77929d81ef0 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 20 Dec 2024 16:39:29 +0000 Subject: [PATCH 5/6] 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 }; } } From 5df547398972ab1f675457876187e23410085116 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 20 Dec 2024 16:46:34 +0000 Subject: [PATCH 6/6] Update docs --- docs/js/hardhat-setup/classes/Networks.md | 46 +++++------------------ 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/docs/js/hardhat-setup/classes/Networks.md b/docs/js/hardhat-setup/classes/Networks.md index 4d504460..0d5e94d2 100644 --- a/docs/js/hardhat-setup/classes/Networks.md +++ b/docs/js/hardhat-setup/classes/Networks.md @@ -28,7 +28,7 @@ #### Defined in -[hardhat-setup/networks.ts:75](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L75) +[hardhat-setup/networks.ts:75](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L75) ## Properties @@ -38,7 +38,7 @@ #### Defined in -[hardhat-setup/networks.ts:73](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L73) +[hardhat-setup/networks.ts:73](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L73) *** @@ -48,13 +48,13 @@ #### Defined in -[hardhat-setup/networks.ts:72](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L72) +[hardhat-setup/networks.ts:72](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L72) ## Methods ### register() -> **register**(`name`, `chainId`, `rpc`?, `privateKey`?, `etherscanNetworkName`?, `etherscanKey`?, `hardfork`?): `void` +> **register**(`name`, `chainId`, `rpc`?, `privateKey`?, `etherscanNetworkName`?, `etherscanKey`?, `hardfork`?, `l1Network`?): `void` #### Parameters @@ -72,13 +72,15 @@ • **hardfork?**: `string` = `'shanghai'` +• **l1Network?**: `string` + #### Returns `void` #### Defined in -[hardhat-setup/networks.ts:99](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L99) +[hardhat-setup/networks.ts:99](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L99) *** @@ -100,7 +102,7 @@ #### Defined in -[hardhat-setup/networks.ts:142](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L142) +[hardhat-setup/networks.ts:124](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L124) *** @@ -132,34 +134,4 @@ #### Defined in -[hardhat-setup/networks.ts:116](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L116) - -*** - -### registerZksync() - -> **registerZksync**(`name`, `chainId`, `rpc`?, `ethNetwork`?, `privateKey`?, `verifyURL`?, `hardfork`?): `void` - -#### Parameters - -• **name**: `string` - -• **chainId**: `number` - -• **rpc?**: `string` - -• **ethNetwork?**: `string` - -• **privateKey?**: `string` - -• **verifyURL?**: `string` - -• **hardfork?**: `string` = `'paris'` - -#### Returns - -`void` - -#### Defined in - -[hardhat-setup/networks.ts:123](https://github.com/1inch/solidity-utils/blob/f9426ba6dab1eac9ac07fe3976b8d1cb2d2e5ba1/hardhat-setup/networks.ts#L123) +[hardhat-setup/networks.ts:117](https://github.com/1inch/solidity-utils/blob/1f96397aedbb993a6d3faaeed4b2f77929d81ef0/hardhat-setup/networks.ts#L117)