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
@@ -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
@@ -75,6 +77,16 @@ const
75
77
  const
76
78
  _dirname =
77
79
  _libcrash_module._dirname;
80
+ /* global
81
+ _echo */
82
+ const
83
+ _echo =
84
+ _libcrash_module._echo;
85
+ /* global
86
+ _echo2*/
87
+ const
88
+ _echo2=
89
+ _libcrash_module._echo2;
78
90
  /* global
79
91
  _file_exists */
80
92
  const
@@ -85,6 +97,11 @@ const
85
97
  const
86
98
  _get =
87
99
  _libcrash_module._get;
100
+ /* global
101
+ _global_get */
102
+ const
103
+ _global_get =
104
+ _libcrash_module._global_get;
88
105
  /* global
89
106
  _homedir_get */
90
107
  const
@@ -140,6 +157,70 @@ const
140
157
  const
141
158
  _set =
142
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;
143
224
  const
144
225
  _evm_contracts_tools_module =
145
226
  await import(
@@ -149,6 +230,16 @@ const
149
230
  const
150
231
  _address_check =
151
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;
152
243
  const
153
244
  _evm_contract_deployment_address_module =
154
245
  await import(
@@ -158,6 +249,42 @@ const
158
249
  const
159
250
  _evm_contract_deployment_address =
160
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;
279
+ const
280
+ _evm_contract_deployments_dir_module =
281
+ await import(
282
+ "./libevm-contract-deployments-dir");
283
+ /* global
284
+ _evm_contract_deployments_dir */
285
+ const
286
+ _evm_contract_deployments_dir =
287
+ _evm_contract_deployments_dir_module._evm_contract_deployments_dir;
161
288
  const
162
289
  _ethereum_data_module =
163
290
  await _require(
@@ -171,24 +298,129 @@ const
171
298
  function
172
299
  _target_networks_get(
173
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"];
174
311
  // TODO:
175
312
  // _evm_wallet_module._balance_discovery
176
- const
177
- _target_networks_type =
178
- typeof(
179
- _target_networks);
180
- if ( _target_networks_type == "undefined" ) {
313
+ _target_networks_type =
314
+ typeof(
315
+ _target_networks);
316
+ if ( _target_networks_type === "undefined" ) {
181
317
  _target_networks =
182
318
  _get(
183
319
  "target",
184
320
  "networks");
185
- }
186
- if ( _target_networks == "" ||
187
- _target_networks == [] ) {
188
- // to be auto-detected
189
- _target_networks = [
190
- "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
191
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;
192
424
  }
193
425
  const
194
426
  _target_network =
@@ -224,185 +456,11 @@ function
224
456
  _target_network);
225
457
  }
226
458
 
227
- function
228
- _default_artifact_path_get(
229
- _type) {
230
- let
231
- _file_name;
232
- const
233
- _home =
234
- _homedir_get();
235
- const
236
- _data_dir =
237
- _path_join( [
238
- _home,
239
- ".local",
240
- "share",
241
- "evm-contract-call" ]);
242
- if ( _type == "abi" ) {
243
- _file_name =
244
- `${contract_address}.abi.json`;
245
- }
246
- else if ( _type == "bytecode" ) {
247
- _file_name =
248
- `${contract_address}.bin`;
249
- }
250
- else if ( _type == "compiler_output" ) {
251
- _file_name =
252
- `${contract_address}.json`;
253
- }
254
- else {
255
- const
256
- _msg =
257
- `Unknown artifact type '${_type}'.`;
258
- _msg_error(
259
- _msg,
260
- 1);
261
- }
262
- const
263
- _artifact =
264
- _path_join( [
265
- _data_dir,
266
- target_network,
267
- _file_name ]);
268
- return _artifact;
269
- }
270
-
271
459
  function
272
460
  _contract_artifacts_retrieve() {
273
461
  true;
274
462
  }
275
463
 
276
- function
277
- _contract_abi_get(
278
- _network,
279
- _address,
280
- _api_key,
281
- _compiler_output,
282
- _abi) {
283
- let
284
- _abi_target;
285
- const
286
- _abi_type =
287
- typeof(
288
- _abi);
289
- if ( _abi_type == "undefined" ) {
290
- _abi =
291
- _get(
292
- "contract",
293
- "abi");
294
- }
295
- const
296
- _network_type =
297
- typeof(
298
- _network);
299
- if ( _network_type == "undefined" ) {
300
- _network =
301
- _get(
302
- "target",
303
- "network");
304
- }
305
- const
306
- _address_type =
307
- typeof(
308
- _address);
309
- if ( _address_type == "undefined" ) {
310
- _address =
311
- _get(
312
- "contract",
313
- "address");
314
- }
315
- const
316
- _api_key_type =
317
- typeof(
318
- _api_key);
319
- if ( _api_key_type == "undefined" ) {
320
- _api_key =
321
- _get(
322
- "api",
323
- "key");
324
- }
325
- const
326
- _compiler_output_type =
327
- typeof(
328
- _compiler_output);
329
- if ( _compiler_output_type == "undefined" ) {
330
- _compiler_output =
331
- _get(
332
- "contract",
333
- "compiler_output");
334
- }
335
- _abi_target =
336
- _abi;
337
- if ( typeof(
338
- _abi_target) == "undefined" ||
339
- _abi_target == "" ) {
340
- _abi_target =
341
- _default_artifact_path_get(
342
- "abi");
343
- }
344
- const
345
- _abi_dir =
346
- _dirname(
347
- _abi);
348
- if ( ! _file_exists(
349
- _abi) &&
350
- ! _file_exists(
351
- _compiler_output) ) {
352
- if ( _file_exists(
353
- _abi_target) ) {
354
- _abi =
355
- _abi_target;
356
- }
357
- else {
358
- _contract_artifacts_retrieve(
359
- _abi_dir);
360
- }
361
- }
362
- return _abi;
363
- }
364
-
365
- function
366
- _contract_abi_auto_detect() {
367
- let
368
- _abi;
369
- const
370
- _network =
371
- _get(
372
- "target",
373
- "network");
374
- const
375
- _address =
376
- _get(
377
- "contract",
378
- "address");
379
- const
380
- _api_key =
381
- _get(
382
- "api",
383
- "key");
384
- const
385
- _compiler_output =
386
- _get(
387
- "contract",
388
- "compiler_output");
389
- _abi =
390
- _get(
391
- "contract",
392
- "abi");
393
- _abi =
394
- _contract_abi_get(
395
- _network,
396
- _address,
397
- _api_key,
398
- _compiler_output,
399
- _abi);
400
- _override_set(
401
- "contract",
402
- "abi",
403
- _abi);
404
- }
405
-
406
464
  function
407
465
  _call_auth_get(
408
466
  _call_type) {
@@ -455,6 +513,98 @@ function
455
513
  _call_type);
456
514
  }
457
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
+
458
608
  async function
459
609
  _evm_contract_call(
460
610
  _call_type,
@@ -475,39 +625,245 @@ async function
475
625
  _contract_bytecode,
476
626
  _contract_compiler_output,
477
627
  _contract_method,
478
- _method_args) {
628
+ _method_args,
629
+ _output_file) {
479
630
  let
480
- _explorer,
631
+ _contract,
632
+ _contract_run_args,
633
+ _contracts,
634
+ _msg,
635
+ _method,
636
+ _methods,
637
+ _network,
481
638
  _out,
482
- _result,
483
- _rpc;
639
+ _receipt,
640
+ _static_call_args,
641
+ _tx,
642
+ _value;
643
+ const
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);
484
684
  if ( _call_type == "static" ) {
485
- const
486
- _infos =
487
- [];
488
- _out =
489
- "";
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
+ }
490
734
  }
491
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
+ }
492
776
  _out =
493
- "";
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 =
798
+ typeof(
799
+ _artifact_type);
800
+ if ( _artifact_type_type === "undefined" ) {
801
+ _msg_empty =
802
+ "Artifact type undefined.";
803
+ _flag_empty =
804
+ true;
805
+ }
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;
812
+ }
813
+ else {
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
+ }
823
+ }
494
824
  }
