From 887e2cbef7d1f1319a443a7c22d2feaa4fa005f8 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Fri, 8 Sep 2023 18:08:54 +0300 Subject: [PATCH] Refactor verification flow --- dictionaries/libraries.txt | 1 + package.json | 1 + src/upgrader.ts | 10 +++++++++- src/verification.ts | 6 ++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dictionaries/libraries.txt b/dictionaries/libraries.txt index b59ff2b..a6c7d85 100644 --- a/dictionaries/libraries.txt +++ b/dictionaries/libraries.txt @@ -21,6 +21,7 @@ mulmod muln nbconvert nbformat +nomicfoundation nomiclabs pygments pyplot diff --git a/package.json b/package.json index e2487e9..f5b7745 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "ethereumjs-util": "^7.1.4" }, "peerDependencies": { + "@nomicfoundation/hardhat-verify": "^1.1.1", "@nomiclabs/hardhat-ethers": "^2.0.4", "@openzeppelin/hardhat-upgrades": "^1.14.0", "@openzeppelin/upgrades-core": "^1.27.1", diff --git a/src/upgrader.ts b/src/upgrader.ts index ab1062b..72e64b9 100644 --- a/src/upgrader.ts +++ b/src/upgrader.ts @@ -96,7 +96,6 @@ export abstract class Upgrader { implementationAddress: newImplementationAddress, name: contract }); - await verify(contract, newImplementationAddress, []); } else { console.log(chalk.gray(`Contract ${contract} is up to date`)); } @@ -120,6 +119,15 @@ export abstract class Upgrader { await this.submitter.submit(this.transactions); + if (process.env.NO_VERIFY) { + console.log("Skip verification"); + } else { + console.log("Start verification"); + for (const contract of contractsToUpgrade) { + await verify(contract.name, contract.implementationAddress, []); + } + } + console.log("Done"); } diff --git a/src/verification.ts b/src/verification.ts index a196e5e..ea39b6f 100644 --- a/src/verification.ts +++ b/src/verification.ts @@ -1,9 +1,11 @@ import { ethers, run, network } from "hardhat"; +import { builtinChains } from "@nomicfoundation/hardhat-verify/internal/chain-config"; import chalk from "chalk"; import { getImplementationAddress } from "@openzeppelin/upgrades-core"; export async function verify(contractName: string, contractAddress: string, constructorArguments: object) { - if (![1337, 31337].includes((await ethers.provider.getNetwork()).chainId)) { + const chainId = (await ethers.provider.getNetwork()).chainId; + if (builtinChains.find(chain => chain.chainId === chainId) !== undefined) { for (let retry = 0; retry <= 5; ++retry) { try { await run("verify:verify", { @@ -29,4 +31,4 @@ export async function verify(contractName: string, contractAddress: string, cons export async function verifyProxy(contractName: string, proxyAddress: string, constructorArguments: object) { await verify(contractName, await getImplementationAddress(network.provider, proxyAddress), constructorArguments); -} \ No newline at end of file +}