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.
Files changed (57) hide show
  1. package/Makefile +9 -1
  2. package/dist/evm-contract-call/evm-contract-call.js +1 -1
  3. package/dist/evm-contract-call/fs-worker.js +1 -1
  4. package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +1 -1
  5. package/dist/evm-contract-deployment-abi/fs-worker.js +1 -1
  6. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
  7. package/dist/evm-contract-deployment-address/fs-worker.js +1 -1
  8. package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +1 -1
  9. package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -1
  10. package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +1 -1
  11. package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -1
  12. package/dist/evm-contract-deployment-deployment-networks +1 -1
  13. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  14. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  15. package/dist/evm-contract-deployment-versions/fs-worker.js +1 -1
  16. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  17. package/dist/evm-contract-deployments-dir/fs-worker.js +1 -1
  18. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  19. package/dist/evm-contracts-tools/fs-worker.js +1 -1
  20. package/dist/libevm-contract-call/fs-worker.js +1 -1
  21. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  22. package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -1
  23. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +1 -1
  24. package/dist/libevm-contract-deployment-address/fs-worker.js +1 -1
  25. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
  26. package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -1
  27. package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +1 -1
  28. package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -1
  29. package/dist/libevm-contract-deployment-compiler-output/libevm-contract-deployment-compiler-output.js +1 -1
  30. package/dist/libevm-contract-deployment-deployment-networks +1 -1
  31. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  32. package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -1
  33. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  34. package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -1
  35. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  36. package/dist/libevm-contracts-tools +1 -1
  37. package/eslint.config.mjs +1 -1
  38. package/evm-contract-call +707 -131
  39. package/evm-contract-deployment-abi +16 -12
  40. package/evm-contract-deployment-address +15 -12
  41. package/evm-contract-deployment-bytecode +15 -12
  42. package/evm-contract-deployment-compiler-output +16 -13
  43. package/evm-contract-deployment-networks +15 -12
  44. package/evm-contract-deployment-versions +15 -12
  45. package/evm-contract-deployments-dir +16 -13
  46. package/evm-contracts-tools +14 -12
  47. package/lib/contract-get +169 -39
  48. package/lib/evm-contract-call-dynamic +1112 -361
  49. package/lib/evm-contract-call-static +463 -73
  50. package/libevm-contract-call +651 -303
  51. package/libevm-contract-deployment +4408 -383
  52. package/libevm-contract-deployment-abi +287 -91
  53. package/libevm-contract-deployment-address +292 -56
  54. package/libevm-contract-deployment-bytecode +275 -80
  55. package/libevm-contract-deployment-compiler-output +341 -93
  56. package/libevm-contract-deployments-dir +53 -49
  57. package/package.json +14 -12
@@ -56,6 +56,11 @@ const
56
56
  const
57
57
  _echo =
58
58
  _libcrash._echo;
59
+ /* global
60
+ _echo2 */
61
+ const
62
+ _echo2 =
63
+ _libcrash._echo2;
59
64
  /* global
60
65
  _exit */
61
66
  const
@@ -347,7 +352,8 @@ async function
347
352
  _target_network,
348
353
  _api_key_path,
349
354
  _measure_unit,
350
- _price_gas) {
355
+ _price_gas,
356
+ _retries_max) {
351
357
  let
352
358
  _gas_fee,
353
359
  _fee_priority,
@@ -360,9 +366,6 @@ async function
360
366
  `Auto-detecting gas price.`;
361
367
  _msg_info(
362
368
  _msg);
363
- const
364
- _retries_max =
365
- 3;
366
369
  _price_feasible_retries_max =
367
370
  _retries_max;
368
371
  _price_gas_transaction_get_selection_mode =
@@ -380,10 +383,24 @@ async function
380
383
  "", // output file
381
384
  _price_gas_transaction_get_retries_max
382
385
  ];
383
- _price_gas = await
384
- _price_gas_transaction_get.apply(
385
- null,
386
- _price_gas_transaction_get_args);
386
+ try {
387
+ _price_gas = await
388
+ _price_gas_transaction_get.apply(
389
+ null,
390
+ _price_gas_transaction_get_args);
391
+ }
392
+ catch(
393
+ _error) {
394
+ _msg =
395
+ "Error getting gas price from the " +
396
+ "network.";
397
+ _msg_error(
398
+ _msg,
399
+ 0);
400
+ _echo2(
401
+ _error);
402
+ throw _error;
403
+ }
387
404
  _price_gas_transaction_get_args = [
388
405
  _target_network,
389
406
  _price_gas_transaction_get_selection_mode,
@@ -395,10 +412,24 @@ async function
395
412
  "", // output file
396
413
  _price_gas_transaction_get_retries_max
397
414
  ];
398
- _gas_fee = await
399
- _price_gas_transaction_get.apply(
400
- null,
401
- _price_gas_transaction_get_args);
415
+ try {
416
+ _gas_fee = await
417
+ _price_gas_transaction_get.apply(
418
+ null,
419
+ _price_gas_transaction_get_args);
420
+ }
421
+ catch(
422
+ _error) {
423
+ _msg =
424
+ "Error getting gas fee from the " +
425
+ "network.";
426
+ _msg_error(
427
+ _msg,
428
+ 0);
429
+ _echo2(
430
+ _error);
431
+ throw _error;
432
+ }
402
433
  _price_gas_transaction_get_args = [
403
434
  _target_network,
404
435
  _price_gas_transaction_get_selection_mode,
@@ -410,10 +441,24 @@ async function
410
441
  "", // output file
411
442
  _price_gas_transaction_get_retries_max
412
443
  ];
413
- _fee_priority = await
414
- _price_gas_transaction_get.apply(
415
- null,
416
- _price_gas_transaction_get_args);
444
+ try {
445
+ _fee_priority = await
446
+ _price_gas_transaction_get.apply(
447
+ null,
448
+ _price_gas_transaction_get_args);
449
+ }
450
+ catch(
451
+ _error) {
452
+ _msg =
453
+ "Error getting fee priority from the " +
454
+ "network.";
455
+ _msg_error(
456
+ _msg,
457
+ 0);
458
+ _echo2(
459
+ _error);
460
+ throw _error;
461
+ }
417
462
  _msg =
418
463
  `Got gas price '${_price_gas}' ` +
419
464
  `${_measure_unit} with '${_gas_fee}' ` +
@@ -424,331 +469,947 @@ async function
424
469
  `'${_price_gas_transaction_get_selection_mode}'.`;
425
470
  _msg_info(
426
471
  _msg);
427
- return _price_gas;
472
+ return [
473
+ _price_gas,
474
+ _gas_fee,
475
+ _fee_priority
476
+ ];
428
477
  }
