evm-contracts-tools 0.0.43 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evm-contract-call/evm-contract-call.js +1 -1
- package/dist/evm-contract-call/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
- package/dist/evm-contract-deployment-address/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-deployment-networks +1 -1
- package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
- package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
- package/dist/evm-contract-deployment-versions/fs-worker.js +1 -1
- package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
- package/dist/evm-contract-deployments-dir/fs-worker.js +1 -1
- package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
- package/dist/evm-contracts-tools/fs-worker.js +1 -1
- package/dist/libevm-contract-call/fs-worker.js +1 -1
- package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
- package/dist/libevm-contract-deployment-address/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
- package/dist/libevm-contract-deployment-deployment-networks +1 -1
- package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
- package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
- package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -1
- package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
- package/dist/libevm-contracts-tools +1 -1
- package/evm-contract-deployment-address +115 -33
- package/evm-contract-deployment-versions +38 -12
- package/libevm-contract-call +2 -2
- package/libevm-contract-deployment-address +445 -67
- package/libevm-contract-deployment-networks +24 -22
- package/libevm-contract-deployment-versions +95 -6
- package/libevm-contract-deployments-dir +4 -5
- package/package.json +9 -9
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
|
|
5
5
|
/** ----------------------------------------------------------------
|
|
6
|
-
* libevm-contract-
|
|
6
|
+
* libevm-contract-deployment-address
|
|
7
7
|
* ----------------------------------------------------------------
|
|
8
8
|
* Copyright ©
|
|
9
9
|
* Pellegrino Prevete
|
|
@@ -66,12 +66,19 @@ const
|
|
|
66
66
|
require(
|
|
67
67
|
"crash-js");
|
|
68
68
|
/* global
|
|
69
|
-
|
|
69
|
+
_chmod */
|
|
70
70
|
/* eslint-disable-next-line
|
|
71
71
|
no-global-assign */
|
|
72
72
|
const
|
|
73
|
-
|
|
74
|
-
_libcrash_module.
|
|
73
|
+
_chmod =
|
|
74
|
+
_libcrash_module._chmod;
|
|
75
|
+
/* global
|
|
76
|
+
_cp */
|
|
77
|
+
/* eslint-disable-next-line
|
|
78
|
+
no-global-assign */
|
|
79
|
+
const
|
|
80
|
+
_cp =
|
|
81
|
+
_libcrash_module._cp;
|
|
75
82
|
/* global
|
|
76
83
|
_file_exists */
|
|
77
84
|
/* eslint-disable-next-line
|
|
@@ -79,6 +86,20 @@ const
|
|
|
79
86
|
const
|
|
80
87
|
_file_exists =
|
|
81
88
|
_libcrash_module._file_exists;
|
|
89
|
+
/* global
|
|
90
|
+
_file_read */
|
|
91
|
+
/* eslint-disable-next-line
|
|
92
|
+
no-global-assign */
|
|
93
|
+
const
|
|
94
|
+
_file_read =
|
|
95
|
+
_libcrash_module._file_read;
|
|
96
|
+
/* global
|
|
97
|
+
_from_bash_ass_array */
|
|
98
|
+
/* eslint-disable-next-line
|
|
99
|
+
no-global-assign */
|
|
100
|
+
const
|
|
101
|
+
_from_bash_ass_array =
|
|
102
|
+
_libcrash_module._from_bash_ass_array;
|
|
82
103
|
/* global
|
|
83
104
|
_homedir_get */
|
|
84
105
|
/* eslint-disable-next-line
|
|
@@ -100,6 +121,13 @@ const
|
|
|
100
121
|
const
|
|
101
122
|
_lib_get =
|
|
102
123
|
_libcrash_module._lib_get;
|
|
124
|
+
/* global
|
|
125
|
+
_mkdir */
|
|
126
|
+
/* eslint-disable-next-line
|
|
127
|
+
no-global-assign */
|
|
128
|
+
const
|
|
129
|
+
_mkdir =
|
|
130
|
+
_libcrash_module._mkdir;
|
|
103
131
|
/* global
|
|
104
132
|
_msg_info */
|
|
105
133
|
/* eslint-disable-next-line
|
|
@@ -121,13 +149,15 @@ const
|
|
|
121
149
|
const
|
|
122
150
|
_path_join =
|
|
123
151
|
_libcrash_module._path_join;
|
|
152
|
+
const
|
|
153
|
+
_evm_chains_info_module =
|
|
154
|
+
require(
|
|
155
|
+
"evm-chains-info");
|
|
124
156
|
/* global
|
|
125
|
-
|
|
126
|
-
/* eslint-disable-next-line
|
|
127
|
-
no-global-assign */
|
|
157
|
+
_evm_chains_info */
|
|
128
158
|
const
|
|
129
|
-
|
|
130
|
-
|
|
159
|
+
_evm_chains_info =
|
|
160
|
+
_evm_chains_info_module._evm_chains_info;
|
|
131
161
|
const
|
|
132
162
|
_libevm_contract_deployments_dir_module =
|
|
133
163
|
require(
|
|
@@ -138,7 +168,7 @@ const
|
|
|
138
168
|
_evm_contract_deployments_dir =
|
|
139
169
|
_libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
|
|
140
170
|
const
|
|
141
|
-
|
|
171
|
+
_libevm_contract_deployment_networks_module =
|
|
142
172
|
require(
|
|
143
173
|
"./libevm-contract-deployment-networks");
|
|
144
174
|
/* global
|
|
@@ -147,14 +177,14 @@ const
|
|
|
147
177
|
_evm_contract_deployment_networks =
|
|
148
178
|
_libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
|
|
149
179
|
const
|
|
150
|
-
|
|
180
|
+
_libevm_contract_deployment_versions_module =
|
|
151
181
|
require(
|
|
152
|
-
"
|
|
182
|
+
"./libevm-contract-deployment-versions");
|
|
153
183
|
/* global
|
|
154
|
-
|
|
184
|
+
_evm_contract_deployment_versions */
|
|
155
185
|
const
|
|
156
|
-
|
|
157
|
-
|
|
186
|
+
_evm_contract_deployment_versions =
|
|
187
|
+
_libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
|
|
158
188
|
|
|
159
189
|
function
|
|
160
190
|
_contract_address_get(
|
|
@@ -165,10 +195,12 @@ function
|
|
|
165
195
|
_version,
|
|
166
196
|
_configuration_format) {
|
|
167
197
|
let
|
|
198
|
+
_config,
|
|
168
199
|
_config_file_ext,
|
|
169
200
|
_config_path,
|
|
170
201
|
_address,
|
|
171
202
|
_found,
|
|
203
|
+
_key_name,
|
|
172
204
|
_msg,
|
|
173
205
|
_net;
|
|
174
206
|
if ( typeof(
|
|
@@ -181,7 +213,7 @@ function
|
|
|
181
213
|
_config_file_ext =
|
|
182
214
|
"sh";
|
|
183
215
|
}
|
|
184
|
-
if ( _configuration_format == "json" ) {
|
|
216
|
+
else if ( _configuration_format == "json" ) {
|
|
185
217
|
_config_file_ext =
|
|
186
218
|
"json"
|
|
187
219
|
}
|
|
@@ -201,8 +233,13 @@ function
|
|
|
201
233
|
_found =
|
|
202
234
|
false;
|
|
203
235
|
for ( _net of _networks ) {
|
|
236
|
+
_path_join_args =
|
|
204
237
|
_config_path =
|
|
205
|
-
|
|
238
|
+
_path_join( [
|
|
239
|
+
_deployments,
|
|
240
|
+
_contract,
|
|
241
|
+
_net,
|
|
242
|
+
`config.${_config_file_ext}` ]);
|
|
206
243
|
if ( _file_exists(
|
|
207
244
|
_config_path) ) {
|
|
208
245
|
_found =
|
|
@@ -219,14 +256,25 @@ function
|
|
|
219
256
|
_msg,
|
|
220
257
|
1);
|
|
221
258
|
}
|
|
222
|
-
|
|
259
|
+
if ( _configuration_format == "json" ) {
|
|
223
260
|
_config =
|
|
224
261
|
_json_read(
|
|
225
|
-
|
|
262
|
+
_config_path);
|
|
263
|
+
_key_name =
|
|
264
|
+
"contract-address";
|
|
265
|
+
}
|
|
266
|
+
else if ( _configuration_format == "bash" ) {
|
|
267
|
+
_config =
|
|
268
|
+
_from_bash_ass_array(
|
|
269
|
+
_file_read(
|
|
270
|
+
_config_path));
|
|
271
|
+
_key_name =
|
|
272
|
+
"contract_address";
|
|
273
|
+
}
|
|
226
274
|
const
|
|
227
275
|
_contract_address =
|
|
228
276
|
_config[
|
|
229
|
-
|
|
277
|
+
_key_name][
|
|
230
278
|
_version];
|
|
231
279
|
if ( _contract_address == "" ||
|
|
232
280
|
_contract_address == null ) {
|
|
@@ -242,58 +290,182 @@ function
|
|
|
242
290
|
return _contract_address;
|
|
243
291
|
}
|
|
244
292
|
|
|
245
|
-
function
|
|
293
|
+
async function
|
|
246
294
|
_network_check(
|
|
247
295
|
_deployments,
|
|
248
296
|
_contract,
|
|
249
297
|
_target_network,
|
|
250
298
|
_target_network_id) {
|
|
251
299
|
let
|
|
300
|
+
_error_flag,
|
|
252
301
|
_msg,
|
|
253
|
-
_network_id
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"
|
|
302
|
+
_network_id;
|
|
303
|
+
_error_flag =
|
|
304
|
+
false;
|
|
305
|
+
_deployments_path =
|
|
306
|
+
_path_join( [
|
|
307
|
+
_deployments,
|
|
308
|
+
_contract ]);
|
|
309
|
+
const
|
|
310
|
+
_evm_contract_deployment_networks_args = [
|
|
311
|
+
_deployments_path,
|
|
312
|
+
"y", // Display all
|
|
313
|
+
"n", // Display safest
|
|
314
|
+
"n" // Display cheapest
|
|
315
|
+
];
|
|
316
|
+
const
|
|
317
|
+
_networks =
|
|
318
|
+
await _evm_contract_deployment_networks.apply(
|
|
319
|
+
null,
|
|
320
|
+
_evm_contract_deployment_networks_args);
|
|
321
|
+
if ( _target_network_id != "" ) {
|
|
322
|
+
if ( ! _networks.includes(
|
|
323
|
+
_target_network_id) ) {
|
|
324
|
+
_msg =
|
|
325
|
+
"The contract does not result deployed on " +
|
|
326
|
+
`network with id '${_target_network_id}'.`;
|
|
327
|
+
_error_flag =
|
|
328
|
+
true;
|
|
329
|
+
}
|
|
266
330
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
331
|
+
else if ( _target_network != "" ) {
|
|
332
|
+
if ( ! _networks.includes(
|
|
333
|
+
_target_network) ) {
|
|
334
|
+
_msg =
|
|
335
|
+
"The contract does not result deployed on " +
|
|
336
|
+
`network '${_target_network}'.`;
|
|
337
|
+
_error_flag =
|
|
338
|
+
true;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
_msg =
|
|
343
|
+
"Provide one between a target network name " +
|
|
344
|
+
"or ID.";
|
|
345
|
+
_error_flag =
|
|
346
|
+
true;
|
|
347
|
+
}
|
|
348
|
+
if ( _error_flag ) {
|
|
349
|
+
_msg_error(
|
|
350
|
+
_msg,
|
|
351
|
+
1);
|
|
352
|
+
}
|
|
353
|
+
if ( _target_network_id == "" ) {
|
|
354
|
+
_evm_chains_info_args = [
|
|
355
|
+
"get", // target command
|
|
356
|
+
"name", // input type
|
|
357
|
+
"id", // output type
|
|
358
|
+
"offline",
|
|
359
|
+
[ "node",
|
|
360
|
+
"system" ], // db types
|
|
361
|
+
"kirsh", // selection method, first
|
|
362
|
+
"n", // api keys
|
|
363
|
+
"n", // query all networks
|
|
364
|
+
_target_network,
|
|
365
|
+
[] // database paths
|
|
366
|
+
];
|
|
367
|
+
_network_id =
|
|
368
|
+
await _evm_chains_info.apply(
|
|
369
|
+
null,
|
|
370
|
+
_evm_chains_info_args);
|
|
272
371
|
}
|
|
273
|
-
else if (
|
|
372
|
+
else if ( _target_network == "" ) {
|
|
373
|
+
_evm_chains_info_args = [
|
|
374
|
+
"get", // target command
|
|
375
|
+
"id" , // input type
|
|
376
|
+
"name", // output type
|
|
377
|
+
"offline",
|
|
378
|
+
[ "node",
|
|
379
|
+
"system" ], // db types
|
|
380
|
+
"kirsh", // selection method, first
|
|
381
|
+
"n", // api keys
|
|
382
|
+
"n", // query all networks
|
|
383
|
+
_target_network_id,
|
|
384
|
+
[] // database paths
|
|
385
|
+
];
|
|
386
|
+
_target_network =
|
|
387
|
+
await _evm_chains_info(
|
|
388
|
+
_evm_chains_info_args);
|
|
389
|
+
}
|
|
390
|
+
if ( _target_network_id != "" ) {
|
|
391
|
+
if ( _target_network_id != _network_id ) {
|
|
392
|
+
_msg =
|
|
393
|
+
"Requested target network ID " +
|
|
394
|
+
`'${_target_network_id}' does ` +
|
|
395
|
+
`not correspond to '${_target_network}' ` +
|
|
396
|
+
`known ID '${_network_id}'.`;
|
|
397
|
+
_msg_error(
|
|
398
|
+
_msg,
|
|
399
|
+
1);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function
|
|
405
|
+
_user_deployments_init(
|
|
406
|
+
_app,
|
|
407
|
+
_deployments_dir) {
|
|
408
|
+
const
|
|
409
|
+
_user_defined =
|
|
410
|
+
"y";
|
|
411
|
+
const
|
|
412
|
+
_evm_contract_deployments_dir_args = [
|
|
413
|
+
_app,
|
|
414
|
+
_user_defined
|
|
415
|
+
];
|
|
416
|
+
const
|
|
417
|
+
_system_deployments =
|
|
418
|
+
await _evm_contract_deployments_dir.apply(
|
|
419
|
+
null,
|
|
420
|
+
_evm_contract_deployments_dir_args);
|
|
421
|
+
_chmod(
|
|
422
|
+
_deployments_dir,
|
|
423
|
+
"0700");
|
|
424
|
+
const
|
|
425
|
+
_files =
|
|
426
|
+
await _ls(
|
|
427
|
+
_system_deployments);
|
|
428
|
+
for ( _file of _files ) {
|
|
429
|
+
_cp(
|
|
430
|
+
_file,
|
|
431
|
+
_deployments_dir);
|
|
432
|
+
}
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async function
|
|
437
|
+
_user_deployments_check(
|
|
438
|
+
_app,
|
|
439
|
+
_deployments_dir) {
|
|
440
|
+
if ( ! _file_exists(
|
|
441
|
+
_deployments_dir) ) {
|
|
442
|
+
const
|
|
443
|
+
_user_deployments_init_args = [
|
|
444
|
+
_app,
|
|
445
|
+
_deployments_dir
|
|
446
|
+
];
|
|
274
447
|
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
448
|
+
_initialized =
|
|
449
|
+
await _user_deployments_init.apply(
|
|
450
|
+
null,
|
|
451
|
+
_user_deployments_init_args);
|
|
279
452
|
}
|
|
280
|
-
return `${_conf_dir}/${_app}/deployments`;
|
|
281
453
|
}
|
|
282
454
|
|
|
283
|
-
function
|
|
455
|
+
async function
|
|
284
456
|
_evm_contract_deployment_address(
|
|
285
457
|
_target_networks,
|
|
286
458
|
_network_ids,
|
|
287
459
|
_networks_all,
|
|
288
460
|
_target_app,
|
|
461
|
+
_target_contract,
|
|
289
462
|
_contract_version,
|
|
290
463
|
_user_defined,
|
|
464
|
+
_configuration_format,
|
|
291
465
|
_deployments_dir) {
|
|
292
466
|
let
|
|
293
467
|
_args,
|
|
294
468
|
_contract_address,
|
|
295
|
-
_contract_address_get_args,
|
|
296
|
-
_contracts_addresses,
|
|
297
469
|
_network,
|
|
298
470
|
_network_check_args,
|
|
299
471
|
_target_network,
|
|
@@ -301,6 +473,12 @@ function
|
|
|
301
473
|
_user_deployments_dir,
|
|
302
474
|
_system_deployments_dir,
|
|
303
475
|
_msg;
|
|
476
|
+
const
|
|
477
|
+
_contracts_addresses =
|
|
478
|
+
[];
|
|
479
|
+
const
|
|
480
|
+
_contract_address_get_args =
|
|
481
|
+
[];
|
|
304
482
|
if ( _user_defined == "n" ) {
|
|
305
483
|
if ( _target_app == "" ) {
|
|
306
484
|
_msg =
|
|
@@ -315,9 +493,10 @@ function
|
|
|
315
493
|
1)
|
|
316
494
|
}
|
|
317
495
|
_system_deployments_dir =
|
|
318
|
-
_evm_contract_deployments_dir(
|
|
319
|
-
|
|
320
|
-
|
|
496
|
+
await _evm_contract_deployments_dir(
|
|
497
|
+
_target_app,
|
|
498
|
+
_user_defined);
|
|
499
|
+
if ( _deployments_dir != _system_deployments_dir ) {
|
|
321
500
|
_msg =
|
|
322
501
|
"To set a custom deployments directory path " +
|
|
323
502
|
"you need to enable the user-defined " +
|
|
@@ -330,8 +509,8 @@ function
|
|
|
330
509
|
else if ( _user_defined == "y" ) {
|
|
331
510
|
if ( _target_app != "" ) {
|
|
332
511
|
_user_deployments_dir =
|
|
333
|
-
_evm_contract_deployments_dir(
|
|
334
|
-
|
|
512
|
+
await _evm_contract_deployments_dir(
|
|
513
|
+
_target_app,
|
|
335
514
|
_user_defined);
|
|
336
515
|
}
|
|
337
516
|
if ( _deployments_dir != _user_deployments_dir ) {
|
|
@@ -342,24 +521,35 @@ function
|
|
|
342
521
|
_msg);
|
|
343
522
|
}
|
|
344
523
|
else {
|
|
345
|
-
_user_deployments_check(
|
|
524
|
+
_user_deployments_check(
|
|
525
|
+
_target_app,
|
|
526
|
+
_deployments_dir);
|
|
346
527
|
}
|
|
347
528
|
}
|
|
348
529
|
else {
|
|
349
530
|
_msg =
|
|
350
|
-
"The 'user-defined' switch argument
|
|
351
|
-
|
|
531
|
+
"The 'user-defined' switch argument " +
|
|
532
|
+
`can be 'y' or 'n', current value '${_user_defined}'.`;
|
|
352
533
|
_msg_error(
|
|
353
534
|
_msg,
|
|
354
535
|
1);
|
|
355
536
|
}
|
|
356
537
|
if ( _networks_all == "y" ) {
|
|
538
|
+
_msg =
|
|
539
|
+
"Selecting all networks."
|
|
540
|
+
_msg_info(
|
|
541
|
+
_msg);
|
|
357
542
|
_target_networks =
|
|
358
|
-
_evm_contract_deployment_networks(
|
|
543
|
+
await _evm_contract_deployment_networks(
|
|
359
544
|
`${_deployments_dir}/${_target_contract}`,
|
|
360
545
|
_networks_all);
|
|
361
546
|
}
|
|
362
547
|
for ( _network of _target_networks ) {
|
|
548
|
+
// _msg =
|
|
549
|
+
// "Info arguments for " +
|
|
550
|
+
// `network '${_network}'.`;
|
|
551
|
+
// _msg_info(
|
|
552
|
+
// _msg);
|
|
363
553
|
_target_network_id =
|
|
364
554
|
"";
|
|
365
555
|
_network_check_args = [
|
|
@@ -368,15 +558,16 @@ function
|
|
|
368
558
|
_network,
|
|
369
559
|
_target_network_id
|
|
370
560
|
];
|
|
371
|
-
_network_check.apply(
|
|
561
|
+
await _network_check.apply(
|
|
372
562
|
null,
|
|
373
563
|
_network_check_args);
|
|
374
564
|
_contract_address_get_args.push( [
|
|
375
565
|
_deployments_dir,
|
|
376
566
|
_target_contract,
|
|
377
|
-
|
|
567
|
+
_network,
|
|
378
568
|
_target_network_id,
|
|
379
|
-
_contract_version
|
|
569
|
+
_contract_version,
|
|
570
|
+
_configuration_format
|
|
380
571
|
] );
|
|
381
572
|
}
|
|
382
573
|
for ( _network of _network_ids ) {
|
|
@@ -388,7 +579,7 @@ function
|
|
|
388
579
|
_target_network,
|
|
389
580
|
_network
|
|
390
581
|
];
|
|
391
|
-
_network_check.apply(
|
|
582
|
+
await _network_check.apply(
|
|
392
583
|
null,
|
|
393
584
|
_network_check_args);
|
|
394
585
|
_contract_address_get_args.push( [
|
|
@@ -396,20 +587,205 @@ function
|
|
|
396
587
|
_target_contract,
|
|
397
588
|
_target_network,
|
|
398
589
|
_target_network_id,
|
|
399
|
-
_contract_version
|
|
590
|
+
_contract_version,
|
|
591
|
+
_configuration_format
|
|
400
592
|
] );
|
|
401
593
|
}
|
|
402
|
-
for ( _args of
|
|
594
|
+
for ( _args of _contract_address_get_args ) {
|
|
403
595
|
_contract_address =
|
|
404
596
|
_contract_address_get.apply(
|
|
405
597
|
null,
|
|
406
598
|
_args);
|
|
407
|
-
|
|
599
|
+
_contracts_addresses.push(
|
|
408
600
|
_contract_address);
|
|
409
601
|
}
|
|
410
602
|
return _contracts_addresses;
|
|
411
603
|
}
|
|
412
604
|
|
|
605
|
+
async function
|
|
606
|
+
_deployments_dir_auto_detect() {
|
|
607
|
+
let
|
|
608
|
+
_deployments;
|
|
609
|
+
_deployments =
|
|
610
|
+
"";
|
|
611
|
+
const
|
|
612
|
+
_app =
|
|
613
|
+
target_app;
|
|
614
|
+
const
|
|
615
|
+
_app_type =
|
|
616
|
+
typeof(
|
|
617
|
+
_app);
|
|
618
|
+
if ( _app_type != "undefined" &&
|
|
619
|
+
_app != "" ) {
|
|
620
|
+
const
|
|
621
|
+
_user_defined =
|
|
622
|
+
user_defined;
|
|
623
|
+
const
|
|
624
|
+
_evm_contract_deployments_dir_args = [
|
|
625
|
+
_app,
|
|
626
|
+
_user_defined
|
|
627
|
+
];
|
|
628
|
+
_deployments =
|
|
629
|
+
await _evm_contract_deployments_dir.apply(
|
|
630
|
+
null,
|
|
631
|
+
_evm_contract_deployments_dir_args);
|
|
632
|
+
}
|
|
633
|
+
const
|
|
634
|
+
_deployments_dir_type =
|
|
635
|
+
typeof(
|
|
636
|
+
deployments_dir);
|
|
637
|
+
if ( _deployments_dir_type === "undefined" ||
|
|
638
|
+
deployments_dir == "" ) {
|
|
639
|
+
deployments_dir =
|
|
640
|
+
_deployments;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
async function
|
|
645
|
+
_contract_version_auto_detect() {
|
|
646
|
+
let
|
|
647
|
+
_config,
|
|
648
|
+
_config_ext,
|
|
649
|
+
_deployments,
|
|
650
|
+
_found,
|
|
651
|
+
_net,
|
|
652
|
+
_network,
|
|
653
|
+
_network_id,
|
|
654
|
+
_networks,
|
|
655
|
+
_version,
|
|
656
|
+
_msg;
|
|
657
|
+
_networks =
|
|
658
|
+
[];
|
|
659
|
+
const
|
|
660
|
+
_contract =
|
|
661
|
+
target_contract;
|
|
662
|
+
_found =
|
|
663
|
+
false;
|
|
664
|
+
if ( configuration_format == "bash" ) {
|
|
665
|
+
_config_ext =
|
|
666
|
+
"sh";
|
|
667
|
+
}
|
|
668
|
+
else if ( configuration_format == "bash" ) {
|
|
669
|
+
_config_ext =
|
|
670
|
+
"json";
|
|
671
|
+
}
|
|
672
|
+
const
|
|
673
|
+
_contract_type =
|
|
674
|
+
typeof(
|
|
675
|
+
_contract);
|
|
676
|
+
if ( _contract != "" &&
|
|
677
|
+
_contract_type != "undefined" ) {
|
|
678
|
+
const
|
|
679
|
+
_deployments_dir_type =
|
|
680
|
+
typeof(
|
|
681
|
+
deployments_dir);
|
|
682
|
+
if ( _deployments_dir_type != "undefined" &&
|
|
683
|
+
deployments_dir != "" ) {
|
|
684
|
+
_deployments =
|
|
685
|
+
deployments_dir;
|
|
686
|
+
if ( 0 < target_networks.length ) {
|
|
687
|
+
_network =
|
|
688
|
+
target_networks[
|
|
689
|
+
0];
|
|
690
|
+
}
|
|
691
|
+
if ( 0 < network_ids.length ) {
|
|
692
|
+
_network_id =
|
|
693
|
+
_network_ids[
|
|
694
|
+
0];
|
|
695
|
+
}
|
|
696
|
+
const
|
|
697
|
+
_deployments_path =
|
|
698
|
+
_path_join( [
|
|
699
|
+
_deployments,
|
|
700
|
+
_contract ] );
|
|
701
|
+
if ( networks_all == "n" ) {
|
|
702
|
+
_networks.push(
|
|
703
|
+
_network,
|
|
704
|
+
_network_id);
|
|
705
|
+
}
|
|
706
|
+
else if ( networks_all == "y" ) {
|
|
707
|
+
const
|
|
708
|
+
_evm_contract_deployment_networks_args = [
|
|
709
|
+
_deployments_path,
|
|
710
|
+
"y", // Display all
|
|
711
|
+
"n", // Display safest
|
|
712
|
+
"n" // Display cheapest
|
|
713
|
+
];
|
|
714
|
+
_networks_new =
|
|
715
|
+
await _evm_contract_deployment_networks.apply(
|
|
716
|
+
null,
|
|
717
|
+
_evm_contract_deployment_networks_args);
|
|
718
|
+
_networks =
|
|
719
|
+
_networks.concat(
|
|
720
|
+
_networks_new);
|
|
721
|
+
}
|
|
722
|
+
for ( _net of _networks ) {
|
|
723
|
+
_config =
|
|
724
|
+
_path_join( [
|
|
725
|
+
_deployments_path,
|
|
726
|
+
_net,
|
|
727
|
+
`config.${_config_ext}`
|
|
728
|
+
]);
|
|
729
|
+
if ( _file_exists(
|
|
730
|
+
_config) ) {
|
|
731
|
+
_found =
|
|
732
|
+
true;
|
|
733
|
+
_msg =
|
|
734
|
+
`Found deployment configuration ` +
|
|
735
|
+
`at location '${_config}'.`;
|
|
736
|
+
_msg_info(
|
|
737
|
+
_msg);
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if ( ! _found ) {
|
|
742
|
+
_msg =
|
|
743
|
+
"No deployment configuration " +
|
|
744
|
+
"file found for network " +
|
|
745
|
+
`'${_network}' with ID ` +
|
|
746
|
+
`'${_network_id}'.`;
|
|
747
|
+
_msg_error(
|
|
748
|
+
_msg,
|
|
749
|
+
1);
|
|
750
|
+
}
|
|
751
|
+
const
|
|
752
|
+
_evm_contract_deployment_versions_args = [
|
|
753
|
+
_config,
|
|
754
|
+
"y", // display highest
|
|
755
|
+
"n", // display lowest
|
|
756
|
+
configuration_format
|
|
757
|
+
];
|
|
758
|
+
_version =
|
|
759
|
+
await _evm_contract_deployment_versions.apply(
|
|
760
|
+
null,
|
|
761
|
+
_evm_contract_deployment_versions_args);
|
|
762
|
+
}
|
|
763
|
+
else if ( _deployments_dir_type == "undefined" ||
|
|
764
|
+
deployments_dir == "" ) {
|
|
765
|
+
const
|
|
766
|
+
_msg =
|
|
767
|
+
"If no target application is specified " +
|
|
768
|
+
"then the user-defined deployments " +
|
|
769
|
+
"switch must be enabled with '-u' and " +
|
|
770
|
+
"a deployments directory must be specified " +
|
|
771
|
+
"with '-d'.";
|
|
772
|
+
_msg_error(
|
|
773
|
+
_msg,
|
|
774
|
+
1);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
const
|
|
778
|
+
_contract_version_type =
|
|
779
|
+
typeof(
|
|
780
|
+
contract_version);
|
|
781
|
+
if ( _contract_version_type == "undefined" ||
|
|
782
|
+
contract_version == "" ) {
|
|
783
|
+
contract_version =
|
|
784
|
+
_version;
|
|
785
|
+
}
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
|
|
413
789
|
function
|
|
414
790
|
_networks_all_auto_detect() {
|
|
415
791
|
let
|
|
@@ -430,10 +806,12 @@ function
|
|
|
430
806
|
}
|
|
431
807
|
|
|
432
808
|
module.exports = {
|
|
433
|
-
|
|
434
|
-
|
|
809
|
+
_contract_version_auto_detect:
|
|
810
|
+
_contract_version_auto_detect,
|
|
811
|
+
_deployments_dir_auto_detect:
|
|
812
|
+
_deployments_dir_auto_detect,
|
|
435
813
|
_evm_contract_deployment_address:
|
|
436
814
|
_evm_contract_deployment_address,
|
|
437
815
|
_networks_all_auto_detect:
|
|
438
|
-
_networks_all_auto_detect
|
|
816
|
+
_networks_all_auto_detect
|
|
439
817
|
};
|