-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
261 lines (243 loc) · 8.49 KB
/
hardhat.config.js
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
require('dotenv').config();
require('@nomiclabs/hardhat-etherscan');
require('@nomiclabs/hardhat-waffle');
require('hardhat-gas-reporter');
require('solidity-coverage');
const axios = require('axios').default;
const {
CODE,
ESHELL,
SHELL_RANDOMIZER,
API_URL = 'http://localhost:3000',
} = process.env;
task('totalNumMintedTokens', 'Total # of minted tokens')
.addOptionalParam('address', `Code's address`, CODE)
.setAction(async (args) => {
const code = await ethers.getContractAt('Code', args.address);
console.log((await code.totalNumMintedTokens()).toString());
});
task('preSaleMaxTotalSupply', 'Max total supply of pre sale')
.addOptionalParam('address', `Code's address`, CODE)
.setAction(async (args) => {
const code = await ethers.getContractAt('Code', args.address);
console.log((await code.PRE_SALE_MAX_TOTAL_SUPPLY()).toString());
});
task('setPreSaleMintTime', 'Set pre sale mint time')
.addOptionalParam('address', `Code's address`, CODE)
.addParam('start', `Start time`)
.addParam('end', `End time`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code
.connect(owner)
.setPreSaleMintTime(args.start, args.end);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('setPublicSaleMintTime', 'Set public sale mint time')
.addOptionalParam('address', `Code's address`, CODE)
.addParam('start', `Start time`)
.addParam('end', `End time`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code
.connect(owner)
.setPublicSaleMintTime(args.start, args.end);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('setMigrationTime', 'Set migration time')
.addOptionalParam('address', `Code's address`, CODE)
.addParam('start', `Start time`)
.addParam('end', `End time`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code.connect(owner).setMigrationTime(args.start, args.end);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('setShell', 'Set shell')
.addOptionalParam('address', `Code's address`, CODE)
.addOptionalParam('eshell', `Shell's address`, ESHELL)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code.connect(owner).setShell(args.eshell);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('shell__setAuthorized', 'Set authorized for shell')
.addOptionalParam('address', `Shell's address`, ESHELL)
.addOptionalParam('authorized', `Address to authorize`, CODE)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Shell', args.address);
const tx = await code.connect(owner).setAuthorized(args.authorized, true);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('shell__setBaseTokenURI', 'Set base token URI for shell')
.addOptionalParam('address', `Shell's address`, ESHELL)
.addOptionalParam('uri', `Token URI`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Shell', args.address);
const tx = await code.connect(owner).setBaseTokenURI(args.uri);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('publicSaleMint', 'Public sale mint')
.addOptionalParam('address', `Code's address`, CODE)
.addOptionalParam('index', `Account's index`, 0, types.int)
.addParam('quantity', `Quantity`)
.setAction(async (args) => {
const [, ...accounts] = await ethers.getSigners();
const accountAddrs = await Promise.all(
accounts.map((account) => account.getAddress()),
);
const res = await axios.get(
`${API_URL}/public/${accountAddrs[args.index]}`,
);
const { ticket, signature } = res.data;
const code = await ethers.getContractAt('Code', args.address);
const PRICE_PER_TOKEN = await code.PRICE_PER_TOKEN();
const tx = await code
.connect(accounts[args.index])
.publicSaleMint(args.quantity, ticket, signature, {
value: PRICE_PER_TOKEN.mul(args.quantity),
});
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('migrate', 'Migrate code to shell')
.addOptionalParam('address', `Code's address`, CODE)
.addOptionalParam('index', `Account's index`, 0, types.int)
.addParam('ids', `Codes' IDs`)
.addParam('quantities', `Codes' quantities`)
.setAction(async (args) => {
const [, ...accounts] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code
.connect(accounts[args.index])
.migrate(JSON.parse(args.ids), JSON.parse(args.quantities));
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('withdraw', 'Withdraw')
.addOptionalParam('address', `Code's address`, CODE)
.addParam('to', `To's address`)
.addParam('amount', `Amount`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const code = await ethers.getContractAt('Code', args.address);
const tx = await code.connect(owner).withdraw(args.to, args.amount);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('shellRandomizer__tokenIdToMetadataId', 'Shell metadata ID')
.addOptionalParam('address', `ShellRandomizer's address`, SHELL_RANDOMIZER)
.addParam('id', `Shell's ID`)
.setAction(async (args) => {
const shellRandomizer = await ethers.getContractAt(
'ShellRandomizer',
args.address,
);
const metadataId = await shellRandomizer.tokenIdToMetadataId(args.id);
console.log(metadataId.toString());
});
task('shellRandomizer__requestRevealTokens', 'Request reveal shell')
.addOptionalParam('address', `ShellRandomizer's address`, SHELL_RANDOMIZER)
.addParam('id', `Shell's ID`)
.addParam('quantity', `Quantity`)
.addParam('from', `Revealer's address`)
.addParam('timestamp', `Timestamp`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const shellRandomizer = await ethers.getContractAt(
'ShellRandomizer',
args.address,
);
const tx = await shellRandomizer
.connect(owner)
.requestRevealTokens(args.id, args.quantity, args.from, args.timestamp);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
task('shellRandomizer__withdrawLINK', 'Withdraw LINK')
.addOptionalParam('address', `ShellRandomizer's address`, SHELL_RANDOMIZER)
.addParam('to', `To's address`)
.addParam('amount', `Amount`)
.setAction(async (args) => {
const [owner] = await ethers.getSigners();
const shellRandomizer = await ethers.getContractAt(
'ShellRandomizer',
args.address,
);
const tx = await shellRandomizer
.connect(owner)
.withdrawLINK(args.to, args.amount);
const receipt = await tx.wait();
console.log(receipt.transactionHash);
});
module.exports = {
solidity: {
version: '0.8.9',
settings: {
optimizer: {
enabled: true,
runs: 10000,
},
},
},
networks: {
mainnet: {
url: process.env.MAINNET_RPC_URL,
accounts: {
mnemonic: process.env.MNEMONIC,
},
},
rinkeby: {
url: process.env.RINKEBY_RPC_URL,
accounts: {
mnemonic: process.env.MNEMONIC,
},
},
polygon: {
url: process.env.POLYGON_RPC_URL,
accounts: {
mnemonic: process.env.MNEMONIC,
},
},
mumbai: {
url: process.env.MUMBAI_RPC_URL,
accounts: {
mnemonic: process.env.MNEMONIC,
},
},
hardhat: {
forking: {
url: process.env.MAINNET_RPC_URL,
blockNumber: 14463387,
},
},
},
mocha: {
timeout: 60 * 60 * 1000,
},
gasReporter: {
enabled: process.env.REPORT_GAS === '1',
currency: 'USD',
gasPrice: 100,
},
etherscan: {
apiKey: {
mainnet: process.env.MAINNET_ETHERSCAN_API_KEY,
rinkeby: process.env.RINKEBY_ETHERSCAN_API_KEY,
polygon: process.env.POLYGON_ETHERSCAN_API_KEY,
polygonMumbai: process.env.MUMBAI_ETHERSCAN_API_KEY,
},
},
};