From 25e84e0245d719a6fce8a39e527a72ecd1895299 Mon Sep 17 00:00:00 2001 From: Bence Haromi <56651250+benceharomi@users.noreply.github.com> Date: Fri, 23 Feb 2024 13:56:58 +0000 Subject: [PATCH] fix(scripts): moved hardhat to be the first import (#195) --- l1-contracts/scripts/deploy-erc20.ts | 2 ++ l1-contracts/scripts/deploy-testkit.ts | 2 ++ l1-contracts/scripts/deploy-testnet-token.ts | 4 +++- l1-contracts/scripts/deploy-withdrawal-helpers.ts | 2 ++ l1-contracts/scripts/migrate-governance.ts | 4 +++- l1-contracts/scripts/read-variable.ts | 4 +++- l1-contracts/scripts/revert-reason.ts | 4 +++- l1-contracts/scripts/verify.ts | 2 ++ l2-contracts/src/deployForceDeployUpgrader.ts | 4 +++- l2-contracts/src/deployTestnetPaymaster.ts | 4 +++- l2-contracts/src/publish-bridge-preimages.ts | 4 +++- l2-contracts/src/upgradeBridgeImpl.ts | 4 +++- l2-contracts/src/verify.ts | 1 + system-contracts/scripts/deploy-preimages.ts | 1 + system-contracts/scripts/preprocess-bootloader.ts | 1 + system-contracts/scripts/utils.ts | 1 + 16 files changed, 36 insertions(+), 8 deletions(-) diff --git a/l1-contracts/scripts/deploy-erc20.ts b/l1-contracts/scripts/deploy-erc20.ts index 39b65346f8c..2618b39df69 100644 --- a/l1-contracts/scripts/deploy-erc20.ts +++ b/l1-contracts/scripts/deploy-erc20.ts @@ -1,4 +1,6 @@ +// hardhat import should be the first import in the file import * as hardhat from "hardhat"; + import "@nomiclabs/hardhat-ethers"; import { Command } from "commander"; import { Wallet } from "ethers"; diff --git a/l1-contracts/scripts/deploy-testkit.ts b/l1-contracts/scripts/deploy-testkit.ts index 4ad2aa6cf35..f910ebb0893 100644 --- a/l1-contracts/scripts/deploy-testkit.ts +++ b/l1-contracts/scripts/deploy-testkit.ts @@ -1,4 +1,6 @@ +// hardhat import should be the first import in the file import * as hardhat from "hardhat"; + import "@nomiclabs/hardhat-ethers"; import { Command } from "commander"; import { ethers, Wallet } from "ethers"; diff --git a/l1-contracts/scripts/deploy-testnet-token.ts b/l1-contracts/scripts/deploy-testnet-token.ts index 219b69c5bf6..317da932316 100644 --- a/l1-contracts/scripts/deploy-testnet-token.ts +++ b/l1-contracts/scripts/deploy-testnet-token.ts @@ -1,8 +1,10 @@ +// hardhat import should be the first import in the file +import * as hardhat from "hardhat"; + import "@nomiclabs/hardhat-ethers"; import { ArgumentParser } from "argparse"; import { Wallet } from "ethers"; import * as fs from "fs"; -import * as hardhat from "hardhat"; import * as path from "path"; import { web3Provider } from "./utils"; diff --git a/l1-contracts/scripts/deploy-withdrawal-helpers.ts b/l1-contracts/scripts/deploy-withdrawal-helpers.ts index cb09bab7777..15b9734dabb 100644 --- a/l1-contracts/scripts/deploy-withdrawal-helpers.ts +++ b/l1-contracts/scripts/deploy-withdrawal-helpers.ts @@ -1,7 +1,9 @@ // This script deploys the contracts required both for production and // for testing of the contracts required for the `withdrawal-helpers` library +// hardhat import should be the first import in the file import * as hardhat from "hardhat"; + import "@nomiclabs/hardhat-ethers"; import { ethers } from "ethers"; import * as fs from "fs"; diff --git a/l1-contracts/scripts/migrate-governance.ts b/l1-contracts/scripts/migrate-governance.ts index 693b0e5e2d1..1d1a7b5a075 100644 --- a/l1-contracts/scripts/migrate-governance.ts +++ b/l1-contracts/scripts/migrate-governance.ts @@ -1,10 +1,12 @@ /// Temporary script that generated the needed calldata for the migration of the governance. +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import { Command } from "commander"; import { BigNumber, ethers, Wallet } from "ethers"; import { formatUnits, parseUnits } from "ethers/lib/utils"; import * as fs from "fs"; -import * as hre from "hardhat"; import { Deployer } from "../src.ts/deploy"; import { applyL1ToL2Alias, getAddressFromEnv, getNumberFromEnv, web3Provider } from "./utils"; diff --git a/l1-contracts/scripts/read-variable.ts b/l1-contracts/scripts/read-variable.ts index 880320fb436..5481cbb1c3e 100644 --- a/l1-contracts/scripts/read-variable.ts +++ b/l1-contracts/scripts/read-variable.ts @@ -1,6 +1,8 @@ +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import { Command } from "commander"; import { BigNumber, ethers } from "ethers"; -import * as hre from "hardhat"; import { web3Provider } from "./utils"; const provider = web3Provider(); diff --git a/l1-contracts/scripts/revert-reason.ts b/l1-contracts/scripts/revert-reason.ts index 5c42a6508fd..2816f282b5e 100644 --- a/l1-contracts/scripts/revert-reason.ts +++ b/l1-contracts/scripts/revert-reason.ts @@ -1,7 +1,9 @@ +// hardhat import should be the first import in the file +import * as hardhat from "hardhat"; + import * as chalk from "chalk"; import { ethers } from "ethers"; import { Interface } from "ethers/lib/utils"; -import * as hardhat from "hardhat"; import { web3Url } from "./utils"; const erc20BridgeInterface = new Interface(hardhat.artifacts.readArtifactSync("L1ERC20Bridge").abi); diff --git a/l1-contracts/scripts/verify.ts b/l1-contracts/scripts/verify.ts index c1e49bc50e2..2cf431bc03e 100644 --- a/l1-contracts/scripts/verify.ts +++ b/l1-contracts/scripts/verify.ts @@ -1,4 +1,6 @@ +// hardhat import should be the first import in the file import * as hardhat from "hardhat"; + import { deployedAddressesFromEnv } from "../scripts/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/l2-contracts/src/deployForceDeployUpgrader.ts b/l2-contracts/src/deployForceDeployUpgrader.ts index 88a142073dd..d63bc50e403 100644 --- a/l2-contracts/src/deployForceDeployUpgrader.ts +++ b/l2-contracts/src/deployForceDeployUpgrader.ts @@ -1,10 +1,12 @@ +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import { Command } from "commander"; import { ethers, Wallet } from "ethers"; import { computeL2Create2Address, create2DeployFromL1, getNumberFromEnv } from "./utils"; import { web3Provider } from "../../l1-contracts/scripts/utils"; import * as fs from "fs"; import * as path from "path"; -import * as hre from "hardhat"; const provider = web3Provider(); const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant"); diff --git a/l2-contracts/src/deployTestnetPaymaster.ts b/l2-contracts/src/deployTestnetPaymaster.ts index d1f35e0ee65..5d32c2c17af 100644 --- a/l2-contracts/src/deployTestnetPaymaster.ts +++ b/l2-contracts/src/deployTestnetPaymaster.ts @@ -1,10 +1,12 @@ +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import { Command } from "commander"; import { ethers, Wallet } from "ethers"; import { computeL2Create2Address, create2DeployFromL1, getNumberFromEnv } from "./utils"; import { web3Provider } from "../../l1-contracts/scripts/utils"; import * as fs from "fs"; import * as path from "path"; -import * as hre from "hardhat"; const provider = web3Provider(); const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant"); diff --git a/l2-contracts/src/publish-bridge-preimages.ts b/l2-contracts/src/publish-bridge-preimages.ts index aa0aa6f6eff..cd21209e7e6 100644 --- a/l2-contracts/src/publish-bridge-preimages.ts +++ b/l2-contracts/src/publish-bridge-preimages.ts @@ -1,10 +1,12 @@ +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import { Command } from "commander"; import { Wallet, ethers } from "ethers"; import * as fs from "fs"; import { Deployer } from "../../l1-contracts/src.ts/deploy"; import * as path from "path"; import { getNumberFromEnv, web3Provider } from "../../l1-contracts/scripts/utils"; -import * as hre from "hardhat"; import { REQUIRED_L2_GAS_PRICE_PER_PUBDATA } from "./utils"; const PRIORITY_TX_MAX_GAS_LIMIT = getNumberFromEnv("CONTRACTS_PRIORITY_TX_MAX_GAS_LIMIT"); diff --git a/l2-contracts/src/upgradeBridgeImpl.ts b/l2-contracts/src/upgradeBridgeImpl.ts index 7a98a7e4317..731b704d8d3 100644 --- a/l2-contracts/src/upgradeBridgeImpl.ts +++ b/l2-contracts/src/upgradeBridgeImpl.ts @@ -1,8 +1,10 @@ +// hardhat import should be the first import in the file +import * as hre from "hardhat"; + import "@nomiclabs/hardhat-ethers"; import { Command } from "commander"; import { Wallet, ethers, BigNumber } from "ethers"; import * as fs from "fs"; -import * as hre from "hardhat"; import * as path from "path"; import { Provider } from "zksync-web3"; import { REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT } from "zksync-web3/build/src/utils"; diff --git a/l2-contracts/src/verify.ts b/l2-contracts/src/verify.ts index 65a7a008421..53fc28f334b 100644 --- a/l2-contracts/src/verify.ts +++ b/l2-contracts/src/verify.ts @@ -1,3 +1,4 @@ +// hardhat import should be the first import in the file import * as hardhat from "hardhat"; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/system-contracts/scripts/deploy-preimages.ts b/system-contracts/scripts/deploy-preimages.ts index 4f45ef56741..035b98e88f9 100644 --- a/system-contracts/scripts/deploy-preimages.ts +++ b/system-contracts/scripts/deploy-preimages.ts @@ -1,3 +1,4 @@ +// hardhat import should be the first import in the file import * as hre from "hardhat"; import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; diff --git a/system-contracts/scripts/preprocess-bootloader.ts b/system-contracts/scripts/preprocess-bootloader.ts index 83e5bc4ade8..ffb44000441 100644 --- a/system-contracts/scripts/preprocess-bootloader.ts +++ b/system-contracts/scripts/preprocess-bootloader.ts @@ -1,3 +1,4 @@ +// hardhat import should be the first import in the file import * as hre from "hardhat"; import { ethers } from "ethers"; diff --git a/system-contracts/scripts/utils.ts b/system-contracts/scripts/utils.ts index 13d1b721a76..2873f20f67c 100644 --- a/system-contracts/scripts/utils.ts +++ b/system-contracts/scripts/utils.ts @@ -1,3 +1,4 @@ +// hardhat import should be the first import in the file import * as hre from "hardhat"; import type { Deployer } from "@matterlabs/hardhat-zksync-deploy";