evm-contracts-tools 0.0.46 → 0.0.48

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.
Files changed (48) hide show
  1. package/Makefile +13 -0
  2. package/dist/evm-contract-call/evm-contract-call.js +1 -1
  3. package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +2 -0
  4. package/dist/evm-contract-deployment-abi/fs-worker.js +1 -0
  5. package/dist/evm-contract-deployment-abi/index.html +31 -0
  6. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
  7. package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +2 -0
  8. package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -0
  9. package/dist/evm-contract-deployment-bytecode/index.html +31 -0
  10. package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +2 -0
  11. package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -0
  12. package/dist/evm-contract-deployment-compiler-output/index.html +31 -0
  13. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  14. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  15. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  16. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  17. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  18. package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -0
  19. package/dist/libevm-contract-deployment-abi/index.html +24 -0
  20. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +2 -0
  21. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
  22. package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -0
  23. package/dist/libevm-contract-deployment-bytecode/index.html +24 -0
  24. package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +2 -0
  25. package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -0
  26. package/dist/libevm-contract-deployment-compiler-output/index.html +24 -0
  27. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  28. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  29. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  30. package/evm-contract-call +44 -40
  31. package/evm-contract-deployment-abi +538 -0
  32. package/evm-contract-deployment-address +34 -29
  33. package/evm-contract-deployment-bytecode +538 -0
  34. package/evm-contract-deployment-compiler-output +537 -0
  35. package/evm-contract-deployments-dir +24 -34
  36. package/lib/address-check +0 -0
  37. package/lib/evm-contract-call-dynamic +46 -17
  38. package/lib/evm-contract-call-static +0 -0
  39. package/libevm-contract-call +0 -18
  40. package/libevm-contract-deployment +650 -0
  41. package/libevm-contract-deployment-abi +446 -0
  42. package/libevm-contract-deployment-address +71 -402
  43. package/libevm-contract-deployment-bytecode +446 -0
  44. package/libevm-contract-deployment-compiler-output +446 -0
  45. package/libevm-contract-deployment-networks +28 -72
  46. package/libevm-contract-deployment-versions +26 -50
  47. package/libevm-contract-deployments-dir +13 -21
  48. package/package.json +54 -15
@@ -30,8 +30,6 @@
30
30
 
31
31
  /* eslint-disable
32
32
  no-unused-vars */
33
- /* eslint-disable
34
- no-useless-assignment */
35
33
 
36
34
  /* EVM Contracts tools global variables */
37
35
  /* global
@@ -65,90 +63,86 @@ const
65
63
  _libcrash_module =
66
64
  require(
67
65
  "crash-js");
66
+ /* global
67
+ _basename */
68
+ const
69
+ _basename =
70
+ _libcrash_module._basename;
68
71
  /* global
69
72
  _chmod */
70
- /* eslint-disable-next-line
71
- no-global-assign */
72
73
  const
73
74
  _chmod =
74
75
  _libcrash_module._chmod;
75
76
  /* global
76
77
  _cp */
77
- /* eslint-disable-next-line
78
- no-global-assign */
79
78
  const
80
79
  _cp =
81
80
  _libcrash_module._cp;
81
+ /* global
82
+ _dir_exists */
83
+ const
84
+ _dir_exists =
85
+ _libcrash_module._dir_exists;
82
86
  /* global
83
87
  _file_exists */
84
- /* eslint-disable-next-line
85
- no-global-assign */
86
88
  const
87
89
  _file_exists =
88
90
  _libcrash_module._file_exists;
89
91
  /* global
90
92
  _file_read */
91
- /* eslint-disable-next-line
92
- no-global-assign */
93
93
  const
94
94
  _file_read =
95
95
  _libcrash_module._file_read;
96
96
  /* global
97
97
  _from_bash_ass_array */
98
- /* eslint-disable-next-line
99
- no-global-assign */
100
98
  const