429
478
 
430
479
  async function
431
- _contract_call_dynamic(
432
- _call_timeout,
480
+ _contract_check(
433
481
  _wallet_seed,
434
482
  _wallet_password,
435
- _api_key_path,
436
- _price_gas,
437
- _msg_value,
438
- _measure_unit,
439
- _target_network,
440
483
  _contract_address,
441
484
  _contract_abi_path,
442
485
  _contract_bytecode_path,
443
486
  _contract_compiler_output_path,
444
- _contract_method,
445
- _method_args,
446
- _verbose) {
487
+ _target_network,
488
+ _api_key_path,
489
+ _contract) {
447
490
  let
448
- _amount,
449
- _contract,
450
- _contract_get_opts,
451
- _fee_priority,
452
- _gas_fee,
453
- _method,
454
- _msg,
455
- _eip_1559,
456
- _price_feasible_retries,
457
- _price_feasible_retries_max,
458
- _price_gas_max,
459
- _price_gas_transaction_get_args,
460
- _price_gas_transaction_get_retries_max,
461
- _price_gas_transaction_get_selection_mode,
462
- _retries_max,
463
- _send_opts,
464
- _receipt,
465
- _tx;
466
- _eip_1559 =
467
- true;
468
- _price_gas_max =
469
- 100000000;
470
- _send_opts =
471
- {};
472
- if ( typeof(
473
- _measure_unit) === "undefined" ||
491
+ _contract_object_get,
492
+ _contract_get_args;
493
+ const
494
+ _contract_type =
495
+ typeof(
496
+ _contract);
497
+ _contract_object_get =
498
+ false;
499
+ if ( _contract_type == "undefined" ) {
500
+ _contract_object_get =
501
+ true;
502
+ }
503
+ else if ( _contract_type == "string" ) {
504
+ if ( _contract.length < 1 ) {
505
+ _contract_object_get =
506
+ true;
507
+ }
508
+ }
509
+ else if ( _contract_type == "object" ) {
510
+ const
511
+ _contract_keys =
512
+ Object.keys(
513
+ _contract);
514
+ if ( _contract_keys.length < 1 ) {
515
+ _contract_object_get =
516
+ true;
517
+ }
518
+ }
519
+ else if ( _contract_type == "boolean" ) {
520
+ _contract_object_get =
521
+ true;
522
+ }
523
+ else {
524
+ _msg =
525
+ "Unknown type for 'Contract' ethers object.";
526
+ _msg_error(
527
+ _msg,
528
+ 0);
529
+ throw _msg;
530
+ }
531
+ if ( ! _contract_object_get ) {
532
+ _msg =
533
+ "Using input ethers " +
534
+ "'Contract' object.";
535
+ _msg_info(
536
+ _msg);
537
+ }
538
+ else {
539
+ const
540
+ _contract_get_args = [
541
+ _wallet_seed,
542
+ _wallet_password,
543
+ _contract_address,
544
+ _contract_abi_path,
545
+ _contract_bytecode_path,
546
+ _contract_compiler_output_path,
547
+ _target_network,
548
+ _api_key_path,
549
+ ];
550
+ try {
551
+ _contract =
552
+ await _contract_get.apply(
553
+ null,
554
+ _contract_get_args);
555
+ await _msg_info_contract_obtained(
556
+ _contract);
557
+ }
558
+ catch(
559
+ _error) {
560
+ _msg =
561
+ "Error obtaining ethers " +
562
+ "contract object.";
563
+ _msg_error(
564
+ _msg,
565
+ 0);
566
+ throw _error;
567
+ }
568
+ }
569
+ return _contract;
570
+ }
571
+
572
+ function
573
+ _measure_unit_check(
574
+ _measure_unit) {
575
+ const
576
+ _measure_unit_type =
577
+ typeof(
578
+ _measure_unit);
579
+ if ( _measure_unit_type === "undefined" ||
474
580
  _measure_unit == "" ) {
475
581
  _measure_unit =
476
582
  "wei";
477
583
  }
478
- if ( typeof(
479
- _price_gas) === "undefined" ||
480
- _price_gas == "" ) {
584
+ else if ( _measure_unit_type === "string" ) {
585
+ if ( _measure_unit.length < 1 ) {
586
+ _measure_unit =
587
+ "wei";
588
+ }
589
+ }
590
+ else if ( _measure_unit_type === "array" ||
591
+ _measure_unit_type === "object" ) {
592
+ _msg =
593
+ "Measure unit must be of type 'string'.";
594
+ _msg_error(
595
+ _msg,
596
+ 0);
597
+ throw _msg;
598
+ }
599
+ else {
600
+ _msg =
601
+ `Unknown type '${_measure_unit_type}' ` +
602
+ "for variable '_measure_unit'.";
603
+ _msg_error(
604
+ _msg,
605
+ 0);
606
+ throw _msg;
607
+ }
608
+ return _measure_unit;
609
+ }
610
+
611
+ async function
612
+ _price_gas_check(
613
+ _price_gas,
614
+ _gas_fee,
615
+ _fee_priority,
616
+ _retries_max) {
617
+ let
618
+ _msg;
619
+ const
620
+ _price_gas_type =
621
+ typeof(
622
+ _price_gas);
623
+ if ( _price_gas_type === "undefined" ) {
624
+ _msg =
625
+ "Gas price not set, setting '0' for " +
626
+ "RPC auto-detection.";
627
+ _msg_info(
628
+ _msg);
481
629
  _price_gas =
482
630
  0;
483
631
  }
632
+ else if ( _price_gas_type === "string" ) {
633
+ if ( 0 < _price_gas.length ) {
634
+ const
635
+ _not_a_number =
636
+ Number(
637
+ _price_gas);
638
+ if ( ( ! ( _not_a_number < 0 ) ) &&
639
+ ( ! ( _not_a_number > 0 ) ) &&
640
+ ( ! ( _not_a_number == 0 ) ) ) {
641
+ if ( _price_gas != "auto" &&
642
+ _price_gas != "fast" &&
643
+ _price_gas != "nextblock" ) {
644
+ _msg =
645
+ `Gas price '${_price_gas}' ` +
646
+ `is not a recognized value for ` +
647
+ `variable '_price_gas'.`;
648
+ _msg_error(
649
+ _msg,
650
+ 0);
651
+ throw _msg;
652
+ }
653
+ }
654
+ }
655
+ else {
656
+ _msg =
657
+ "Gas price not set, setting '0' for " +
658
+ "auto-detection.";
659
+ _msg_info(
660
+ _msg);
661
+ _price_gas =
662
+ 0;
663
+ }
664
+ }
665
+ else {
666
+ _msg =
667
+ "Unknown value for variable " +
668
+ `'_price_gas' (${_price_gas_type}):`;
669
+ _msg_error(
670
+ _msg,
671
+ 0);
672
+ _echo2(
673
+ _price_gas);
674
+ throw _msg;
675
+ }
484
676
  if ( _price_gas == "auto" ||
485
677
  _price_gas == "fast" ||
486
678
  _price_gas == "nextblock" ) {
487
- _price_gas =
488
- _price_gas_auto_detect(
489
- _target_network,
490
- _api_key_path,
491
- _measure_unit,
492
- _price_gas);
679
+ _msg =
680
+ `Gas price set to '${_price_gas}', ` +
681
+ `evaluating actual value.`;
682
+ _msg_info(
683
+ _msg);
684
+ try {
685
+ [ _price_gas,
686
+ _gas_fee,
687
+ _fee_priority ] =
688
+ await _price_gas_auto_detect(
689
+ _target_network,
690
+ _api_key_path,
691
+ _measure_unit,
692
+ _price_gas,
693
+ _retries_max);
694
+ }
695
+ catch(
696
+ _error) {
697
+ _msg =
698
+ "Error getting gas price."
699
+ _msg_error(
700
+ _msg,
701
+ 0);
702
+ _echo2(
703
+ _error);
704
+ throw _error;
705
+ }
493
706
  }
494
707
  else {
495
708
  _msg =
496
- `Setting gas price '${_price_gas}'.`;
709
+ `Setting input gas price ` +
710
+ `'${_price_gas}'.`;
497
711
  _msg_info(
498
712
  _msg);
499
713
  }
500
714
  _price_gas =
501
715
  Number(
502
716
  _price_gas);
503
- if ( typeof(
504
- _msg_value) === "undefined" ) {
717
+ _gas_fee =
718
+ Number(
719
+ _gas_fee);
720
+ _fee_priority =
721
+ Number(
722
+ _fee_priority);
723
+ return _fee_priority;
724
+ }
725
+
726
+ function
727
+ _msg_value_check(
728
+ _msg_value) {
729
+ const
730
+ _msg_value_type =
731
+ typeof(
732
+ _msg_value);
733
+ if ( _msg_value_type === "undefined" ) {
734
+ _msg =
735
+ "Message value not set, " +
736
+ "setting transaction value '0'.";
737
+ _msg_info(
738
+ _msg);
505
739
  _msg_value =
506
740
  0;
507
741
  }
742
+ else if ( _msg_value_type === "string" ) {
743
+ if ( 0 < _msg_value.length ) {
744
+ const
745
+ _not_a_number =
746
+ Number(
747
+ _msg_value);
748
+ if ( ( ! ( _not_a_number < 0 ) ) &&
749
+ ( ! ( _not_a_number > 0 ) ) &&
750
+ ( ! ( _not_a_number == 0 ) ) ) {
751
+ _msg =
752
+ `Message value '${_msg_value}' ` +
753
+ `is not a recognized value ` +
754
+ `(a number) for ` +
755
+ `variable '_msg_value'.`;
756
+ _msg_error(
757
+ _msg,
758
+ 0);
759
+ throw _msg;
760
+ }
761
+ }
762
+ else {
763
+ _msg =
764
+ "Message value not set, " +
765
+ "setting transaction value '0'.";
766
+ _msg_info(
767
+ _msg);
768
+ _msg_value =
769
+ 0;
770
+ }
771
+ }
508
772
  _msg_value =
509
773
  BigInt(
510
774
  _msg_value);
511
- if ( typeof(
512
- _call_timeout) === "undefined" ||
513
- _call_timeout == "" ) {
775
+ return _msg_value;
776
+ }
777
+
778
+ function
779
+ _call_timeout_check(
780
+ _call_timeout) {
781
+ const
782
+ _call_timeout_type =
783
+ typeof(
784
+ _call_timeout);
785
+ if ( _call_timeout_type === "number" ) {
786
+ true;
787
+ }
788
+ else if ( _call_timeout_type === "undefined" ) {
789
+ _msg =
790
+ "Setting timeout to '300' seconds.";
514
791
  _msg_info(
515
- "Setting timeout to '300' seconds.");
792
+ _msg);
516
793
  _call_timeout =
517
794
  300000;
518
795
  }
519
- else {
520
- _call_timeout =
521
- Number(
522
- _call_timeout);
523
- }
524
- if ( typeof(
525
- _measure_unit) === "undefined" ||
526
- _measure_unit == "" ) {
527
- _measure_unit =
528
- "wei";
529
- }
530
- if ( typeof(
531
- _verbose) === "undefined" ||
532
- _verbose == "" ) {
533
- _verbose =
534
- "n";
535
- }
536
- _contract_get_opts = [
537
- _wallet_seed,
538
- _wallet_password,
539
- _contract_address,
540
- _contract_abi_path,
541
- _contract_bytecode_path,
542
- _contract_compiler_output_path,
543
- _target_network,
544
- _api_key_path,
545
- ];
546
- try {
547
- _contract =
548
- await _contract_get.apply(
549
- null,
550
- _contract_get_opts);
551
- await _msg_info_contract_obtained(
552
- _contract);
553
- _method =
554
- await _contract.getFunction(
555
- _contract_method);
556
- _msg_info_method_obtained(
557
- _method);
558
- if ( _price_gas > 0 ) {
559
- try {
560
- _tx = await
561
- _method.populateTransaction.apply(
562
- null,
563
- _method_args);
564
- }
565
- catch(
566
- _error) {
796
+ else if ( _call_timeout_type === "string" ) {
797
+ if ( 0 < _call_timeout.length ) {
798
+ const
799
+ _not_a_number =
800
+ Number(
801
+ _call_timeout);
802
+ if ( ( ! ( _not_a_number < 0 ) ) &&
803
+ ( ! ( _not_a_number > 0 ) ) &&
804
+ ( ! ( _not_a_number == 0 ) ) ) {
567
805
  _msg =
568
- "Error populating transaction.";
569
- _error_display(
570
- _error);
806
+ `Call timeout '${_call_timeout}' ` +
807
+ `is not a recognized value (a number) for ` +
808
+ `variable '_call_timeout'.`;
571
809
  _msg_error(
572
810
  _msg,
573
811
  0);
812
+ throw _msg;
574
813
  }
575
- _gas_limit =
576
- Math.floor(
577
- 15803479 * 12 / 10);
578
- // 17000000;
579
- // _gas_limit =
580
- // _price_gas * 2;
814
+ }
815
+ else {
581
816
  _msg =
582
- `Setting gas price '${_price_gas}' ` +
583
- `${_measure_unit}, gas limit '${_gas_limit}' ` +
584
- `'${_measure_unit}' gas fee '${_gas_fee}' ` +
585
- `${_measure_unit}' and fee priority ` +
586
- `'${_fee_priority}' '${_measure_unit}'.`;
817
+ "Setting timeout to '300' seconds.";
587
818
  _msg_info(
588
819
  _msg);
589
- if ( _eip_1559 == false ) {
590
- _tx[
591
- "gasPrice"] =
592
- _price_gas;
593
- }
594
- else if ( _eip_1559 == true ) {
595
- _price_feasible_retries =
596
- 0;
597
- while( _price_gas_max < Number(_price_gas) &&
598
- _price_feasible_retries <= _price_feasible_retries_max ) {
599
- _price_feasible_retries =
600
- _price_feasible_retries + 1;
601
- _msg =
602
- `Current gas price '${_price_gas}', ` +
603
- `maximum gas price '${_price_gas_max}'. ` +
604
- `Waiting 30 seconds before retrying.`;
605
- _msg_info(
606
- _msg);
607
- await _sleep(
608
- 30000);
609
- _price_gas_transaction_get_args = [
610
- _target_network,
611
- _price_gas_transaction_get_selection_mode,
612
- _api_key_path,
613
- _measure_unit,
614
- "", // wallet seed
615
- "", // target address,
616
- "price", // output type
617
- "", // output file
618
- _price_gas_transaction_get_retries_max
619
- ];
620
- _price_gas = await
621
- _price_gas_transaction_get.apply(
622
- null,
623
- _price_gas_transaction_get_args);
624
- // _gas_limit =
625
- // Math.floor(
626
- // 15803479 * 12 / 10);
627
- // 17000000;
628
- // 15803479 * 2;
629
- // _price_gas;
630
- if ( Number(_price_gas) <= _price_gas_max ) {
631
- _gas_fee = await
632
- _price_gas_transaction_get.apply(
633
- null,
634
- _price_gas_transaction_get_args);
635
- _price_gas_transaction_get_args = [
636
- _target_network,
637
- _price_gas_transaction_get_selection_mode,
638
- _api_key_path,
639
- _measure_unit,
640
- "", // wallet seed
641
- "", // target address,
642
- "priority", // output type
643
- "", // output file
644
- _price_gas_transaction_get_retries_max
645
- ];
646
- _fee_priority = await
647
- _price_gas_transaction_get.apply(
648
- null,
649
- _price_gas_transaction_get_args);
650
- }
651
- }
652
- if ( _price_feasible_retries_max < _price_feasible_retries ) {
653
- _msg =
654
- `Setting price to max price ` +
655
- `'${_price_gas_max}'`;
656
- _msg_info(
657
- _msg);
658
- _price_gas =
659
- _price_gas_max;
660
- }
661
- _price_feasible_retries =
662
- _price_feasible_retries + 1;
663
- _price_gas_max =
664
- Math.max(
665
- _price_gas_max,
666
- // _gas_limit,
667
- _gas_fee,
668
- _fee_priority,
669
- _price_gas,
670
- );
671
- // _tx[
672
- // "gasLimit"] =
673
- // _gas_limit;
674
- _tx[
675
- "maxFeePerGas"] =
676
- _gas_fee;
677
- _tx[
678
- "maxPriorityFeePerGas"] =
679
- _fee_priority;
820
+ _call_timeout =
821
+ 300000;
822
+ }
823
+ }
824
+ else if ( _call_timeout_type === "object" ) {
825
+ _msg =
826
+ `Call timeout '${_call_timeout}' ` +
827
+ `is not a recognized value (a number) for ` +
828
+ `variable '_call_timeout':`;
829
+ _msg_error(
830
+ _msg,
831
+ 0);
832
+ _echo2(
833
+ _call_timeout);
834
+ throw _msg;
835
+ }
836
+ _call_timeout =
837
+ Number(
838
+ _call_timeout);
839
+ return _call_timeout;
840
+ }
841
+
842
+ async function
843
+ _method_check(
844
+ _contract_method,
845
+ _method) {
846
+ let
847
+ _method_object_get;
848
+ const
849
+ _method_type =
850
+ typeof(
851
+ _method);
852
+ _method_object_get =
853
+ false;
854
+ if ( _method_type == "undefined" ) {
855
+ _method_object_get =
856
+ true;
857
+ }
858
+ else if ( _method_type == "string" ) {
859
+ if ( _method.length < 1 ) {
860
+ _method_object_get =
861
+ true;
862
+ }
863
+ }
864
+ else if ( _method_type == "object" ) {
865
+ const
866
+ _method_keys =
867
+ Object.keys(
868
+ _method);
869
+ if ( _method_keys.length < 1 ) {
870
+ _method_object_get =
871
+ true;
872
+ }
873
+ }
874
+ if ( ! _method_object_get ) {
875
+ _msg =
876
+ "Using input ethers " +
877
+ "'Contract.Method' object.";
878
+ _msg_info(
879
+ _msg);
880
+ }
881
+ else {
882
+ try {
883
+ _method =
884
+ await _contract.getFunction(
885
+ _contract_method);
886
+ await _msg_info_method_obtained(
887
+ _method);
888
+ }
889
+ catch(
890
+ _error) {
891
+ _msg =
892
+ "Error obtaining ethers " +
893
+ "contract method object.";
894
+ _msg_error(
895
+ _msg,
896
+ 0);
897
+ throw _error;
898
+ }
899
+ }
900
+ return _method;
901
+ }
902
+
903
+ async function
904
+ _call_price_gas_manual(
905
+ _price_feasible_retries_max,
906
+ _measure_unit,
907
+ _target_network,
908
+ _api_key_path,
909
+ _price_gas,
910
+ _gas_fee,
911
+ _fee_priority,
912
+ _method,
913
+ _method_args,
914
+ _tx) {
915
+ let
916
+ _gas_limit,
917
+ _msg,
918
+ _price_feasible_retries,
919
+ _price_gas_max,
920
+ _price_gas_transaction_get_args;
921
+ const
922
+ _price_gas_type =
923
+ typeof(
924
+ _price_gas);
925
+ if ( _price_gas_type == "string" ) {
926
+ if ( 0 < _price_gas.length ) {
927
+ if ( ! ( _price_gas < 0 ) &&
928
+ ! ( _price_gas == 0 ) &&
929
+ ! ( _price_gas > 0 ) ) {
930
+ _price_gas_transaction_get_selection_mode =
931
+ _price_gas;
680
932
  }
681
- if ( _msg_value > 0 ) {
682
- if ( _measure_unit == "ether" ) {
683
- _amount =
684
- _ethers_to_wei(
685
- _msg_value);
686
- }
687
- else if ( _measure_unit == "wei" ) {
688
- _amount =
689
- _msg_value;
690
- }
691
- else if ( _measure_unit == "" ) {
692
- _amount =
693
- _msg_value;
694
- }
695
- else {
696
- _msg =
697
- `Unknown measure unit '${_measure_unit}'.`;
698
- _msg_error(
699
- _msg,
700
- 1);
701
- }
702
- _tx[
703
- "value"] =
704
- _amount;
705
- // _method_args.push(
706
- // _send_opts);
933
+ else {
934
+ _msg =
935
+ `Setting numeric value '${_price_gas}' ` +
936
+ `as gas price ` +
937
+ "selection mode value.";
938
+ _msg_info(
939
+ _msg);
940
+ }
941
+ }
942
+ else {
943
+ _msg =
944
+ "Gas price variable '_price_gas' " +
945
+ "empty, auto-detecting.";
946
+ _msg_info(
947
+ _msg);
948
+ }
949
+ }
950
+ else if ( _price_gas_type == "number" ) {
951
+ _msg =
952
+ `Setting numeric value '${_price_gas}' ` +
953
+ `as gas price ` +
954
+ "selection mode value.";
955
+ _msg_info(
956
+ _msg);
957
+ }
958
+ else {
959
+ _msg =
960
+ "Input variable '_price_gas' must be " +
961
+ `a number (type '${_price_gas_type}').`;
962
+ _msg_error(
963
+ _msg,
964
+ 0);
965
+ throw _msg;
966
+ }
967
+ _price_gas_transaction_get_selection_mode =
968
+ _price_gas;
969
+ _price_gas_max =
970
+ 100000000;
971
+ try {
972
+ _tx = await
973
+ _method.populateTransaction.apply(
974
+ null,
975
+ _method_args);
976
+ }
977
+ catch(
978
+ _error) {
979
+ _msg =
980
+ "Error populating transaction.";
981
+ _error_display(
982
+ _error);
983
+ _msg_error(
984
+ _msg,
985
+ 0);
986
+ throw _error;
987
+ }
988
+ // An hardcoded gas limit parameter.
989
+ _gas_limit =
990
+ Math.floor(
991
+ 15803479 * 12 / 10);
992
+ // 17000000;
993
+ // Setting as gas limit double
994
+ // of how much you wanna spend.
995
+ // _gas_limit =
996
+ // _price_gas * 2;
997
+ _msg =
998
+ `Setting gas price '${_price_gas}' ` +
999
+ `${_measure_unit}, gas limit '${_gas_limit}' ` +
1000
+ `'${_measure_unit}' gas fee '${_gas_fee}' ` +
1001
+ `${_measure_unit}' and fee priority ` +
1002
+ `'${_fee_priority}' '${_measure_unit}'.`;
1003
+ _msg_info(
1004
+ _msg);
1005
+ // Non-proof of stake networks
1006
+ if ( _eip_1559 == false ) {
1007
+ _tx[
1008
+ "gasPrice"] =
1009
+ _price_gas;
1010
+ }
1011
+ // Proof of stake networks
1012
+ else if ( _eip_1559 == true ) {
1013
+ _price_feasible_retries =
1014
+ 0;
1015
+ while( _price_gas_max < Number(
1016
+ _price_gas) &&
1017
+ _price_feasible_retries <= _price_feasible_retries_max ) {
1018
+ _price_feasible_retries =
1019
+ _price_feasible_retries + 1;
1020
+ _msg =
1021
+ `Current gas price '${_price_gas}', ` +
1022
+ `maximum gas price '${_price_gas_max}'. ` +
1023
+ `Waiting 30 seconds before retrying.`;
1024
+ _msg_info(
1025
+ _msg);
1026
+ await _sleep(
1027
+ 30000);
1028
+ _price_gas_transaction_get_args = [
1029
+ _target_network,
1030
+ _price_gas_transaction_get_selection_mode,
1031
+ _api_key_path,
1032
+ _measure_unit,
1033
+ "", // wallet seed
1034
+ "", // target address,
1035
+ "price", // output type
1036
+ "", // output file
1037
+ _price_gas_transaction_get_retries_max
1038
+ ];
1039
+ _price_gas = await
1040
+ _price_gas_transaction_get.apply(
1041
+ null,
1042
+ _price_gas_transaction_get_args);
1043
+ // _gas_limit =
1044
+ // Math.floor(
1045
+ // 15803479 * 12 / 10);
1046
+ // 17000000;
1047
+ // 15803479 * 2;
1048
+ // _price_gas;
1049
+ if ( Number(_price_gas) <= _price_gas_max ) {
1050
+ _gas_fee = await
1051
+ _price_gas_transaction_get.apply(
1052
+ null,
1053
+ _price_gas_transaction_get_args);
1054
+ _price_gas_transaction_get_args = [
1055
+ _target_network,
1056
+ _price_gas_transaction_get_selection_mode,
1057
+ _api_key_path,
1058
+ _measure_unit,
1059
+ "", // wallet seed
1060
+ "", // target address,
1061
+ "priority", // output type
1062
+ "", // output file
1063
+ _price_gas_transaction_get_retries_max
1064
+ ];
1065
+ _fee_priority = await
1066
+ _price_gas_transaction_get.apply(
1067
+ null,
1068
+ _price_gas_transaction_get_args);
1069
+ }
1070
+ }
1071
+ if ( _price_feasible_retries_max < _price_feasible_retries ) {
1072
+ _msg =
1073
+ `Setting price to max price ` +
1074
+ `'${_price_gas_max}'.`;
1075
+ _msg_info(
1076
+ _msg);
1077
+ _price_gas =
1078
+ _price_gas_max;
1079
+ }
1080
+ _price_feasible_retries =
1081
+ _price_feasible_retries + 1;
1082
+ _price_gas_max =
1083
+ Math.max(
1084
+ _price_gas_max,
1085
+ // _gas_limit,
1086
+ _gas_fee,
1087
+ _fee_priority,
1088
+ _price_gas,
1089
+ );
1090
+ // _tx[
1091
+ // "gasLimit"] =
1092
+ // _gas_limit;
1093
+ _tx[
1094
+ "maxFeePerGas"] =
1095
+ _gas_fee;
1096
+ _tx[
1097
+ "maxPriorityFeePerGas"] =
1098
+ _fee_priority;
1099
+ }
1100
+ if ( _msg_value > 0 ) {
1101
+ if ( _measure_unit == "ether" ) {
1102
+ _amount =
1103
+ _ethers_to_wei(
1104
+ _msg_value);
1105
+ }
1106
+ else if ( _measure_unit == "wei" ) {
1107
+ _amount =
1108
+ _msg_value;
1109
+ }
1110
+ else if ( _measure_unit == "" ) {
1111
+ _msg =
1112
+ `Measure unit not set, `;
1113
+ `defaulting to 'wei'.`;
1114
+ _msg_info(
1115
+ _msg);
1116
+ _amount =
1117
+ _msg_value;
1118
+ }
1119
+ else {
1120
+ _msg =
1121
+ `Unknown measure unit '${_measure_unit}'.`;
1122
+ _msg_error(
1123
+ _msg,
1124
+ 0);
1125
+ throw _msg;
1126
+ }
1127
+ _tx[
1128
+ "value"] =
1129
+ _amount;
1130
+ // _method_args.push(
1131
+ // _send_opts);
1132
+ }
1133
+ try {
1134
+ _tx = await
1135
+ _contract.runner.sendTransaction(
1136
+ _tx);
1137
+ }
1138
+ catch(
1139
+ _error) {
1140
+ _msg =
1141
+ "Error sending transaction using " +
1142
+ "'contract.runner.sendTransaction'.";
1143
+ _msg_error(
1144
+ _msg,
1145
+ 0);
1146
+ throw _error;
1147
+ }
1148
+ return _tx;
1149
+ }
1150
+
1151
+ async function
1152
+ _call_price_gas_auto(
1153
+ _measure_unit,
1154
+ _msg_value,
1155
+ _method,
1156
+ _method_args) {
1157
+ let
1158
+ _amount,
1159
+ _msg,
1160
+ _tx;
1161
+ const
1162
+ _send_opts =
1163
+ {};
1164
+ if ( _msg_value > 0 ) {
1165
+ if ( _measure_unit == "ether" ) {
1166
+ _amount =
1167
+ _ethers_to_wei(
1168
+ _msg_value);
1169
+ }
1170
+ else if ( _measure_unit == "wei" ) {
1171
+ _amount =
1172
+ _msg_value;
1173
+ }
1174
+ else if ( _measure_unit == "" ) {
1175
+ _msg =
1176
+ "No measure unit set, " +
1177
+ "defaulting to 'wei'.";
1178
+ _amount =
1179
+ _msg_value;
1180
+ }
1181
+ else {
1182
+ _msg =
1183
+ `Unknown measure unit '${_measure_unit}'.`;
1184
+ _msg_error(
1185
+ _msg,
1186
+ 0);
1187
+ throw _msg;
1188
+ }
1189
+ _send_opts[
1190
+ "value"] =
1191
+ _amount;
1192
+ _method_args.push(
1193
+ _send_opts);
1194
+ _msg =
1195
+ `Set message value '${_amount}' ` +
1196
+ `'${_measure_unit}'.`;
1197
+ _msg_info(
1198
+ _msg);
1199
+ }
1200
+ try {
1201
+ _tx =
1202
+ await _method.send.apply(
1203
+ null,
1204
+ _method_args)
1205
+ }
1206
+ catch(
1207
+ _error) {
1208
+ _msg =
1209
+ "Error sending transaction to the " +
1210
+ "network using the 'send' method" +
1211
+ "of the Ethers method object.";
1212
+ _msg_error(
1213
+ _msg,
1214
+ 0);
1215
+ _echo2(
1216
+ _error);
1217
+ throw _error;
1218
+ }
1219
+ return _tx;
1220
+ }
1221
+
1222
+ async function
1223
+ _contract_call_dynamic(
1224
+ _call_timeout,
1225
+ _wallet_seed,
1226
+ _wallet_password,
1227
+ _api_key_path,
1228
+ _price_gas,
1229
+ _msg_value,
1230
+ _measure_unit,
1231
+ _target_network,
1232
+ _contract_address,
1233
+ _contract_abi_path,
1234
+ _contract_bytecode_path,
1235
+ _contract_compiler_output_path,
1236
+ _contract_method,
1237
+ _method_args,
1238
+ _verbose,
1239
+ _retries_max,
1240
+ _contract,
1241
+ _method) {
1242
+ let
1243
+ _amount,
1244
+ _call_price_gas_manual_args,
1245
+ _call_price_gas_auto_args,
1246
+ _contract_object_get,
1247
+ _fee_priority,
1248
+ _gas_fee,
1249
+ _msg,
1250
+ _eip_1559,
1251
+ _price_feasible_retries_max,
1252
+ _price_gas_max,
1253
+ _price_gas_transaction_get_args,
1254
+ _price_gas_transaction_get_retries_max,
1255
+ _price_gas_transaction_get_selection_mode,
1256
+ _send_opts,
1257
+ _receipt,
1258
+ _tx;
1259
+ _eip_1559 =
1260
+ true;
1261
+ _send_opts =
1262
+ {};
1263
+ _measure_unit =
1264
+ _measure_unit_check(
1265
+ _measure_unit);
1266
+ try {
1267
+ [ _price_gas,
1268
+ _gas_fee,
1269
+ _fee_priority ] =
1270
+ await _price_gas_check(
1271
+ _price_gas,
1272
+ _gas_fee,
1273
+ _fee_priority,
1274
+ _retries_max);
1275
+ }
1276
+ catch(
1277
+ _error) {
1278
+ _msg =
1279
+ "Error checking input gas price.";
1280
+ _msg_error(
1281
+ _msg,
1282
+ 0);
1283
+ _echo2(
1284
+ _error);
1285
+ throw _error;
1286
+ }
1287
+ _msg_value =
1288
+ _msg_value_check(
1289
+ _value);
1290
+ _call_timeout =
1291
+ _call_timeout_check(
1292
+ _call_timeout);
1293
+ if ( typeof(
1294
+ _verbose) === "undefined" ||
1295
+ _verbose == "" ) {
1296
+ _verbose =
1297
+ "n";
1298
+ }
1299
+ const
1300
+ _contract_check_args = [
1301
+ _wallet_seed,
1302
+ _wallet_password,
1303
+ _contract_address,
1304
+ _contract_abi_path,
1305
+ _contract_bytecode_path,
1306
+ _contract_compiler_output_path,
1307
+ _target_network,
1308
+ _api_key_path,
1309
+ _contract
1310
+ ];
1311
+ try {
1312
+ _contract =
1313
+ await _contract_check.apply(
1314
+ null,
1315
+ _contract_check_args);
1316
+ }
1317
+ catch(
1318
+ _error) {
1319
+ _msg =
1320
+ "Error validating ethers " +
1321
+ "contract object.";
1322
+ _msg_error(
1323
+ _msg,
1324
+ 0);
1325
+ throw _error;
1326
+ }
1327
+ const
1328
+ _method_check_args = [
1329
+ _contract_method,
1330
+ _method
1331
+ ];
1332
+ try {
1333
+ _method =
1334
+ await _method_check.apply(
1335
+ null,
1336
+ _method_check_args);
1337
+ }
1338
+ catch(
1339
+ _error) {
1340
+ _msg =
1341
+ "Error validating ethers " +
1342
+ "contract method object.";
1343
+ _msg_error(
1344
+ _msg,
1345
+ 0);
1346
+ throw _error;
1347
+ }
1348
+ try {
1349
+ if ( _price_gas > 0 ) {
1350
+ _call_price_gas_manual_args = [
1351
+ _retries_max,
1352
+ _measure_unit,
1353
+ _target_network,
1354
+ _api_key_path,
1355
+ _price_gas,
1356
+ _gas_fee,
1357
+ _fee_priority,
1358
+ _method,
1359
+ _method_args,
1360
+ _tx
1361
+ ];
1362
+ try {
1363
+ _tx =
1364
+ await _call_price_gas_manual.apply(
1365
+ null,
1366
+ _call_price_gas_manual_args);
1367
+ }
1368
+ catch(
1369
+ _error) {
1370
+ _msg =
1371
+ "Error sending transaction setting " +
1372
+ "gas price manually.";
1373
+ _error_display(
1374
+ _error);
1375
+ _msg_error(
1376
+ _msg,
1377
+ 0);
1378
+ throw _error;
707
1379
  }
708
- _tx = await
709
- _contract.runner.sendTransaction(
710
- _tx);
711
- // _tx =
712
- // await _method.send.apply(
713
- // null,
714
- // _method_args)
715
1380
  }
716
1381
  else {
717
1382
  _msg =
718
1383
  "Setting no gas price.";
719
1384
  _msg_info(
720
1385
  _msg);
721
- if ( _msg_value > 0 ) {
722
- if ( _measure_unit == "ether" ) {
723
- _amount =
724
- _ethers_to_wei(
725
- _msg_value);
726
- }
727
- else if ( _measure_unit == "wei" ) {
728
- _amount =
729
- _msg_value;
730
- }
731
- else if ( _measure_unit == "" ) {
732
- _amount =
733
- _msg_value;
734
- }
735
- else {
736
- _msg =
737
- `Unknown measure unit '${_measure_unit}'.`;
738
- _msg_error(
739
- _msg,
740
- 1);
741
- }
742
- _send_opts[
743
- "value"] =
744
- _amount;
745
- _method_args.push(
746
- _send_opts);
1386
+ _call_price_gas_auto_args = [
1387
+ _retries_max,
1388
+ _measure_unit,
1389
+ _msg_value,
1390
+ _method,
1391
+ _method_args,
1392
+ _tx
1393
+ ];
1394
+ try {
1395
+ _tx =
1396
+ await _call_price_gas_auto.apply(
1397
+ null,
1398
+ _call_price_gas_auto_args);
1399
+ }
1400
+ catch(
1401
+ _error) {
1402
+ _msg =
1403
+ "Error sending transaction to the " +
1404
+ "network by letting the RPC set the " +
1405
+ "gas price value.";
1406
+ _msg_error(
1407
+ _msg,
1408
+ 0);
1409
+ _echo2(
1410
+ _error);
1411
+ throw _error;
747
1412
  }
748
- _tx =
749
- await _method.send.apply(
750
- null,
751
- _method_args)
752
1413
  }
753
1414
  if ( typeof(
754
1415
  _tx) == "undefined" ) {
@@ -765,13 +1426,25 @@ async function
765
1426
  _msg_info(
766
1427
  _msg);
767
1428
  if ( _verbose == "y" ) {
768
- console.log(
1429
+ _echo(
769
1430
  _tx);
770
1431
  }
771
- _receipt =
772
- await _tx.wait(
773
- 1,
774
- _call_timeout);
1432
+ try {
1433
+ _receipt =
1434
+ await _tx.wait(
1435
+ 1,
1436
+ _call_timeout);
1437
+ }
1438
+ catch(
1439
+ _error) {
1440
+ _msg =
1441
+ "Error getting transaction " +
1442
+ "receipt.";
1443
+ _msg_error(
1444
+ _msg,
1445
+ 0);
1446
+ throw _error;
1447
+ }
775
1448
  } catch (
776
1449
  _error) {
777
1450
  if ( "code" in _error ) {
@@ -812,14 +1485,60 @@ async function
812
1485
  _msg);
813
1486
  throw _error;
814
1487
  }
815
- return [ _tx,
816
- _receipt];
1488
+ return [
1489
+ _tx,
1490
+ _receipt,
1491
+ _method,
1492
+ _contract
1493
+ ];
817
1494
  }
818
1495
 
819
1496
  function
820
1497
  _receipt_cost_get(
821
1498
  _receipt) {
1499
+ true;
1500
+ }
822
1501
 
1502
+ function
1503
+ _retries_max_check(
1504
+ _retries_max) {
1505
+ let
1506
+ _msg;
1507
+ const
1508
+ _retries_max_type =
1509
+ typeof(
1510
+ _retries_max);
1511
+ if ( _retries_max_type === "undefined" ) {
1512
+ _msg =
1513
+ "Setting maximum call retries to '100'.";
1514
+ _msg_info(
1515
+ _msg);
1516
+ _retries_max =
1517
+ 100;
1518
+ }
1519
+ else if ( _retries_max_type === "string" ) {
1520
+ if ( _retries_max.length < 1 ) {
1521
+ _msg =
1522
+ "Setting maximum call retries to '100'.";
1523
+ _msg_info(
1524
+ _msg);
1525
+ _retries_max =
1526
+ 100;
1527
+ }
1528
+ }
1529
+ else {
1530
+ _msg =
1531
+ "Variable '_retries_max' must be " +
1532
+ `a number, not a '${_retries_max_type}'.`;
1533
+ _msg_error(
1534
+ _msg,
1535
+ 0);
1536
+ throw _msg;
1537
+ }
1538
+ _retries_max =
1539
+ Number(
1540
+ _retries_max);
1541
+ return _retries_max;
823
1542
  }
824
1543
 
825
1544
  async function
@@ -840,16 +1559,25 @@ async function
840
1559
  _contract_method,
841
1560
  _method_args,
842
1561
  _output_file,
843
- _verbose) {
1562
+ _verbose,
1563
+ _contract,
1564
+ _method) {
844
1565
  let
1566
+ _attempt,
845
1567
  _msg,
846
1568
  _receipt,
847
1569
  _receipt_type,
848
1570
  _tx,
849
1571
  _tx_cost,
850
- _contract_call_dynamic_opts,
851
1572
  _wallet_path_list,
852
1573
  _wallet_path;
1574
+ const
1575
+ _global =
1576
+ _global_get();
1577
+ const
1578
+ _quiet =
1579
+ _global[
1580
+ "quiet"];
853
1581
  if ( typeof(
854
1582
  _price_gas) === "undefined" ||
855
1583
  _price_gas == "" ) {
@@ -860,55 +1588,18 @@ async function
860
1588
  _price_gas =
861
1589
  "";
862
1590
  }
863
- if ( typeof(
864
- _retries_max) === "undefined" ||
865
- _retries_max == "" ) {
866
- _msg =
867
- "Setting maximum call retries to '100'.";
868
- _msg_info(
869
- _msg);
870
- _retries_max =
871
- 100;
872
- }
873
1591
  _retries_max =
874
- Number(
1592
+ _retries_max_check(
875
1593
  _retries_max);
876
- if ( typeof(
877
- _call_timeout) === "undefined" ||
878
- _call_timeout == "" ) {
879
- _msg =
880
- "Setting timeout to '300' seconds.";
881
- _msg_info(
882
- _msg);
883
- _call_timeout =
884
- 300000;
885
- }
886
1594
  _call_timeout =
887
- Number(
1595
+ _call_timeout_check(
888
1596
  _call_timeout);
889
- if ( typeof(
890
- _msg_value) === "undefined" ||
891
- _msg_value == "" ) {
892
- _msg =
893
- "Setting transaction value '0'.";
894
- _msg_info(
895
- _msg);
896
- _msg_value =
897
- 0;
898
- }
899
1597
  _msg_value =
900
- BigInt(
1598
+ _msg_value_check(
901
1599
  _msg_value);
902
- if ( typeof(
903
- _measure_unit) === undefined ||
904
- _measure_unit == "" ) {
905
- _msg =
906
- "Setting measure unit to 'wei'.";
907
- _msg_info(
908
- _msg);
909
- _measure_unit =
910
- "wei";
911
- }
1600
+ _measure_unit =
1601
+ _measure_unit_check(
1602
+ _measure_unit);
912
1603
  if ( typeof(
913
1604
  _wallet_password) === "undefined" ||
914
1605
  _wallet_password == "" ) {
@@ -938,31 +1629,87 @@ async function
938
1629
  _verbose =
939
1630
  "n";
940
1631
  }
941
- _contract_call_dynamic_opts = [
942
- _call_timeout,
943
- _wallet_seed,
944
- _wallet_password,
945
- _api_key_path,
946
- _price_gas,
947
- _msg_value,
948
- _measure_unit,
949
- _target_network,
950
- _contract_address,
951
- _contract_abi_path,
952
- _contract_bytecode_path,
953
- _contract_compiler_output_path,
954
- _contract_method,
955
- _method_args
956
- ];
1632
+ const
1633
+ _contract_check_args = [
1634
+ _wallet_seed,
1635
+ _wallet_password,
1636
+ _contract_address,
1637
+ _contract_abi_path,
1638
+ _contract_bytecode_path,
1639
+ _contract_compiler_output_path,
1640
+ _target_network,
1641
+ _api_key_path,
1642
+ _contract
1643
+ ];
1644
+ try {
1645
+ _contract =
1646
+ await _contract_check.apply(
1647
+ null,
1648
+ _contract_check_args);
1649
+ }
1650
+ catch(
1651
+ _error) {
1652
+ _msg =
1653
+ "Error validating ethers " +
1654
+ "contract object.";
1655
+ _msg_error(
1656
+ _msg,
1657
+ 0);
1658
+ throw _error;
1659
+ }
1660
+ const
1661
+ _method_check_args = [
1662
+ _contract_method,
1663
+ _method
1664
+ ];
1665
+ try {
1666
+ _method =
1667
+ await _method_check.apply(
1668
+ null,
1669
+ _method_check_args);
1670
+ }
1671
+ catch(
1672
+ _error) {
1673
+ _msg =
1674
+ "Error validating ethers " +
1675
+ "contract method object.";
1676
+ _msg_error(
1677
+ _msg,
1678
+ 0);
1679
+ throw _error;
1680
+ }
1681
+ const
1682
+ _contract_call_dynamic_args = [
1683
+ _call_timeout,
1684
+ _wallet_seed,
1685
+ _wallet_password,
1686
+ _api_key_path,
1687
+ _price_gas,
1688
+ _msg_value,
1689
+ _measure_unit,
1690
+ _target_network,
1691
+ _contract_address,
1692
+ _contract_abi_path,
1693
+ _contract_bytecode_path,
1694
+ _contract_compiler_output_path,
1695
+ _contract_method,
1696
+ _method_args,
1697
+ _verbose,
1698
+ _retries_max,
1699
+ _contract,
1700
+ _method
1701
+ ];
957
1702
  _attempt =
958
1703
  1;
959
1704
  while ( _attempt <= _retries_max ) {
960
1705
  try {
961
1706
  [ _tx,
962
- _receipt ] =
1707
+ _receipt,
1708
+ _method,
1709
+ _contract ] =
963
1710
  await _contract_call_dynamic.apply(
964
1711
  null,
965
- _contract_call_dynamic_opts);
1712
+ _contract_call_dynamic_args);
966
1713
  _receipt_type =
967
1714
  typeof(
968
1715
  _receipt);
@@ -983,15 +1730,15 @@ async function
983
1730
  "Transaction response:";
984
1731
  _msg_info(
985
1732
  _msg);
986
- console.log(
1733
+ _echo(
987
1734
  _tx);
988
1735
  _msg =
989
1736
  "Transaction receipt:";
990
1737
  _msg_info(
991
1738
  _msg);
992
- console.log(
1739
+ _echo(
993
1740
  _receipt);
994
- }
1741
+ }
995
1742
  if ( _receipt.hash != undefined ) {
996
1743
  _receipt_tx_cost_get(
997
1744
  _receipt,
@@ -1012,7 +1759,7 @@ async function
1012
1759
  _tx_cost =
1013
1760
  _wei_to_ether(
1014
1761
  _tx_cost);
1015
- }
1762
+ }
1016
1763
  _msg =
1017
1764
  `Transaction cost: '${_tx_cost}'.`;
1018
1765
  _msg_info(
@@ -1053,8 +1800,12 @@ async function
1053
1800
  "Maximum number of retries reached.";
1054
1801
  throw _msg;
1055
1802
  }
1056
- return [_tx,
1057
- _receipt ];
1803
+ return [
1804
+ _tx,
1805
+ _receipt,
1806
+ _contract,
1807
+ _method
1808
+ ];
1058
1809
  }
1059
1810
 
1060
1811
  function