evm-contracts-tools 0.0.47 → 0.0.49

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 (31) hide show
  1. package/dist/evm-contract-call/evm-contract-call.js +1 -1
  2. package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +2 -0
  3. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +2 -0
  4. package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +2 -0
  5. package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +2 -0
  6. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  7. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  8. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  9. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  10. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  11. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +1 -1
  12. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +2 -0
  13. package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +2 -0
  14. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  15. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  16. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  17. package/evm-contract-deployment-abi +19 -21
  18. package/evm-contract-deployment-address +11 -11
  19. package/evm-contract-deployment-bytecode +18 -20
  20. package/evm-contract-deployment-compiler-output +19 -22
  21. package/evm-contract-deployments-dir +24 -34
  22. package/libevm-contract-call +0 -18
  23. package/libevm-contract-deployment +650 -0
  24. package/libevm-contract-deployment-abi +13 -32
  25. package/libevm-contract-deployment-address +20 -37
  26. package/libevm-contract-deployment-bytecode +13 -33
  27. package/libevm-contract-deployment-compiler-output +41 -458
  28. package/libevm-contract-deployment-networks +28 -72
  29. package/libevm-contract-deployment-versions +26 -50
  30. package/libevm-contract-deployments-dir +13 -21
  31. package/package.json +14 -11
@@ -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
@@ -77,8 +75,6 @@ const
77
75
  _libcrash_module._chmod;
78
76
  /* global
79
77
  _cp */
80
- /* eslint-disable-next-line
81
- no-global-assign */
82
78
  const
83
79
  _cp =
84
80
  _libcrash_module._cp;
@@ -94,57 +90,41 @@ const
94
90
  _libcrash_module._file_exists;
95
91
  /* global
96
92
  _file_read */
97
- /* eslint-disable-next-line
98
- no-global-assign */
99
93
  const
100
94
  _file_read =
101
95
  _libcrash_module._file_read;
102
96
  /* global
103
97
  _from_bash_ass_array */
104
- /* eslint-disable-next-line
105
- no-global-assign */
106
98
  const
107
99
  _from_bash_ass_array =
108
100
  _libcrash_module._from_bash_ass_array;
109
101
  /* global
110
102
  _homedir_get */
111
- /* eslint-disable-next-line
112
- no-global-assign */
113
103
  const
114
104
  _homedir_get =
115
105
  _libcrash_module._homedir_get;
116
106
  /* global
117
107
  _json_read */
118
- /* eslint-disable-next-line
119
- no-global-assign */
120
108
  const
121
109
  _json_read =
122
110
  _libcrash_module._json_read;
123
111
  /* global
124
112
  _lib_get */
125
- /* eslint-disable-next-line
126
- no-global-assign */
127
113
  const
128
114
  _lib_get =
129
115
  _libcrash_module._lib_get;
130
116
  /* global
131
117
  _mkdir */
132
- /* eslint-disable-next-line
133
- no-global-assign */
134
118
  const
135
119
  _mkdir =
136
120
  _libcrash_module._mkdir;
137
121
  /* global
138
122
  _msg_info */
139
- /* eslint-disable-next-line
140
- no-global-assign */
141
123
  const
142
124
  _msg_info =
143
125
  _libcrash_module._msg_info;
144
126
  /* global
145
127
  _msg_error */
146
- /* eslint-disable-next-line
147
- no-global-assign */
148
128
  const
149
129
  _msg_error =
150
130
  _libcrash_module._msg_error;
@@ -155,8 +135,6 @@ const
155
135
  _libcrash_module._override_set;
156
136
  /* global
157
137
  _path_join */
158
- /* eslint-disable-next-line
159
- no-global-assign */
160
138
  const
161
139
  _path_join =
162
140
  _libcrash_module._path_join;
@@ -191,32 +169,32 @@ const
191
169
  _contract_version_auto_detect */
192
170
  const
193
171
  _contract_version_auto_detect =
194
- _libevm_contract_deployment._contract_version_auto_detect;
172
+ _libevm_contract_deployment_module._contract_version_auto_detect;
195
173
  /* global
196
174
  _deployments_dir_auto_detect */
197
175
  const
198
176
  _deployments_dir_auto_detect =
