Skip to content

Commit 86542fb

Browse files
authored
Merge pull request #228 from keep-network/deployment-scripts-improvements
Deployment scripts improvements In this PR we improve the deployment scripts with: - waitForConfirmations to ensure transaction is mined before executing next steps, - Etherscan contracts verification.
2 parents c62e667 + 426117b commit 86542fb

10 files changed

+77
-27
lines changed

deploy/01_deploy_underwriter_token.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"
22
import { DeployFunction } from "hardhat-deploy/types"
33

44
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5-
const { getNamedAccounts, deployments } = hre
5+
const { getNamedAccounts, deployments, helpers } = hre
66
const { deployer } = await getNamedAccounts()
77

88
const underwriterToken = await deployments.deploy("UnderwriterToken", {
99
from: deployer,
1010
args: ["covT underwriter token", "covT"],
1111
log: true,
12+
waitConfirmations: 1,
1213
})
1314

15+
if (hre.network.tags.etherscan) {
16+
await helpers.etherscan.verify(underwriterToken)
17+
}
18+
1419
if (hre.network.tags.tenderly) {
1520
await hre.tenderly.verify({
1621
name: "UnderwriterToken",

deploy/02_deploy_asset_pool.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1515
from: deployer,
1616
args: [T.address, UnderwriterToken.address, rewardManager],
1717
log: true,
18+
waitConfirmations: 1,
1819
})
1920

20-
if (hre.network.tags.tenderly) {
21-
await hre.tenderly.verify({
22-
name: "AssetPool",
23-
address: AssetPool.address,
24-
})
25-
}
26-
2721
const rewardsPoolAddress = helpers.address.validate(
2822
await read("AssetPool", "rewardsPool")
2923
)
@@ -41,6 +35,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
4135
address: rewardsPoolAddress,
4236
receipt,
4337
transactionHash: AssetPool.transactionHash,
38+
args: [T.address, AssetPool.address, rewardManager],
4439
},
4540
RewardsPool
4641
)
@@ -52,6 +47,29 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5247
AssetPool.address,
5348
deployer
5449
)
50+
51+
if (hre.network.tags.etherscan) {
52+
await helpers.etherscan.verify(
53+
AssetPool,
54+
// Provide contract name as a workaround for error returned by hardhat:
55+
// "More than one contract was found to match the deployed bytecode."
56+
"contracts/AssetPool.sol:AssetPool"
57+
)
58+
59+
await helpers.etherscan.verify(rewardsPoolDeploymentArtifact)
60+
}
61+
62+
if (hre.network.tags.tenderly) {
63+
await hre.tenderly.verify({
64+
name: "AssetPool",
65+
address: AssetPool.address,
66+
})
67+
68+
await hre.tenderly.verify({
69+
name: "RewardsPool",
70+
address: rewardsPoolAddress,
71+
})
72+
}
5573
}
5674

5775
export default func

deploy/03_deploy_coverage_pool.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1111
from: deployer,
1212
args: [AssetPool.address],
1313
log: true,
14+
waitConfirmations: 1,
1415
})
1516

17+
await helpers.ownable.transferOwnership(
18+
"AssetPool",
19+
CoveragePool.address,
20+
deployer
21+
)
22+
23+
if (hre.network.tags.etherscan) {
24+
await helpers.etherscan.verify(CoveragePool)
25+
}
26+
1627
if (hre.network.tags.tenderly) {
1728
await hre.tenderly.verify({
1829
name: "CoveragePool",
1930
address: CoveragePool.address,
2031
})
2132
}
22-
23-
await helpers.ownable.transferOwnership(
24-
"AssetPool",
25-
CoveragePool.address,
26-
deployer
27-
)
2833
}
2934

3035
export default func

deploy/04_deploy_batched_phased_escrow.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"
22
import { DeployFunction } from "hardhat-deploy/types"
33

44
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5-
const { getNamedAccounts, deployments } = hre
5+
const { getNamedAccounts, deployments, helpers } = hre
66
const { deployer } = await getNamedAccounts()
77

88
const T = await deployments.get("T")
@@ -12,8 +12,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1212
from: deployer,
1313
args: [T.address],
1414
log: true,
15+
waitConfirmations: 1,
1516
})
1617

