-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtasks.ts
368 lines (335 loc) · 12.1 KB
/
tasks.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
import { task, types } from 'hardhat/config';
import { SUB_TASK_NAMES } from './subtasks';
import { printSeparator } from './utils';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { PARAMS_NAMES } from './constants';
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signers";
import { BigNumber } from "ethers";
enum TASK_NAMES {
EXPORT_DATA = 'stacktical:export-data',
DEPLOY_SLA = 'stacktical:deploy-sla',
BOOTSTRAP_DSLA_PROTOCOL = 'stacktical:bootstrap',
REQUEST_SLI = 'stacktical:request-sli',
RESTART_SERVICES = 'stacktical:restart-services',
GET_PRECOORDINATOR = 'stacktical:get-precoordinator',
SET_PRECOORDINATOR = 'stacktical:set-precoordinator',
CHAINLINK_DOCKER_COMPOSE = 'stacktical:chainlink-docker-compose',
PREPARE_CHAINLINK_NODES = 'stacktical:prepare-chainlink-nodes',
FULFILL_SLI = 'stacktical:fulfill-sli',
INITIALIZE_DEFAULT_ADDRESSES = 'stacktical:initialize-addresses',
RESTART_CHAINLINK_NODES = 'stacktical:restart-chainlink-nodes',
CHECK_CONTRACTS_ALLOWANCE = 'stacktical:check-contracts-allowance',
SET_CONTRACTS_ALLOWANCE = 'stacktical:set-contracts-allowance',
REGISTRIES_CONFIGURATION = 'stacktical:registries-config',
GET_VALID_SLAS = 'stacktical:get-valid-slas',
GET_REVERT_MESSAGE = 'stacktical:get-revert-message',
DEPLOY_MESSENGER = 'stacktical:deploy-messenger',
GET_MESSENGER = 'stacktical:get-messenger',
TRANSFER_OWNERSHIP = 'stacktical:transfer-ownership',
PROVIDER_WITHDRAW = 'stacktical:provider-withdraw',
UNLOCK_TOKENS = 'stacktical:unlock-tokens',
GRAPH_MANIFESTOS = 'stacktical:graph-manifestos',
GET_SLA_FROM_TX = 'stacktical:get-sla-from-tx',
UPDATE_MESSENGER_SPEC = 'stacktical:update-messenger-spec',
AVAX_ACCOUNTS = 'accounts',
AVAX_BALANCES = 'balances',
}
task(TASK_NAMES.AVAX_ACCOUNTS, "Prints the list of accounts", async (args, hre): Promise<void> => {
const accounts: SignerWithAddress[] = await hre.ethers.getSigners()
accounts.forEach((account: SignerWithAddress): void => {
console.log(account.address)
})
})
task(TASK_NAMES.AVAX_BALANCES, "Prints the list of AVAX account balances", async (args, hre): Promise<void> => {
const accounts: SignerWithAddress[] = await hre.ethers.getSigners()
for(const account of accounts){
const balance: BigNumber = await hre.ethers.provider.getBalance(
account.address
);
console.log(`${account.address} has balance ${balance.toString()}`);
}
})
task(
TASK_NAMES.GRAPH_MANIFESTOS,
'Unlock value from a finished SLA contract'
).setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.EXPORT_SUBGRAPH_DATA, taskArgs);
await run(SUB_TASK_NAMES.SETUP_GRAPH_MANIFESTOS, taskArgs);
});
task(TASK_NAMES.UPDATE_MESSENGER_SPEC, 'Update messenger spec')
.addParam(PARAMS_NAMES.INDEX, 'Messenger index')
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.UPDATE_MESSENGER_SPEC, taskArgs);
});
task(TASK_NAMES.UNLOCK_TOKENS, 'Unlock value from a finished SLA contract')
.addOptionalParam(
PARAMS_NAMES.SLA_ADDRESS,
'(optional) The SLA address. Defaults to last deployed SLA by deployer address'
)
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.UNLOCK_TOKENS, taskArgs);
});
task(
TASK_NAMES.GET_SLA_FROM_TX,
'Get a transaction along with the events of it'
)
.addParam(PARAMS_NAMES.TRANSACTION_HASH, 'Transaction hash')
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.GET_SLA_FROM_TX, taskArgs);
});
task(TASK_NAMES.DEPLOY_SLA, 'Deploy customized SLA from stacktical config')
.addOptionalParam(
PARAMS_NAMES.INDEX,
'id of the arrays of SLAs of the deploy_sla stacktical config'
)
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.DEPLOY_SLA, taskArgs);
});
task(
TASK_NAMES.PROVIDER_WITHDRAW,
'Deploy customized SLA from stacktical config'
)
.addOptionalParam(
PARAMS_NAMES.SLA_ADDRESS,
'(optional) The SLA address. Defaults to last deployed SLA by deployer address'
)
.addParam(
'tokenAddress',
'Address of the token to withdraw from e.g. DSLA = 0x3aFfCCa64c2A6f4e3B6Bd9c64CD2C969EFd1ECBe in Mainnet'
)
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.PROVIDER_WITHDRAW, taskArgs);
});
task(TASK_NAMES.EXPORT_DATA, 'Export data to exported-data folder').setAction(
async (_, { run }) => {
await run(SUB_TASK_NAMES.EXPORT_NETWORKS);
await run(SUB_TASK_NAMES.EXPORT_TO_FRONT_END);
}
);
task(TASK_NAMES.BOOTSTRAP_DSLA_PROTOCOL, 'Bootstrap DSLA protocol').setAction(
async (_, { run }) => {
const bootstrapSubtasks = [
SUB_TASK_NAMES.BOOTSTRAP_MESSENGER_REGISTRY,
SUB_TASK_NAMES.BOOTSTRAP_STAKE_REGISTRY,
SUB_TASK_NAMES.BOOTSTRAP_PERIOD_REGISTRY,
SUB_TASK_NAMES.SET_CONTRACTS_ALLOWANCE,
];
for (let subtask of bootstrapSubtasks) {
printSeparator();
console.log(subtask);
await run(subtask);
printSeparator();
}
}
);
task(
TASK_NAMES.REQUEST_SLI,
'Request a SLI verification for next verifiable period'
)
.addOptionalParam(
PARAMS_NAMES.SLA_ADDRESS,
'(optional) The SLA address. Defaults to last deployed SLA by deployer address'
)
.addFlag('retry', ' pass the flag retry to trigger the retry mechanism')
.setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.REQUEST_SLI, taskArgs);
});
task(
TASK_NAMES.CHECK_CONTRACTS_ALLOWANCE,
'Check token allowances'
).setAction(async (_, { run }) => {
await run(SUB_TASK_NAMES.CHECK_CONTRACTS_ALLOWANCE);
});
task(
TASK_NAMES.SET_CONTRACTS_ALLOWANCE,
'Set token allowances'
).setAction(async (_, { run }) => {
await run(SUB_TASK_NAMES.SET_CONTRACTS_ALLOWANCE);
});
task(
TASK_NAMES.PREPARE_CHAINLINK_NODES,
'Prepare the Chainlink nodes with job config, funds and permissions'
).setAction(async (taskArgs, { run }) => {
await run(SUB_TASK_NAMES.PREPARE_CHAINLINK_NODES);
});
task(
TASK_NAMES.RESTART_SERVICES,
'Deploy or reset the local services (IPFS, Ganache, Graph protocol node)'
).setAction(async (_, { run }) => {
console.log(SUB_TASK_NAMES.STOP_LOCAL_GANACHE);
await run(SUB_TASK_NAMES.STOP_LOCAL_GANACHE);
console.log(SUB_TASK_NAMES.STOP_LOCAL_IPFS);
await run(SUB_TASK_NAMES.STOP_LOCAL_IPFS);
console.log(SUB_TASK_NAMES.STOP_LOCAL_GRAPH_NODE);
await run(SUB_TASK_NAMES.STOP_LOCAL_GRAPH_NODE);
console.log(SUB_TASK_NAMES.START_LOCAL_GANACHE);
await run(SUB_TASK_NAMES.START_LOCAL_GANACHE);
console.log(SUB_TASK_NAMES.START_LOCAL_IPFS);
await run(SUB_TASK_NAMES.START_LOCAL_IPFS);
console.log(SUB_TASK_NAMES.START_LOCAL_GRAPH_NODE);
await run(SUB_TASK_NAMES.START_LOCAL_GRAPH_NODE);
});
task(
TASK_NAMES.GET_PRECOORDINATOR,
'Get the PreCoordinator configuration'
).setAction(async (_, { run }) => {
await run(SUB_TASK_NAMES.GET_PRECOORDINATOR);
});
task(
TASK_NAMES.SET_PRECOORDINATOR,
'Set the PreCoordinator service configuration from stacktical configuration'
)
.addParam(PARAMS_NAMES.INDEX, 'Messenger id of stacktical.messengers')
.setAction(async (taskArgs, { run }) => {
printSeparator();
await run(SUB_TASK_NAMES.SETUP_DOCKER_COMPOSE);
printSeparator();
await run(SUB_TASK_NAMES.PREPARE_CHAINLINK_NODES);
printSeparator();
await run(SUB_TASK_NAMES.SET_PRECOORDINATOR, taskArgs);
printSeparator();
await run(SUB_TASK_NAMES.UPDATE_PRECOORDINATOR, taskArgs);
printSeparator();
await run(SUB_TASK_NAMES.GET_PRECOORDINATOR);
printSeparator();
});
task(
TASK_NAMES.CHAINLINK_DOCKER_COMPOSE,
'Deploys Oracle and LinkToken contracts and creates the proper docker-compose files'
).setAction(async (_, { run }) => {
await run(SUB_TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES);
await run(SUB_TASK_NAMES.DEPLOY_CHAINLINK_CONTRACTS);
await run(SUB_TASK_NAMES.SETUP_DOCKER_COMPOSE);
});
task(
TASK_NAMES.REGISTRIES_CONFIGURATION,
'Get registries contracts configuration'
).setAction(async (_, hre: any) => {
await hre.run(SUB_TASK_NAMES.REGISTRIES_CONFIGURATION);
});
task(TASK_NAMES.FULFILL_SLI, 'Fulfill pendant contract sli')
.addParam(
'address',
'Address of the SLA contract to fulfill sli',
undefined,
types.string
)
.addParam('periodId', 'Period to use to fulfill sli', undefined, types.string)
.addParam(
'nodeName',
'Name of the Chainlink node to use to fulfill sli',
undefined,
types.string
)
.setAction(async (taskArgs, hre: any) => {
await hre.run(SUB_TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES);
await hre.run(SUB_TASK_NAMES.FULFILL_SLI, taskArgs);
});
task(
TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES,
'Initialize default addresses'
).setAction(async (_, hre: any) => {
await hre.run(SUB_TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES);
});
task(
TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES,
'Initialize default addresses'
).setAction(async (_, hre: any) => {
await hre.run(SUB_TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES);
});
task(
TASK_NAMES.RESTART_CHAINLINK_NODES,
'Deploy or reset the local chainlink nodes'
).setAction(async (_, hre: any) => {
console.log(SUB_TASK_NAMES.STOP_LOCAL_CHAINLINK_NODES);
await hre.run(SUB_TASK_NAMES.STOP_LOCAL_CHAINLINK_NODES);
console.log(SUB_TASK_NAMES.SETUP_DOCKER_COMPOSE);
await hre.run(SUB_TASK_NAMES.SETUP_DOCKER_COMPOSE);
console.log(SUB_TASK_NAMES.START_LOCAL_CHAINLINK_NODES);
await hre.run(SUB_TASK_NAMES.START_LOCAL_CHAINLINK_NODES);
});
task(TASK_NAMES.GET_VALID_SLAS, 'Get all valid SLAs by network').setAction(
async (_, hre: any) => {
await hre.run(SUB_TASK_NAMES.GET_VALID_SLAS);
}
);
task(TASK_NAMES.GET_REVERT_MESSAGE, 'Get revert message for transaction hash')
.addParam('transactionHash', 'Transaction hash to get message')
.setAction(async (taskArgs, hre: any) => {
await hre.run(SUB_TASK_NAMES.GET_REVERT_MESSAGE, taskArgs);
});
task(TASK_NAMES.DEPLOY_MESSENGER, 'deploy a messenger in the MessengerRegistry')
.addParam(
PARAMS_NAMES.INDEX,
'Id of the messenger on the messengers list of the network config'
)
.setAction(async (taskArgs, hre: any) => {
await hre.run(SUB_TASK_NAMES.DEPLOY_MESSENGER, taskArgs);
});
task(TASK_NAMES.GET_MESSENGER, 'get messenger data')
.addOptionalParam(
PARAMS_NAMES.INDEX,
'Id of the messenger on the messengers list of the network config'
)
.setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
await hre.run(SUB_TASK_NAMES.GET_MESSENGER, taskArgs);
});
task(
TASK_NAMES.TRANSFER_OWNERSHIP,
'transfer ownership of core contracts to a owner address'
)
.addOptionalParam('newOwner', 'address of the new owner')
.setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
await hre.run(SUB_TASK_NAMES.TRANSFER_OWNERSHIP, taskArgs);
});
// task(TASK_NAMES.FULFILL_ANALYTICS, 'Fulfill pendant network analytics')
// .addParam(
// 'periodId',
// 'Period id of the period to fulfill',
// undefined,
// types.int
// )
// .addParam(
// 'periodType',
// 'Period type of the period to fulfill',
// undefined,
// types.int
// )
// .addParam('networkTicker', 'Network ticker of the period to fulfill')
// .addParam(
// 'nodeName',
// 'Name of the Chainlink node to use to fulfill',
// undefined,
// types.string
// )
// .addFlag('signTransaction', 'signs the transaction to fulfill the analytics')
// .setAction(async (taskArgs, hre: any) => {
// await hre.run(SUB_TASK_NAMES.INITIALIZE_DEFAULT_ADDRESSES);
// await hre.run(SUB_TASK_NAMES.FULFILL_ANALYTICS, taskArgs);
// });
// task(TASK_NAMES.PREC_FULFILL_ANALYTICS, 'Prec fulfill analytics')
// .addParam(
// 'periodId',
// 'Period id of the period to fulfill',
// undefined,
// types.int
// )
// .addParam(
// 'periodType',
// 'Period type of the period to fulfill',
// undefined,
// types.int
// )
// .addParam('networkTicker', 'Network ticker of the period to fulfill')
// .addParam(
// 'nodeName',
// 'Name of the Chainlink node to use to fulfill',
// undefined,
// types.string
// )
// .addFlag('signTransaction', 'signs the transaction to fulfill the analytics')
//
// .setAction(async (taskArgs, hre: any) => {
// await hre.run(SUB_TASK_NAMES.PREC_FULFILL_ANALYTICS, taskArgs);
// });
module.exports = {};