199
- _libevm_contract_deployment._deployments_dir_auto_detect;
177
+ _libevm_contract_deployment_module._deployments_dir_auto_detect;
200
178
  /* global
201
179
  _network_check */
202
180
  const
203
181
  _network_check =
204
- _libevm_contract_deployment._network_check;
182
+ _libevm_contract_deployment_module._network_check;
205
183
  /* global
206
184
  _networks_all_auto_detect */
207
185
  const
208
186
  _networks_all_auto_detect =
209
- _libevm_contract_deployment._networks_all_auto_detect;
187
+ _libevm_contract_deployment_module._networks_all_auto_detect;
210
188
  /* global
211
189
  _target_app_auto_detect */
212
190
  const
213
191
  _target_app_auto_detect =
214
- _libevm_contract_deployment._target_app_auto_detect;
192
+ _libevm_contract_deployment_module._target_app_auto_detect;
215
193
  /* global
216
194
  _user_deployments_check */
217
195
  const
218
196
  _user_deployments_check =
219
- _libevm_contract_deployment._user_deployments_check;
197
+ _libevm_contract_deployment_module._user_deployments_check;
220
198
  const
221
199
  _libevm_contract_deployment_networks_module =
222
200
  require(
@@ -263,9 +241,10 @@ function
263
241
  _deployments,
264
242
  _contract,
265
243
  _net,
266
- `config.${_config_file_ext}` ]);
244
+ _version,
245
+ `${_contract}.json` ]);
267
246
  if ( _file_exists(
268
- _config_path) ) {
247
+ _compiler_output_path) ) {
269
248
  _found =
270
249
  true;
271
250
  break;
@@ -280,204 +259,28 @@ function
280
259
  _msg,
281
260
  1);
282
261
  }
283
- if ( _configuration_format == "json" ) {
284
- _config =
285
- _json_read(
286
- _config_path);
287
- _key_name =
288
- "contract-address";
289
- }
290
- else if ( _configuration_format == "bash" ) {
291
- _config =
292
- _from_bash_ass_array(
293
- _file_read(
294
- _config_path));
295
- _key_name =
296
- "contract_address";
297
- }
298
262
  const
299
- _contract_address =
300
- _config[
301
- _key_name][
302
- _version];
303
- if ( _contract_address == "" ||
304
- _contract_address == null ) {
263
+ _contract_compiler_output =
264
+ _compiler_output_path;
265
+ if ( _contract_compiler_output == "" ||
266
+ _contract_compiler_output == null ||
267
+ typeof(
268
+ _contract_compiler_output) == "undefined" ) {
305
269
  _msg =
306
270
  `No '${_contract}' version '${_version}' ` +
307
- `contract deployment specified for network ` +
308
- `'${_network}' for directory at path `+
271
+ `contract deployment compiler output for network ` +
272
+ `'${_network}' found at directory with path `+
309
273
  `'${_deployments}'.`;
310
274
  _msg_error(
311
275
  _msg,
312
- 1);
313
- }
314
- return _contract_address;
315
- }
316
-
317
- async function
318
- _network_check(
319
- _deployments,
320
- _contract,
321
- _target_network,
322
- _target_network_id) {
323
- let
324
- _error_flag,
325
- _msg,
326
- _network_id;
327
- _error_flag =
328
- false;
329
- _deployments_path =
330
- _path_join( [
331
- _deployments,
332
- _contract ]);
333
- const
334
- _evm_contract_deployment_networks_args = [
335
- _deployments_path,
336
- "y", // Display all
337
- "n", // Display safest
338
- "n" // Display cheapest
339
- ];
340
- const
341
- _networks =
342
- await _evm_contract_deployment_networks.apply(
343
- null,
344
- _evm_contract_deployment_networks_args);
345
- if ( _target_network_id != "" ) {
346
- if ( ! _networks.includes(
347
- _target_network_id) ) {
348
- _msg =
349
- "The contract does not result deployed on " +
350
- `network with id '${_target_network_id}'.`;
351
- _error_flag =
352
- true;
353
- }
354
- }
355
- else if ( _target_network != "" ) {
356
- if ( ! _networks.includes(
357
- _target_network) ) {
358
- _msg =
359
- "The contract does not result deployed on " +
360
- `network '${_target_network}'.`;
361
- _error_flag =
362
- true;
363
- }
364
- }
365
- else {
366
- _msg =
367
- "Provide one between a target network name " +
368
- "or ID.";
369
- _error_flag =
370
- true;
371
- }
372
- if ( _error_flag ) {
373
- _msg_error(
374
- _msg,
375
- 1);
376
- }
377
- if ( _target_network_id == "" ) {
378
- _evm_chains_info_args = [
379
- "get", // target command
380
- "name", // input type
381
- "id", // output type
382
- "offline",
383
- [ "node",
384
- "system" ], // db types
385
- "kirsh", // selection method, first
386
- "n", // api keys
387
- "n", // query all networks
388
- _target_network,
389
- [] // database paths
390
- ];
391
- _network_id =
392
- await _evm_chains_info.apply(
393
- null,
394
- _evm_chains_info_args);
395
- }
396
- else if ( _target_network == "" ) {
397
- _evm_chains_info_args = [
398
- "get", // target command
399
- "id" , // input type
400
- "name", // output type
401
- "offline",
402
- [ "node",
403
- "system" ], // db types
404
- "kirsh", // selection method, first
405
- "n", // api keys
406
- "n", // query all networks
407
- _target_network_id,
408
- [] // database paths
409
- ];
410
- _target_network =
411
- await _evm_chains_info(
412
- _evm_chains_info_args);
413
- }
414
- if ( _target_network_id != "" ) {
415
- if ( _target_network_id != _network_id ) {
416
- _msg =
417
- "Requested target network ID " +
418
- `'${_target_network_id}' does ` +
419
- `not correspond to '${_target_network}' ` +
420
- `known ID '${_network_id}'.`;
421
- _msg_error(
422
- _msg,
423
- 1);
424
- }
276
+ 0);
277
+ throw _msg;
425
278
  }