495
825
  else {
496
- const
497
- _msg =
498
- `Unknown call type ` +
499
- `'${_call_type}'.`;
826
+ _msg_wrong =
827
+ "Artifact type must be of type string.";
828
+ _flag_wrong =
829
+ true;
830
+ }
831
+ if ( _flag_empty ) {
500
832
  _msg_error(
501
- _msg,
833
+ _msg_empty,
502
834
  0);
503
- throw _msg;
835
+ throw _msg_empty;
504
836
  }
505
- return _out;
837
+ if ( _flag_wrong ) {
838
+ _msg_error(
839
+ _msg_wrong,
840
+ 0);
841
+ throw _msg_wrong;
842
+ }
843
+ return _artifact_type;
506
844
  }
507
845
 
508
846
  function
509
847
  _artifact_local_auto_detect(
510
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
+ }
511
867
  const
512
868
  _artifact =
513
869
  _default_artifact_path_get(
@@ -680,6 +1036,7 @@ async function
680
1036
  let
681
1037
  _app,
682
1038
  _contract_dir,
1039
+ _is_dir,
683
1040
  _msg;
684
1041
  const
685
1042
  _lib =
@@ -699,8 +1056,14 @@ async function
699
1056
  "deployments",
700
1057
  _contract_name
701
1058
  ]);
702
- if ( _dir_exists(
703
- _contract_dir) ) {
1059
+ // _echo(_contract_dir);
1060
+ _is_dir =
1061
+ await _dir_exists(
1062
+ _contract_dir);
1063
+ // _echo(_is_dir);
1064
+ if ( _is_dir ) {
1065
+ // _echo(
1066
+ // _contract_dir);
704
1067
  _target_apps[
705
1068
  _app] =
706
1069
  1;
@@ -747,7 +1110,7 @@ async function
747
1110
  0];
748
1111
  }
