Skip to content

Commit

Permalink
Merge pull request #226 from skalenetwork/verification
Browse files Browse the repository at this point in the history
Refactor verification flow
  • Loading branch information
DimaStebaev authored Sep 12, 2023
2 parents ce65a05 + 887e2cb commit d717465
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions dictionaries/libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mulmod
muln
nbconvert
nbformat
nomicfoundation
nomiclabs
pygments
pyplot
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 9 additions & 1 deletion src/upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
}
Expand All @@ -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");
}

Expand Down
6 changes: 4 additions & 2 deletions src/verification.ts
Original file line number Diff line number Diff line change
@@ -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", {
Expand All @@ -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);
}
}

0 comments on commit d717465

Please sign in to comment.