From 851ebd3fc04cabce37f07410327c894824d97d33 Mon Sep 17 00:00:00 2001 From: Marko Arambasic Date: Thu, 26 Oct 2023 16:15:51 +0200 Subject: [PATCH] update: add no compile flag to hardhat verify --- .changeset/selfish-trees-cheat.md | 5 +++++ packages/hardhat-zksync-verify/package.json | 4 ++-- packages/hardhat-zksync-verify/src/index.ts | 4 +++- packages/hardhat-zksync-verify/src/task-actions.ts | 8 ++++++-- packages/hardhat-zksync-verify/src/types.ts | 3 +++ yarn.lock | 11 ++++++++++- 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 .changeset/selfish-trees-cheat.md diff --git a/.changeset/selfish-trees-cheat.md b/.changeset/selfish-trees-cheat.md new file mode 100644 index 000000000..12da7b503 --- /dev/null +++ b/.changeset/selfish-trees-cheat.md @@ -0,0 +1,5 @@ +--- +"@matterlabs/hardhat-zksync-verify": patch +--- + +Add noCompile flag to the contract verification script to not recompile the contracts before sending verification request diff --git a/packages/hardhat-zksync-verify/package.json b/packages/hardhat-zksync-verify/package.json index 3a5f24a09..fb9843a15 100644 --- a/packages/hardhat-zksync-verify/package.json +++ b/packages/hardhat-zksync-verify/package.json @@ -32,13 +32,13 @@ "README.md" ], "dependencies": { - "axios": "^1.4.0", "@matterlabs/hardhat-zksync-solc": "0.4.1", + "@nomicfoundation/hardhat-verify": "^1.0.2", + "axios": "^1.4.0", "chalk": "4.1.2", "dockerode": "^3.3.4" }, "devDependencies": { - "@nomicfoundation/hardhat-verify": "^1.0.2", "@types/chai": "^4.2.0", "@types/mocha": "^9.1.0", "@types/node": "^18.11.17", diff --git a/packages/hardhat-zksync-verify/src/index.ts b/packages/hardhat-zksync-verify/src/index.ts index 40dccc484..dad1be4ac 100644 --- a/packages/hardhat-zksync-verify/src/index.ts +++ b/packages/hardhat-zksync-verify/src/index.ts @@ -21,7 +21,9 @@ extendEnvironment((hre: HardhatRuntimeEnvironment) => { hre.network.verifyURL = hre.network.config.verifyURL ?? TESTNET_VERIFY_URL; }); -task(TASK_VERIFY, 'Verifies contract on Ethereum and zkSync networks').setAction(verify); +task(TASK_VERIFY, 'Verifies contract on Ethereum and zkSync networks') +.addFlag("noCompile", "Run verify without compile") +.setAction(verify); subtask(TASK_VERIFY_VERIFY).setAction(verifyContract); diff --git a/packages/hardhat-zksync-verify/src/task-actions.ts b/packages/hardhat-zksync-verify/src/task-actions.ts index be562fb5d..2102f09a6 100644 --- a/packages/hardhat-zksync-verify/src/task-actions.ts +++ b/packages/hardhat-zksync-verify/src/task-actions.ts @@ -41,6 +41,7 @@ export async function verify( contract: string; constructorArgsParams: any[]; libraries: string; + noCompile: boolean; }, hre: HardhatRuntimeEnvironment, runSuper: RunSuperFunction @@ -69,6 +70,7 @@ export async function verify( constructorArguments: constructorArguments, contract: args.contract, libraries, + noCompile: args.noCompile, }); } @@ -120,7 +122,7 @@ export async function getConstructorArguments( } export async function verifyContract( - { address, contract: contractFQN, constructorArguments, libraries }: TaskArguments, + { address, contract: contractFQN, constructorArguments, libraries, noCompile }: TaskArguments, hre: HardhatRuntimeEnvironment, runSuper: RunSuperFunction ): Promise { @@ -138,7 +140,9 @@ export async function verifyContract( const compilerVersions: string[] = await hre.run(TASK_VERIFY_GET_COMPILER_VERSIONS); - await hre.run(TASK_COMPILE, { quiet: true }); + if (!noCompile) { + await hre.run(TASK_COMPILE, { quiet: true }); + } const contractInformation: ContractInformation = await hre.run(TASK_VERIFY_GET_CONTRACT_INFORMATION, { contractFQN: contractFQN, diff --git a/packages/hardhat-zksync-verify/src/types.ts b/packages/hardhat-zksync-verify/src/types.ts index c14c46f08..3a43732a6 100644 --- a/packages/hardhat-zksync-verify/src/types.ts +++ b/packages/hardhat-zksync-verify/src/types.ts @@ -19,6 +19,9 @@ export interface VerificationArgs { // --list-networks flag listNetworks: boolean; + + // Do not compile contracts before verifying + noCompile?: boolean; } export interface Libraries { diff --git a/yarn.lock b/yarn.lock index 2070fcb39..2d99edd18 100644 --- a/yarn.lock +++ b/yarn.lock @@ -719,7 +719,7 @@ ts-morph "^19.0.0" "@matterlabs/hardhat-zksync-node@link:packages/hardhat-zksync-node": - version "0.0.1-beta.1" + version "0.0.1-beta.4" dependencies: "@matterlabs/hardhat-zksync-solc" "0.4.2" axios "^1.4.0" @@ -757,6 +757,15 @@ "@openzeppelin/upgrades-core" "~1.27.0" dockerode "^3.3.4" +"@matterlabs/hardhat-zksync-verify@link:packages/hardhat-zksync-verify": + version "0.2.0" + dependencies: + "@matterlabs/hardhat-zksync-solc" "0.4.1" + "@nomicfoundation/hardhat-verify" "^1.0.2" + axios "^1.4.0" + chalk "4.1.2" + dockerode "^3.3.4" + "@matterlabs/hardhat-zksync-vyper@link:packages/hardhat-zksync-vyper": version "0.2.2" dependencies: