evm-contracts-tools 0.0.57 → 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/Makefile +9 -1
- 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 +707 -131
- 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 +651 -303
- package/libevm-contract-deployment +4408 -383
- package/libevm-contract-deployment-abi +287 -91
- package/libevm-contract-deployment-address +292 -56
- package/libevm-contract-deployment-bytecode +275 -80
- package/libevm-contract-deployment-compiler-output +341 -93
- package/libevm-contract-deployments-dir +53 -49
- package/package.json +14 -12
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
|
*/
|
|
@@ -88,6 +91,11 @@ const
|
|
|
88
91
|
const
|
|
89
92
|
_echo =
|
|
90
93
|
_libcrash._echo;
|
|
94
|
+
/* global
|
|
95
|
+
_echo2 */
|
|
96
|
+
const
|
|
97
|
+
_echo2 =
|
|
98
|
+
_libcrash._echo2;
|
|
91
99
|
/* global
|
|
92
100
|
_exit */
|
|
93
101
|
const
|
|
@@ -186,6 +194,31 @@ const
|
|
|
186
194
|
const
|
|
187
195
|
_cache_dir_auto_detect =
|
|
188
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;
|
|
189
222
|
/* global
|
|
190
223
|
_data_dir_auto_detect */
|
|
191
224
|
const
|
|
@@ -197,30 +230,30 @@ const
|
|
|
197
230
|
_default_artifact_path_get =
|
|
198
231
|
_libevm_contract_call_module._default_artifact_path_get;
|
|
199
232
|
/* global
|
|
200
|
-
|
|
233
|
+
_deployments_dir_auto_detect */
|
|
201
234
|
const
|
|
202
|
-
|
|
203
|
-
_libevm_contract_call_module.
|
|
235
|
+
_deployments_dir_auto_detect =
|
|
236
|
+
_libevm_contract_call_module._deployments_dir_auto_detect;
|
|
204
237
|
/* global
|
|
205
238
|
_evm_contract_call */
|
|
206
239
|
const
|
|
207
240
|
_evm_contract_call =
|
|
208
241
|
_libevm_contract_call_module._evm_contract_call;
|
|
209
242
|
/* global
|
|
210
|
-
|
|
243
|
+
_help_display_check */
|
|
211
244
|
const
|
|
212
|
-
|
|
213
|
-
_libevm_contract_call_module.
|
|
245
|
+
_help_display_check =
|
|
246
|
+
_libevm_contract_call_module._help_display_check;
|
|
214
247
|
/* global
|
|
215
248
|
_target_app_auto_detect */
|
|
216
249
|
const
|
|
217
250
|
_target_app_auto_detect =
|
|
218
251
|
_libevm_contract_call_module._target_app_auto_detect;
|
|
219
252
|
/* global
|
|
220
|
-
|
|
253
|
+
_target_contract_auto_detect */
|
|
221
254
|
const
|
|
222
|
-
|
|
223
|
-
_libevm_contract_call_module.
|
|
255
|
+
_target_contract_auto_detect =
|
|
256
|
+
_libevm_contract_call_module._target_contract_auto_detect;
|
|
224
257
|
|
|
225
258
|
function
|
|
226
259
|
_global_variables() {
|
|
@@ -294,6 +327,13 @@ function
|
|
|
294
327
|
"call",
|
|
295
328
|
"type",
|
|
296
329
|
"");
|
|
330
|
+
/* global
|
|
331
|
+
output_file:
|
|
332
|
+
writable */
|
|
333
|
+
_set(
|
|
334
|
+
"output",
|
|
335
|
+
"file",
|
|
336
|
+
"");
|
|
297
337
|
/* global
|
|
298
338
|
index_retrieve:
|
|
299
339
|
writable */
|
|
@@ -385,43 +425,318 @@ function
|
|
|
385
425
|
"";
|
|
386
426
|
}
|
|
387
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
|
+
|
|
388
694
|
async function
|
|
389
695
|
_overrides_set(
|
|
390
696
|
_help_display) {
|
|
391
|
-
|
|
392
|
-
|
|
697
|
+
let
|
|
698
|
+
_address_valid,
|
|
699
|
+
_contract_address,
|
|
700
|
+
_msg;
|
|
701
|
+
_help_display =
|
|
702
|
+
_help_display_check(
|
|
703
|
+
_help_display);
|
|
704
|
+
const
|
|
705
|
+
_global =
|
|
706
|
+
_global_get();
|
|
707
|
+
const
|
|
708
|
+
_quiet =
|
|
709
|
+
_global[
|
|
710
|
+
"quiet"];
|
|
711
|
+
if ( _quiet == "" ) {
|
|
712
|
+
_global[
|
|
713
|
+
"quiet"] =
|
|
714
|
+
"y";
|
|
715
|
+
}
|
|
716
|
+
const
|
|
717
|
+
_target_app =
|
|
718
|
+
_get(
|
|
719
|
+
"target",
|
|
720
|
+
"app");
|
|
721
|
+
const
|
|
722
|
+
_target_networks =
|
|
723
|
+
_get(
|
|
724
|
+
"target",
|
|
725
|
+
"networks");
|
|
726
|
+
await _cache_dir_auto_detect();
|
|
727
|
+
await _data_dir_auto_detect();
|
|
393
728
|
_override_set(
|
|
394
729
|
"call",
|
|
395
730
|
"date",
|
|
396
731
|
_get_date_human());
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
_help_display != "" ) {
|
|
402
|
-
const
|
|
403
|
-
_address_valid =
|
|
404
|
-
_address_check(
|
|
405
|
-
contract_address);
|
|
406
|
-
if ( ! _address_valid ) {
|
|
407
|
-
const
|
|
408
|
-
_msg =
|
|
409
|
-
"Contract address " +
|
|
410
|
-
`'${contract_address}' is ` +
|
|
411
|
-
`invalid.`;
|
|
412
|
-
_msg_error(
|
|
413
|
-
_msg,
|
|
414
|
-
1);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
732
|
+
_override_set(
|
|
733
|
+
"output",
|
|
734
|
+
"file",
|
|
735
|
+
"");
|
|
417
736
|
_override_set(
|
|
418
737
|
"wallet",
|
|
419
738
|
"name",
|
|
420
739
|
"default");
|
|
421
|
-
_override_set(
|
|
422
|
-
"index",
|
|
423
|
-
"retrieve",
|
|
424
|
-
"n");
|
|
425
740
|
_override_set(
|
|
426
741
|
"retries",
|
|
427
742
|
"max",
|
|
@@ -447,27 +762,132 @@ async function
|
|
|
447
762
|
"msg",
|
|
448
763
|
"value",
|
|
449
764
|
"0");
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
765
|
+
const
|
|
766
|
+
_wallet_overrides_set_args = [
|
|
767
|
+
"evm-wallet",
|
|
768
|
+
wallet_name,
|
|
769
|
+
call_auth,
|
|
770
|
+
"n", // qr support
|
|
771
|
+
_target_networks
|
|
772
|
+
];
|
|
773
|
+
try {
|
|
774
|
+
await _wallet_overrides_set.apply(
|
|
775
|
+
null,
|
|
776
|
+
_wallet_overrides_set_args);
|
|
777
|
+
}
|
|
778
|
+
catch(
|
|
779
|
+
_error) {
|
|
780
|
+
_msg =
|
|
781
|
+
"Error running '_wallet_overrides_set' " +
|
|
782
|
+
"with arguments:";
|
|
783
|
+
_msg_error(
|
|
784
|
+
_msg,
|
|
785
|
+
0);
|
|
786
|
+
_echo2(
|
|
787
|
+
_error);
|
|
788
|
+
throw _error;
|
|
789
|
+
}
|
|
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();
|
|
840
|
+
try {
|
|
841
|
+
_contract_address =
|
|
842
|
+
_get(
|
|
843
|
+
"contract",
|
|
844
|
+
"address");
|
|
845
|
+
_address_valid =
|
|
846
|
+
await _address_check(
|
|
847
|
+
_contract_address);
|
|
848
|
+
}
|
|
849
|
+
catch(
|
|
850
|
+
_error) {
|
|
851
|
+
_msg =
|
|
852
|
+
"Error detecting validity " +
|
|
853
|
+
` of address '${_contract_address}'`;
|
|
854
|
+
_msg_error(
|
|
855
|
+
_msg,
|
|
856
|
+
0);
|
|
857
|
+
_echo2(
|
|
858
|
+
_error);
|
|
859
|
+
throw _error;
|
|
860
|
+
}
|
|
861
|
+
if ( ! _address_valid ) {
|
|
862
|
+
_msg =
|
|
863
|
+
"Contract address " +
|
|
864
|
+
`'${contract_address}' is ` +
|
|
865
|
+
`invalid.`;
|
|
866
|
+
_msg_error(
|
|
867
|
+
_msg,
|
|
868
|
+
0);
|
|
869
|
+
throw _msg;
|
|
870
|
+
}
|
|
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) {
|
|
881
|
+
_msg =
|
|
882
|
+
"Error running '_artifacts_auto_detect'.";
|
|
883
|
+
_msg_error(
|
|
884
|
+
_msg,
|
|
885
|
+
0);
|
|
886
|
+
_echo2(
|
|
887
|
+
_error);
|
|
888
|
+
throw _error;
|
|
465
889
|
}
|
|
466
890
|
}
|
|
467
|
-
await _wallet_overrides_set(
|
|
468
|
-
"evm-wallet",
|
|
469
|
-
wallet_name,
|
|
470
|
-
call_auth);
|
|
471
891
|
}
|
|
472
892
|
|
|
473
893
|
function
|
|
@@ -496,7 +916,7 @@ function
|
|
|
496
916
|
` Wallet password: ${wallet_password}`,
|
|
497
917
|
` Wallet seed: ${wallet_seed}`,
|
|
498
918
|
` Network options:`,
|
|
499
|
-
`
|
|
919
|
+
` Target networks: ${target_networks}`,
|
|
500
920
|
` Max retries: ${retries_max}`,
|
|
501
921
|
` Call timeout: ${call_timeout}`,
|
|
502
922
|
` API key: ${api_key}`,
|
|
@@ -555,6 +975,12 @@ function
|
|
|
555
975
|
" -t --call-type It can be 'static' or 'dynamic'.",
|
|
556
976
|
` <call-type> Default: '${call_type}`,
|
|
557
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'.",
|
|
558
984
|
" call options:",
|
|
559
985
|
` -V --msg-value How much '${measure_unit} to attach to the`,
|
|
560
986
|
` <msg-value> transaction.`,
|
|
@@ -650,7 +1076,10 @@ async function
|
|
|
650
1076
|
_cmdline_parse() {
|
|
651
1077
|
let
|
|
652
1078
|
_help_display,
|
|
653
|
-
|
|
1079
|
+
_method_args,
|
|
1080
|
+
_msg,
|
|
1081
|
+
_network,
|
|
1082
|
+
_target_networks_set;
|
|
654
1083
|
const
|
|
655
1084
|
_argv_args = {
|
|
656
1085
|
"booleans": [
|
|
@@ -662,7 +1091,9 @@ async function
|
|
|
662
1091
|
"index-retrieve",
|
|
663
1092
|
"v",
|
|
664
1093
|
"verbose"
|
|
665
|
-
]
|
|
1094
|
+
],
|
|
1095
|
+
"string":
|
|
1096
|
+
true
|
|
666
1097
|
};
|
|
667
1098
|
const
|
|
668
1099
|
_argv =
|
|
@@ -741,15 +1172,31 @@ async function
|
|
|
741
1172
|
"method",
|
|
742
1173
|
_argv[
|
|
743
1174
|
"_"][
|
|
744
|
-
|
|
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
|
+
}
|
|
745
1196
|
_set(
|
|
746
1197
|
"method",
|
|
747
1198
|
"args",
|
|
748
|
-
|
|
749
|
-
"_"].slice(
|
|
750
|
-
2,
|
|
751
|
-
_argv[
|
|
752
|
-
"_"].length - 2));
|
|
1199
|
+
_method_args);
|
|
753
1200
|
if ( "t" in _argv ) {
|
|
754
1201
|
_set(
|
|
755
1202
|
"call",
|
|
@@ -764,6 +1211,20 @@ async function
|
|
|
764
1211
|
_argv[
|
|
765
1212
|
"call-type"]);
|
|
766
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
|
+
}
|
|
767
1228
|
if ( "T" in _argv ) {
|
|
768
1229
|
_set(
|
|
769
1230
|
"call",
|
|
@@ -958,25 +1419,6 @@ async function
|
|
|
958
1419
|
"auth",
|
|
959
1420
|
"y");
|
|
960
1421
|
}
|
|
961
|
-
const
|
|
962
|
-
_target_networks =
|
|
963
|
-
_get(
|
|
964
|
-
"target",
|
|
965
|
-
"networks");
|
|
966
|
-
if ( "n" in _argv ) {
|
|
967
|
-
_target_networks.push(
|
|
968
|
-
_argv[
|
|
969
|
-
"n"]);
|
|
970
|
-
}
|
|
971
|
-
if ( "network" in _argv ) {
|
|
972
|
-
_target_networks.push(
|
|
973
|
-
_argv[
|
|
974
|
-
"network"]);
|
|
975
|
-
}
|
|
976
|
-
_set(
|
|
977
|
-
"target",
|
|
978
|
-
"networks",
|
|
979
|
-
_target_networks);
|
|
980
1422
|
_libevm_cmdline_parse(
|
|
981
1423
|
_argv);
|
|
982
1424
|
if ( _argv[
|
|
@@ -1016,6 +1458,12 @@ function
|
|
|
1016
1458
|
_argv_url_get(
|
|
1017
1459
|
"index_retrieve")[
|
|
1018
1460
|
0]);
|
|
1461
|
+
_set(
|
|
1462
|
+
"target",
|
|
1463
|
+
"app",
|
|
1464
|
+
_argv_url_get(
|
|
1465
|
+
"app")[
|
|
1466
|
+
0]);
|
|
1019
1467
|
_set(
|
|
1020
1468
|
"data",
|
|
1021
1469
|
"dir",
|
|
@@ -1129,76 +1577,204 @@ async function
|
|
|
1129
1577
|
_evm_contract_call_cmdline(
|
|
1130
1578
|
_app_opts) {
|
|
1131
1579
|
let
|
|
1132
|
-
|
|
1133
|
-
|
|
1580
|
+
_msg,
|
|
1581
|
+
_result,
|
|
1582
|
+
_results,
|
|
1583
|
+
_results_list,
|
|
1584
|
+
_results_type;
|
|
1585
|
+
try {
|
|
1134
1586
|
_results =
|
|
1135
1587
|
await _evm_contract_call.apply(
|
|
1136
1588
|
null,
|
|
1137
|
-
|
|
1138
|
-
const
|
|
1589
|
+
_app_opts);
|
|
1139
1590
|
_results_type =
|
|
1140
1591
|
typeof(
|
|
1141
1592
|
_results);
|
|
1142
|
-
|
|
1593
|
+
_msg =
|
|
1594
|
+
`Got results '${_results}' ` +
|
|
1595
|
+
`(type '${_results_type}').`;
|
|
1596
|
+
_msg_info(
|
|
1597
|
+
_msg);
|
|
1598
|
+
}
|
|
1599
|
+
catch(
|
|
1600
|
+
_error) {
|
|
1601
|
+
_msg =
|
|
1602
|
+
"Error running '_evm_contract_call' " +
|
|
1603
|
+
`with options '${_app_opts}'.`;
|
|
1604
|
+
_msg_error(
|
|
1605
|
+
_msg,
|
|
1606
|
+
0);
|
|
1607
|
+
_echo2(
|
|
1608
|
+
_error);
|
|
1609
|
+
throw _error;
|
|
1610
|
+
}
|
|
1611
|
+
if ( _results_type == "array" ) {
|
|
1143
1612
|
for ( _result of _results ) {
|
|
1144
|
-
|
|
1613
|
+
await _printf(
|
|
1145
1614
|
_result);
|
|
1146
1615
|
}
|
|
1147
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
|
+
}
|
|
1148
1628
|
else if ( _results_type == "string" ) {
|
|
1149
1629
|
_printf(
|
|
1150
1630
|
_results);
|
|
1151
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
|
+
}
|
|
1648
|
+
return _results;
|
|
1152
1649
|
}
|
|
1153
1650
|
|
|
1154
1651
|
async function
|
|
1155
1652
|
_main() {
|
|
1156
|
-
|
|
1653
|
+
let
|
|
1654
|
+
_cmdline_out,
|
|
1655
|
+
_msg,
|
|
1656
|
+
_overrides_set_up;
|
|
1657
|
+
try {
|
|
1157
1658
|
_overrides_set_up =
|
|
1158
1659
|
await _overrides_set();
|
|
1660
|
+
}
|
|
1661
|
+
catch(
|
|
1662
|
+
_error) {
|
|
1663
|
+
_msg =
|
|
1664
|
+
"Error setting up " +
|
|
1665
|
+
"overrides.";
|
|
1666
|
+
_msg_error(
|
|
1667
|
+
_msg,
|
|
1668
|
+
0);
|
|
1669
|
+
throw _error;
|
|
1670
|
+
}
|
|
1671
|
+
const
|
|
1672
|
+
_global =
|
|
1673
|
+
_global_get();
|
|
1674
|
+
const
|
|
1675
|
+
_quiet =
|
|
1676
|
+
_global[
|
|
1677
|
+
"quiet"];
|
|
1159
1678
|
_config_show();
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1679
|
+
_set(
|
|
1680
|
+
"app",
|
|
1681
|
+
"opts",
|
|
1682
|
+
[
|
|
1683
|
+
call_type,
|
|
1684
|
+
call_timeout,
|
|
1685
|
+
wallet_name,
|
|
1686
|
+
wallet_path,
|
|
1687
|
+
wallet_password,
|
|
1688
|
+
wallet_seed,
|
|
1689
|
+
api_key,
|
|
1690
|
+
msg_value,
|
|
1691
|
+
price_gas,
|
|
1692
|
+
measure_unit,
|
|
1693
|
+
retries_max,
|
|
1694
|
+
target_networks,
|
|
1695
|
+
rpc_selection,
|
|
1696
|
+
contract_address,
|
|
1697
|
+
contract_abi,
|
|
1698
|
+
contract_bytecode,
|
|
1699
|
+
contract_compiler_output,
|
|
1700
|
+
contract_method,
|
|
1701
|
+
method_args
|
|
1702
|
+
]);
|
|
1703
|
+
const
|
|
1704
|
+
_app_opts =
|
|
1705
|
+
_get(
|
|
1706
|
+
"app",
|
|
1707
|
+
"opts");
|
|
1708
|
+
try {
|
|
1709
|
+
_msg =
|
|
1710
|
+
"Running '_evm_contract_call_cmdline' " +
|
|
1711
|
+
`with parameters:`;
|
|
1712
|
+
_msg_info(
|
|
1713
|
+
_msg);
|
|
1714
|
+
if ( _quiet == "n" ) {
|
|
1715
|
+
_echo(
|
|
1716
|
+
_app_opts);
|
|
1717
|
+
}
|
|
1718
|
+
_cmdline_out =
|
|
1719
|
+
await _evm_contract_call_cmdline(
|
|
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
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
catch(
|
|
1732
|
+
_error) {
|
|
1733
|
+
_msg =
|
|
1734
|
+
"Running '_evm_contract_call_cmdline' " +
|
|
1735
|
+
`with parameters '${_app_opts}' failed.`;
|
|
1736
|
+
_msg_error(
|
|
1737
|
+
_msg,
|
|
1738
|
+
0);
|
|
1739
|
+
_echo2(
|
|
1740
|
+
_error);
|
|
1741
|
+
throw _error;
|
|
1742
|
+
}
|
|
1743
|
+
_exit(
|
|
1744
|
+
0);
|
|
1745
|
+
return _cmdline_out;
|
|
1183
1746
|
}
|
|
1184
1747
|
|
|
1185
|
-
_global_variables();
|
|
1186
|
-
_libevm_global_variables();
|
|
1187
1748
|
if ( await _cmdline_check(
|
|
1188
1749
|
"evm-contract-call.js") ||
|
|
1189
1750
|
await _cmdline_check(
|
|
1190
1751
|
"evm-contract-call") ||
|
|
1191
1752
|
await _cmdline_check(
|
|
1192
1753
|
"./evm-contract-call") ) {
|
|
1754
|
+
_global_variables();
|
|
1755
|
+
_libevm_global_variables();
|
|
1193
1756
|
await _cmdline_parse();
|
|
1194
1757
|
}
|
|
1195
|
-
else{
|
|
1758
|
+
else {
|
|
1196
1759
|
_url_parse();
|
|
1197
1760
|
_libevm_url_parse();
|
|
1198
1761
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
_main();
|
|
1762
|
+
|
|
1763
|
+
try {
|
|
1764
|
+
await _main();
|
|
1765
|
+
}
|
|
1766
|
+
catch(
|
|
1767
|
+
_error) {
|
|
1768
|
+
const
|
|
1769
|
+
_msg =
|
|
1770
|
+
"Error running 'main'.";
|
|
1771
|
+
_msg_error(
|
|
1772
|
+
_msg,
|
|
1773
|
+
0);
|
|
1774
|
+
_echo2(
|
|
1775
|
+
_error);
|
|
1776
|
+
throw _error;
|
|
1777
|
+
}
|
|
1202
1778
|
|
|
1203
1779
|
export {
|
|
1204
1780
|
_evm_contract_call
|