279
+ return _contract_compiler_output;
426
280
  }
427
281
 
428
282
  async function
429
- _user_deployments_init(
430
- _app,
431
- _deployments_dir) {
432
- const
433
- _user_defined =
434
- "y";
435
- const
436
- _evm_contract_deployments_dir_args = [
437
- _app,
438
- _user_defined
439
- ];
440
- const
441
- _system_deployments =
442
- await _evm_contract_deployments_dir.apply(
443
- null,
444
- _evm_contract_deployments_dir_args);
445
- _chmod(
446
- _deployments_dir,
447
- "0700");
448
- const
449
- _files =
450
- await _ls(
451
- _system_deployments);
452
- for ( _file of _files ) {
453
- _cp(
454
- _file,
455
- _deployments_dir);
456
- }
457
- return true;
458
- }
459
-
460
- async function
461
- _user_deployments_check(
462
- _app,
463
- _deployments_dir) {
464
- if ( ! _file_exists(
465
- _deployments_dir) ) {
466
- const
467
- _user_deployments_init_args = [
468
- _app,
469
- _deployments_dir
470
- ];
471
- const
472
- _initialized =
473
- await _user_deployments_init.apply(
474
- null,
475
- _user_deployments_init_args);
476
- }
477
- }
478
-
479
- async function
480
- _evm_contract_deployment_address(
283
+ _evm_contract_deployment_compiler_output(
481
284
  _target_networks,
482
285
  _network_ids,
483
286
  _networks_all,
@@ -489,7 +292,7 @@ async function
489
292
  _deployments_dir) {
490
293
  let
491
294
  _args,
492
- _contract_address,
295
+ _contract_compiler_output,
493
296
  _network,
494
297
  _network_check_args,
495
298
  _target_network,
@@ -498,10 +301,10 @@ async function
498
301
  _system_deployments_dir,
499
302
  _msg;
500
303
  const
501
- _contracts_addresses =
304
+ _contracts_compiler_outputs =
502
305
  [];
503
306
  const
504
- _contract_address_get_args =
307
+ _contract_compiler_output_get_args =
505
308
  [];
506
309
  if ( _user_defined == "n" ) {
507
310
  if ( _target_app == "" ) {
@@ -514,7 +317,8 @@ async function
514
317
  "path with '-d'.";
515
318
  _msg_error(
516
319
  _msg,
517
- 1)
320
+ 0);
321
+ throw _msg;
518
322
  }
519
323
  _system_deployments_dir =
520
324
  await _evm_contract_deployments_dir(
@@ -527,7 +331,8 @@ async function
527
331
  "deployments switch with '-u'." +
528
332
  _msg_error(
529
333
  _msg,
530
- 1)
334
+ 0);
335
+ throw _msg;
531
336
  }
532
337
  }
