evm-contracts-tools 0.0.45 → 0.0.47

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 (38) hide show
  1. package/Makefile +13 -0
  2. package/dist/evm-contract-call/evm-contract-call.js +1 -1
  3. package/dist/evm-contract-deployment-abi/fs-worker.js +1 -0
  4. package/dist/evm-contract-deployment-abi/index.html +31 -0
  5. package/dist/evm-contract-deployment-bytecode/fs-worker.js +1 -0
  6. package/dist/evm-contract-deployment-bytecode/index.html +31 -0
  7. package/dist/evm-contract-deployment-compiler-output/fs-worker.js +1 -0
  8. package/dist/evm-contract-deployment-compiler-output/index.html +31 -0
  9. package/dist/evm-contract-deployment-networks/evm-contract-deployment-networks.js +1 -1
  10. package/dist/evm-contract-deployment-versions/evm-contract-deployment-versions.js +1 -1
  11. package/dist/evm-contract-deployments-dir/evm-contract-deployments-dir.js +1 -1
  12. package/dist/evm-contracts-tools/evm-contracts-tools.js +1 -1
  13. package/dist/libevm-contract-call/libevm-contract-call.js +1 -1
  14. package/dist/libevm-contract-deployment-abi/fs-worker.js +1 -0
  15. package/dist/libevm-contract-deployment-abi/index.html +24 -0
  16. package/dist/libevm-contract-deployment-abi/libevm-contract-deployment-abi.js +2 -0
  17. package/dist/libevm-contract-deployment-bytecode/fs-worker.js +1 -0
  18. package/dist/libevm-contract-deployment-bytecode/index.html +24 -0
  19. package/dist/libevm-contract-deployment-compiler-output/fs-worker.js +1 -0
  20. package/dist/libevm-contract-deployment-compiler-output/index.html +24 -0
  21. package/dist/libevm-contract-deployment-networks/libevm-contract-deployment-networks.js +1 -1
  22. package/dist/libevm-contract-deployment-versions/libevm-contract-deployment-versions.js +1 -1
  23. package/dist/libevm-contract-deployments-dir/libevm-contract-deployments-dir.js +1 -1
  24. package/evm-contract-call +44 -40
  25. package/evm-contract-deployment-abi +540 -0
  26. package/evm-contract-deployment-address +23 -18
  27. package/evm-contract-deployment-bytecode +540 -0
  28. package/evm-contract-deployment-compiler-output +540 -0
  29. package/lib/address-check +0 -0
  30. package/lib/evm-contract-call-dynamic +46 -17
  31. package/lib/evm-contract-call-static +0 -0
  32. package/libevm-contract-deployment-abi +465 -0
  33. package/libevm-contract-deployment-address +58 -372
  34. package/libevm-contract-deployment-bytecode +466 -0
  35. package/libevm-contract-deployment-compiler-output +863 -0
  36. package/package.json +50 -12
  37. package/dist/evm-contract-deployment-address/evm-contract-deployment-address.js +0 -2
  38. package/dist/libevm-contract-deployment-address/libevm-contract-deployment-address.js +0 -2
package/evm-contract-call CHANGED
@@ -98,6 +98,11 @@ const
98
98
  const
99
99
  _msg_error =
100
100
  _libcrash._msg_error;
101
+ /* global
102
+ _override_set */
103
+ const
104
+ _override_set =
105
+ _libcrash._override_set;
101
106
  /* global
102
107
  _printf */
103
108
  const
@@ -284,45 +289,43 @@ async function
284
289
  1);
285
290
  }
286
291
  }
287
- if ( call_date == "" ||
288
- typeof(
289
- call_date) == "undefined" ) {
290
- call_date =
291
- _get_date_human();
292
- }
293
- if ( wallet_name == "" ) {
294
- wallet_name =
295
- "default";
296
- }
297
- if ( index_retrieve == "" ) {
298
- index_retrieve =
299
- "n";
300
- }
301
- if ( retries_max == "" ) {
302
- retries_max =
303
- "300";
304
- }
305
- if ( rpc_selection == "" ) {
306
- rpc_selection =
307
- "kirsh";
308
- }
309
- if ( call_type == "" ) {
310
- call_type =
311
- "static";
312
- }
292
+ _override_set(
293
+ "call",
294
+ "date",
295
+ _get_date_human());
296
+ _override_set(
297
+ "wallet",
298
+ "name",
299
+ "default");
300
+ _override_set(
301
+ "index",
302
+ "retrieve",
303
+ "n");
304
+ _override_set(
305
+ "retries",
306
+ "max",
307
+ "300");
308
+ _override_set(
309
+ "rpc",
310
+ "selection",
311
+ "kirsh");
312
+ _override_set(
313
+ "call",
314
+ "type",
315
+ "static");
313
316
  _call_auth_auto_detect();
