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.
Files changed (56) hide show
  1. package/dist/evm-contract-call/evm-contract-call.js +1 -1
  2. package/dist/evm-contract-call/fs-worker.js +1 -1
  3. package/dist/evm-contract-deployment-abi/evm-contract-deployment-abi.js +1 -1
  4. package/dist/evm-contract-deployment-abi/fs-worker.js +1 -1
  5. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +1 -1
  6. package/dist/evm-contract-deployment-address/fs-worker.js +1 -1
  7. package/dist/evm-contract-deployment-bytecode/evm-contract-deployment-bytecode.js +1 -1
  8. package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -1
  9. package/dist/evm-contract-deployment-compiler-output/evm-contract-deployment-compiler-output.js +1 -1
  10. package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -1
  11. package/dist/evm-contract-deployment-deployment-networks +1 -1
  12. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  13. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  14. package/dist/evm-contract-deployment-versions/fs-worker.js +1 -1
  15. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  16. package/dist/evm-contract-deployments-dir/fs-worker.js +1 -1
  17. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  18. package/dist/evm-contracts-tools/fs-worker.js +1 -1
  19. package/dist/libevm-contract-call/fs-worker.js +1 -1
  20. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  21. package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -1
  22. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +1 -1
  23. package/dist/libevm-contract-deployment-address/fs-worker.js +1 -1
  24. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +1 -1
  25. package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -1
  26. package/dist/libevm-contract-deployment-bytecode/libevm-contract-deployment-bytecode.js +1 -1
  27. package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -1
  28. package/dist/libevm-contract-deployment-compiler-output/libevm-contract-deployment-compiler-output.js +1 -1
  29. package/dist/libevm-contract-deployment-deployment-networks +1 -1
  30. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  31. package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -1
  32. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  33. package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -1
  34. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  35. package/dist/libevm-contracts-tools +1 -1
  36. package/eslint.config.mjs +1 -1
  37. package/evm-contract-call +514 -172
  38. package/evm-contract-deployment-abi +16 -12
  39. package/evm-contract-deployment-address +15 -12
  40. package/evm-contract-deployment-bytecode +15 -12
  41. package/evm-contract-deployment-compiler-output +16 -13
  42. package/evm-contract-deployment-networks +15 -12
  43. package/evm-contract-deployment-versions +15 -12
  44. package/evm-contract-deployments-dir +16 -13
  45. package/evm-contracts-tools +14 -12
  46. package/lib/contract-get +169 -39
  47. package/lib/evm-contract-call-dynamic +1112 -361
  48. package/lib/evm-contract-call-static +463 -73
  49. package/libevm-contract-call +625 -435
  50. package/libevm-contract-deployment +4388 -481
  51. package/libevm-contract-deployment-abi +287 -91
  52. package/libevm-contract-deployment-address +27 -16
  53. package/libevm-contract-deployment-bytecode +275 -80
  54. package/libevm-contract-deployment-compiler-output +341 -93
  55. package/libevm-contract-deployments-dir +53 -50
  56. package/package.json +11 -11
@@ -2,25 +2,27 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- /** ----------------------------------------------------------------
5
+ /** ----------------------------------------------------------
6
6
  * libevm-contract-call
7
- * ----------------------------------------------------------------
7
+ * ----------------------------------------------------------
8
8
  * Copyright ©
9
9
  * Pellegrino Prevete
10
- * 2024, 2025, 2026
10
+ * 2025, 2026
11
11
  *
12
12
  * All rights reserved
13
- * ----------------------------------------------------------------
13
+ * ----------------------------------------------------------
14
14
  *
15
- * This program is free software: you can redistribute it and/or
16
- * modify it under the terms of the GNU General Public License as
17
- * published by the Free Software Foundation, either version 3 of
18
- * the License, or (at your option) any later version.
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 be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
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
27
  * You should have received a copy of the
26
28
  * GNU General Public License
@@ -80,6 +82,11 @@ const
80
82
  const
81
83
  _echo =
82
84
  _libcrash_module._echo;
85
+ /* global
86
+ _echo2*/
87
+ const
88
+ _echo2=
89
+ _libcrash_module._echo2;
83
90
  /* global
84
91
  _file_exists */
85
92
  const
@@ -90,6 +97,11 @@ const
90
97
  const
91
98
  _get =
92
99
  _libcrash_module._get;
100
+ /* global
101
+ _global_get */
102
+ const
103
+ _global_get =
104
+ _libcrash_module._global_get;
93
105
  /* global
94
106
  _homedir_get */
95
107
  const
@@ -145,6 +157,70 @@ const
145
157
  const
146
158
  _set =
