evm-contracts-tools 0.0.46 → 0.0.47

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 (38) 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/fs-worker.js +1 -0
  4. package/dist/evm-contract-deployment-abi/index.html +31 -0
  5. package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -0
  6. package/dist/evm-contract-deployment-bytecode/index.html +31 -0
  7. package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -0
  8. package/dist/evm-contract-deployment-compiler-output/index.html +31 -0
  9. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  10. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  11. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  12. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  13. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  14. package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -0
  15. package/dist/libevm-contract-deployment-abi/index.html +24 -0
  16. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +2 -0
  17. package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -0
  18. package/dist/libevm-contract-deployment-bytecode/index.html +24 -0
  19. package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -0
  20. package/dist/libevm-contract-deployment-compiler-output/index.html +24 -0
  21. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  22. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  23. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  24. package/evm-contract-call +44 -40
  25. package/evm-contract-deployment-abi +540 -0
  26. package/evm-contract-deployment-address +23 -18
  27. package/evm-contract-deployment-bytecode +540 -0
  28. package/evm-contract-deployment-compiler-output +540 -0
  29. package/lib/address-check +0 -0
  30. package/lib/evm-contract-call-dynamic +46 -17
  31. package/lib/evm-contract-call-static +0 -0
  32. package/libevm-contract-deployment-abi +465 -0
  33. package/libevm-contract-deployment-address +58 -372
  34. package/libevm-contract-deployment-bytecode +466 -0
  35. package/libevm-contract-deployment-compiler-output +863 -0
  36. package/package.json +44 -8
  37. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +0 -2
  38. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +0 -2
