evm-contracts-tools 0.0.55 → 0.0.62

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.
@@ -61,8 +61,8 @@
61
61
 
62
62
  const
63
63
  _libcrash_module =
64
- require(
65
- "crash-js");
64
+ await import(
65
+ "libcrash-js");
66
66
  /* global
67
67
  _basename */
68
68
  const
@@ -83,6 +83,16 @@ const
83
83
  const
84
84
  _dir_exists =
85
85
  _libcrash_module._dir_exists;
86
+ /* global
87
+ _echo */
88
+ const
89
+ _echo =
90
+ _libcrash_module._echo;
91
+ /* global
92
+ _echo2 */
93
+ const
94
+ _echo2 =
95
+ _libcrash_module._echo2;
86
96
  /* global
87
97
  _file_exists */
88
98
  const
@@ -98,6 +108,11 @@ const
98
108
  const
99
109
  _from_bash_ass_array =
100
110
  _libcrash_module._from_bash_ass_array;
111
+ /* global
112
+ _global_get */
113
+ const
114
+ _global_get =
115
+ _libcrash_module._global_get;
101
116
  /* global
102
117
  _homedir_get */
103
118
  const
@@ -143,27 +158,14 @@ const
143
158
  const
144
159
  _pwd =
145
160
  _libcrash_module._pwd;
146
- const
147
- _evm_chains_info_module =
148
- require(
149
- "evm-chains-info");
150
161
  /* global
151
- _evm_chains_info */
162
+ _require */
152
163
  const
153
- _evm_chains_info =
154
- _evm_chains_info_module._evm_chains_info;
155
- const
156
- _libevm_contract_deployments_dir_module =
157
- require(
158
- "./libevm-contract-deployments-dir");
159
- /* global
160
- _evm_contract_deployments_dir */
161
- const
162
- _evm_contract_deployments_dir =
163
- _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
164
+ _require =
165
+ _libcrash_module._require;
164
166
  const
165
167
  _libevm_contract_deployment_module =