533
338
  else if ( _user_defined == "y" ) {
@@ -556,11 +361,12 @@ async function
556
361
  `can be 'y' or 'n', current value '${_user_defined}'.`;
557
362
  _msg_error(
558
363
  _msg,
559
- 1);
364
+ 0);
365
+ throw _msg;
560
366
  }
561
367
  if ( _networks_all == "y" ) {
562
368
  _msg =
563
- "Selecting all networks."
369
+ "Selecting all networks.";
564
370
  _msg_info(
565
371
  _msg);
566
372
  _target_networks =
@@ -585,7 +391,7 @@ async function
585
391
  await _network_check.apply(
586
392
  null,
587
393
  _network_check_args);
588
- _contract_address_get_args.push( [
394
+ _contract_compiler_output_get_args.push( [
589
395
  _deployments_dir,
590
396
  _target_contract,
591
397
  _network,
@@ -606,7 +412,7 @@ async function
606
412
  await _network_check.apply(
607
413
  null,
608
414
  _network_check_args);
609
- _contract_address_get_args.push( [
415
+ _contract_compiler_output_get_args.push( [
610
416
  _deployments_dir,
611
417
  _target_contract,
612
418
  _target_network,
@@ -615,238 +421,15 @@ async function
615
421
  _configuration_format
616
422
  ] );
617
423
  }
618
- for ( _args of _contract_address_get_args ) {
619
- _contract_address =
620
- _contract_address_get.apply(
424
+ for ( _args of _contract_compiler_output_get_args ) {
425
+ _contract_compiler_output =
426
+ _contract_compiler_output_get.apply(
621
427
  null,
622
428
  _args);
623
- _contracts_addresses.push(
624
- _contract_address);
625
- }
626
- return _contracts_addresses;
627
- }
628
-
629
- async function
630
- _deployments_dir_auto_detect() {
631
- let
632
- _deployments;
633
- _deployments =
634
- "";
635
- const
636
- _app =
637
- target_app;
638
- const
639
- _app_type =
640
- typeof(
641
- _app);
642
- if ( _app_type != "undefined" &&
643
- _app != "" ) {
644
- const
645
- _user_defined =
646
- user_defined;
647
- const
648
- _evm_contract_deployments_dir_args = [
649
- _app,
650
- _user_defined
651
- ];
652
- _deployments =
653
- await _evm_contract_deployments_dir.apply(
654
- null,
655
- _evm_contract_deployments_dir_args);
656
- }
657
- _override_set(
658
- "deployments",
659
- "dir",
660
- _deployments);
661
- }
662
-
663
- async function
664
- _contract_version_auto_detect() {
665
- let
666
- _config,
667
- _config_ext,
668
- _deployments,
669
- _found,
670
- _net,
671
- _network,
672
- _network_id,
673
- _networks,
674
- _version,
675
- _msg;
676
- _networks =
677
- [];
678
- const
679
- _contract =
680
- target_contract;
681
- _found =
682
- false;
683
- if ( configuration_format == "bash" ) {
684
- _config_ext =
685
- "sh";
686
- }
687
- else if ( configuration_format == "bash" ) {
688
- _config_ext =
689
- "json";
690
- }
691
- const
692
- _contract_type =
693
- typeof(
694
- _contract);
695
- if ( _contract != "" &&
696
- _contract_type != "undefined" ) {
697
- const
698
- _deployments_dir_type =
699
- typeof(
700
- deployments_dir);
701
- if ( _deployments_dir_type != "undefined" &&
702
- deployments_dir != "" ) {
703
- _deployments =
704
- deployments_dir;
705
- if ( 0 < target_networks.length ) {
706
- _network =
707
- target_networks[
708
- 0];
709
- }
710
- if ( 0 < network_ids.length ) {
711
- _network_id =
712
- _network_ids[
713
- 0];
714
- }
715
- const
716
- _deployments_path =
717
- _path_join( [
718
- _deployments,
719
- _contract ] );
720
- if ( networks_all == "n" ) {
721
- _networks.push(
722
- _network,
723
- _network_id);
724
- }
725
- else if ( networks_all == "y" ) {
726
- const
727
- _evm_contract_deployment_networks_args = [
728
- _deployments_path,
729
- "y", // Display all
730
- "n", // Display safest
731
- "n" // Display cheapest
732
- ];
733
- _networks_new =
734
- await _evm_contract_deployment_networks.apply(
735
- null,
736
- _evm_contract_deployment_networks_args);
737
- _networks =
738
- _networks.concat(
739
- _networks_new);
740
- }
741
- for ( _net of _networks ) {
742
- _config =
743
- _path_join( [
744
- _deployments_path,
745
- _net,
746
- `config.${_config_ext}`
747
- ]);
748
- if ( _file_exists(
749
- _config) ) {
750
- _found =
751
- true;
752
- _msg =
753
- `Found deployment configuration ` +
754
- `at location '${_config}'.`;
755
- _msg_info(
756
- _msg);
757
- break;
758
- }
759
- }
760
- if ( ! _found ) {
761
- _msg =
762
- "No deployment configuration " +
763
- "file found for network " +
764
- `'${_network}' with ID ` +
765
- `'${_network_id}'.`;
766
- _msg_error(
767
- _msg,
768
- 1);
769
- }
770
- const
771
- _evm_contract_deployment_versions_args = [
772
- _config,
773
- "y", // display highest
774
- "n", // display lowest
775
- configuration_format
776
- ];
777
- _version =
778
- await _evm_contract_deployment_versions.apply(
779
- null,
780
- _evm_contract_deployment_versions_args);
781
- }
782
- else if ( _deployments_dir_type == "undefined" ||
783
- deployments_dir == "" ) {
784
- const
785
- _msg =
786
- "If no target application is specified " +
787
- "then the user-defined deployments " +
788
- "switch must be enabled with '-u' and " +
789
- "a deployments directory must be specified " +
790
- "with '-d'.";
791
- _msg_error(
792
- _msg,
793
- 1);
794
- }
795
- }
796
- _override_set(
797
- "contract",
798
- "version",
799
- _version);
800
- return true;
801
- }
802
-
803
- function
804
- _networks_all_auto_detect() {
805
- let
806
- _networks_all;
807
- _networks_all =
808
- "n";
809
- if ( target_networks.length < 1 &&
810
- network_ids.length < 1 ) {
811
- _networks_all =
812
- "y";
813
- }
814
- _override_set(
815
- "networks",
816
- "all",
817
- _networks_all);
818
- }
819
-
820
- async function
821
- _target_app_auto_detect() {
822
- let
823
- _app;
824
- const
825
- _dir_current_name =
826
- _basename(
827
- _pwd());
828
- const
829
- _user_defined =
830
- user_defined;
831
- const
832
- _evm_contract_deployments_dir_args = [
833
- _dir_current_name,
834
- _user_defined
835
- ];
836
- const
837
- _target_dir =
838
- await _evm_contract_deployments_dir.apply(
839
- null,
840
- _evm_contract_deployments_dir_args);
841
- if ( _dir_exists(
842
- _target_dir) ) {
843
- _app =
844
- _dir_current_name;
429
+ _contracts_compiler_outputs.push(
430
+ _contract_compiler_output);
845
431
  }
846
- _override_set(
847
- "target",
848
- "app",
849
- _app);
432
+ return _contracts_compiler_outputs;
850
433
  }
851
434
 
852
435
  module.exports = {
@@ -854,8 +437,8 @@ module.exports = {
854
437
  _contract_version_auto_detect,
855
438
  _deployments_dir_auto_detect:
856
439
  _deployments_dir_auto_detect,
857
- _evm_contract_deployment_address:
858
- _evm_contract_deployment_address,
440
+ _evm_contract_deployment_compiler_output:
441
+ _evm_contract_deployment_compiler_output,
859
442
  _networks_all_auto_detect:
860
443
  _networks_all_auto_detect,
861
444
  _target_app_auto_detect: