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-deployment-abi
7
- * ----------------------------------------------------------------
7
+ * ----------------------------------------------------------
8
8
  * Copyright ©
9
9
  * Pellegrino Prevete
10
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
@@ -83,6 +85,11 @@ const
83
85
  const
84
86
  _dir_exists =
85
87
  _libcrash_module._dir_exists;
88
+ /* global
89
+ _echo2 */
90
+ const
91
+ _echo2 =
92
+ _libcrash_module._echo2;
86
93
  /* global
87
94
  _file_exists */
88
95
  const
@@ -157,15 +164,6 @@ const
157
164
  const
158
165
  _evm_chains_info =
159
166
  _evm_chains_info_module._evm_chains_info;
160
- const
161
- _libevm_contract_deployments_dir_module =
162
- await import(
163
- "./libevm-contract-deployments-dir");
164
- /* global
165
- _evm_contract_deployments_dir */
166
- const
167
- _evm_contract_deployments_dir =
168
- _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
169
167
  const
170
168
  _libevm_contract_deployment_module =
171
169
  await import(
@@ -200,6 +198,25 @@ const
200
198
  const
201
199
  _user_deployments_check =
202
200
  _libevm_contract_deployment_module._user_deployments_check;
201
+ /* global
202
+ _user_defined_check */
203
+ const
204
+ _user_defined_check =
205
+ _libevm_contract_deployment_module._user_defined_check;
206
+ /* global
207
+ _version_check */
208
+ const
209
+ _version_check =
210
+ _libevm_contract_deployment_module._version_check;
211
+ const
212
+ _libevm_contract_deployments_dir_module =
213
+ await import(
214
+ "./libevm-contract-deployments-dir");
215
+ /* global
216
+ _evm_contract_deployments_dir */
217
+ const
218
+ _evm_contract_deployments_dir =
219
+ _libevm_contract_deployments_dir_module._evm_contract_deployments_dir;
203
220
  const
204
221
  _libevm_contract_deployment_networks_module =
205
222
  await import(
@@ -209,53 +226,134 @@ const
209
226
  const
210
227
  _evm_contract_deployment_networks =
211
228
  _libevm_contract_deployment_networks_module._evm_contract_deployment_networks;
212
- const
213
- _libevm_contract_deployment_versions_module =
214
- await import(
215
- "./libevm-contract-deployment-versions");
216
- /* global
217
- _evm_contract_deployment_versions */
218
- const
219
- _evm_contract_deployment_versions =
220
- _libevm_contract_deployment_versions_module._evm_contract_deployment_versions;
221
229
 
222
- function
230
+ async function
223
231
  _contract_abi_get(
224
232
  _deployments,
233
+ _app,
225
234
  _contract,
226
235
  _network,
227
236
  _network_id,
228
- _version) {
237
+ _version,
238
+ _configuration_format,
239
+ _user_defined) {
229
240
  let
230
241
  _abi_path,
242
+ _abi_retrieve,
231
243
  _address,
244
+ _break,
232
245
  _found,
233
- _key_name,
234
246
  _msg,
235
- _net;
247
+ _net,
248
+ _non_empty_networks;
236
249
  const
237
250
  _networks = [
238
251
  _network,
239
252
  _network_id
240
253
  ];
254
+ _non_empty_networks =
255
+ false;
241
256
  _found =
242
257
  false;
258
+ // _echo2(
259
+ // _networks);
243
260
  for ( _net of _networks ) {
244
- _abi_path =
245
- _path_join( [
246
- _deployments,
247
- _contract,
248
- _net,
249
- _version,
250
- `${_contract}.abi.json` ]);
251
- if ( _file_exists(
252
- _abi_path) ) {
253
- _found =
261
+ _abi_retrieve =
262
+ false;
263
+ _break =
264
+ false;
265
+ if ( _net.length < 1 ) {
266
+ _msg =
267
+ `Empty value network '${_net}', ` +
268
+ "skipping.";
269
+ _msg_info(
270
+ _msg);
271
+ }
272
+ else {
273
+ _abi_retrieve =
274
+ true;
275
+ }
276
+ if ( _abi_retrieve ) {
277
+ _non_empty_networks =
254
278
  true;
279
+ _msg =
280
+ "Getting ABI for network " +
281
+ `'${_net}'.`;
282
+ _msg_info(
283
+ _msg);
284
+ const
285
+ _version_check_args = [
286
+ _version,
287
+ _app, // app
288
+ _contract,
289
+ "", // address
290
+ _net,
291
+ _user_defined,
292
+ _deployments,
293
+ "", // config file
294
+ _configuration_format
295
+ ];
296
+ try {
297
+ _version =
298
+ await _version_check.apply(
299
+ null,
300
+ _version_check_args);
301
+ }
302
+ catch(
303
+ _error) {
304
+ _msg =
305
+ "Error running '_version_check' " +
306
+ "with arguments:";
307
+ _msg_error(
308
+ _msg,
309
+ 0);
310
+ _echo2(
311
+ _version_check_args);
312
+ _echo2(
313
+ _error);
314
+ throw _error;
315
+ }
316
+ _msg =
317
+ `Checked version '${_version}'.`;
318
+ _msg_info(
319
+ _msg);
320
+ _abi_path =
321
+ _path_join( [
322
+ _deployments,
323
+ _contract,
324
+ _net,
325
+ _version,
326
+ `${_contract}.abi.json`
327
+ ]);
328
+ _msg =
329
+ `Checking file '${_abi_path}'.`;
330
+ _msg_info(
331
+ _msg);
332
+ if ( _file_exists(
333
+ _abi_path) ) {
334
+ _found =
335
+ true;
336
+ _break =
337
+ true;
338
+ }
339
+ else {
340
+ _msg =
341
+ `ABI at path '${_abi_path}' ` +
342
+ `not found.`;
343
+ _msg_info(
344
+ _msg);
345
+ }
346
+ }
347
+ if ( _break ) {
348
+ _msg =
349
+ "File found, breaking loop.";
350
+ _msg_info(
351
+ _msg);
255
352
  break;
256
353
  }
257
354
  }
258
- if ( ! _found ) {
355
+ if ( ! _found &&
356
+ _non_empty_networks ) {
259
357
  _msg =
260
358
  `No ABI file for '${_network}' deployment ` +
261
359
  `of contract '${_contract}' ` +
@@ -268,10 +366,13 @@ function
268
366
  const
269
367
  _contract_abi =
270
368
  _abi_path;
271
- if ( _contract_abi == "" ||
272
- typeof(
273
- _contract_abi) == "undefined" ||
274
- _contract_abi == null ) {
369
+ const
370
+ _contract_abi_type =
371
+ typeof(
372
+ _contract_abi);
373
+ if ( _contract_abi === "" ||
374
+ _contract_abi_type === "undefined" ||
375
+ _contract_abi === null ) {
275
376
  _msg =
276
377
  `No '${_contract}' version '${_version}' ` +
277
378
  `contract deployment specified for network ` +
@@ -282,6 +383,10 @@ function
282
383
  0);
283
384
  throw _msg;
284
385
  }
386
+ _msg =
387
+ `Got ABI: '${_contract_abi}'.`;
388
+ _msg_info(
389
+ _msg);
285
390
  return _contract_abi;
286
391
  }
287
392
 
@@ -299,6 +404,7 @@ async function
299
404
  let
300
405
  _args,
301
406
  _contract_abi,
407
+ _deployments_dir_get,
302
408
  _network,
303
409
  _network_check_args,
304
410
  _target_network,
@@ -312,6 +418,59 @@ async function
312
418
  const
313
419
  _contract_abi_get_args =
314
420
  [];
421
+ _user_defined =
422
+ _user_defined_check(
423
+ _user_defined);
424
+ const
425
+ _deployments_dir_type =
426
+ typeof(
427
+ _deployments_dir);
428
+ _deployments_dir_get =
429
+ false;
430
+ if ( _deployments_dir_type === "undefined" ) {
431
+ _msg =
432
+ "Deployments directory undefined, getting.";
433
+ _msg_info(
434
+ _msg);
435
+ _deployments_dir_get =
436
+ true;
437
+ }
438
+ else if ( _deployments_dir_type === "string" ) {
439
+ if ( _deployments_dir.length < 1 ) {
440
+ _msg =
441
+ "Deployments directory not set, getting.";
442
+ _msg_info(
443
+ _msg);
444
+ _deployments_dir_get =
445
+ true;
446
+ }
447
+ }
448
+ if ( _deployments_dir_get ) {
449
+ const
450
+ _evm_contract_deployments_dir_args = [
451
+ _target_app,
452
+ _user_defined
453
+ ];
454
+ try {
455
+ _deployments_dir =
456
+ await _evm_contract_deployments_dir.apply(
457
+ null,
458
+ _evm_contract_deployments_dir_args);
459
+ }
460
+ catch(
461
+ _error) {
462
+ _msg =
463
+ "Error while retrieving system deployments " +
464
+ "directory location for auto-detection.";
465
+ _msg_error(
466
+ _msg,
467
+ 0);
468
+ _msg_error(
469
+ _error,
470
+ 0);
471
+ throw _error;
472
+ }
473
+ }
315
474
  if ( _user_defined == "n" ) {
316
475
  if ( _target_app == "" ) {
317
476
  _msg =
@@ -367,7 +526,8 @@ async function
367
526
  `can be 'y' or 'n', current value '${_user_defined}'.`;
368
527
  _msg_error(
369
528
  _msg,
370
- 1);
529
+ 0);
530
+ throw _msg;
371
531
  }
372
532
  if ( _networks_all == "y" ) {
373
533
  _msg =
@@ -385,52 +545,88 @@ async function
385
545
  // `network '${_network}'.`;
386
546
  // _msg_info(
387
547
  // _msg);
388
- _target_network_id =
389
- "";
390
- _network_check_args = [
391
- _deployments_dir,
392
- _target_contract,
393
- _network,
394
- _target_network_id
395
- ];
396
- await _network_check.apply(
397
- null,
398
- _network_check_args);
399
- _contract_abi_get_args.push( [
400
- _deployments_dir,
401
- _target_contract,
402
- _network,
403
- _target_network_id,
404
- _contract_version,
405
- _configuration_format
406
- ] );
548
+ if ( _network.length < 1 ) {
549
+ _msg =
550
+ "Empty network, skipping.";
551
+ _msg_info(
552
+ _msg);
553
+ }
554
+ else {
555
+ _target_network_id =
556
+ "";
557
+ _network_check_args = [
558
+ _deployments_dir,
559
+ _target_contract,
560
+ _network,
561
+ _target_network_id
562
+ ];
563
+ await _network_check.apply(
564
+ null,
565
+ _network_check_args);
566
+ _contract_abi_get_args.push( [
567
+ _deployments_dir,
568
+ _target_app,
569
+ _target_contract,
570
+ _network,
571
+ _target_network_id,
572
+ _contract_version,
573
+ _configuration_format,
574
+ _user_defined
575
+ ] );
576
+ }
407
577
  }
408
- for ( _network of _network_ids ) {
409
- _target_network =
410
- "";
411
- _network_check_args = [
412
- _deployments_dir,
413
- _target_contract,
414
- _target_network,
415
- _network
416
- ];
417
- await _network_check.apply(
418
- null,
419
- _network_check_args);
420
- _contract_abi_get_args.push( [
421
- _deployments_dir,
422
- _target_contract,
423
- _target_network,
424
- _target_network_id,
425
- _contract_version,
426
- _configuration_format
427
- ] );
578
+ for ( _network of _network_ids ) {
579
+ if ( _network.length < 1 ) {
580
+ _msg =
581
+ "Empty network, skipping.";
582
+ _msg_info(
583
+ _msg);
584
+ }
585
+ else {
586
+ _target_network =
587
+ "";
588
+ _network_check_args = [
589
+ _deployments_dir,
590
+ _target_contract,
591
+ _target_network,
592
+ _network
593
+ ];
594
+ await _network_check.apply(
595
+ null,
596
+ _network_check_args);
597
+ _contract_abi_get_args.push( [
598
+ _deployments_dir,
599
+ _target_app,
600
+ _target_contract,
601
+ _target_network,
602
+ _network,
603
+ _contract_version,
604
+ _configuration_format,
605
+ _user_defined
606
+ ] );
607
+ }
428
608
  }
429
609
  for ( _args of _contract_abi_get_args ) {
430
- _contract_abi =
431
- _contract_abi_get.apply(
432
- null,
610
+ try {
611
+ _contract_abi =
612
+ await _contract_abi_get.apply(
613
+ null,
614
+ _args);
615
+ }
616
+ catch(
617
+ _error) {
618
+ _msg =
619
+ "Error running '_contract_abi_get' " +
620
+ "with parameters:";
621
+ _msg_error(
622
+ _msg,
623
+ 0);
624
+ _echo2(
433
625
  _args);
626
+ _echo2(
627
+ _error);
628
+ throw _error;
629
+ }
434
630
  _contracts_abis.push(
435
631
  _contract_abi);
436
632
  }