evm-contracts-tools 0.0.62 → 0.0.64
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-abi/evm-contract-deployment-abi.js +1 -1
- package/dist/evm-contract-deployment-abi/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-bytecode/evm-contract-deployment-bytecode.js +1 -1
- package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -1
- package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +1 -1
- package/dist/evm-contract-deployment-compiler-output/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-abi/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.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-bytecode/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +1 -1
- package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -1
- package/dist/libevm-contract-deployment-compiler-output/libevm-contract-deployment-compiler-output.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/eslint.config.mjs +1 -1
- package/evm-contract-call +514 -172
- package/evm-contract-deployment-abi +16 -12
- package/evm-contract-deployment-address +15 -12
- package/evm-contract-deployment-bytecode +15 -12
- package/evm-contract-deployment-compiler-output +16 -13
- package/evm-contract-deployment-networks +15 -12
- package/evm-contract-deployment-versions +15 -12
- package/evm-contract-deployments-dir +16 -13
- package/evm-contracts-tools +14 -12
- package/lib/contract-get +169 -39
- package/lib/evm-contract-call-dynamic +1112 -361
- package/lib/evm-contract-call-static +463 -73
- package/libevm-contract-call +625 -435
- package/libevm-contract-deployment +4388 -481
- package/libevm-contract-deployment-abi +287 -91
- package/libevm-contract-deployment-address +27 -16
- package/libevm-contract-deployment-bytecode +275 -80
- package/libevm-contract-deployment-compiler-output +341 -93
- package/libevm-contract-deployments-dir +53 -50
- package/package.json +11 -11
package/evm-contract-call
CHANGED
|
@@ -2,27 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* evm-contract-call
|
|
7
|
-
*
|
|
5
|
+
/** ----------------------------------------------------------
|
|
6
|
+
* evm-contract-call
|
|
7
|
+
* ----------------------------------------------------------
|
|
8
8
|
* Copyright ©
|
|
9
9
|
* Pellegrino Prevete
|
|
10
10
|
* 2024, 2025, 2026
|
|
11
11
|
*
|
|
12
12
|
* All rights reserved
|
|
13
|
-
*
|
|
13
|
+
* ----------------------------------------------------------
|
|
14
14
|
*
|
|
15
|
-
* This program is free software: you can redistribute it
|
|
16
|
-
* modify it under the terms of the GNU General
|
|
17
|
-
* published by the Free Software
|
|
18
|
-
*
|
|
15
|
+
* This program is free software: you can redistribute it
|
|
16
|
+
* and/or modify it under the terms of the GNU General
|
|
17
|
+
* Public License as published by the Free Software
|
|
18
|
+
* Foundation, either version 3 of the License, or
|
|
19
|
+
* (at your option) any later version.
|
|
19
20
|
*
|
|
20
|
-
* This program is distributed in the hope that it will
|
|
21
|
-
* but WITHOUT ANY WARRANTY; without even the
|
|
22
|
-
* MERCHANTABILITY or FITNESS FOR A
|
|
23
|
-
*
|
|
21
|
+
* This program is distributed in the hope that it will
|
|
22
|
+
* be useful, but WITHOUT ANY WARRANTY; without even the
|
|
23
|
+
* implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE.
|
|
25
|
+
* See the GNU General Public License for more details.
|
|
24
26
|
*
|
|
25
|
-
* You should have received a copy of the
|
|
27
|
+
* You should have received a copy of the
|
|
28
|
+
* GNU General Public License
|
|
26
29
|
* along with this program.
|
|
27
30
|
* If not, see <https://www.gnu.org/licenses/>.
|
|
28
31
|
*/
|
|
@@ -191,6 +194,31 @@ const
|
|
|
191
194
|
const
|
|
192
195
|
_cache_dir_auto_detect =
|
|
193
196
|
_libevm_contract_call_module._cache_dir_auto_detect;
|
|
197
|
+
/* global
|
|
198
|
+
_call_auth_auto_detect */
|
|
199
|
+
const
|
|
200
|
+
_call_auth_auto_detect =
|
|
201
|
+
_libevm_contract_call_module._call_auth_auto_detect;
|
|
202
|
+
/* global
|
|
203
|
+
_contract_abi_auto_detect */
|
|
204
|
+
const
|
|
205
|
+
_contract_abi_auto_detect =
|
|
206
|
+
_libevm_contract_call_module._contract_abi_auto_detect;
|
|
207
|
+
/* global
|
|
208
|
+
_contract_address_auto_detect */
|
|
209
|
+
const
|
|
210
|
+
_contract_address_auto_detect =
|
|
211
|
+
_libevm_contract_call_module._contract_address_auto_detect;
|
|
212
|
+
/* global
|
|
213
|
+
_contract_bytecode_auto_detect */
|
|
214
|
+
const
|
|
215
|
+
_contract_bytecode_auto_detect =
|
|
216
|
+
_libevm_contract_call_module._contract_bytecode_auto_detect;
|
|
217
|
+
/* global
|
|
218
|
+
_contract_compiler_output_auto_detect */
|
|
219
|
+
const
|
|
220
|
+
_contract_compiler_output_auto_detect =
|
|
221
|
+
_libevm_contract_call_module._contract_compiler_output_auto_detect;
|
|
194
222
|
/* global
|
|
195
223
|
_data_dir_auto_detect */
|
|
196
224
|
const
|
|
@@ -202,30 +230,25 @@ const
|
|
|
202
230
|
_default_artifact_path_get =
|
|
203
231
|
_libevm_contract_call_module._default_artifact_path_get;
|
|
204
232
|
/* global
|
|
205
|
-
|
|
233
|
+
_deployments_dir_auto_detect */
|
|
206
234
|
const
|
|
207
|
-
|
|
208
|
-
_libevm_contract_call_module.
|
|
235
|
+
_deployments_dir_auto_detect =
|
|
236
|
+
_libevm_contract_call_module._deployments_dir_auto_detect;
|
|
209
237
|
/* global
|
|
210
238
|
_evm_contract_call */
|
|
211
239
|
const
|
|
212
240
|
_evm_contract_call =
|
|
213
241
|
_libevm_contract_call_module._evm_contract_call;
|
|
214
242
|
/* global
|
|
215
|
-
|
|
243
|
+
_help_display_check */
|
|
216
244
|
const
|
|
217
|
-
|
|
218
|
-
_libevm_contract_call_module.
|
|
245
|
+
_help_display_check =
|
|
246
|
+
_libevm_contract_call_module._help_display_check;
|
|
219
247
|
/* global
|
|
220
248
|
_target_app_auto_detect */
|
|
221
249
|
const
|
|
222
250
|
_target_app_auto_detect =
|
|
223
251
|
_libevm_contract_call_module._target_app_auto_detect;
|
|
224
|
-
/* global
|
|
225
|
-
_contract_address_auto_detect */
|
|
226
|
-
const
|
|
227
|
-
_contract_address_auto_detect =
|
|
228
|
-
_libevm_contract_call_module._contract_address_auto_detect;
|
|
229
252
|
/* global
|
|
230
253
|
_target_contract_auto_detect */
|
|
231
254
|
const
|
|
@@ -304,6 +327,13 @@ function
|
|
|
304
327
|
"call",
|
|
305
328
|
"type",
|
|
306
329
|
"");
|
|
330
|
+
/* global
|
|
331
|
+
output_file:
|
|
332
|
+
writable */
|
|
333
|
+
_set(
|
|
334
|
+
"output",
|
|
335
|
+
"file",
|
|
336
|
+
"");
|
|
307
337
|
/* global
|
|
308
338
|
index_retrieve:
|
|
309
339
|
writable */
|
|
@@ -395,14 +425,282 @@ function
|
|
|
395
425
|
"";
|
|
396
426
|
}
|
|
397
427
|
|
|
428
|
+
async function
|
|
429
|
+
_artifacts_auto_detect() {
|
|
430
|
+
let
|
|
431
|
+
_contract_abi,
|
|
432
|
+
_contract_bytecode,
|
|
433
|
+
_msg;
|
|
434
|
+
const
|
|
435
|
+
_global =
|
|
436
|
+
_global_get();
|
|
437
|
+
const
|
|
438
|
+
_quiet =
|
|
439
|
+
_global[
|
|
440
|
+
"quiet"];
|
|
441
|
+
_contract_abi =
|
|
442
|
+
_get(
|
|
443
|
+
"contract",
|
|
444
|
+
"abi");
|
|
445
|
+
_contract_bytecode =
|
|
446
|
+
_get(
|
|
447
|
+
"contract",
|
|
448
|
+
"bytecode");
|
|
449
|
+
const
|
|
450
|
+
_contract_compiler_output =
|
|
451
|
+
_get(
|
|
452
|
+
"contract",
|
|
453
|
+
"compiler_output");
|
|
454
|
+
const
|
|
455
|
+
_contract_address =
|
|
456
|
+
_get(
|
|
457
|
+
"contract",
|
|
458
|
+
"address");
|
|
459
|
+
const
|
|
460
|
+
_target_contract =
|
|
461
|
+
_get(
|
|
462
|
+
"target",
|
|
463
|
+
"contract");
|
|
464
|
+
const
|
|
465
|
+
_contract_address_type =
|
|
466
|
+
typeof(
|
|
467
|
+
_contract_address);
|
|
468
|
+
const
|
|
469
|
+
_contract_abi_type =
|
|
470
|
+
typeof(
|
|
471
|
+
_contract_abi);
|
|
472
|
+
const
|
|
473
|
+
_contract_bytecode_type =
|
|
474
|
+
typeof(
|
|
475
|
+
_contract_bytecode);
|
|
476
|
+
const
|
|
477
|
+
_contract_compiler_output_type =
|
|
478
|
+
typeof(
|
|
479
|
+
_contract_compiler_output);
|
|
480
|
+
if ( _contract_address_type !== "undefined" &&
|
|
481
|
+
_contract_address_type === "string" ) {
|
|
482
|
+
if ( 0 < _contract_address.length ) {
|
|
483
|
+
if ( _contract_abi_type === "array" ) {
|
|
484
|
+
_msg =
|
|
485
|
+
"Contract ABI with type " +
|
|
486
|
+
"array not implemented.";
|
|
487
|
+
_msg_error(
|
|
488
|
+
_msg,
|
|
489
|
+
0);
|
|
490
|
+
throw _msg;
|
|
491
|
+
}
|
|
492
|
+
else if ( _contract_abi_type === "string" ) {
|
|
493
|
+
if ( 0 < _contract_abi.length ) {
|
|
494
|
+
_msg =
|
|
495
|
+
"Selecting contract ABI:";
|
|
496
|
+
_msg_info(
|
|
497
|
+
_msg);
|
|
498
|
+
if ( _quiet == "n" ) {
|
|
499
|
+
_echo(
|
|
500
|
+
_contract_abi);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
_msg =
|
|
505
|
+
"Specified no contract ABI " +
|
|
506
|
+
`for contract '${_target_contract}' ` +
|
|
507
|
+
`and address '${_contract_address}', ` +
|
|
508
|
+
"auto-detecting.";
|
|
509
|
+
_msg_info(
|
|
510
|
+
_msg);
|
|
511
|
+
try {
|
|
512
|
+
await _contract_abi_auto_detect();
|
|
513
|
+
}
|
|
514
|
+
catch(
|
|
515
|
+
_error) {
|
|
516
|
+
_msg =
|
|
517
|
+
"Error auto-detecting contract ABI.";
|
|
518
|
+
_msg_error(
|
|
519
|
+
_msg,
|
|
520
|
+
0);
|
|
521
|
+
throw _error;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
_msg =
|
|
527
|
+
`Unknown type '${_contract_abi_type}' ` +
|
|
528
|
+
`for contract ABI (must be string).`;
|
|
529
|
+
_msg_error(
|
|
530
|
+
_msg,
|
|
531
|
+
0);
|
|
532
|
+
throw _msg;
|
|
533
|
+
}
|
|
534
|
+
_contract_abi =
|
|
535
|
+
_get(
|
|
536
|
+
"contract",
|
|
537
|
+
"abi");
|
|
538
|
+
if ( _contract_bytecode_type === "array" ) {
|
|
539
|
+
_msg =
|
|
540
|
+
"Contract bytecode with type " +
|
|
541
|
+
"array not implemented.";
|
|
542
|
+
_msg_error(
|
|
543
|
+
_msg,
|
|
544
|
+
0);
|
|
545
|
+
throw _msg;
|
|
546
|
+
}
|
|
547
|
+
else if ( _contract_bytecode_type === "string" ) {
|
|
548
|
+
if ( 0 < _contract_bytecode.length ) {
|
|
549
|
+
_msg =
|
|
550
|
+
"Selecting contract Bytecode:";
|
|
551
|
+
_msg_info(
|
|
552
|
+
_msg);
|
|
553
|
+
if ( _quiet == "n" ) {
|
|
554
|
+
_echo(
|
|
555
|
+
_contract_bytecode);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
_msg =
|
|
560
|
+
"Specified no contract bytecode " +
|
|
561
|
+
`for contract '${_target_contract}' ` +
|
|
562
|
+
`and address '${_contract_address}', ` +
|
|
563
|
+
"auto-detecting.";
|
|
564
|
+
_msg_info(
|
|
565
|
+
_msg);
|
|
566
|
+
try {
|
|
567
|
+
await _contract_bytecode_auto_detect();
|
|
568
|
+
}
|
|
569
|
+
catch(
|
|
570
|
+
_error) {
|
|
571
|
+
_msg =
|
|
572
|
+
"Error running " +
|
|
573
|
+
"'_contract_bytecode_auto_detect'.";
|
|
574
|
+
_msg_error(
|
|
575
|
+
_msg,
|
|
576
|
+
0);
|
|
577
|
+
throw _error;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
_msg =
|
|
583
|
+
`Unknown type '${_contract_bytecode_type}' ` +
|
|
584
|
+
`for contract bytecode (must be string).`;
|
|
585
|
+
_msg_error(
|
|
586
|
+
_msg,
|
|
587
|
+
0);
|
|
588
|
+
throw _msg;
|
|
589
|
+
}
|
|
590
|
+
_contract_bytecode =
|
|
591
|
+
_get(
|
|
592
|
+
"contract",
|
|
593
|
+
"bytecode");
|
|
594
|
+
if ( _contract_compiler_output_type === "array" ) {
|
|
595
|
+
_msg =
|
|
596
|
+
"Contract compiler output with type " +
|
|
597
|
+
"array not implemented.";
|
|
598
|
+
_msg_error(
|
|
599
|
+
_msg,
|
|
600
|
+
0);
|
|
601
|
+
throw _msg;
|
|
602
|
+
}
|
|
603
|
+
else if ( _contract_compiler_output_type === "string" ) {
|
|
604
|
+
if ( 0 < _contract_compiler_output.length ) {
|
|
605
|
+
_msg =
|
|
606
|
+
"Selecting contract compiler output:";
|
|
607
|
+
_msg_info(
|
|
608
|
+
_msg);
|
|
609
|
+
if ( _quiet == "n" ) {
|
|
610
|
+
_echo(
|
|
611
|
+
_contract_compiler_output);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
_msg =
|
|
616
|
+
"Specified no contract compiler output " +
|
|
617
|
+
`for contract '${_target_contract}' ` +
|
|
618
|
+
`and address '${_contract_address}', ` +
|
|
619
|
+
"auto-detecting.";
|
|
620
|
+
_msg_info(
|
|
621
|
+
_msg);
|
|
622
|
+
try {
|
|
623
|
+
await _contract_compiler_output_auto_detect();
|
|
624
|
+
}
|
|
625
|
+
catch(
|
|
626
|
+
_error) {
|
|
627
|
+
let
|
|
628
|
+
_error_info;
|
|
629
|
+
_error_info =
|
|
630
|
+
false;
|
|
631
|
+
_msg =
|
|
632
|
+
"Error auto-detecting contract compiler output.";
|
|
633
|
+
if ( _contract_abi !== "" &&
|
|
634
|
+
_contract_bytecode !== "" ) {
|
|
635
|
+
_error_info =
|
|
636
|
+
true;
|
|
637
|
+
}
|
|
638
|
+
if ( _error_info ) {
|
|
639
|
+
_msg_info(
|
|
640
|
+
_msg);
|
|
641
|
+
_msg =
|
|
642
|
+
"Performing call using ABI and " +
|
|
643
|
+
"and bytecode.";
|
|
644
|
+
_msg_info(
|
|
645
|
+
_msg);
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
_msg_error(
|
|
649
|
+
_msg,
|
|
650
|
+
0);
|
|
651
|
+
_msg =
|
|
652
|
+
"Either one between the contract abi " +
|
|
653
|
+
"plus the bytecode or the contract " +
|
|
654
|
+
"compiler output must be available " +
|
|
655
|
+
"to perform a call.";
|
|
656
|
+
_msg_error(
|
|
657
|
+
_msg,
|
|
658
|
+
0);
|
|
659
|
+
throw _error;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
_msg =
|
|
666
|
+
`Unknown type '${_contract_compiler_output_type}' ` +
|
|
667
|
+
`for contract compiler output (must be string).`;
|
|
668
|
+
_msg_error(
|
|
669
|
+
_msg,
|
|
670
|
+
0);
|
|
671
|
+
throw _msg;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
_msg =
|
|
676
|
+
"No address in input, artifacts detection " +
|
|
677
|
+
"skipped.";
|
|
678
|
+
_msg_info(
|
|
679
|
+
_msg);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
_msg =
|
|
684
|
+
`Uknown type for contract address (type ` +
|
|
685
|
+
`'${_contract_address_type}'):`;
|
|
686
|
+
_msg_error(
|
|
687
|
+
_msg,
|
|
688
|
+
0);
|
|
689
|
+
_echo2(
|
|
690
|
+
_contract_address);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
398
694
|
async function
|
|
399
695
|
_overrides_set(
|
|
400
696
|
_help_display) {
|
|
401
697
|
let
|
|
402
698
|
_address_valid,
|
|
403
|
-
_contract_abi,
|
|
404
699
|
_contract_address,
|
|
405
700
|
_msg;
|
|
701
|
+
_help_display =
|
|
702
|
+
_help_display_check(
|
|
703
|
+
_help_display);
|
|
406
704
|
const
|
|
407
705
|
_global =
|
|
408
706
|
_global_get();
|
|
@@ -431,6 +729,10 @@ async function
|
|
|
431
729
|
"call",
|
|
432
730
|
"date",
|
|
433
731
|
_get_date_human());
|
|
732
|
+
_override_set(
|
|
733
|
+
"output",
|
|
734
|
+
"file",
|
|
735
|
+
"");
|
|
434
736
|
_override_set(
|
|
435
737
|
"wallet",
|
|
436
738
|
"name",
|
|
@@ -460,37 +762,81 @@ async function
|
|
|
460
762
|
"msg",
|
|
461
763
|
"value",
|
|
462
764
|
"0");
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// await _target_networks_auto_detect();
|
|
765
|
+
const
|
|
766
|
+
_wallet_overrides_set_args = [
|
|
767
|
+
"evm-wallet",
|
|
768
|
+
wallet_name,
|
|
769
|
+
call_auth,
|
|
770
|
+
"n", // qr support
|
|
771
|
+
_target_networks
|
|
772
|
+
];
|
|
472
773
|
try {
|
|
473
|
-
await
|
|
774
|
+
await _wallet_overrides_set.apply(
|
|
775
|
+
null,
|
|
776
|
+
_wallet_overrides_set_args);
|
|
474
777
|
}
|
|
475
778
|
catch(
|
|
476
779
|
_error) {
|
|
477
780
|
_msg =
|
|
478
|
-
"Error
|
|
781
|
+
"Error running '_wallet_overrides_set' " +
|
|
782
|
+
"with arguments:";
|
|
479
783
|
_msg_error(
|
|
480
784
|
_msg,
|
|
481
785
|
0);
|
|
482
786
|
_echo2(
|
|
483
|
-
|
|
484
|
-
throw _error;
|
|
787
|
+
_error);
|
|
788
|
+
throw _error;
|
|
485
789
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
790
|
+
if ( ! _help_display ) {
|
|
791
|
+
try {
|
|
792
|
+
await _target_app_auto_detect();
|
|
793
|
+
}
|
|
794
|
+
catch(
|
|
795
|
+
_error) {
|
|
796
|
+
_msg =
|
|
797
|
+
"Error auto-detecting target application.";
|
|
798
|
+
_msg_error(
|
|
799
|
+
_msg,
|
|
800
|
+
0);
|
|
801
|
+
throw _error;
|
|
802
|
+
}
|
|
803
|
+
try {
|
|
804
|
+
await _deployments_dir_auto_detect();
|
|
805
|
+
}
|
|
806
|
+
catch(
|
|
807
|
+
_error) {
|
|
808
|
+
_msg =
|
|
809
|
+
"Error auto-detecting deployments directory.";
|
|
810
|
+
_msg_error(
|
|
811
|
+
_msg,
|
|
812
|
+
0);
|
|
813
|
+
throw _error;
|
|
814
|
+
}
|
|
815
|
+
try {
|
|
816
|
+
await _target_contract_auto_detect();
|
|
817
|
+
}
|
|
818
|
+
catch(
|
|
819
|
+
_error) {
|
|
820
|
+
_msg =
|
|
821
|
+
"Error auto-detecting target contract.";
|
|
822
|
+
_msg_error(
|
|
823
|
+
_msg,
|
|
824
|
+
0);
|
|
825
|
+
throw _error;
|
|
826
|
+
}
|
|
827
|
+
try {
|
|
828
|
+
await _contract_address_auto_detect();
|
|
829
|
+
}
|
|
830
|
+
catch(
|
|
831
|
+
_error) {
|
|
832
|
+
_msg =
|
|
833
|
+
"Error auto-detecting contract address.";
|
|
834
|
+
_msg_error(
|
|
835
|
+
_msg,
|
|
836
|
+
0);
|
|
837
|
+
throw _error;
|
|
838
|
+
}
|
|
839
|
+
// await _target_networks_auto_detect();
|
|
494
840
|
try {
|
|
495
841
|
_contract_address =
|
|
496
842
|
_get(
|
|
@@ -522,96 +868,26 @@ async function
|
|
|
522
868
|
0);
|
|
523
869
|
throw _msg;
|
|
524
870
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
_contract_address =
|
|
536
|
-
_get(
|
|
537
|
-
"contract",
|
|
538
|
-
"address");
|
|
539
|
-
const
|
|
540
|
-
_target_contract =
|
|
541
|
-
_get(
|
|
542
|
-
"target",
|
|
543
|
-
"contract");
|
|
544
|
-
const
|
|
545
|
-
_contract_address_type =
|
|
546
|
-
typeof(
|
|
547
|
-
_contract_address);
|
|
548
|
-
const
|
|
549
|
-
_contract_abi_type =
|
|
550
|
-
typeof(
|
|
551
|
-
_contract_abi);
|
|
552
|
-
if ( _contract_address_type !== "undefined" &&
|
|
553
|
-
_contract_address != "" ) {
|
|
554
|
-
if ( _contract_abi_type === "array" ) {
|
|
871
|
+
_override_set(
|
|
872
|
+
"index",
|
|
873
|
+
"retrieve",
|
|
874
|
+
"n");
|
|
875
|
+
// _api_key_auto_detect();
|
|
876
|
+
try {
|
|
877
|
+
await _artifacts_auto_detect();
|
|
878
|
+
}
|
|
879
|
+
catch(
|
|
880
|
+
_error) {
|
|
555
881
|
_msg =
|
|
556
|
-
"
|
|
882
|
+
"Error running '_artifacts_auto_detect'.";
|
|
557
883
|
_msg_error(
|
|
558
884
|
_msg,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
_msg =
|
|
564
|
-
"Contract ABI:";
|
|
565
|
-
_msg_error(
|
|
566
|
-
_msg,
|
|
567
|
-
0);
|
|
568
|
-
_echo2(
|
|
569
|
-
_contract_abi);
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
_msg =
|
|
573
|
-
"Specified no contract ABI " +
|
|
574
|
-
`for contract '${_target_contract}' ` +
|
|
575
|
-
`and address'${_contract_address}',` +
|
|
576
|
-
"auto-detecting.";
|
|
577
|
-
_msg_info(
|
|
578
|
-
_msg);
|
|
579
|
-
try {
|
|
580
|
-
_contract_abi =
|
|
581
|
-
await _default_artifact_path_get(
|
|
582
|
-
"abi");
|
|
583
|
-
await _artifact_local_auto_detect(
|
|
584
|
-
"bytecode");
|
|
585
|
-
await _artifact_local_auto_detect(
|
|
586
|
-
"compiler_output");
|
|
587
|
-
if ( _contract_abi == "" ||
|
|
588
|
-
_default_artifact_path_get(
|
|
589
|
-
"abi") == _contract_abi ) {
|
|
590
|
-
await _contract_abi_auto_detect();
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
catch(
|
|
594
|
-
_error) {
|
|
595
|
-
_msg =
|
|
596
|
-
"Sigh.";
|
|
597
|
-
_msg_error(
|
|
598
|
-
_msg,
|
|
599
|
-
0);
|
|
600
|
-
throw _error;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
885
|
+
0);
|
|
886
|
+
_echo2(
|
|
887
|
+
_error);
|
|
888
|
+
throw _error;
|
|
603
889
|
}
|
|
604
890
|
}
|
|
605
|
-
else {
|
|
606
|
-
_msg =
|
|
607
|
-
`Contract address (type ` +
|
|
608
|
-
`'${_contract_address_type}'):`;
|
|
609
|
-
_msg_error(
|
|
610
|
-
_msg,
|
|
611
|
-
0);
|
|
612
|
-
_echo2(
|
|
613
|
-
_contract_address);
|
|
614
|
-
}
|
|
615
891
|
}
|
|
616
892
|
|
|
617
893
|
function
|
|
@@ -699,6 +975,12 @@ function
|
|
|
699
975
|
" -t --call-type It can be 'static' or 'dynamic'.",
|
|
700
976
|
` <call-type> Default: '${call_type}`,
|
|
701
977
|
"",
|
|
978
|
+
" -o --output-file If specified saves the call output",
|
|
979
|
+
" <file-path> at the specified location, otherwise it",
|
|
980
|
+
" will print it on stdout.",
|
|
981
|
+
` Default: '${output_file}`,
|
|
982
|
+
"",
|
|
983
|
+
" -t --call-type It can be 'static' or 'dynamic'.",
|
|
702
984
|
" call options:",
|
|
703
985
|
` -V --msg-value How much '${measure_unit} to attach to the`,
|
|
704
986
|
` <msg-value> transaction.`,
|
|
@@ -794,6 +1076,7 @@ async function
|
|
|
794
1076
|
_cmdline_parse() {
|
|
795
1077
|
let
|
|
796
1078
|
_help_display,
|
|
1079
|
+
_method_args,
|
|
797
1080
|
_msg,
|
|
798
1081
|
_network,
|
|
799
1082
|
_target_networks_set;
|
|
@@ -889,15 +1172,31 @@ async function
|
|
|
889
1172
|
"method",
|
|
890
1173
|
_argv[
|
|
891
1174
|
"_"][
|
|
892
|
-
|
|
1175
|
+
1]);
|
|
1176
|
+
try {
|
|
1177
|
+
const
|
|
1178
|
+
_args_length =
|
|
1179
|
+
_argv[
|
|
1180
|
+
"_"].length;
|
|
1181
|
+
_method_args =
|
|
1182
|
+
await _argv[
|
|
1183
|
+
"_"].slice(
|
|
1184
|
+
2,
|
|
1185
|
+
_args_length);
|
|
1186
|
+
}
|
|
1187
|
+
catch(
|
|
1188
|
+
_error) {
|
|
1189
|
+
_msg =
|
|
1190
|
+
"Error slicing '_argv'.";
|
|
1191
|
+
_msg_error(
|
|
1192
|
+
_msg,
|
|
1193
|
+
0);
|
|
1194
|
+
throw _error;
|
|
1195
|
+
}
|
|
893
1196
|
_set(
|
|
894
1197
|
"method",
|
|
895
1198
|
"args",
|
|
896
|
-
|
|
897
|
-
"_"].slice(
|
|
898
|
-
2,
|
|
899
|
-
_argv[
|
|
900
|
-
"_"].length - 2));
|
|
1199
|
+
_method_args);
|
|
901
1200
|
if ( "t" in _argv ) {
|
|
902
1201
|
_set(
|
|
903
1202
|
"call",
|
|
@@ -912,6 +1211,20 @@ async function
|
|
|
912
1211
|
_argv[
|
|
913
1212
|
"call-type"]);
|
|
914
1213
|
}
|
|
1214
|
+
if ( "o" in _argv ) {
|
|
1215
|
+
_set(
|
|
1216
|
+
"output",
|
|
1217
|
+
"file",
|
|
1218
|
+
_argv[
|
|
1219
|
+
"o"]);
|
|
1220
|
+
}
|
|
1221
|
+
if ( "output-file" in _argv ) {
|
|
1222
|
+
_set(
|
|
1223
|
+
"output",
|
|
1224
|
+
"file",
|
|
1225
|
+
_argv[
|
|
1226
|
+
"output-file"]);
|
|
1227
|
+
}
|
|
915
1228
|
if ( "T" in _argv ) {
|
|
916
1229
|
_set(
|
|
917
1230
|
"call",
|
|
@@ -1265,12 +1578,23 @@ async function
|
|
|
1265
1578
|
_app_opts) {
|
|
1266
1579
|
let
|
|
1267
1580
|
_msg,
|
|
1268
|
-
|
|
1581
|
+
_result,
|
|
1582
|
+
_results,
|
|
1583
|
+
_results_list,
|
|
1584
|
+
_results_type;
|
|
1269
1585
|
try {
|
|
1270
1586
|
_results =
|
|
1271
1587
|
await _evm_contract_call.apply(
|
|
1272
1588
|
null,
|
|
1273
1589
|
_app_opts);
|
|
1590
|
+
_results_type =
|
|
1591
|
+
typeof(
|
|
1592
|
+
_results);
|
|
1593
|
+
_msg =
|
|
1594
|
+
`Got results '${_results}' ` +
|
|
1595
|
+
`(type '${_results_type}').`;
|
|
1596
|
+
_msg_info(
|
|
1597
|
+
_msg);
|
|
1274
1598
|
}
|
|
1275
1599
|
catch(
|
|
1276
1600
|
_error) {
|
|
@@ -1280,41 +1604,47 @@ async function
|
|
|
1280
1604
|
_msg_error(
|
|
1281
1605
|
_msg,
|
|
1282
1606
|
0);
|
|
1283
|
-
_echo(
|
|
1284
|
-
_msg);
|
|
1285
1607
|
_echo2(
|
|
1286
1608
|
_error);
|
|
1287
1609
|
throw _error;
|
|
1288
1610
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1611
|
+
if ( _results_type == "array" ) {
|
|
1612
|
+
for ( _result of _results ) {
|
|
1613
|
+
await _printf(
|
|
1614
|
+
_result);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
else if ( _results_type == "object" ) {
|
|
1618
|
+
for ( _result in _results ) {
|
|
1619
|
+
_msg =
|
|
1620
|
+
`Got result '${_result}':`;
|
|
1621
|
+
_msg_info(
|
|
1622
|
+
_msg);
|
|
1623
|
+
await _printf(
|
|
1624
|
+
_results[
|
|
1625
|
+
_result]);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
else if ( _results_type == "string" ) {
|
|
1629
|
+
_printf(
|
|
1630
|
+
_results);
|
|
1631
|
+
}
|
|
1632
|
+
else if ( _results_type == "undefined" ) {
|
|
1633
|
+
_msg =
|
|
1634
|
+
"No results";
|
|
1635
|
+
_msg_error(
|
|
1636
|
+
_msg,
|
|
1637
|
+
0);
|
|
1638
|
+
throw _msg;
|
|
1639
|
+
}
|
|
1640
|
+
else {
|
|
1641
|
+
_msg =
|
|
1642
|
+
`Result type '${_results_type}'.`;
|
|
1643
|
+
_msg_error(
|
|
1644
|
+
_msg,
|
|
1645
|
+
0);
|
|
1646
|
+
throw _msg;
|
|
1647
|
+
}
|
|
1318
1648
|
return _results;
|
|
1319
1649
|
}
|
|
1320
1650
|
|
|
@@ -1388,6 +1718,15 @@ async function
|
|
|
1388
1718
|
_cmdline_out =
|
|
1389
1719
|
await _evm_contract_call_cmdline(
|
|
1390
1720
|
_app_opts);
|
|
1721
|
+
_msg =
|
|
1722
|
+
"Done running '_evm_contract_call_cmdline' " +
|
|
1723
|
+
`with parameters:`;
|
|
1724
|
+
_msg_info(
|
|
1725
|
+
_msg);
|
|
1726
|
+
if ( _quiet == "n" ) {
|
|
1727
|
+
_echo(
|
|
1728
|
+
_app_opts);
|
|
1729
|
+
}
|
|
1391
1730
|
}
|
|
1392
1731
|
catch(
|
|
1393
1732
|
_error) {
|
|
@@ -1401,23 +1740,26 @@ async function
|
|
|
1401
1740
|
_error);
|
|
1402
1741
|
throw _error;
|
|
1403
1742
|
}
|
|
1743
|
+
_exit(
|
|
1744
|
+
0);
|
|
1404
1745
|
return _cmdline_out;
|
|
1405
1746
|
}
|
|
1406
1747
|
|
|
1407
|
-
_global_variables();
|
|
1408
|
-
_libevm_global_variables();
|
|
1409
1748
|
if ( await _cmdline_check(
|
|
1410
1749
|
"evm-contract-call.js") ||
|
|
1411
1750
|
await _cmdline_check(
|
|
1412
1751
|
"evm-contract-call") ||
|
|
1413
1752
|
await _cmdline_check(
|
|
1414
1753
|
"./evm-contract-call") ) {
|
|
1754
|
+
_global_variables();
|
|
1755
|
+
_libevm_global_variables();
|
|
1415
1756
|
await _cmdline_parse();
|
|
1416
1757
|
}
|
|
1417
|
-
else{
|
|
1758
|
+
else {
|
|
1418
1759
|
_url_parse();
|
|
1419
1760
|
_libevm_url_parse();
|
|
1420
1761
|
}
|
|
1762
|
+
|
|
1421
1763
|
try {
|
|
1422
1764
|
await _main();
|
|
1423
1765
|
}
|