314
- if ( call_timeout == "" ) {
315
- call_timeout =
316
- "300000";
317
- }
318
- if ( measure_unit == "" ) {
319
- measure_unit =
320
- "ether";
321
- }
322
- if ( msg_value == "" ) {
323
- msg_value =
324
- "0";
325
- }
317
+ _override_set(
318
+ "call",
319
+ "timeout",
320
+ "300000");
321
+ _override_set(
322
+ "measure",
323
+ "unit",
324
+ "ether");
325
+ _override_set(
326
+ "msg",
327
+ "value",
328
+ "0");
326
329
  // _api_key_auto_detect();
327
330
  if ( contract_address != "" ) {
328
331
  if ( contract_abi == "" ) {
@@ -374,6 +377,7 @@ function
374
377
  ` Contract address: ${contract_address}`,
375
378
  ` Contract ABI: ${contract_abi}`,
376
379
  ` Contract bytecode: ${contract_bytecode}`,
380
+ ` Retrieve from Index: ${index_retrieve}`,
377
381
  ` Contract compiler output: ${contract_compiler_output}`,
378
382
  ` Call options:`,
379
383
  ` Message value: ${msg_value}`,
@@ -398,7 +402,7 @@ function
398
402
  "",
399
403
  "Usage:",
400
404
  "",
401
- " evm-contract-call.js",
405
+ ` ${app_name}`,
402
406
  " [options]",
403
407
  " <contract-address>",
404
408
  " <contract-method>",
@@ -449,7 +453,7 @@ function
449
453
  "",
450
454
  " -I --index-retrieve Enables retrieving contract's artifacts",
451
455
  ` from the EVM Contracts Source Index.`,
452
- ` Default: '${contract_compiler_output}'.`,
456
+ ` Default: '${index_retrieve}'.`,
453
457
  "",
454
458
  " credentials options:",
455
459
  "",
@@ -0,0 +1,540 @@
1
+ #!/usr/bin/env node
2
+
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ /** ----------------------------------------------------------------
6
+ * evm-contract-deployment-address.js
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
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.
19
+ *
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.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
29
+
30
+ /* eslint-disable
31
+ no-unused-vars */
32
+
33
+ /* Crash Javascript global variables */
34
+ /* global
35
+ quiet:
36
+ writable */
37
+
38
+ const
39
+ _libcrash =
40
+ require(
41
+ "crash-js");
42
+ /* global
43
+ _argv_get */
44
+ const
45
+ _argv_get =
46
+ _libcrash._argv_get;
47
+ /* global
48
+ _argv_url_get */
49
+ const
50
+ _argv_url_get =
51
+ _libcrash._argv_url_get;
52
+ /* global
53
+ _cmdline_check */
54
+ const
55
+ _cmdline_check =
56
+ _libcrash._cmdline_check;
57
+ /* global
58
+ _get_date_human */
59
+ const
60
+ _get_date_human =
61
+ _libcrash._get_date_human;
62
+ /* global
63
+ _msg_info */
64
+ const
65
+ _msg_info =
66
+ _libcrash._msg_info;
67
+ /* global
68
+ _msg_error */
69
+ const
70
+ _msg_error =
71
+ _libcrash._msg_error;
72
+ /* global
73
+ _override_set */
74
+ const
75
+ _override_set =
76
+ _libcrash._override_set;
77
+ /* global
78
+ _printf */
79
+ const
80
+ _printf =
81
+ _libcrash._printf;
82
+ /* global
83
+ _process_exit */
84
+ const
85
+ _process_exit =
86
+ _libcrash._process_exit;
87
+ const
88
+ _libevm_contract_deployment_address_module =
89
+ require(
90
+ "./libevm-contract-deployment-address");
91
+ /* global
92
+ _evm_contract_deployment_address */
93
+ const
94
+ _evm_contract_deployment_address =
95
+ _libevm_contract_deployment_address_module._evm_contract_deployment_address;
96
+ /* global
97
+ _contract_version_auto_detect */
98
+ const
99
+ _contract_version_auto_detect =
100
+ _libevm_contract_deployment_address_module._contract_version_auto_detect;
101
+ /* global
102
+ _deployments_dir_auto_detect */
103
+ const
104
+ _deployments_dir_auto_detect =
105
+ _libevm_contract_deployment_address_module._deployments_dir_auto_detect;
106
+ /* global
107
+ _networks_all_auto_detect */
108
+ const
109
+ _networks_all_auto_detect =
110
+ _libevm_contract_deployment_address_module._networks_all_auto_detect;
111
+ /* global
112
+ _target_app_auto_detect */
113
+ const
114
+ _target_app_auto_detect =
115
+ _libevm_contract_deployment_address_module._target_app_auto_detect;
116
+
117
+ function
118
+ _global_variables() {
119
+ /* global
120
+ app_name:
121
+ writable */
122
+ app_name =
123
+ "evm-contract-deployments-address.js";
124
+ /* global
125
+ app_opts:
126
+ writable */
127
+ app_opts =
128
+ [];
129
+ /* global
130
+ runtime_environment:
131
+ writable */
132
+ runtime_environment =
133
+ "";
134
+ /* global
135
+ resolve_date:
136
+ writable */
137
+ resolve_date =
138
+ "";
139
+ /* global
140
+ target_networks:
141
+ writable */
142
+ target_networks =
143
+ [];
144
+ /* global
145
+ network_ids:
146
+ writable */
147
+ network_ids =
148
+ [];
149
+ /* global
150
+ networks_all:
151
+ writable */
152
+ networks_all =
153
+ "";
154
+ /* global
155
+ target_app:
156
+ writable */
157
+ target_app =
158
+ "";
159
+ /* global
160
+ target_contract:
161
+ writable */
162
+ target_contract =
163
+ "";
164
+ /* global
165
+ contract_version:
166
+ writable */
167
+ contract_version =
168
+ "";
169
+ /* global
170
+ user_defined:
171
+ writable */
172
+ user_defined =
173
+ "";
174
+ /* global
175
+ configuration_format:
176
+ writable */
177
+ configuration_format =
178
+ "";
179
+ /* global
180
+ deployments_dir:
181
+ writable */
182
+ deployments_dir =
183
+ "";
184
+ quiet =
185
+ "";
186
+ /* global
187
+ verbose:
188
+ writable */
189
+ verbose =
190
+ "";
191
+ }
192
+
193
+ async function
194
+ _overrides_set(
195
+ _help_display) {
196
+ _override_set(
197
+ "resolve",
198
+ "date",
199
+ _get_date_human());
200
+ _override_set(
201
+ "configuration",
202
+ "format",
203
+ "bash");
204
+ _networks_all_auto_detect();
205
+ _override_set(
206
+ "user",
207
+ "defined",
208
+ "n");
209
+ await _target_app_auto_detect();
210
+ await _deployments_dir_auto_detect();
211
+ await _contract_version_auto_detect();
212
+ }
213
+
214
+ function
215
+ _config_show() {
216
+ let
217
+ _line;
218
+ const
219
+ _text = [
220
+ `${app_name} configuration:`,
221
+ ` Resolve date: ${resolve_date}`,
222
+ ` Runtime environment: ${runtime_environment}`,
223
+ ` Target networks: ${target_networks}`,
224
+ ` Network ID (chain ID): ${network_ids}`,
225
+ ` All networks: ${networks_all}`,
226
+ ` Target application: ${target_app}`,
227
+ ` User-defined address: ${user_defined}`,
228
+ ` Deployments path: ${deployments_dir}`,
229
+ ];
230
+ for ( _line of _text ) {
231
+ _msg_info(
232
+ _line);
233
+ }
234
+ }
235
+
236
+ function
237
+ _usage(
238
+ _exit_code) {
239
+ let
240
+ _line;
241
+ const
242
+ _text = [
243
+ "",
244
+ "Returns an EVM network's contract deployment address",
245
+ "",
246
+ "Usage:",
247
+ "",
248
+ ` ${app_name}`,
249
+ " [options]",
250
+ " <target-contract>",
251
+ "",
252
+ " networks:",
253
+ " All those supported",
254
+ " by 'evm-chains-info'.",
255
+ "",
256
+ " options:",
257
+ "",
258
+ " -n, --network <network> EVM network name.",
259
+ " -i, --chain-id <number> EVM network id (chain ID).",
260
+ " -a, --target-app <app> Application whose target",
261
+ " contract is part of.",
262
+ ` Default: '${target_app}`,
263
+ " -A, --networks-all Returns address for all",
264
+ " available networks.",
265
+ ` Default: '${networks_all}`,
266
+ " -V, --contract-version <version> Contract version.",
267
+ ` Default: '${contract_version}`,
268
+ " -u, --user-defined Returns contract address for",
269
+ " user-defined file system",
270
+ " deployment instead of the system",
271
+ " one.",
272
+ ` Default: '${user_defined}`,
273
+ " -d, --deployments-dir <dir> Specify contract deployments",
274
+ " directory path.",
275
+ ` Default: '${deployments_dir}`,
276
+ " -f, --configuration-format <format> Specify contract deployments",
277
+ " directory path.",
278
+ ` Default: '${configuration_format}`,
279
+ "",
280
+ " -h --help This message.",
281
+ " -v --verbose Enable verbose output.",
282
+ ""
283
+ ];
284
+ for ( _line of _text ) {
285
+ console.log(
286
+ _line);
287
+ }
288
+ _process_exit(
289
+ _exit_code);
290
+ }
291
+
292
+ async function
293
+ _cmdline_parse() {
294
+ let
295
+ _help_display,
296
+ _msg;
297
+ const
298
+ _argv_args = {
299
+ "booleans": [
300
+ "A",
301
+ "networks-all",
302
+ "u",
303
+ "user-defined",
304
+ "h",
305
+ "help",
306
+ "v",
307
+ "verbose"
308
+ ]
309
+ };
310
+ const
311
+ _argv =
312
+ _argv_get(
313
+ _argv_args);
314
+ const
315
+ _options =
316
+ _argv[
317
+ "_"];
318
+ quiet =
319
+ "y";
320
+ runtime_environment =
321
+ "node";
322
+ if ( _argv[
323
+ "h"] ) {
324
+ _help_display =
325
+ true;
326
+ }
327
+ if ( _argv[
328
+ "help"] ) {
329
+ _help_display =
330
+ true;
331
+ }
332
+ if ( ( _options.indexOf(
333
+ "--help") > -1 ||
334
+ _options.indexOf(
335
+ "-h") > -1) ) {
336
+ _help_display =
337
+ true;
338
+ }
339
+ if ( _help_display ) {
340
+ quiet =
341
+ "n";
342
+ await _overrides_set(
343
+ _help_display);
344
+ _usage(
345
+ 0);
346
+ }
347
+ if ( typeof(
348
+ _argv) == "undefined" ||
349
+ _argv[
350
+ "_"].length < 1 ) {
351
+ _msg =
352
+ "Target contract " +
353
+ "argument required.";
354
+ _msg_error(
355
+ _msg,
356
+ 0);
357
+ _usage(
358
+ 1);
359
+ }
360
+ target_contract =
361
+ _argv[
362
+ "_"][
363
+ 0];
364
+ if ( "n" in _argv ) {
365
+ target_networks.push(
366
+ _argv[
367
+ "n"].toString());
368
+ }
369
+ if ( "network" in _argv ) {
370
+ target_networks.push(
371
+ _argv[
372
+ "network"].toString());
373
+ }
374
+ if ( "i" in _argv ) {
375
+ network_ids.push(
376
+ _argv[
377
+ "i"].toString());
378
+ }
379
+ if ( "network-id" in _argv ) {
380
+ network_ids.push(
381
+ _argv[
382
+ "network-id"].toString());
383
+ }
384
+ if ( "a" in _argv ) {
385
+ target_app =
386
+ _argv[
387
+ "a"];
388
+ }
389
+ if ( "target-app" in _argv ) {
390
+ target_app =
391
+ _argv[
392
+ "target-app"];
393
+ }
394
+ if ( _argv[
395
+ "A"] ||
396
+ _argv[
397
+ "networks-all"] ) {
398
+ networks_all =
399
+ "y";
400
+ }
401
+ if ( _argv[
402
+ "u"] ||
403
+ _argv[
404
+ "user-defined"] ) {
405
+ user_defined =
406
+ "y";
407
+ }
408
+ if ( "f" in _argv ) {
409
+ configuration_format =
410
+ _argv[
411
+ "f"];
412
+ }
413
+ if ( "configuration-format" in _argv ) {
414
+ configuration_format =
415
+ _argv[
416
+ "configuration-format"];
417
+ }
418
+ if ( _argv[
419
+ "v"] ||
420
+ _argv[
421
+ "verbose"] ) {
422
+ quiet =
423
+ "n";
424
+ }
425
+ }
426
+
427
+ function
428
+ _url_parse() {
429
+ let
430
+ _method,
431
+ _network;
432
+ runtime_environment =
433
+ "browser";
434
+ target_networks =
435
+ _argv_url_get(
436
+ "network");
437
+ network_ids =
438
+ _argv_url_get(
439
+ "network_id");
440
+ target_ids =
441
+ _argv_url_get(
442
+ "chain_id");
443
+ networks_all =
444
+ _argv_url_get(
445
+ "networks_all")[
446
+ 0];
447
+ target_app =
448
+ _argv_url_get(
449
+ "target_app")[
450
+ 0];
451
+ target_contract =
452
+ _argv_url_get(
453
+ "target_contract")[
454
+ 0];
455
+ contract_version =
456
+ _argv_url_get(
457
+ "contract_version")[
458
+ 0];
459
+ user_defined =
460
+ _argv_url_get(
461
+ "user_defined")[
462
+ 0];
463
+ configuration_format =
464
+ _argv_url_get(
465
+ "configuration_format")[
466
+ 0];
467
+ deployments_dir =
468
+ _argv_url_get(
469
+ "deployments_dir")[
470
+ 0];
471
+ quiet =
472
+ _argv_url_get(
473
+ "quiet");
474
+ if ( quiet.length === 0 ) {
475
+ quiet =
476
+ "n";
477
+ }
478
+ }
479
+
480
+ async function
481
+ _evm_contract_deployment_address_cmdline(
482
+ _app_opts) {
483
+ let
484
+ _result;
485
+ const
486
+ _results =
487
+ await _evm_contract_deployment_address.apply(
488
+ null,
489
+ _app_opts);
490
+ const
491
+ _results_type =
492
+ typeof(
493
+ _results);
494
+ if ( _results_type == "object" ) {
495
+ for ( _result of _results ) {
496
+ console.log(
497
+ _result);
498
+ }
499
+ }
500
+ else if ( _results_type == "string" ) {
501
+ _printf(
502
+ _results);
503
+ }
504
+ }
505
+
506
+ async function
507
+ _main() {
508
+ const
509
+ _overrides_set_up =
510
+ await _overrides_set();
511
+ _config_show();
512
+ const
513
+ app_opts = [
514
+ target_networks,
515
+ network_ids,
516
+ networks_all,
517
+ target_app,
518
+ target_contract,
519
+ contract_version,
520
+ user_defined,
521
+ configuration_format,
522
+ deployments_dir,
523
+ ];
524
+ const
525
+ _address =
526
+ await _evm_contract_deployment_address_cmdline(
527
+ app_opts);
528
+ }
529
+
530
+ _global_variables();
531
+ if ( _cmdline_check(
532
+ "evm-contract-deployment-address.js") ||
533
+ _cmdline_check(
534
+ "evm-contract-deployment-address") ) {
535
+ _cmdline_parse();
536
+ }
537
+ else{
538
+ _url_parse();
539
+ }
540
+ _main();
@@ -69,6 +69,11 @@ const
69
69
  const
70
70
  _msg_error =
71
71
  _libcrash._msg_error;
72
+ /* global
73
+ _override_set */
74
+ const
75
+ _override_set =
76
+ _libcrash._override_set;
72
77
  /* global
73
78
  _printf */
74
79
  const
@@ -103,6 +108,11 @@ const
103
108
  const
104
109
  _networks_all_auto_detect =
105
110
  _libevm_contract_deployment_address_module._networks_all_auto_detect;
111
+ /* global
112
+ _target_app_auto_detect */
113
+ const
114
+ _target_app_auto_detect =
115
+ _libevm_contract_deployment_address_module._target_app_auto_detect;
106
116
 
107
117
  function
108
118
  _global_variables() {
@@ -183,25 +193,20 @@ function
183
193
  async function
184
194
  _overrides_set(
185
195
  _help_display) {
186
- if ( resolve_date == "" ||
187
- typeof(
188
- resolve_date) == "undefined" ) {
189
- resolve_date =
190
- _get_date_human();
191
- }
192
- if ( typeof(
193
- configuration_format) == "undefined" ||
194
- configuration_format == "" ) {
195
- configuration_format =
196
- "bash";
197
- }
196
+ _override_set(
197
+ "resolve",
198
+ "date",
199
+ _get_date_human());
200
+ _override_set(
201
+ "configuration",
202
+ "format",
203
+ "bash");
198
204
  _networks_all_auto_detect();
199
- if ( typeof(
200
- user_defined) == "undefined" ||
201
- user_defined == "" ) {
202
- user_defined =
203
- "n";
204
- }
205
+ _override_set(
206
+ "user",
207
+ "defined",
208
+ "n");
209
+ await _target_app_auto_detect();
205
210
  await _deployments_dir_auto_detect();
206
211
  await _contract_version_auto_detect();
207
212
  }