166
- require(
168
+ await import(
167
169
  "./libevm-contract-deployment");
168
170
  /* global
169
171
  _contract_version_auto_detect */
@@ -197,24 +199,15 @@ const
197
199
  _libevm_contract_deployment_module._user_deployments_check;
198
200
  const
199
201
  _libevm_contract_deployment_networks_module =
200
- require(
202
+ await import(
201
203
  "./libevm-contract-deployment-networks");
202
204
  /* global
203
205
  _evm_contract_deployment_networks */
204
206
  const
205
207
  _evm_contract_deployment_networks =
206
208
  _libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
207
- const
208
- _libevm_contract_deployment_versions_module =
209
- require(
210
- "./libevm-contract-deployment-versions");
211
- /* global
212
- _evm_contract_deployment_versions */
213
- const
214
- _evm_contract_deployment_versions =
215
- _libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
216
209
 
217
- function
210
+ async function
218
211
  _contract_address_get(
219
212
  _deployments,
220
213
  _contract,
@@ -226,13 +219,39 @@ function
226
219
  _config,
227
220
  _config_file_ext,
228
221
  _config_path,
222
+ _evm_contract_deployment_versions_args,
223
+ _libevm_contract_deployment_versions_module,
229
224
  _found,
230
225
  _key_name,
231
226
  _msg,
232
227
  _net;
233
- if ( typeof(
234
- _configuration_format) === "undefined" ||
228
+ const
229
+ _global =
230
+ _global_get();
231
+ const
232
+ _quiet =
233
+ _global[
234
+ "quiet"];
235
+ _msg =
236
+ "Reading address from " +
237
+ "configuration file.";
238
+ _msg_info(
239
+ _msg);
240
+ const
241
+ _version_type =
242
+ typeof(
243
+ _version);
244
+ const
245
+ _configuration_format_type =
246
+ typeof(
247
+ _configuration_format);
248
+ if ( _configuration_format_type === "undefined" ||
235
249
  _configuration_format == "" ) {
250
+ _msg =
251
+ "Configuration format not set, " +
252
+ "setting default (bash).";
253
+ _msg_info(
254
+ _msg);
236
255
  _configuration_format =
237
256
  "bash";
238
257
  }
@@ -299,13 +318,78 @@ function
299
318
  _key_name =
300
319
  "contract_address";
301
320
  }
321
+ else {
322
+ _msg =
323
+ "Unknown configuration format " +
324
+ `'${_configuration_format}'.`;
325
+ _msg_error(
326
+ _msg,
327
+ 0);
328
+ throw _msg;
329
+ }
330
+ if ( _version_type === "undefined" ||
331
+ _version == "" ) {
332
+ _msg =
333
+ "No version selected, " +
334
+ "retrieving.";
335
+ _msg_info(
336
+ _msg);
337
+ _libevm_contract_deployment_versions_module =
338
+ await import(
339
+ "./libevm-contract-deployment-versions");
340
+ const
341
+ _evm_contract_deployment_versions =
342
+ _libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
343
+ _evm_contract_deployment_versions_args = [
344
+ _config_path,
345
+ "y", // display highest
346
+ "n", // display lowest
347
+ _configuration_format
348
+ ];
349
+ try {
350
+ _msg =
351
+ "Running '_evm_contract_deployment_versions' " +
352
+ "with arguments:";
353
+ _msg_info(
354
+ _msg);
355
+ if ( _quiet == "n" ) {
356
+ _echo(
357
+ _evm_contract_deployment_versions_args);
358
+ }
359
+ _version =
360
+ await _evm_contract_deployment_versions.apply(
361
+ null,
362
+ _evm_contract_deployment_versions_args);
363
+ _msg =
364
+ "Got contract version " +
365
+ `'${_version}'.`;
366
+ _msg_info(
367
+ _msg);
368
+ }
369
+ catch(
370
+ _error) {
371
+ _msg =
372
+ "Error while running " +
373
+ "'_evm_contract_deployment_versions' with arguments:";
374
+ _msg_error(
375
+ _msg,
376
+ 0);
377
+ _echo2(
378
+ _evm_contract_deployment_versions_args);
379
+ throw _error;
380
+ }
381
+ }
302
382
  const
303
383
  _contract_address =
304
384
  _config[
305
385
  _key_name][
306
386
  _version];
307
- if ( _contract_address == "" ||
308
- _contract_address == null ) {
387
+ const
388
+ _contract_address_type =
389
+ typeof(
390
+ _contract_address);
391
+ if ( _contract_address_type === "undefined" ||
392
+ _contract_address == "" ) {
309
393
  _msg =
310
394
  `No '${_contract}' version '${_version}' ` +
311
395
  `contract deployment specified for network ` +
@@ -316,6 +400,12 @@ function
316
400
  0);
317
401
  throw _msg;
318
402
  }
403
+ else if ( _contract_address_type == "string" ) {
404
+ _msg =
405
+ `Got contract address '${_contract_address}'`;
406
+ _msg_info(
407
+ _msg);
408
+ }
319
409
  return _contract_address;
320
410
  }
321
411
 
@@ -331,23 +421,71 @@ async function
331
421
  _configuration_format,
332
422
  _deployments_dir) {
333
423
  let
424
+ _address,
334
425
  _args,
335
426
  _contract_address,
427
+ _msg,
336
428
  _network,
337
429
  _network_check_args,
338
430
  _target_network,
339
431
  _target_network_id,
340
432
  _user_deployments_dir,
341
- _system_deployments_dir,
342
- _msg;
433
+ _system_deployments_dir;
434
+ const
435
+ _libevm_contract_deployments_dir_module =
436
+ await import(
437
+ "./libevm-contract-deployments-dir");
438
+ const
439
+ _evm_contract_deployments_dir =
440
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
343
441
  const
344
442
  _contracts_addresses =
345
443
  [];
346
444
  const
347
445
  _contract_address_get_args =
348
446
  [];
447
+ const
448
+ _user_defined_type =
449
+ typeof(
450
+ _user_defined);
451
+ const
452
+ _deployments_dir_type =
453
+ typeof(
454
+ _deployments_dir);
455
+ if ( _user_defined_type === "undefined" ||
456
+ _user_defined === "" ) {
457
+ _msg =
458
+ "User defined not specified, setting " +
459
+ "default (n).";
460
+ _msg_info(
461
+ _msg);
462
+ _user_defined =
463
+ "n";
464
+ }
465
+ if ( _deployments_dir_type === "undefined" ||
466
+ _deployments_dir === "" ) {
467
+ try {
468
+ _deployments_dir =
469
+ await _evm_contract_deployments_dir(
470
+ _target_app,
471
+ _user_defined);
472
+ }
473
+ catch(
474
+ _error) {
475
+ _msg =
476
+ "Error while retrieving system deployments " +
477
+ "directory location for auto-detection.";
478
+ _msg_error(
479
+ _msg,
480
+ 0);
481
+ _msg_error(
482
+ _error,
483
+ 0);
484
+ throw _error;
485
+ }
486
+ }
349
487
  if ( _user_defined == "n" ) {
350
- if ( _target_app == "" ) {
488
+ if ( _target_app === "" ) {
351
489
  _msg =
352
490
  "A target application needs to " +
353
491
  "be specified with option '-a' " +
@@ -360,10 +498,25 @@ async function
360
498
  0);
361
499
  throw _msg;
362
500
  }
363
- _system_deployments_dir =
364
- await _evm_contract_deployments_dir(
365
- _target_app,
366
- _user_defined);
501
+ try {
502
+ _system_deployments_dir =
503
+ await _evm_contract_deployments_dir(
504
+ _target_app,
505
+ _user_defined);
506
+ }
507
+ catch(
508
+ _error) {
509
+ _msg =
510
+ "Error while retrieving system deployments " +
511
+ "directory location.";
512
+ _msg_error(
513
+ _msg,
514
+ 0);
515
+ _msg_error(
516
+ _error,
517
+ 0);
518
+ throw _error;
519
+ }
367
520
  if ( _deployments_dir != _system_deployments_dir ) {
368
521
  _msg =
369
522
  "To set a custom deployments directory path " +
@@ -377,10 +530,25 @@ async function
377
530
  }
378
531
  else if ( _user_defined == "y" ) {
379
532
  if ( _target_app != "" ) {
380
- _user_deployments_dir =
381
- await _evm_contract_deployments_dir(
382
- _target_app,
383
- _user_defined);
533
+ try {
534
+ _user_deployments_dir =
535
+ await _evm_contract_deployments_dir(
536
+ _target_app,
537
+ _user_defined);
538
+ }
539
+ catch(
540
+ _error) {
541
+ _msg =
542
+ "Error while retrieving user deployments " +
543
+ "directory location.";
544
+ _msg_error(
545
+ _msg,
546
+ 0);
547
+ _msg_error(
548
+ _error,
549
+ 0);
550
+ throw _error;
551
+ }
384
552
  }
385
553
  if ( _deployments_dir != _user_deployments_dir ) {
386
554
  _msg =
@@ -402,18 +570,46 @@ async function
402
570
  _msg_error(
403
571
  _msg,
404
572
  0);
405
- throw _msg;
573
+ const
574
+ _exception = {
575
+ "msg":
576
+ _msg
577
+ };
578
+ throw _exception;
406
579
  }
407
580
  if ( _networks_all == "y" ) {
408
581
  _msg =
409
582
  "Selecting all networks.";
410
583
  _msg_info(
411
584
  _msg);
412
- _target_networks =
413
- await _evm_contract_deployment_networks(
414
- `${_deployments_dir}/${_target_contract}`,
415
- _networks_all);
585
+ try {
586
+ _target_networks =
587
+ await _evm_contract_deployment_networks(
588
+ `${_deployments_dir}/${_target_contract}`,
589
+ _networks_all);
590
+ }
591
+ catch(
592
+ _error) {
593
+ _msg =
594
+ "Error while retrieving networks " +
595
+ `for contract '${_target_contract}'.`;
596
+ _msg_error(
597
+ _msg,
598
+ 0);
599
+ _echo2(
600
+ _error);
601
+ throw _error;
602
+ }
416
603
  }
604
+ _msg =
605
+ `Getting '${_target_contract}' contract address for ` +
606
+ `libEVM app '${_target_app}' ` +
607
+ `for networks with RPCs '${_target_networks}' ` +
608
+ `and chain ID '${_network_ids}', (user-defined contracts: ` +
609
+ `'${_user_defined}'), by looking for configuration files ` +
610
+ `of type '${_configuration_format}'.`;
611
+ _msg_info(
612
+ _msg);
417
613
  for ( _network of _target_networks ) {
418
614
  // _msg =
419
615
  // "Info arguments for " +
@@ -456,31 +652,73 @@ async function
456
652
  _deployments_dir,
457
653
  _target_contract,
458
654
  _target_network,
459
- _target_network_id,
655
+ _network,
460
656
  _contract_version,
461
657
  _configuration_format
462
658
  ] );
463
659
  }
464
660
  for ( _args of _contract_address_get_args ) {
465
- _contract_address =
466
- _contract_address_get.apply(
467
- null,
661
+ try {
662
+ _msg =
663
+ "Running " +
664
+ "_contract_address_get " +
665
+ `with parameters:`;
666
+ _msg_info(
667
+ _msg);
668
+ _echo2(
669
+ _args);
670
+ _contract_address =
671
+ await _contract_address_get.apply(
672
+ null,
673
+ _args);
674
+ }
675
+ catch(
676
+ _error) {
677
+ _msg =
678
+ "Error while running " +
679
+ "_contract_address_get " +
680
+ `with parameters:`;
681
+ _msg_error(
682
+ _msg,
683
+ 0);
684
+ _echo2(
468
685
  _args);
686
+ _echo2(
687
+ _error);
688
+ throw _msg;
689
+ }
469
690
  _contracts_addresses.push(
470
691
  _contract_address);
471
692
  }
472
- return _contracts_addresses;
693
+ const
694
+ _contracts_addresses_set =
695
+ {};
696
+ for ( _address of _contracts_addresses ) {
697
+ _contracts_addresses_set[
698
+ _address] =
699
+ 1;
700
+ }
701
+ return Object.keys(
702
+ _contracts_addresses_set);
473
703
  }
474
704
 
475
- module.exports = {
476
- _contract_version_auto_detect:
477
- _contract_version_auto_detect,
478
- _deployments_dir_auto_detect:
479
- _deployments_dir_auto_detect,
480
- _evm_contract_deployment_address:
481
- _evm_contract_deployment_address,
482
- _networks_all_auto_detect:
483
- _networks_all_auto_detect,
484
- _target_app_auto_detect:
485
- _target_app_auto_detect
705
+ export {
706
+ _contract_version_auto_detect,
707
+ _deployments_dir_auto_detect,
708
+ _evm_contract_deployment_address,
709
+ _networks_all_auto_detect,
710
+ _target_app_auto_detect
486
711
  };
712
+
713
+ // module.exports = {
714
+ // _contract_version_auto_detect:
715
+ // _contract_version_auto_detect,
716
+ // _deployments_dir_auto_detect:
717
+ // _deployments_dir_auto_detect,
718
+ // _evm_contract_deployment_address:
719
+ // _evm_contract_deployment_address,
720
+ // _networks_all_auto_detect:
721
+ // _networks_all_auto_detect,
722
+ // _target_app_auto_detect:
723
+ // _target_app_auto_detect
724
+ // };
@@ -83,7 +83,8 @@ function
83
83
  if ( _error_flag ) {
84
84
  _msg_error(
85
85
  _msg,
86
- 1);
86
+ 0);
87
+ throw _msg;
87
88
  }
88
89
  }
89
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  { "name": "evm-contracts-tools",
2
2
  "version":
3
- "0.0.55",
3
+ "0.0.62",
4
4
  "description":
5
5
  "JavaScript programs and libraries to enable seamless development of native computer applications designed to interact with Ethereum Virtual Machine-compatible networks.",
6
6
  "funding": {
@@ -100,7 +100,7 @@
100
100
  },
101
101
  "devDependencies": {
102
102
  "crash-js-webpack":
103
- "^0.0.69",
103
+ "^0.0.77",
104
104
  "brace-expansion":
105
105
  "^5.0.9",
106
106
  "eslint":
@@ -108,11 +108,11 @@
108
108
  "@eslint/js":
109
109
  "^10.0.1",
110
110
  "fast-uri":
111
- "^4.1.2",
111
+ "^4.1.4",
112
112
  "globals":
113
113
  "^17.3.0",
114
114
  "safely-serve":
115
- "^0.0.19",
115
+ "^0.0.21",
116
116
  "webpack":
117
117
  "^5.109.2",
118
118
  "webpack-cli":
@@ -120,31 +120,33 @@
120
120
  },
121
121
  "dependencies": {
122
122
  "libcrash-js":
123
- "npm:crash-js@^100000000000001.1000000000000001.1000000000000001",
123
+ "npm:crash-js@^1000000000000011.1000000000000001.1000000000000001",
124
124
  "ethers":
125
125
  "^6.13.2",
126
126
  "evm-chains-info":
127
- "^0.0.34",
127
+ "^0.0.36",
128
128
  "evm-transactions-tools":
129
- "^0.0.11111111",
129
+ "^0.1.10000000001",
130
130
  "evm-wallet":
131
- "npm:evm-wallet.js@^0.0.92",
131
+ "npm:evm-wallet.js@^0.0.96",
132
132
  "libevm":
133
- "^0.0.39",
133
+ "^0.0.41",
134
134
  "ws":
135
135
  "^8.21.0",
136
136
  "yargs":
137
137
  "18.0.0"
138
138
  },
139
139
  "overrides": {
140
+ "libcrash-js":
141
+ "npm:crash-js@^1000000000000011.1000000000000001.1000000000000001",
140
142
  "evm-contracts-tools":
141
143
  "./evm-contracts-tools",
142
144
  "evm-wallet":
143
- "npm:evm-wallet.js@^0.0.92",
145
+ "npm:evm-wallet.js@^0.0.96",
144
146
  "evm-wallet.js":
145
- "npm:evm-wallet.js@^0.0.92",
147
+ "npm:evm-wallet.js@^0.0.96",
146
148
  "libevm":
147
- "^0.0.39"
149
+ "^0.0.41"
148
150
  },
149
151
  "type":
150
152
  "module",