diff --git a/.github/workflows/contracts.yaml b/.github/workflows/contracts.yaml index 829ede66..2b313663 100644 --- a/.github/workflows/contracts.yaml +++ b/.github/workflows/contracts.yaml @@ -144,6 +144,7 @@ jobs: CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} run: yarn deploy --network ${{ github.event.inputs.environment }} - name: Bump up package version @@ -171,49 +172,6 @@ jobs: upstream_ref: ${{ github.event.inputs.upstream_ref }} version: ${{ steps.npm-version-bump.outputs.version }} - - name: Upload files needed for etherscan verification - uses: actions/upload-artifact@v3 - with: - name: Artifacts for etherscan verifcation - path: | - ./deployments - ./package.json - ./yarn.lock - - contracts-etherscan-verification: - needs: [contracts-deployment-testnet] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Download files needed for etherscan verification - uses: actions/download-artifact@v3 - with: - name: Artifacts for etherscan verifcation - - - uses: actions/setup-node@v3 - with: - node-version: "14.x" - cache: "yarn" - - - name: Install needed dependencies - run: yarn install --frozen-lockfile - - # If we don't remove the `keep-core` contracts from `node-modules`, the - # `etherscan-verify` plugins tries to verify them, which is not desired. - - name: Prepare for verification on Etherscan - run: | - rm -rf ./node_modules/@keep-network/keep-core - rm -rf ./external/npm - - - name: Verify contracts on Etherscan - env: - ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - run: | - yarn run hardhat --network ${{ github.event.inputs.environment }} \ - etherscan-verify --license GPL-3.0 --force-license - # This job is responsible for publishing packages from `dapp-development` # branch, which are slightly modified to help with the process of testing some # features on the Threshold Token dApp. The job starts only if workflow gets @@ -244,6 +202,7 @@ jobs: CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.DAPP_DEV_GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} run: yarn deploy --network ${{ github.event.inputs.environment }} - name: Bump up package version diff --git a/deploy/00_resolve_nucypher_staking_escrow.ts b/deploy/00_resolve_nucypher_staking_escrow.ts index 53188089..b7e8da36 100644 --- a/deploy/00_resolve_nucypher_staking_escrow.ts +++ b/deploy/00_resolve_nucypher_staking_escrow.ts @@ -26,7 +26,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } else if ( // TODO: For testnets currently we deploy a stub contract. We should consider // switching to an actual contract. - hre.network.name !== "ropsten" && hre.network.name !== "goerli" && (!hre.network.tags.allowStubs || (hre.network.config as HardhatNetworkConfig)?.forking?.enabled) diff --git a/deploy/00_resolve_nucypher_token.ts b/deploy/00_resolve_nucypher_token.ts index cc35e53f..90b5237a 100644 --- a/deploy/00_resolve_nucypher_token.ts +++ b/deploy/00_resolve_nucypher_token.ts @@ -21,7 +21,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } else if ( // TODO: For testnets currently we deploy a stub contract. We should consider // switching to an actual contract. - hre.network.name !== "ropsten" && hre.network.name !== "goerli" && (!hre.network.tags.allowStubs || (hre.network.config as HardhatNetworkConfig)?.forking?.enabled) diff --git a/deploy/01_deploy_t.ts b/deploy/01_deploy_t.ts index 32314b8b..73105066 100644 --- a/deploy/01_deploy_t.ts +++ b/deploy/01_deploy_t.ts @@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types" import { DeployFunction } from "hardhat-deploy/types" const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts, deployments } = hre + const { getNamedAccounts, deployments, helpers } = hre const { deployer } = await getNamedAccounts() const T = await deployments.deploy("T", { @@ -10,6 +10,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction(T.transactionHash, 5, 300000) + await helpers.etherscan.verify(T) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "T", diff --git a/deploy/03_deploy_vending_machine_keep.ts b/deploy/03_deploy_vending_machine_keep.ts index 1fea3b26..f88b84cb 100644 --- a/deploy/03_deploy_vending_machine_keep.ts +++ b/deploy/03_deploy_vending_machine_keep.ts @@ -29,6 +29,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + vendingMachine.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify(vendingMachine) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "VendingMachineKeep", diff --git a/deploy/04_deploy_vending_machine_nu.ts b/deploy/04_deploy_vending_machine_nu.ts index 7fb178b3..939b10e5 100644 --- a/deploy/04_deploy_vending_machine_nu.ts +++ b/deploy/04_deploy_vending_machine_nu.ts @@ -25,6 +25,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + vendingMachine.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify(vendingMachine) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "VendingMachineNuCypher", diff --git a/deploy/06_deploy_keep_stake.ts b/deploy/06_deploy_keep_stake.ts index 83599291..f24d71fa 100644 --- a/deploy/06_deploy_keep_stake.ts +++ b/deploy/06_deploy_keep_stake.ts @@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types" import { DeployFunction } from "hardhat-deploy/types" const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts, deployments } = hre + const { getNamedAccounts, deployments, helpers } = hre const { deployer } = await getNamedAccounts() const KeepTokenStaking = await deployments.get("KeepTokenStaking") @@ -13,6 +13,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + KeepStake.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify(KeepStake) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "KeepStake", diff --git a/deploy/07_deploy_token_staking.ts b/deploy/07_deploy_token_staking.ts index 0f0c084a..80f39e3a 100644 --- a/deploy/07_deploy_token_staking.ts +++ b/deploy/07_deploy_token_staking.ts @@ -4,7 +4,7 @@ import { DeployFunction } from "hardhat-deploy/types" import { ethers, upgrades } from "hardhat" const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts, deployments } = hre + const { getNamedAccounts, deployments, helpers } = hre const { execute, log } = deployments const { deployer } = await getNamedAccounts() @@ -69,6 +69,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { await execute("TokenStaking", { from: deployer }, "initialize") log("Initialized TokenStaking.") + + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + TokenStaking.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify(TokenStaking) + } } if (hre.network.tags.tenderly) { diff --git a/deploy/30_deploy_tokenholder_timelock.ts b/deploy/30_deploy_tokenholder_timelock.ts index 9d15fc59..23d3a775 100644 --- a/deploy/30_deploy_tokenholder_timelock.ts +++ b/deploy/30_deploy_tokenholder_timelock.ts @@ -7,7 +7,7 @@ import { DeployFunction } from "hardhat-deploy/types" import { ethers } from "ethers" const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts, deployments } = hre + const { getNamedAccounts, deployments, helpers } = hre const { deployer } = await getNamedAccounts() const proposers = [] @@ -21,6 +21,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + timelock.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify(timelock) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "TokenholderTimelock", diff --git a/deploy/31_deploy_tokenholder_governor.ts b/deploy/31_deploy_tokenholder_governor.ts index fb02389d..d14fcbcc 100644 --- a/deploy/31_deploy_tokenholder_governor.ts +++ b/deploy/31_deploy_tokenholder_governor.ts @@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types" import { DeployFunction } from "hardhat-deploy/types" const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts, deployments } = hre + const { getNamedAccounts, deployments, helpers } = hre const { deployer, thresholdCouncil } = await getNamedAccounts() // TODO: fail if thresholdCouncil is undefined on mainnet @@ -23,6 +23,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }) + if (hre.network.tags.etherscan) { + await hre.ethers.provider.waitForTransaction( + timelock.transactionHash, + 5, + 300000 + ) + await helpers.etherscan.verify( + timelock, + "contracts/governance/TokenholderGovernor.sol:TokenholderGovernor" + ) + } + if (hre.network.tags.tenderly) { await hre.tenderly.verify({ name: "TokenholderGovernor", diff --git a/hardhat.config.ts b/hardhat.config.ts index d98a1b00..beb1df44 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,5 +1,6 @@ import { HardhatUserConfig } from "hardhat/config" +import "@nomiclabs/hardhat-etherscan" import "@keep-network/hardhat-helpers" import "@nomiclabs/hardhat-waffle" import "@openzeppelin/hardhat-upgrades" @@ -54,26 +55,7 @@ const config: HardhatUserConfig = { process.env.KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, ] : undefined, - tags: ["tenderly"], - }, - rinkeby: { - url: process.env.CHAIN_API_URL || "", - chainId: 4, - accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY - ? [process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY] - : undefined, - tags: ["tenderly"], - }, - ropsten: { - url: process.env.CHAIN_API_URL || "", - chainId: 3, - accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY - ? [ - process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, - process.env.KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, - ] - : undefined, - tags: ["tenderly"], + tags: ["etherscan", "tenderly"], }, mainnet: { url: process.env.CHAIN_API_URL || "", @@ -81,17 +63,15 @@ const config: HardhatUserConfig = { accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY ? [process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY] : undefined, - tags: ["tenderly"], + tags: ["etherscan", "tenderly"], }, }, tenderly: { username: "thesis", project: "thesis/threshold-network", }, - verify: { - etherscan: { - apiKey: process.env.ETHERSCAN_API_KEY, - }, + etherscan: { + apiKey: process.env.ETHERSCAN_API_KEY, }, external: { contracts: [ @@ -112,7 +92,6 @@ const config: HardhatUserConfig = { // with `yarn link` command, uncomment the line below to use the linked // dependencies. // development: ["external/npm/@keep-network/keep-core/artifacts"], - ropsten: ["external/npm/@keep-network/keep-core/artifacts"], goerli: ["external/npm/@keep-network/keep-core/artifacts"], mainnet: ["./external/mainnet"], }, @@ -128,7 +107,6 @@ const config: HardhatUserConfig = { }, keepRegistryKeeper: { default: 1, // same as the deployer - ropsten: "0x923C5Dbf353e99394A21Aa7B67F3327Ca111C67D", goerli: "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", }, }, diff --git a/package.json b/package.json index e9522f0b..a5d632d8 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,10 @@ "prepublishOnly": "hardhat prepare-artifacts --network $npm_config_network" }, "devDependencies": { - "@keep-network/hardhat-helpers": "^0.6.0-pre.8", + "@keep-network/hardhat-helpers": "^0.6.0-pre.16", "@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep#d6ec02e", "@nomiclabs/hardhat-ethers": "^2.0.2", + "@nomiclabs/hardhat-etherscan": "3.0.4", "@nomiclabs/hardhat-waffle": "^2.0.1", "@openzeppelin/hardhat-upgrades": "^1.12.0", "@tenderly/hardhat-tenderly": "^1.0.12", diff --git a/yarn.lock b/yarn.lock index 88a969e1..ecf759ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -375,7 +375,7 @@ "@ethersproject/logger" "^5.6.0" "@ethersproject/rlp" "^5.6.1" -"@ethersproject/address@^5.5.0", "@ethersproject/address@^5.7.0": +"@ethersproject/address@^5.0.2", "@ethersproject/address@^5.5.0", "@ethersproject/address@^5.7.0": version "5.7.0" resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.7.0.tgz#19b56c4d74a3b0a46bfdbb6cfcc0a153fc697f37" integrity sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA== @@ -1189,10 +1189,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@keep-network/hardhat-helpers@^0.6.0-pre.8": - version "0.6.0-pre.8" - resolved "https://registry.yarnpkg.com/@keep-network/hardhat-helpers/-/hardhat-helpers-0.6.0-pre.8.tgz#6e0722889a0132dabed5182fb32f6424ff4a77d0" - integrity sha512-51oLHceBubutBYxfVk2pLjgyhvpcDC1ahKM3V9lOiTa9lbWyY18Dza7rnM9V04kq+8DbweQRM0M9/f+K26nl9g== +"@keep-network/hardhat-helpers@^0.6.0-pre.16": + version "0.6.0-pre.16" + resolved "https://registry.yarnpkg.com/@keep-network/hardhat-helpers/-/hardhat-helpers-0.6.0-pre.16.tgz#a610d44592393d054176857a0b8db37f33d85da5" + integrity sha512-wt9ot3/Bhb2E6hTCQLKzpHM7G8iHITxaBgGJVdR/hn4W0LfETvc7vSyb7SlT8vW+tAX4NfXxW7rLq7AxI8hC/A== "@keep-network/keep-core@>1.8.1-dev <1.8.1-goerli": version "1.8.1-dev.0" @@ -1236,6 +1236,19 @@ resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.0.5.tgz#131b0da1b71680d5a01569f916ae878229d326d3" integrity sha512-A2gZAGB6kUvLx+kzM92HKuUF33F1FSe90L0TmkXkT2Hh0OKRpvWZURUSU2nghD2yC4DzfEZ3DftfeHGvZ2JTUw== +"@nomiclabs/hardhat-etherscan@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.0.4.tgz#b12e3e226a5b73c4a66d0e6943f948bd093b2711" + integrity sha512-AZPlnyCYp3YObmhtsFo6RWgY/81fQKRF5h42iV22H4jz9MwP+SWeoB99YVPLnxId2fmAYu3VgCNeE9QpApv06g== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^5.0.2" + debug "^4.1.1" + fs-extra "^7.0.1" + semver "^6.3.0" + undici "^4.14.1" + "@nomiclabs/hardhat-waffle@^2.0.1": version "2.0.2" resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.2.tgz#6030aa6fd9ea05327bf79d1107356af906d8b1e4" @@ -2700,6 +2713,11 @@ bignumber.js@^9.0.0: resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.2.tgz#71c6c6bed38de64e24a65ebe16cfcf23ae693673" integrity sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw== +bignumber.js@^9.0.1: + version "9.1.0" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62" + integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A== + binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" @@ -3103,6 +3121,14 @@ cbor@^4.1.5: json-text-sequence "^0.1" nofilter "^1.0.3" +cbor@^5.0.2: + version "5.2.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-5.2.0.tgz#4cca67783ccd6de7b50ab4ed62636712f287a67c" + integrity sha512-5IMhi9e1QU76ppa5/ajP1BmMWZ2FHkhAhjeVKQ/EFCgYSEaeVaoGtL7cxJskf9oCCk+XjzaIdc3IuU/dbA/o2A== + dependencies: + bignumber.js "^9.0.1" + nofilter "^1.0.4" + cbor@^8.0.0: version "8.1.0" resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" @@ -7657,7 +7683,7 @@ node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== -nofilter@^1.0.3: +nofilter@^1.0.3, nofilter@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.4.tgz#78d6f4b6a613e7ced8b015cec534625f7667006e" integrity sha512-N8lidFp+fCz+TD51+haYdbDGrcBWwuHX40F5+z0qkUjMJ5Tp+rdSuAkMJ9N9eoolDlEVTf6u5icM+cNKkKW2mA== @@ -10058,6 +10084,11 @@ underscore@1.9.1: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== +undici@^4.14.1: + version "4.16.0" + resolved "https://registry.yarnpkg.com/undici/-/undici-4.16.0.tgz#469bb87b3b918818d3d7843d91a1d08da357d5ff" + integrity sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw== + undici@^5.4.0: version "5.9.1" resolved "https://registry.yarnpkg.com/undici/-/undici-5.9.1.tgz#fc9fd85dd488f965f153314a63d9426a11f3360b"