-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhardhat.task.ts
248 lines (222 loc) · 10.4 KB
/
hardhat.task.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
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
import { BigNumber, ContractReceipt, ethers } from "ethers";
import { task } from "hardhat/config";
import { ContractInfo } from "./utils/util_contractinfo";
import { ContractTool } from "./utils/util_contracttool";
import { InitTool } from "./utils/util_inittool";
import { logtools } from "./utils/util_log";
import { OP_Tools } from "./init/op_tool";
export module extTask {
export function RegTasks() {
task("xbalance", "blance of one addr")
.addPositionalParam("addrname", "like 'deployer'")
.setAction(async ({ addrname }, _hre) => {
let name = addrname;
console.log("name=" + name);
let addr = (await _hre.getNamedAccounts())[name];
console.log("addr=" + addr);
let signer = await _hre.ethers.getSigner(addr);
let blanceof: BigNumber = await signer.getBalance();
console.log("balanceof=" + ethers.utils.formatEther(blanceof));
});
task("xdeploy", "deplay contracts")
.addPositionalParam("type", "[all|group|one]")
.addOptionalPositionalParam("name")
.setAction(async ({ type, name }, _hre) => {
let _name = name as string;
console.log("xdeploy:" + type + "," + _name)
if (type == "all") {
await ContractTool.DeployAll(_hre);
}
else if (type == "group") {
await ContractTool.DeployGroup(_hre, _name);
}
else if (type == "one") {
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
let info = ContractTool.GetInfo(_hre, _name);
if (info == null) throw "not found contract.";
await ContractTool.DeployOne(_hre, info);
}
else {
throw "not support this type.";
}
});
task("xverify", "verify contracts")
.addPositionalParam("type", "[all|group|one]")
.addOptionalPositionalParam("name")
.setAction(async ({ type, name }, _hre) => {
let _name = name as string;
console.log("xverify:" + type + "," + _name)
if (type == "all") {
await ContractTool.DeployAll(_hre);
await ContractTool.VerifyAll(_hre);
}
else if (type == "group") {
await ContractTool.DeployGroup(_hre, _name);
await ContractTool.VerifyGroup(_hre, _name);
}
else if (type == "one") {
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
let info = ContractTool.GetInfo(_hre, _name);
if (info == null) throw "not found contract.";
await ContractTool.DeployOne(_hre, info);
await ContractTool.VerifyOne(_hre, info);
}
else {
throw "not support this type.";
}
});
task("xcheck", "check contracts")
.addPositionalParam("type", "[all|group|one]")
.addOptionalPositionalParam("name")
.setAction(async ({ type, name }, _hre) => {
console.log("==xcheck");
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
InitTool.RegInitFuncs(_hre);
let _name = name as string;
console.log("xcheck:" + type + "," + _name)
if (type == "all") {
await InitTool.CheckFunc_All(_hre);
}
else if (type == "group") {
await InitTool.CheckFunc_Group(_hre, _name);
}
else if (type == "one") {
await InitTool.CheckFunc_One(_hre, _name);
}
else {
throw "not support this type.";
}
});
task("xinit", "init contracts")
.addPositionalParam("type", "[all|group|one]")
.addOptionalPositionalParam("name")
.setAction(async ({ type, name }, _hre) => {
console.log("==xinit");
await ContractTool.LoadDeployInfo(_hre);
if (_hre.network.name == "hardhat") {
//本地测试合约是没有的,必须跑一遍
await ContractTool.DeployAll(_hre);
InitTool.inittwice = true;
}
await ContractInfo.LoadFromFile(_hre);
InitTool.RegInitFuncs(_hre);
let _name = name as string;
console.log("xinit:" + type + "," + _name)
if (type == "all") {
await InitTool.InitFunc_All(_hre);
}
else if (type == "group") {
await InitTool.InitFunc_Group(_hre, _name);
}
else if (type == "one") {
await InitTool.InitFunc_One(_hre, _name);
}
else {
throw "not support this type.";
}
});
task("xgen", "deploy and init a gen contracts")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgen");
await ContractTool.DeployGenGroup(_hre, genid);
InitTool.RegInitFuncs(_hre);
await InitTool.InitFunc_GenGroup(_hre, genid);
await InitTool.ConfigFunc_GenGroup(_hre, genid);
});
task("xgeninitonly", "deploy and init a gen contracts")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgen");
await ContractTool.DeployGenGroup(_hre, genid);
InitTool.RegInitFuncs(_hre);
await InitTool.InitFunc_GenGroup(_hre, genid);
});
task("xgenconfigonly", "deploy and init a gen contracts")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgen");
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
//await ContractTool.DeployGenGroup(_hre, genid);
InitTool.RegInitFuncs(_hre);
await InitTool.ConfigFunc_GenGroup(_hre, genid);
});
task("xgento", "deploy and init contracts to target gen")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgento");
await ContractTool.DeployAll(_hre);
InitTool.RegInitFuncs(_hre);
await InitTool.InitFunc_All(_hre);
for (var i = 1; i <= genid; i++) {
logtools.loggreen("==xgen " + i);
await ContractTool.DeployGenGroup(_hre, i);
await InitTool.InitFunc_GenGroup(_hre, i);
await InitTool.ConfigFunc_GenGroup(_hre, i);
}
});
task("xgento_initonly", "deploy and init contracts to target gen")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgento");
await ContractTool.DeployAll(_hre);
InitTool.RegInitFuncs(_hre);
await InitTool.InitFunc_All(_hre);
for (var i = 1; i <= genid; i++) {
logtools.loggreen("==xgen " + i);
await ContractTool.DeployGenGroup(_hre, i);
await InitTool.InitFunc_GenGroup(_hre, i);
}
});
task("xgento_configonly", "deploy and init contracts to target gen")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
console.log("==xgento");
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
//await ContractTool.DeployAll(_hre);
InitTool.RegInitFuncs(_hre);
//await InitTool.InitFunc_All(_hre);
for (var i = 1; i <= genid; i++) {
logtools.loggreen("==xgen " + i);
//await ContractTool.DeployGenGroup(_hre, i);
await InitTool.ConfigFunc_GenGroup(_hre, i);
}
});
task("xgentest", "run tests for target gen")
.addPositionalParam("genid", "numbers for gen,like 4")
.setAction(async ({ genid }, _hre) => {
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
console.log("==xgentest");
InitTool.RegInitFuncs(_hre);
await InitTool.InitFunc_Test(_hre, genid);
});
task("xtest", "run test")
.addPositionalParam("testfile", "test file name")
.setAction(async ({ testfile }, _hre) => {
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
console.log("==xtest");
console.log("file:" + testfile);
await _hre.run("test",{"testFiles":[testfile]});
});
task("xoptool", "run optool")
.setAction(async ({ }, _hre) => {
await ContractTool.LoadDeployInfo(_hre);
await ContractInfo.LoadFromFile(_hre);
await OP_Tools.guildSecond(_hre);
//await OP_Tools.ESportPoolV2_Expedition_20230725(_hre);
//await OP_Tools.PlatOnOffChainBridgeServiceRole(_hre);
//await OP_Tools.UniversalNFTDataRole_VeTokenPool(_hre);
//await OP_Tools.PlatOnOffChainBridgeMintRole(_hre);
//await OP_Tools.AddChargeToken(_hre);
//await OP_Tools.AirDropShip(_hre);
//await OP_Tools.AddAssetMinterTotalCount(_hre);
});
}
}