18+
if (hre.network.tags.etherscan) {
19+
await helpers.etherscan.verify(BatchedPhasedEscrow)
20+
}
21+
1722
if (hre.network.tags.tenderly) {
1823
await hre.tenderly.verify({
1924
name: "BatchedPhasedEscrow",

deploy/05_deploy_coverage_pool_beneficiary.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1818
from: deployer,
1919
args: [T.address, RewardsPoolAddress],
2020
log: true,
21+
waitConfirmations: 1,
2122
}
2223
)
2324

24-
if (hre.network.tags.tenderly) {
25-
await hre.tenderly.verify({
26-
name: "CoveragePoolBeneficiary",
27-
address: CoveragePoolBeneficiary.address,
28-
})
29-
}
30-
3125
await execute(
3226
"BatchedPhasedEscrow",
33-
{ from: deployer, log: true },
27+
{ from: deployer, log: true, waitConfirmations: 1 },
3428
"approveBeneficiary",
3529
CoveragePoolBeneficiary.address
3630
)
@@ -46,6 +40,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
4640
CoveragePoolBeneficiary.address,
4741
rewardManager
4842
)
43+
44+
if (hre.network.tags.etherscan) {
45+
await helpers.etherscan.verify(CoveragePoolBeneficiary)
46+
}
47+
48+
if (hre.network.tags.tenderly) {
49+
await hre.tenderly.verify({
50+
name: "CoveragePoolBeneficiary",
51+
address: CoveragePoolBeneficiary.address,
52+
})
53+
}
4954
}
5055

5156
export default func

deploy/06_approve_treasury_guild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1111

1212
await execute(
1313
"CoveragePool",
14-
{ from: deployer, log: true },
14+
{ from: deployer, log: true, waitConfirmations: 1 },
1515
"approveFirstRiskManager",
1616
treasuryGuild
1717
)

deploy/07_transfer_ownership_to_t_council.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
88

99
await execute(
1010
"BatchedPhasedEscrow",
11-
{ from: deployer, log: true },
11+
{ from: deployer, log: true, waitConfirmations: 1 },
1212
"setDrawee",
1313
thresholdCouncil
1414
)

hardhat.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "hardhat-gas-reporter"
77
import "hardhat-deploy"
88
import "hardhat-dependency-compiler"
99
import "solidity-coverage"
10+
import "@nomiclabs/hardhat-etherscan"
1011
import "@tenderly/hardhat-tenderly"
1112

1213
const config: HardhatUserConfig = {
@@ -43,6 +44,14 @@ const config: HardhatUserConfig = {
4344
chainId: 1101,
4445
tags: ["local"],
4546
},
47+
goerli: {
48+
url: process.env.CHAIN_API_URL || "",
49+
chainId: 5,
50+
accounts: process.env.ACCOUNTS_PRIVATE_KEYS
51+
? process.env.ACCOUNTS_PRIVATE_KEYS.split(",")
52+
: undefined,
53+
tags: ["etherscan", "tenderly"],
54+
},
4655
ropsten: {
4756
url: process.env.CHAIN_API_URL || "",
4857
chainId: 3,
@@ -102,15 +111,18 @@ const config: HardhatUserConfig = {
102111
},
103112
rewardManager: {
104113
default: 1,
114+
goerli: 0, // use deployer account
105115
ropsten: 0, // use deployer account
106116
mainnet: 0, // use deployer account
107117
},
108118
thresholdCouncil: {
109119
default: 2,
120+
goerli: 0, // use deployer account
110121
mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f",
111122
},
112123
treasuryGuild: {
113124
default: 3,
125+
goerli: 0, // use deployer account
114126
mainnet: "0x71E47a4429d35827e0312AA13162197C23287546",
115127
},
116128
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@threshold-network/solidity-contracts": "development"
4343
},
4444
"devDependencies": {
45-
"@keep-network/hardhat-helpers": "^0.6.0-pre.15",
45+
"@keep-network/hardhat-helpers": "^0.6.0-pre.17",
4646
"@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep#d6ec02e",
4747
"@nomiclabs/hardhat-ethers": "^2.0.6",
4848
"@nomiclabs/hardhat-etherscan": "^3.1.0",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@
13411341
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf"
13421342
integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==
13431343

1344-
"@keep-network/hardhat-helpers@^0.6.0-pre.15":
1344+
"@keep-network/hardhat-helpers@^0.6.0-pre.17":
13451345
version "0.6.0-pre.17"
13461346
resolved "https://registry.yarnpkg.com/@keep-network/hardhat-helpers/-/hardhat-helpers-0.6.0-pre.17.tgz#de085c8f5d684cc7e4ae793fdc6c104a09fd03ce"
13471347
integrity sha512-G3Jp+I77po8e4moOrUY/wQCRYGt/g1aBoDjL2cbxMkAWFFrb9OBu1a5Vi5eOwO4ttWthN5c9vZKWJicR6kwOLg==

0 commit comments

Comments
 (0)