101
99
  _from_bash_ass_array =
102
100
  _libcrash_module._from_bash_ass_array;
103
101
  /* global
104
102
  _homedir_get */
105
- /* eslint-disable-next-line
106
- no-global-assign */
107
103
  const
108
104
  _homedir_get =
109
105
  _libcrash_module._homedir_get;
110
106
  /* global
111
107
  _json_read */
112
- /* eslint-disable-next-line
113
- no-global-assign */
114
108
  const
115
109
  _json_read =
116
110
  _libcrash_module._json_read;
117
111
  /* global
118
112
  _lib_get */
119
- /* eslint-disable-next-line
120
- no-global-assign */
121
113
  const
122
114
  _lib_get =
123
115
  _libcrash_module._lib_get;
124
116
  /* global
125
117
  _mkdir */
126
- /* eslint-disable-next-line
127
- no-global-assign */
128
118
  const
129
119
  _mkdir =
130
120
  _libcrash_module._mkdir;
131
121
  /* global
132
122
  _msg_info */
133
- /* eslint-disable-next-line
134
- no-global-assign */
135
123
  const
136
124
  _msg_info =
137
125
  _libcrash_module._msg_info;
138
126
  /* global
139
127
  _msg_error */
140
- /* eslint-disable-next-line
141
- no-global-assign */
142
128
  const
143
129
  _msg_error =
144
130
  _libcrash_module._msg_error;
131
+ /* global
132
+ _override_set */
133
+ const
134
+ _override_set =
135
+ _libcrash_module._override_set;
145
136
  /* global
146
137
  _path_join */
147
- /* eslint-disable-next-line
148
- no-global-assign */
149
138
  const
150
139
  _path_join =
151
140
  _libcrash_module._path_join;
141
+ /* global
142
+ _pwd */
143
+ const
144
+ _pwd =
145
+ _libcrash_module._pwd;
152
146
  const
153
147
  _evm_chains_info_module =
154
148
  require(
@@ -167,6 +161,40 @@ const
167
161
  const
168
162
  _evm_contract_deployments_dir =
169
163
  _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
164
+ const
165
+ _libevm_contract_deployment_module =
166
+ require(
167
+ "./libevm-contract-deployment");
168
+ /* global
169
+ _contract_version_auto_detect */
170
+ const
171
+ _contract_version_auto_detect =
172
+ _libevm_contract_deployment_module._contract_version_auto_detect;
173
+ /* global
174
+ _deployments_dir_auto_detect */
175
+ const
176
+ _deployments_dir_auto_detect =
177
+ _libevm_contract_deployment_module._deployments_dir_auto_detect;
178
+ /* global
179
+ _network_check */
180
+ const
181
+ _network_check =
182
+ _libevm_contract_deployment_module._network_check;
183
+ /* global
184
+ _networks_all_auto_detect */
185
+ const
186
+ _networks_all_auto_detect =
187
+ _libevm_contract_deployment_module._networks_all_auto_detect;
188
+ /* global
189
+ _target_app_auto_detect */
190
+ const
191
+ _target_app_auto_detect =
192
+ _libevm_contract_deployment_module._target_app_auto_detect;
193
+ /* global
194
+ _user_deployments_check */
195
+ const
196
+ _user_deployments_check =
197
+ _libevm_contract_deployment_module._user_deployments_check;
170
198
  const
171
199
  _libevm_contract_deployment_networks_module =
172
200
  require(
@@ -198,7 +226,6 @@ function
198
226
  _config,
199
227
  _config_file_ext,
200
228
  _config_path,
201
- _address,
202
229
  _found,
203
230
  _key_name,
204
231
  _msg,
@@ -215,7 +242,7 @@ function
215
242
  }
216
243
  else if ( _configuration_format == "json" ) {
217
244
  _config_file_ext =
218
- "json"
245
+ "json";
219
246
  }
220
247
  else {
221
248
  _msg =
@@ -223,7 +250,8 @@ function
223
250
  `${_configuration_format}'.`;
224
251
  _msg_error(
225
252
  _msg,
226
- 1);
253
+ 0);
254
+ throw _msg;
227
255
  }