147
159
  _libcrash_module._set;
160
+ const
161
+ _libevm_contract_deployment_module =
162
+ await import(
163
+ "./libevm-contract-deployment");
164
+ /* global
165
+ _contract_abi_auto_detect */
166
+ const
167
+ _contract_abi_auto_detect =
168
+ _libevm_contract_deployment_module._contract_abi_auto_detect;
169
+ /* global
170
+ _contract_abi_check */
171
+ const
172
+ _contract_abi_check =
173
+ _libevm_contract_deployment_module._contract_abi_check;
174
+ /* global
175
+ _contract_address_auto_detect */
176
+ const
177
+ _contract_address_auto_detect =
178
+ _libevm_contract_deployment_module._contract_address_auto_detect;
179
+ /* global
180
+ _contract_address_check */
181
+ const
182
+ _contract_address_check =
183
+ _libevm_contract_deployment_module._contract_address_check;
184
+ /* global
185
+ _contract_bytecode_auto_detect */
186
+ const
187
+ _contract_bytecode_auto_detect =
188
+ _libevm_contract_deployment_module._contract_bytecode_auto_detect;
189
+ /* global
190
+ _contract_bytecode_check */
191
+ const
192
+ _contract_bytecode_check =
193
+ _libevm_contract_deployment_module._contract_bytecode_check;
194
+ /* global
195
+ _contract_compiler_output_auto_detect */
196
+ const
197
+ _contract_compiler_output_auto_detect =
198
+ _libevm_contract_deployment_module._contract_compiler_output_auto_detect;
199
+ /* global
200
+ _contract_compiler_output_check */
201
+ const
202
+ _contract_compiler_output_check =
203
+ _libevm_contract_deployment_module._contract_compiler_output_check;
204
+ /* global
205
+ _default_artifact_path_get */
206
+ const
207
+ _default_artifact_path_get =
208
+ _libevm_contract_deployment_module._default_artifact_path_get;
209
+ /* global
210
+ _deployments_dir_auto_detect */
211
+ const
212
+ _deployments_dir_auto_detect =
213
+ _libevm_contract_deployment_module._deployments_dir_auto_detect;
214
+ /* global
215
+ _target_contract_auto_detect */
216
+ const
217
+ _target_contract_auto_detect =
218
+ _libevm_contract_deployment_module._target_contract_auto_detect;
219
+ /* global
220
+ _target_contract_check */
221
+ const
222
+ _target_contract_check =
223
+ _libevm_contract_deployment_module._target_contract_check;
148
224
  const
149
225
  _evm_contracts_tools_module =