@@ -0,0 +1,863 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------
6
+ * libevm-contract-deployment-address
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the
26
+ * GNU General Public License
27
+ * along with this program.
28
+ * If not, see <https://www.gnu.org/licenses/>.
29
+ */
30
+
31
+ /* eslint-disable
32
+ no-unused-vars */
33
+ /* eslint-disable
34
+ no-useless-assignment */
35
+
36
+ /* EVM Contracts tools global variables */
37
+ /* global
38
+ call_type */
39
+ /* global
40
+ call_auth:
41
+ writable */
42
+
43
+ /* libEVM global variables */
44
+ /* global
45
+ api_key */
46
+ /* global
47
+ contract_abi:
48
+ writable */
49
+ /* global
50
+ contract_address */
51
+ /* global
52
+ contract_bytecode:
53
+ writable */
54
+ /* global
55
+ contract_compiler_output:
56
+ writable */
57
+ /* global
58
+ target_network:
59
+ writable */
60
+ /* global
61
+ target_networks:
62
+ writable */
63
+
64
+ const
65
+ _libcrash_module =
66
+ require(
67
+ "crash-js");
68
+ /* global
69
+ _basename */
70
+ const
71
+ _basename =
72
+ _libcrash_module._basename;
73
+ /* global
74
+ _chmod */
75
+ const
76
+ _chmod =
77
+ _libcrash_module._chmod;
78
+ /* global
79
+ _cp */
80
+ /* eslint-disable-next-line
81
+ no-global-assign */
82
+ const
83
+ _cp =
84
+ _libcrash_module._cp;
85
+ /* global
86
+ _dir_exists */
87
+ const
88
+ _dir_exists =
89
+ _libcrash_module._dir_exists;
90
+ /* global
91
+ _file_exists */
92
+ const
93
+ _file_exists =
94
+ _libcrash_module._file_exists;
95
+ /* global
96
+ _file_read */
97
+ /* eslint-disable-next-line
98
+ no-global-assign */
99
+ const
100
+ _file_read =
101
+ _libcrash_module._file_read;
102
+ /* global
103
+ _from_bash_ass_array */
104
+ /* eslint-disable-next-line
105
+ no-global-assign */
106
+ const
107
+ _from_bash_ass_array =
108
+ _libcrash_module._from_bash_ass_array;
109
+ /* global
110
+ _homedir_get */
111
+ /* eslint-disable-next-line
112
+ no-global-assign */
113
+ const
114
+ _homedir_get =
115
+ _libcrash_module._homedir_get;
116
+ /* global
117
+ _json_read */
118
+ /* eslint-disable-next-line
119
+ no-global-assign */
120
+ const
121
+ _json_read =
122
+ _libcrash_module._json_read;
123
+ /* global
124
+ _lib_get */
125
+ /* eslint-disable-next-line
126
+ no-global-assign */
127
+ const
128
+ _lib_get =
129
+ _libcrash_module._lib_get;
130
+ /* global
131
+ _mkdir */
132
+ /* eslint-disable-next-line
133
+ no-global-assign */
134
+ const
135
+ _mkdir =
136
+ _libcrash_module._mkdir;
137
+ /* global
138
+ _msg_info */
139
+ /* eslint-disable-next-line
140
+ no-global-assign */
141
+ const
142
+ _msg_info =
143
+ _libcrash_module._msg_info;
144
+ /* global
145
+ _msg_error */
146
+ /* eslint-disable-next-line
147
+ no-global-assign */
148
+ const
149
+ _msg_error =
150
+ _libcrash_module._msg_error;
151
+ /* global
152
+ _override_set */
153
+ const
154
+ _override_set =
155
+ _libcrash_module._override_set;
156
+ /* global
157
+ _path_join */
158
+ /* eslint-disable-next-line
159
+ no-global-assign */
160
+ const
161
+ _path_join =
162
+ _libcrash_module._path_join;
163
+ /* global
164
+ _pwd */
165
+ const
166
+ _pwd =
167
+ _libcrash_module._pwd;
168
+ const
169
+ _evm_chains_info_module =
170
+ require(
171
+ "evm-chains-info");
172
+ /* global
173
+ _evm_chains_info */
174
+ const
175
+ _evm_chains_info =
176
+ _evm_chains_info_module._evm_chains_info;
177
+ const
178
+ _libevm_contract_deployments_dir_module =
179
+ require(
180
+ "./libevm-contract-deployments-dir");
181
+ /* global
182
+ _evm_contract_deployments_dir */
183
+ const
184
+ _evm_contract_deployments_dir =
185
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
186
+ const
187
+ _libevm_contract_deployment_module =
188
+ require(
189
+ "./libevm-contract-deployment");
190
+ /* global
191
+ _contract_version_auto_detect */
192
+ const
193
+ _contract_version_auto_detect =
194
+ _libevm_contract_deployment._contract_version_auto_detect;
195
+ /* global
196
+ _deployments_dir_auto_detect */
197
+ const
198
+ _deployments_dir_auto_detect =
199
+ _libevm_contract_deployment._deployments_dir_auto_detect;
200
+ /* global
201
+ _network_check */
202
+ const
203
+ _network_check =
204
+ _libevm_contract_deployment._network_check;
205
+ /* global
206
+ _networks_all_auto_detect */
207
+ const
208
+ _networks_all_auto_detect =
209
+ _libevm_contract_deployment._networks_all_auto_detect;
210
+ /* global
211
+ _target_app_auto_detect */
212
+ const
213
+ _target_app_auto_detect =
214
+ _libevm_contract_deployment._target_app_auto_detect;
215
+ /* global
216
+ _user_deployments_check */
217
+ const
218
+ _user_deployments_check =
219
+ _libevm_contract_deployment._user_deployments_check;
220
+ const
221
+ _libevm_contract_deployment_networks_module =
222
+ require(
223
+ "./libevm-contract-deployment-networks");
224
+ /* global
225
+ _evm_contract_deployment_networks */
226
+ const
227
+ _evm_contract_deployment_networks =
228
+ _libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
229
+ const
230
+ _libevm_contract_deployment_versions_module =
231
+ require(
232
+ "./libevm-contract-deployment-versions");
233
+ /* global
234
+ _evm_contract_deployment_versions */
235
+ const
236
+ _evm_contract_deployment_versions =
237
+ _libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
238
+
239
+ function
240
+ _contract_compiler_output_get(
241
+ _deployments,
242
+ _contract,
243
+ _network,
244
+ _network_id,
245
+ _version,
246
+ _configuration_format) {
247
+ let
248
+ _compiler_output,
249
+ _compiler_output_path,
250
+ _found,
251
+ _msg,
252
+ _net;
253
+ const
254
+ _networks = [
255
+ _network,
256
+ _network_id
257
+ ];
258
+ _found =
259
+ false;
260
+ for ( _net of _networks ) {
261
+ _compiler_output_path =
262
+ _path_join( [
263
+ _deployments,
264
+ _contract,
265
+ _net,
266
+ `config.${_config_file_ext}` ]);
267
+ if ( _file_exists(
268
+ _config_path) ) {
269
+ _found =
270
+ true;
271
+ break;
272
+ }
273
+ }
274
+ if ( ! _found ) {
275
+ _msg =
276
+ `No network '${_network}' deployment ` +
277
+ `configuration for contract '${_contract}' ` +
278
+ `found at path '${_deployments}'.`;
279
+ _msg_error(
280
+ _msg,
281
+ 1);
282
+ }
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
+ const
299
+ _contract_address =
300
+ _config[
301
+ _key_name][
302
+ _version];
303
+ if ( _contract_address == "" ||
304
+ _contract_address == null ) {
305
+ _msg =
306
+ `No '${_contract}' version '${_version}' ` +
307
+ `contract deployment specified for network ` +
308
+ `'${_network}' for directory at path `+
309
+ `'${_deployments}'.`;
310
+ _msg_error(
311
+ _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
+ }
425
+ }
426
+ }
427
+
428
+ 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(
481
+ _target_networks,
482
+ _network_ids,
483
+ _networks_all,
484
+ _target_app,
485
+ _target_contract,
486
+ _contract_version,
487
+ _user_defined,
488
+ _configuration_format,
489
+ _deployments_dir) {
490
+ let
491
+ _args,
492
+ _contract_address,
493
+ _network,
494
+ _network_check_args,
495
+ _target_network,
496
+ _target_network_id,
497
+ _user_deployments_dir,
498
+ _system_deployments_dir,
499
+ _msg;
500
+ const
501
+ _contracts_addresses =
502
+ [];
503
+ const
504
+ _contract_address_get_args =
505
+ [];
506
+ if ( _user_defined == "n" ) {
507
+ if ( _target_app == "" ) {
508
+ _msg =
509
+ "A target application needs to " +
510
+ "be specified with option '-a' " +
511
+ "if not enabling user-defined " +
512
+ "deployments with '-u' and " +
513
+ "specifying a deployments directory " +
514
+ "path with '-d'.";
515
+ _msg_error(
516
+ _msg,
517
+ 1)
518
+ }
519
+ _system_deployments_dir =
520
+ await _evm_contract_deployments_dir(
521
+ _target_app,
522
+ _user_defined);
523
+ if ( _deployments_dir != _system_deployments_dir ) {
524
+ _msg =
525
+ "To set a custom deployments directory path " +
526
+ "you need to enable the user-defined " +
527
+ "deployments switch with '-u'." +
528
+ _msg_error(
529
+ _msg,
530
+ 1)
531
+ }
532
+ }
533
+ else if ( _user_defined == "y" ) {
534
+ if ( _target_app != "" ) {
535
+ _user_deployments_dir =
536
+ await _evm_contract_deployments_dir(
537
+ _target_app,
538
+ _user_defined);
539
+ }
540
+ if ( _deployments_dir != _user_deployments_dir ) {
541
+ _msg =
542
+ "Using custom deployments directory " +
543
+ `path '${_deployments_dir}'.`;
544
+ _msg_info(
545
+ _msg);
546
+ }
547
+ else {
548
+ _user_deployments_check(
549
+ _target_app,
550
+ _deployments_dir);
551
+ }
552
+ }
553
+ else {
554
+ _msg =
555
+ "The 'user-defined' switch argument " +
556
+ `can be 'y' or 'n', current value '${_user_defined}'.`;
557
+ _msg_error(
558
+ _msg,
559
+ 1);
560
+ }
561
+ if ( _networks_all == "y" ) {
562
+ _msg =
563
+ "Selecting all networks."
564
+ _msg_info(
565
+ _msg);
566
+ _target_networks =
567
+ await _evm_contract_deployment_networks(
568
+ `${_deployments_dir}/${_target_contract}`,
569
+ _networks_all);
570
+ }
571
+ for ( _network of _target_networks ) {
572
+ // _msg =
573
+ // "Info arguments for " +
574
+ // `network '${_network}'.`;
575
+ // _msg_info(
576
+ // _msg);
577
+ _target_network_id =
578
+ "";
579
+ _network_check_args = [
580
+ _deployments_dir,
581
+ _target_contract,
582
+ _network,
583
+ _target_network_id
584
+ ];
585
+ await _network_check.apply(
586
+ null,
587
+ _network_check_args);
588
+ _contract_address_get_args.push( [
589
+ _deployments_dir,
590
+ _target_contract,
591
+ _network,
592
+ _target_network_id,
593
+ _contract_version,
594
+ _configuration_format
595
+ ] );
596
+ }
597
+ for ( _network of _network_ids ) {
598
+ _target_network =
599
+ "";
600
+ _network_check_args = [
601
+ _deployments_dir,
602
+ _target_contract,
603
+ _target_network,
604
+ _network
605
+ ];
606
+ await _network_check.apply(
607
+ null,
608
+ _network_check_args);
609
+ _contract_address_get_args.push( [
610
+ _deployments_dir,
611
+ _target_contract,
612
+ _target_network,
613
+ _target_network_id,
614
+ _contract_version,
615
+ _configuration_format
616
+ ] );
617
+ }
618
+ for ( _args of _contract_address_get_args ) {
619
+ _contract_address =
620
+ _contract_address_get.apply(
621
+ null,
622
+ _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;
845
+ }
846
+ _override_set(
847
+ "target",
848
+ "app",
849
+ _app);
850
+ }
851
+
852
+ module.exports = {
853
+ _contract_version_auto_detect:
854
+ _contract_version_auto_detect,
855
+ _deployments_dir_auto_detect:
856
+ _deployments_dir_auto_detect,
857
+ _evm_contract_deployment_address:
858
+ _evm_contract_deployment_address,
859
+ _networks_all_auto_detect:
860
+ _networks_all_auto_detect,
861
+ _target_app_auto_detect:
862
+ _target_app_auto_detect
863
+ };