749
1112
 
750
- function
1113
+ async function
751
1114
  _target_app_auto_detect() {
752
1115
  let
753
1116
  _target_app;
@@ -765,7 +1128,7 @@ function
765
1128
  if ( _contract_address_type != "undefined" &&
766
1129
  _contract_address != "" ) {
767
1130
  _target_app =
768
- _target_app_get(
1131
+ await _target_app_get(
769
1132
  _contract_address);
770
1133
  }
771
1134
  _override_set(
@@ -774,88 +1137,6 @@ function
774
1137
  _target_app);
775
1138
  }
776
1139
 
777
- async function
778
- _contract_address_auto_detect() {
779
- let
780
- _contract_address,
781
- _evm_contract_deployment_address_args,
782
- _msg;
783
- _contract_address =
784
- _get(
785
- "contract",
786
- "address");
787
- const
788
- _target_app =
789
- _get(
790
- "target",
791
- "app");
792
- const
793
- _target_network =
794
- _get(
795
- "target",
796
- "network");
797
- const
798
- _target_contract =
799
- _get(
800
- "target",
801
- "contract");
802
- const
803
- _deployments_dir =
804
- _get(
805
- "deployments",
806
- "dir");
807
- if ( _contract_address != "" ) {
808
- const
809
- _address_valid =
810
- await _address_check(
811
- _contract_address);
812
- if ( ! _address_valid ) {
813
- if ( _target_app != "" &&
814
- _target_network != "" &&
815
- _target_contract != "" ) {
816
- _msg =
817
- "Looking for address " +
818
- "corresponding to contract " +
819
- `'${_target_contract}' for the ` +
820
- `'${_target_app}' ` +
821
- "libEVM application on network " +
822
- `'${_target_network}'.`;
823
- _msg_info(
824
- _msg);
825
- _evm_contract_deployment_address_args = [
826
- [ _target_network ], // target networks
827
- [ _target_network ], // target chain ids
828
- "n", // all networks
829
- _target_app,
830
- _target_contract,
831
- "", // contract version
832
- "n", // user-level
833
- "", // configuration format
834
- _deployments_dir
835
- ];
836
- _contract_address =
837
- await _evm_contract_deployment_address.apply(
838
- null,
839
- _evm_contract_deployment_address_args);
840
- }
841
- else {
842
- _msg =
843
- "One between the " +
844
- `application '${_target_app}', ` +
845
- `the network '${_target_network}' ` +
846
- `or the contract '${_target_contract}' ` +
847
- `has not been specified.`;
848
- _msg_info(
849
- _msg);
850
- }
851
- }
852
- }
853
- _set(
854
- "contract",
855
- "address",
856
- _contract_address);
857
- }
858
-
859
1140
  function
860
1141
  _data_dir_auto_detect() {
861
1142
  const
@@ -903,6 +1184,51 @@ function
903
1184
  _cache_dir);
904
1185
  }
905
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
+
906
1232
  // ES6 module exports
907
1233
 
908
1234
  export {
@@ -913,12 +1239,20 @@ export {
913
1239
  _call_auth_auto_detect,
914
1240
  _call_auth_get,
915
1241
  _contract_abi_auto_detect,
916
- _contract_abi_get,
1242
+ _contract_abi_check,
917
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,
918
1249
  _data_dir_auto_detect,
919
1250
  _default_artifact_path_get,
1251
+ _deployments_dir_auto_detect,
920
1252
  _evm_contract_call,
1253
+ _help_display_check,
921
1254
  _target_app_auto_detect,
1255
+ _target_contract_auto_detect,
922
1256
  _target_networks_auto_detect,
923
1257
  _target_networks_get
924
1258
  };
@@ -940,20 +1274,34 @@ export {
940
1274
  // _call_auth_get,
941
1275
  // _contract_abi_auto_detect:
942
1276
  // _contract_abi_auto_detect,
943
- // _contract_abi_get:
944
- // _contract_abi_get,
1277
+ // _contract_abi_check:
1278
+ // _contract_abi_check,
945
1279
  // _contract_address_auto_detect:
946
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,
947
1291
  // _data_dir_auto_detect:
948
1292
  // _data_dir_auto_detect,
949
1293
  // _default_artifact_path_get:
950
1294
  // _default_artifact_path_get,
1295
+ // _deployments_dir_auto_detect:
1296
+ // _deployments_dir_auto_detect,
951
1297
  // _evm_contract_call:
952
1298
  // _evm_contract_call,
953
1299
  // _target_app_auto_detect:
954
1300
  // _target_app_auto_detect,
955
1301
  // _target_networks_auto_detect:
956
1302
  // _target_networks_auto_detect,
1303
+ // _target_contract_auto_detect:
1304
+ // _target_contract_auto_detect,
957
1305
  // _target_networks_get:
958
1306
  // _target_networks_get
959
1307
  // };