228
256
  const
229
257
  _networks = [
@@ -233,7 +261,6 @@ function
233
261
  _found =
234
262
  false;
235
263
  for ( _net of _networks ) {
236
- _path_join_args =
237
264
  _config_path =
238
265
  _path_join( [
239
266
  _deployments,
@@ -254,7 +281,8 @@ function
254
281
  `found at path '${_deployments}'.`;
255
282
  _msg_error(
256
283
  _msg,
257
- 1);
284
+ 0);
285
+ throw _msg;
258
286
  }
259
287
  if ( _configuration_format == "json" ) {
260
288
  _config =
@@ -285,173 +313,12 @@ function
285
313
  `'${_deployments}'.`;
286
314
  _msg_error(
287
315
  _msg,
288
- 1);
316
+ 0);
317
+ throw _msg;
289
318
  }
290
319
  return _contract_address;
291
320
  }
292
321
 
293
- async function
294
- _network_check(
295
- _deployments,
296
- _contract,
297
- _target_network,
298
- _target_network_id) {
299
- let
300
- _error_flag,
301
- _msg,
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
- }
330
- }
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);
371
- }
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
- ];
447
- const
448
- _initialized =
449
- await _user_deployments_init.apply(
450
- null,
451
- _user_deployments_init_args);
452
- }
453
- }
454
-
455
322
  async function
456
323
  _evm_contract_deployment_address(
457
324
  _target_networks,
@@ -490,7 +357,8 @@ async function
490
357
  "path with '-d'.";
491
358
  _msg_error(
492
359
  _msg,
493
- 1)
360
+ 0);
361
+ throw _msg;
494
362
  }
495
363
  _system_deployments_dir =
496
364
  await _evm_contract_deployments_dir(
@@ -503,7 +371,8 @@ async function
503
371
  "deployments switch with '-u'." +
504
372
  _msg_error(
505
373
  _msg,
506
- 1)
374
+ 0);
375
+ throw _msg;
507
376
  }
508
377
  }
509
378
  else if ( _user_defined == "y" ) {
@@ -532,11 +401,12 @@ async function
532
401
  `can be 'y' or 'n', current value '${_user_defined}'.`;
533
402
  _msg_error(
534
403
  _msg,
535
- 1);
404
+ 0);
405
+ throw _msg;
536
406
  }
537
407
  if ( _networks_all == "y" ) {
538
408
  _msg =
539
- "Selecting all networks."
409
+ "Selecting all networks.";
540
410
  _msg_info(
541
411
  _msg);
542
412
  _target_networks =
@@ -602,209 +472,6 @@ async function
602
472
  return _contracts_addresses;
603
473
  }
604
474
 
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
-
789
- function
790
- _networks_all_auto_detect() {
791
- let
792
- _networks_all;
793
- _networks_all =
794
- "n";
795
- if ( target_networks.length < 1 &&
796
- network_ids.length < 1 ) {
797
- _networks_all =
798
- "y";
799
- }
800
- if ( typeof(
801
- networks_all) === "undefined" ||
802
- networks_all == "" ) {
803
- networks_all =
804
- _networks_all;
805
- }
806
- }
807
-
808
475
  module.exports = {
809
476
  _contract_version_auto_detect:
810
477
  _contract_version_auto_detect,
@@ -813,5 +480,7 @@ module.exports = {
813
480
  _evm_contract_deployment_address:
814
481
  _evm_contract_deployment_address,
815
482
  _networks_all_auto_detect:
816
- _networks_all_auto_detect
483
+ _networks_all_auto_detect,
484
+ _target_app_auto_detect:
485
+ _target_app_auto_detect
817
486
  };