150
226
  await import(
@@ -154,6 +230,16 @@ const
154
230
  const
155
231
  _address_check =
156
232
  _evm_contracts_tools_module._address_check;
233
+ /* global
234
+ _contract_call_static */
235
+ const
236
+ _contract_call_static =
237
+ _evm_contracts_tools_module._contract_call_static;
238
+ /* global
239
+ _contract_run */
240
+ const
241
+ _contract_run =
242
+ _evm_contracts_tools_module._contract_run;
157
243
  const
158
244
  _evm_contract_deployment_address_module =
159
245
  await import(
@@ -163,6 +249,33 @@ const
163
249
  const
164
250
  _evm_contract_deployment_address =
165
251
  _evm_contract_deployment_address_module._evm_contract_deployment_address;
252
+ const
253
+ _evm_contract_deployment_abi_module =
254
+ await import(
255
+ "./libevm-contract-deployment-abi");
256
+ /* global
257
+ _evm_contract_deployment_abi */
258
+ const
259
+ _evm_contract_deployment_abi =
260
+ _evm_contract_deployment_abi_module._evm_contract_deployment_abi;
261
+ const
262
+ _evm_contract_deployment_bytecode_module =
263
+ await import(
264
+ "./libevm-contract-deployment-bytecode");
265
+ /* global
266
+ _evm_contract_deployment_bytecode */
267
+ const
268
+ _evm_contract_deployment_bytecode =
269
+ _evm_contract_deployment_bytecode_module._evm_contract_deployment_bytecode;
270
+ const
271
+ _evm_contract_deployment_compiler_output_module =
272
+ await import(
273
+ "./libevm-contract-deployment-compiler-output");
274
+ /* global
275
+ _evm_contract_deployment_compiler_output */
276
+ const
277
+ _evm_contract_deployment_compiler_output =
278
+ _evm_contract_deployment_compiler_output_module._evm_contract_deployment_compiler_output;
166
279
  const
167
280
  _evm_contract_deployments_dir_module =
168
281
  await import(
@@ -185,24 +298,129 @@ const
185
298
  function
186
299
  _target_networks_get(
187
300
  _target_networks) {
301
+ let
302
+ _msg,
303
+ _target_networks_type;
304
+ const
305
+ _global =
306
+ _global_get();
307
+ const
308
+ _quiet =
309
+ _global[
310
+ "quiet"];
188
311
  // TODO:
189
312
  // _evm_wallet_module._balance_discovery
190
- const
191
- _target_networks_type =
192
- typeof(
193
- _target_networks);
194
- if ( _target_networks_type == "undefined" ) {
313
+ _target_networks_type =
314
+ typeof(
315
+ _target_networks);
316
+ if ( _target_networks_type === "undefined" ) {
195
317
  _target_networks =
196
318
  _get(
197
319
  "target",
198
320
  "networks");
199
- }
200
- if ( _target_networks == "" ||
201
- _target_networks == [] ) {
202
- // to be auto-detected
203
- _target_networks = [
204
- "1"
321
+ _msg =
322
+ "Variable '_target_networks' undefined, " +
323
+ `defaulting to value ` +
324
+ `'${_target_networks}' of global variable ` +
325
+ `'target_networks'.`;
326
+ _msg_info(
327
+ _msg);
328
+ _target_networks_type =
329
+ typeof(
330
+ _target_networks);
331
+ if ( _target_networks_type === "undefined" ) {
332
+ _msg =
333
+ "Global variable 'target_networks' undefined, " +
334
+ `defaulting to chain with ID 1.`;
335
+ _msg_info(
336
+ _msg);
337
+ _target_networks = [
338
+ 1
205
339
  ];
340
+ }
341
+ else if ( _target_networks_type === "string" ) {
342
+ if ( _target_networks.length < 1 ) {
343
+ _msg =
344
+ "Global variable 'target_networks' undefined, " +
345
+ `defaulting to chain with ID 1.`;
346
+ _msg_info(
347
+ _msg);
348
+ _target_networks = [
349
+ 1
350
+ ];
351
+ }
352
+ else {
353
+ _msg =
354
+ `Unknown type '${_target_networks_type}' ` +
355
+ `for variable '_target_networks'.`;
356
+ _msg_error(
357
+ _msg,
358
+ 0);
359
+ _echo2(
360
+ _target_networks);
361
+ throw _msg;
362
+ }
363
+ }
364
+ }
365
+ else if ( _target_networks_type === "string" ) {
366
+ if ( _target_networks.length < 1 ) {
367
+ _target_networks =
368
+ _get(
369
+ "target",
370
+ "networks");
371
+ _msg =
372
+ "Variable '_target_networks' undefined, " +
373
+ `defaulting to value ` +
374
+ `'${_target_networks}' of global variable ` +
375
+ `'target_networks'.`;
376
+ _msg_info(
377
+ _msg);
378
+ _target_networks_type =
379
+ typeof(
380
+ _target_networks);
381
+ if ( _target_networks_type === "undefined" ) {
382
+ _msg =
383
+ "Global variable 'target_networks' undefined, " +
384
+ `defaulting to chain with ID 1.`;
385
+ _msg_info(
386
+ _msg);
387
+ _target_networks = [
388
+ 1
389
+ ];
390
+ }
391
+ }
392
+ else {
393
+ _msg =
394
+ `Invalid type 'string' ` +
395
+ `for variable '_target_networks' ` +
396
+ `('${_target_networks}').`;
397
+ _msg_error(
398
+ _msg,
399
+ 0);
400
+ _echo2(
401
+ _target_networks);
402
+ throw _msg;
403
+ }
404
+ }
405
+ else if ( _target_networks_type === "array" ||
406
+ _target_networks_type === "object" ) {
407
+ _msg =
408
+ "Selecting target networks:";
409
+ _msg_info(
410
+ _msg);
411
+ if ( _quiet == "n" ) {
412
+ _echo(
413
+ _target_networks);
414
+ }
415
+ }
416
+ else {
417
+ _msg =
418
+ "Variable '_target_networks' must be of " +
419
+ "type 'array'.";
420
+ _msg_error(
421
+ _msg,
422
+ 0);
423
+ throw _msg;
206
424
  }
207
425
  const
208
426
  _target_network =
@@ -238,210 +456,11 @@ function
238
456
  _target_network);
239
457
  }
240
458
 
241
- function
242
- _default_artifact_path_get(
243
- _type,
244
- _target_network,
245
- _contract_address) {
246
- let
247
- _file_name;
248
- const
249
- _network_type =
250
- typeof(
251
- _target_network);
252
- if ( _network_type === "undefined" ||
253
- _target_network === "" ) {
254
- _target_network =
255
- _get(
256
- "target",
257
- "network");
258
- }
259
- const
260
- _contract_address_type =
261
- typeof(
262
- _contract_address);
263
- if ( _contract_address_type === "undefined" ||
264
- _contract_address === "" ) {
265
- _contract_address =
266
- _get(
267
- "contract",
268
- "address");
269
- }
270
- const
271
- _home =
272
- _homedir_get();
273
- const
274
- _data_dir =
275
- _path_join( [
276
- _home,
277
- ".local",
278
- "share",
279
- "evm-contract-call" ]);
280
- if ( _type == "abi" ) {
281
- _file_name =
282
- `${_contract_address}.abi.json`;
283
- }
284
- else if ( _type == "bytecode" ) {
285
- _file_name =
286
- `${_contract_address}.bin`;
287
- }
288
- else if ( _type == "compiler_output" ) {
289
- _file_name =
290
- `${_contract_address}.json`;
291
- }
292
- else {
293
- const
294
- _msg =
295
- `Unknown artifact type '${_type}'.`;
296
- _msg_error(
297
- _msg,
298
- 0);
299
- throw _msg;
300
- }
301
- const
302
- _artifact =
303
- _path_join( [
304
- _data_dir,
305
- _target_network,
306
- _file_name ]);
307
- return _artifact;
308
- }
309
-
310
459
  function
311
460
  _contract_artifacts_retrieve() {
312
461
  true;
313
462
  }
314
463
 
315
- function
316
- _contract_abi_get(
317
- _network,
318
- _address,
319
- _api_key,
320
- _compiler_output,
321
- _abi) {
322
- let
323
- _abi_target;
324
- const
325
- _abi_type =
326
- typeof(
327
- _abi);
328
- if ( _abi_type == "undefined" ) {
329
- _abi =
330
- _get(
331
- "contract",
332
- "abi");
333
- }
334
- const
335
- _network_type =
336
- typeof(
337
- _network);
338
- if ( _network_type == "undefined" ) {
339
- _network =
340
- _get(
341
- "target",
342
- "network");
343
- }
344
- const
345
- _address_type =
346
- typeof(
347
- _address);
348
- if ( _address_type == "undefined" ) {
349
- _address =
350
- _get(
351
- "contract",
352
- "address");
353
- }
354
- const
355
- _api_key_type =
356
- typeof(
357
- _api_key);
358
- if ( _api_key_type == "undefined" ) {
359
- _api_key =
360
- _get(
361
- "api",
362
- "key");
363
- }
364
- const
365
- _compiler_output_type =
366
- typeof(
367
- _compiler_output);
368
- if ( _compiler_output_type == "undefined" ) {
369
- _compiler_output =
370
- _get(
371
- "contract",
372
- "compiler_output");
373
- }
374
- _abi_target =
375
- _abi;
376
- if ( typeof(
377
- _abi_target) === "undefined" ||
378
- _abi_target === "" ) {
379
- _abi_target =
380
- _default_artifact_path_get(
381
- "abi");
382
- }
383
- const
384
- _abi_dir =
385
- _dirname(
386
- _abi);
387
- if ( ! _file_exists(
388
- _abi) &&
389
- ! _file_exists(
390
- _compiler_output) ) {
391
- if ( _file_exists(
392
- _abi_target) ) {
393
- _abi =
394
- _abi_target;
395
- }
396
- else {
397
- _contract_artifacts_retrieve(
398
- _abi_dir);
399
- }
400
- }
401
- return _abi;
402
- }
403
-
404
- function
405
- _contract_abi_auto_detect() {
406
- let
407
- _abi;
408
- const
409
- _network =
410
- _get(
411
- "target",
412
- "network");
413
- const
414
- _address =
415
- _get(
416
- "contract",
417
- "address");
418
- const
419
- _api_key =
420
- _get(
421
- "api",
422
- "key");
423
- const
424
- _compiler_output =
425
- _get(
426
- "contract",
427
- "compiler_output");
428
- _abi =
429
- _get(
430
- "contract",
431
- "abi");
432
- _abi =
433
- _contract_abi_get(
434
- _network,
435
- _address,
436
- _api_key,
437
- _compiler_output,
438
- _abi);
439
- _override_set(
440
- "contract",
441
- "abi",
442
- _abi);
443
- }
444
-
445
464
  function
446
465
  _call_auth_get(
447
466
  _call_type) {
@@ -494,6 +513,98 @@ function
494
513
  _call_type);
495
514
  }
496
515
 
516
+ function
517
+ _call_type_check(
518
+ _call_type) {
519
+ let
520
+ _msg;
521
+ const
522
+ _call_type_type =
523
+ typeof(
524
+ _call_type);
525
+ if ( _call_type_type == "undefined" ) {
526
+ _call_type =
527
+ "static";
528
+ }
529
+ else if ( _call_type_type == "string" ) {
530
+ if ( _call_type.length < 1 ) {
531
+ // To be properly auto-detected.
532
+ _call_type =
533
+ "static";
534
+ }
535
+ }
536
+ else if ( _call_type_type == "object" ||
537
+ _call_type_type == "array" ) {
538
+ _msg =
539
+ "Parameter '_call_type' " +
540
+ "must be of type 'string'";
541
+ _msg_error(
542
+ _msg,
543
+ 0);
544
+ throw _msg;
545
+ }
546
+ else {
547
+ _msg =
548
+ `Call type '${_call_type}' ` +
549
+ `('${_call_type_type}'):`;
550
+ _msg_error(
551
+ _msg,
552
+ 0);
553
+ _echo2(
554
+ _call_type);
555
+ throw _msg;
556
+ }
557
+ return _call_type;
558
+ }
559
+
560
+ function
561
+ _contracts_init(
562
+ _contracts,
563
+ _target_networks) {
564
+ let
565
+ _network;
566
+ for ( _network of _target_networks ) {
567
+ if ( ! ( _network in _contracts ) ) {
568
+ _contracts[
569
+ _network] =
570
+ "";
571
+ }
572
+ }
573
+ return _contracts;
574
+ }
575
+
576
+ function
577
+ _methods_init(
578
+ _methods,
579
+ _target_networks) {
580
+ let
581
+ _network;
582
+ for ( _network of _target_networks ) {
583
+ if ( ! ( _network in _methods ) ) {
584
+ _methods[
585
+ _network] =
586
+ "";
587
+ }
588
+ }
589
+ return _methods;
590
+ }
591
+
592
+ function
593
+ _target_networks_check(
594
+ _target_networks) {
595
+ const
596
+ _target_networks_length =
597
+ _target_networks.length;
598
+ if ( _target_networks.length < 1 ) {
599
+ const
600
+ _msg =
601
+ "Auto-selecting network (chain ID '1').";
602
+ _target_networks.push(
603
+ 1);
604
+ }
605
+ return _target_networks;
606
+ }
607
+
497
608
  async function
498
609
  _evm_contract_call(
499
610
  _call_type,
@@ -514,75 +625,245 @@ async function
514
625
  _contract_bytecode,
515
626
  _contract_compiler_output,
516
627
  _contract_method,
517
- _method_args) {
518
- // let
519
- // _msg,
520
- // _out;
628
+ _method_args,
629
+ _output_file) {
630
+ let
631
+ _contract,
632
+ _contract_run_args,
633
+ _contracts,
634
+ _msg,
635
+ _method,
636
+ _methods,
637
+ _network,
638
+ _out,
639
+ _receipt,
640
+ _static_call_args,
641
+ _tx,
642
+ _value;
521
643
  const
522
- _call_type_type =
644
+ _global =
645
+ _global_get();
646
+ const
647
+ _quiet =
648
+ _global[
649
+ "quiet"];
650
+ _contracts =
651
+ {};
652
+ _methods =
653
+ {};
654
+ _target_networks =
655
+ _target_networks_check(
656
+ _target_networks);
657
+ _contracts =
658
+ _contracts_init(
659
+ _contracts,
660
+ _target_networks);
661
+ _methods =
662
+ _methods_init(
663
+ _methods,
664
+ _target_networks);
665
+ _out =
666
+ [];
667
+ _call_type =
668
+ _call_type_check(
669
+ _call_type);
670
+ // const
671
+ // _rpc =
672
+ // await =
673
+ // _rpc_get.apply(
674
+ // null,
675
+ // _rpc_get_args);
676
+ // _out.push(
677
+ // _call_type);
678
+ // return _out;
679
+ // _msg =
680
+ // "Running EVM network call " +
681
+ // `of type '${_call_type}'.`;
682
+ // _msg_info(
683
+ // _msg);
684
+ if ( _call_type == "static" ) {
685
+ for ( _network of _target_networks ) {
686
+ _method =
687
+ _methods[
688
+ _network];
689
+ _static_call_args = [
690
+ _wallet_seed,
691
+ _retries_max,
692
+ _api_key,
693
+ _network,
694
+ _contract_abi,
695
+ _contract_bytecode,
696
+ _contract_compiler_output,
697
+ _method,
698
+ _contract_address,
699
+ _contract_method,
700
+ _method_args
701
+ ];
702
+ _msg =
703
+ "Performing static call " +
704
+ `on network '${_network}' ` +
705
+ "with arguments:";
706
+ _msg_info(
707
+ _msg);
708
+ if ( _quiet == "n" ) {
709
+ _echo(
710
+ _static_call_args);
711
+ }
712
+ try {
713
+ [ _value,
714
+ _method ] =
715
+ await _contract_call_static.apply(
716
+ null,
717
+ _static_call_args);
718
+ }
719
+ catch(
720
+ _error) {
721
+ _msg =
722
+ "Error running '_contract_call_static' " +
723
+ "with arguments:";
724
+ _msg_error(
725
+ _msg,
726
+ 0);
727
+ _echo2(
728
+ _static_call_args);
729
+ throw _error;
730
+ }
731
+ _out.push(
732
+ _value);
733
+ }
734
+ }
735
+ else if ( _call_type == "dynamic" ) {
736
+ for ( _network of _target_networks ) {
737
+ _method =
738
+ _methods[
739
+ _network];
740
+ _contract =
741
+ _contracts[
742
+ _network];
743
+ _contract_run_args = [
744
+ _retries_max,
745
+ _call_timeout,
746
+ _wallet_seed,
747
+ _wallet_password,
748
+ _api_key,
749
+ _price_gas,
750
+ _msg_value,
751
+ _measure_unit,
752
+ _network,
753
+ _contract_address,
754
+ _contract_abi,
755
+ _contract_bytecode,
756
+ _contract_compiler_output,
757
+ _contract_method,
758
+ _method_args,
759
+ _output_file,
760
+ _quiet,
761
+ _contract,
762
+ _method
763
+ ];
764
+ [ _tx,
765
+ _receipt,
766
+ _method,
767
+ _contract ] =
768
+ await _contract_run.apply(
769
+ null,
770
+ _contract_run_args);
771
+ _out.push([
772
+ _tx,
773
+ _receipt
774
+ ]);
775
+ }
776
+ _out =
777
+ await _contract_run.apply(
778
+ null,
779
+ _contract_run_args);
780
+ }
781
+ return _out;
782
+ }
783
+
784
+ function
785
+ _artifact_type_check(
786
+ _artifact_type) {
787
+ let
788
+ _flag_empty,
789
+ _flag_wrong,
790
+ _msg_empty,
791
+ _msg_wrong;
792
+ _flag_empty =
793
+ false;
794
+ _flag_wrong =
795
+ false;
796
+ const
797
+ _artifact_type_type =
523
798
  typeof(
524
- _call_type);
525
- if ( _call_type_type == "undefined" ) {
526
- _call_type =
527
- "static";
799
+ _artifact_type);
800
+ if ( _artifact_type_type === "undefined" ) {
801
+ _msg_empty =
802
+ "Artifact type undefined.";
803
+ _flag_empty =
804
+ true;
528
805
  }
529
- else if ( _call_type_type == "string" ) {
530
- if ( _call_type.length < 1 ) {
531
- // Properly
532
- _call_type =
533
- "static";
806
+ else if ( _artifact_type_type === "string" ) {
807
+ if ( _artifact_type_type.length < 1 ) {
808
+ _msg_empty =
809
+ "Artifact type not set.";
810
+ _flag_empty =
811
+ true;
534
812
  }
535
813
  else {
536
- _echo(
537
- _call_type);
814
+ if ( _artifact_type !== "abi" &&
815
+ _artifact_type !== "bytecode" &&
816
+ _artifact_type !== "compiler_output" ) {
817
+ _msg_wrong =
818
+ "Artifact type can be 'abi', " +
819
+ "'bytecode' or 'compiler_output'.";
820
+ _flag_wrong =
821
+ true;
822
+ }
538
823
  }
539
824
  }
540
- else if ( _call_type_type == "object" ) {
541
- _echo(
542
- _call_type);
543
- }
544
825
  else {
545
- _echo(
546
- _call_type);
826
+ _msg_wrong =
827
+ "Artifact type must be of type string.";
828
+ _flag_wrong =
829
+ true;
547
830
  }
548
- return [ _call_type ];
549
- // _msg =
550
- // "Running EVM network call " +
551
- // `of type '${_call_type}'.`;
552
- // _msg_info(
553
- // _msg);
554
- // if ( _call_type == "static" ) {
555
- // _out =
556
- // "static";
557
- // _echo(
558
- // "static");
559
- // // const
560
- // // _infos =
561
- // // [];
562
- // // _out =
563
- // // "";
564
- // }
565
- // else if ( _call_type == "dynamic" ) {
566
- // _echo(
567
- // "dynamic");
568
- // _out =
569
- // "static";
570
- // }
571
- // else {
572
- // _msg =
573
- // `Unknown call type ` +
574
- // `'${_call_type}'.`;
575
- // _msg_error(
576
- // _msg,
577
- // 0);
578
- // throw _msg;
579
- // }
580
- // return _out;
831
+ if ( _flag_empty ) {
832
+ _msg_error(
833
+ _msg_empty,
834
+ 0);
835
+ throw _msg_empty;
836
+ }
837
+ if ( _flag_wrong ) {
838
+ _msg_error(
839
+ _msg_wrong,
840
+ 0);
841
+ throw _msg_wrong;
842
+ }
843
+ return _artifact_type;
581
844
  }
582
845
 
583
846
  function
584
847
  _artifact_local_auto_detect(
585
848
  _artifact_type) {
849
+ let
850
+ _msg;
851
+ try {
852
+ _artifact_type =
853
+ _artifact_type_check(
854
+ _artifact_type);
855
+ }
856
+ catch(
857
+ _error) {
858
+ _msg =
859
+ "Error checking artifact type.";
860
+ _msg_error(
861
+ _msg,
862
+ 0);
863
+ _echo2(
864
+ _error);
865
+ throw _error;
866
+ }
586
867
  const
587
868
  _artifact =
588
869
  _default_artifact_path_get(
@@ -856,161 +1137,6 @@ async function
856
1137
  _target_app);
857
1138
  }
858
1139
 
859
- async function
860
- _target_contract_auto_detect() {
861
- let
862
- _target_contract;
863
- _target_contract =
864
- "";
865
- const
866
- _contract_address =
867
- _get(
868
- "contract",
869
- "address");
870
- const
871
- _address_valid =
872
- await _address_check(
873
- _contract_address);
874
- if ( ! _address_valid ) {
875
- _target_contract =
876
- _contract_address;
877
- }
878
- _override_set(
879
- "target",
880
- "contract",
881
- _target_contract);
882
- }
883
-
884
- async function
885
- _contract_address_auto_detect() {
886
- let
887
- _contract_address,
888
- _contract_addresses,
889
- _evm_contract_deployment_address_args,
890
- _msg,
891
- _network;
892
- const
893
- _target_networks_index =
894
- {};
895
- _contract_address =
896
- _get(
897
- "contract",
898
- "address");
899
- const
900
- _target_app =
901
- _get(
902
- "target",
903
- "app");
904
- const
905
- _target_networks =
906
- _get(
907
- "target",
908
- "networks");
909
- const
910
- _target_contract =
911
- _get(
912
- "target",
913
- "contract");
914
- const
915
- _deployments_dir =
916
- _get(
917
- "deployments",
918
- "dir");
919
- for ( _network of _target_networks ) {
920
- _target_networks_index[
921
- _network] =
922
- 1;
923
- }
924
- const
925
- _target_networks_set =
926
- Object.keys(
927
- _target_networks_index);
928
- _msg =
929
- "Auto-detecting address " +
930
- `for contract '${_contract_address}' ` +
931
- `on network '${_target_networks_set}' ` +
932
- `for application '${_target_app}'.`;
933
- _msg_info(
934
- _msg);
935
- if ( _contract_address != "" ) {
936
- const
937
- _address_valid =
938
- await _address_check(
939
- _contract_address);
940
- if ( _address_valid ) {
941
- _msg =
942
- `Address '${_contract_address}' ` +
943
- `is valid.`;
944
- _msg_info(
945
- _msg);
946
- }
947
- else {
948
- if ( _target_app != "" &&
949
- 0 < _target_networks.length &&
950
- _target_contract != "" ) {
951
- _msg =
952
- "Looking for address " +
953
- "corresponding to contract " +
954
- `'${_target_contract}' for the ` +
955
- `'${_target_app}' ` +
956
- "libEVM application on network " +
957
- `'${_target_networks}' at deployments ` +
958
- `directory '${_deployments_dir}'.`;
959
- _msg_info(
960
- _msg);
961
- _evm_contract_deployment_address_args = [
962
- _target_networks_set, // target networks
963
- _target_networks_set, // target chain ids
964
- "n", // all networks
965
- _target_app,
966
- _target_contract,
967
- "", // contract version
968
- "n", // user-level
969
- "", // configuration format
970
- _deployments_dir
971
- ];
972
- try {
973
- _contract_addresses =
974
- await _evm_contract_deployment_address.apply(
975
- null,
976
- _evm_contract_deployment_address_args);
977
- _contract_address =
978
- _contract_addresses[
979
- 0];
980
- }
981
- catch(
982
- _error) {
983
- _msg =
984
- "Error while looking for contract " +
985
- "address from local libEVM applications " +
986
- "deployments directories.";
987
- _msg_error(
988
- _msg,
989
- 0);
990
- _msg_error(
991
- _error,
992
- 0);
993
- throw _error;
994
- }
995
- }
996
- else {
997
- _msg =
998
- "One between the " +
999
- `application '${_target_app}', ` +
1000
- `the network '${_target_networks_set}' ` +
1001
- `or the contract '${_target_contract}' ` +
1002
- `has not been specified.`;
1003
- _msg_info(
1004
- _msg);
1005
- }
1006
- }
1007
- }
1008
- _set(
1009
- "contract",
1010
- "address",
1011
- _contract_address);
1012
- }
1013
-
1014
1140
  function
1015
1141
  _data_dir_auto_detect() {
1016
1142
  const
@@ -1058,6 +1184,51 @@ function
1058
1184
  _cache_dir);
1059
1185
  }
1060
1186
 
1187
+ function
1188
+ _help_display_check(
1189
+ _help_display) {
1190
+ let
1191
+ _msg;
1192
+ const
1193
+ _help_display_type =
1194
+ typeof(
1195
+ _help_display);
1196
+ if ( _help_display_type === "undefined" ) {
1197
+ _help_display =
1198
+ false;
1199
+ }
1200
+ else if ( _help_display_type === "boolean" ) {
1201
+ true;
1202
+ }
1203
+ else if ( _help_display_type === "string" ) {
1204
+ if ( _help_display.length < 1 ) {
1205
+ _help_display =
1206
+ false;
1207
+ }
1208
+ else {
1209
+ if ( _help_display == "true" ) {
1210
+ _help_display =
1211
+ true;
1212
+ }
1213
+ else if ( _help_display == "false" ) {
1214
+ _help_display =
1215
+ false;
1216
+ }
1217
+ else {
1218
+ _msg =
1219
+ `Unknown value '${_help_display}' ` +
1220
+ "for variable '_help_display' (boolean).";
1221
+ _msg_error(
1222
+ _msg,
1223
+ 0);
1224
+ throw _msg;
1225
+ }
1226
+ }
1227
+ }
1228
+ return _help_display;
1229
+ }
1230
+
1231
+
1061
1232
  // ES6 module exports
1062
1233
 
1063
1234
  export {
@@ -1068,11 +1239,18 @@ export {
1068
1239
  _call_auth_auto_detect,
1069
1240
  _call_auth_get,
1070
1241
  _contract_abi_auto_detect,
1071
- _contract_abi_get,
1242
+ _contract_abi_check,
1072
1243
  _contract_address_auto_detect,
1244
+ _contract_address_check,
1245
+ _contract_bytecode_auto_detect,
1246
+ _contract_bytecode_check,
1247
+ _contract_compiler_output_auto_detect,
1248
+ _contract_compiler_output_check,
1073
1249
  _data_dir_auto_detect,
1074
1250
  _default_artifact_path_get,
1251
+ _deployments_dir_auto_detect,
1075
1252
  _evm_contract_call,
1253
+ _help_display_check,
1076
1254
  _target_app_auto_detect,
1077
1255
  _target_contract_auto_detect,
1078
1256
  _target_networks_auto_detect,
@@ -1096,14 +1274,26 @@ export {
1096
1274
  // _call_auth_get,
1097
1275
  // _contract_abi_auto_detect:
1098
1276
  // _contract_abi_auto_detect,
1099
- // _contract_abi_get:
1100
- // _contract_abi_get,
1277
+ // _contract_abi_check:
1278
+ // _contract_abi_check,
1101
1279
  // _contract_address_auto_detect:
1102
1280
  // _contract_address_auto_detect,
1281
+ // _contract_address_check:
1282
+ // _contract_address_check,
1283
+ // _contract_bytecode_auto_detect:
1284
+ // _contract_bytecode_auto_detect,
1285
+ // _contract_bytecode_check:
1286
+ // _contract_bytecode_check,
1287
+ // _contract_compiler_output_auto_detect:
1288
+ // _contract_compiler_output_auto_detect,
1289
+ // _contract_compiler_output_check:
1290
+ // _contract_compiler_output_check,
1103
1291
  // _data_dir_auto_detect:
1104
1292
  // _data_dir_auto_detect,
1105
1293
  // _default_artifact_path_get:
1106
1294
  // _default_artifact_path_get,
1295
+ // _deployments_dir_auto_detect:
1296
+ // _deployments_dir_auto_detect,
1107
1297
  // _evm_contract_call:
1108
1298
  // _evm_contract_call,
1109
1299
  // _target_app_auto_detect: