-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
185 lines (171 loc) · 5.74 KB
/
hardhat.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import 'dotenv/config';
import { task, types } from "hardhat/config";
import { HardhatUserConfig } from "hardhat/types";
import "@nomiclabs/hardhat-waffle";
import '@typechain/hardhat';
import 'hardhat-dependency-compiler';
import "hardhat-spdx-license-identifier";
import "hardhat-preprocessor";
import { removeConsoleLog } from 'hardhat-preprocessor';
import "hardhat-log-remover";
import "solidity-coverage";
import "@nomiclabs/hardhat-solhint";
import "hardhat-gas-reporter";
import "@nomiclabs/hardhat-etherscan";
import "@openzeppelin/hardhat-upgrades";
import {
hashBytecodeWithoutMetadata,
Manifest,
} from "@openzeppelin/upgrades-core";
import "hardhat-abi-exporter";
let mnemonic = process.env.MNEMONIC;
if (!mnemonic) {
// FOR DEV ONLY, SET IT IN .env files if you want to keep it private
// (IT IS IMPORTANT TO HAVE A NON RANDOM MNEMONIC SO THAT SCRIPTS CAN ACT ON THE SAME ACCOUNTS)
mnemonic = 'test test test test test test test test test test test junk';
}
const accounts = { mnemonic };
task("accounts", "Prints the list of accounts", async (args, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(await account.address);
}
});
task("wban-lp-rewards:deploy", "Deploy wBAN LP Rewards NFT")
.addParam("contract", "The contract metadata URI", '', types.string)
.addParam("uri", "The URI template for the NFTs", '', types.string)
.addParam("opensea", "The address of the OpenSea proxy", '', types.string)
.setAction(async (args, hre) => {
const accounts = await hre.ethers.getSigners();
console.info(`Deploying wBAN LP Rewards with owner "${accounts[0].address}"`)
// deploy upgradeable contract
const WBANLPRewards = await hre.ethers.getContractFactory("WBANLPRewards");
const wbanLPRewards = await hre.upgrades.deployProxy(
WBANLPRewards, [args.contract, args.uri, args.opensea], { initializer: "initializeWithOpenSeaProxy" }
);
await wbanLPRewards.deployed();
console.log(`wBAN LP Rewards proxy deployed at: "${wbanLPRewards.address}"`);
// peer into OpenZeppelin manifest to extract the implementation address
const ozUpgradesManifestClient = await Manifest.forNetwork(hre.network.provider);
const manifest = await ozUpgradesManifestClient.read();
const bytecodeHash = hashBytecodeWithoutMetadata(WBANLPRewards.bytecode);
const implementationContract = manifest.impls[bytecodeHash];
// verify implementation contract
if (implementationContract) {
console.log(`wBAN LP Rewards impl deployed at: "${implementationContract.address}"`);
await hre.run("verify:verify", {
address: implementationContract.address
});
}
});
task("wban-lp-rewards:upgrade", "Upgrade wBAN LP Rewards NFT")
.addParam("contract", "The smart-contract address", '', types.string)
.setAction(async (args, hre) => {
const accounts = await hre.ethers.getSigners();
console.info(`Upgrading wBAN LP Rewards with owner "${accounts[0].address}"`)
// deploy upgradeable contract
const WBANLPRewards = await hre.ethers.getContractFactory("WBANLPRewards");
const proxy = WBANLPRewards.attach(args.contract);
await hre.upgrades.upgradeProxy(proxy, WBANLPRewards);
// peer into OpenZeppelin manifest to extract the implementation address
const ozUpgradesManifestClient = await Manifest.forNetwork(hre.network.provider);
const manifest = await ozUpgradesManifestClient.read();
const bytecodeHash = hashBytecodeWithoutMetadata(WBANLPRewards.bytecode);
const implementationContract = manifest.impls[bytecodeHash];
// verify implementation contract
if (implementationContract) {
console.log(`wBAN LP Rewards impl deployed at: "${implementationContract.address}"`);
await hre.run("verify:verify", {
address: implementationContract.address
});
}
});
task("wban-lp-rewards:change-metadata", "Upgrade wBAN LP Rewards NFT")
.addParam("contract", "The smart-contract address", '', types.string)
.addParam("uri", "The new URI for metadata files", '', types.string)
.setAction(async (args, hre) => {
const accounts = await hre.ethers.getSigners();
console.info(`Changing wBAN LP Rewards with owner "${accounts[0].address}" metadata URI to "${args.uri}"`)
const WBANLPRewards = await hre.ethers.getContractFactory("WBANLPRewards");
const rewards = WBANLPRewards.attach(args.contract);
await rewards.changeURI(args.uri);
});
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.4",
settings: {
metadata: {
bytecodeHash: "none"
},
optimizer: {
enabled: true,
runs: 5000
},
outputSelection: {
"*": {
"*": ["metadata"]
}
}
},
}
],
},
networks: {
hardhat: {
accounts
},
localhost: {
url: 'http://localhost:8545',
accounts,
},
rinkeby: {
gasMultiplier: 2,
accounts,
url: "https://rinkeby.infura.io/v3/2b0e677e7a214cc9855fa34e2e1f682e"
},
polygontestnet: {
url: 'https://matic-mumbai.chainstacklabs.com',
accounts,
chainId: 80001,
gasMultiplier: 1.1,
//gasPrice: 45000000000,
},
polygon: {
url: 'https://polygon-rpc.com',
accounts,
chainId: 137,
gasMultiplier: 1.1,
//gasPrice: 45000000000,
}
},
typechain: {
outDir: 'artifacts/typechain',
target: 'ethers-v5',
},
spdxLicenseIdentifier: {
overwrite: true,
runOnCompile: true,
},
preprocess: {
eachLine: removeConsoleLog((bre) => bre.network.name !== 'hardhat' && bre.network.name !== 'localhost'),
},
gasReporter: {
currency: 'EUR',
gasPrice: 20, // in gwei
// coinmarketcap: ,
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: process.env.ETHERSCAN_API_KEY
},
abiExporter: {
path: './abi',
clear: true,
flat: false,
spacing: 2
}
};
export default config;