evm-contracts-tools 0.0.37 → 0.0.39

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 (30) hide show
  1. package/Makefile +12 -0
  2. package/dist/evm-contract-call/fs-worker.js +1 -0
  3. package/dist/evm-contract-deployment-address/fs-worker.js +1 -0
  4. package/dist/evm-contract-deployment-address/index.html +31 -0
  5. package/dist/evm-contract-deployment-deployment-networks +1 -0
  6. package/dist/evm-contract-deployment-networks/index.html +31 -0
  7. package/dist/evm-contract-deployment-versions/fs-worker.js +1 -0
  8. package/dist/evm-contract-deployment-versions/index.html +33 -0
  9. package/dist/evm-contract-deployments-dir/fs-worker.js +1 -0
  10. package/dist/evm-contracts-tools/fs-worker.js +1 -0
  11. package/dist/libevm-contract-call/fs-worker.js +1 -1
  12. package/dist/libevm-contract-deployment-address/fs-worker.js +1 -0
  13. package/dist/libevm-contract-deployment-address/index.html +24 -0
  14. package/dist/libevm-contract-deployment-deployment-networks +1 -0
  15. package/dist/libevm-contract-deployment-networks/index.html +24 -0
  16. package/dist/libevm-contract-deployment-versions/fs-worker.js +1 -0
  17. package/dist/libevm-contract-deployment-versions/index.html +33 -0
  18. package/dist/libevm-contract-deployments-dir/fs-worker.js +1 -0
  19. package/dist/libevm-contracts-tools +1 -0
  20. package/evm-contract-deployment-address +453 -0
  21. package/evm-contract-deployment-networks +440 -0
  22. package/evm-contract-deployment-versions +392 -0
  23. package/lib/address-check +0 -0
  24. package/lib/evm-contract-call-dynamic +0 -0
  25. package/lib/evm-contract-call-static +0 -0
  26. package/libevm-contract-deployment-address +439 -0
  27. package/libevm-contract-deployment-networks +295 -0
  28. package/libevm-contract-deployment-versions +113 -0
  29. package/libevm-contract-deployments-dir +0 -81
  30. package/package.json +73 -23
@@ -0,0 +1,453 @@
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
+ _printf */
74
+ const
75
+ _printf =
76
+ _libcrash._printf;
77
+ /* global
78
+ _process_exit */
79
+ const
80
+ _process_exit =
81
+ _libcrash._process_exit;
82
+ const
83
+ _libevm_contract_deployment_address_module =
84
+ require(
85
+ "./libevm-contract-deployment-address");
86
+ /* global
87
+ _evm_contract_deployment_address */
88
+ const
89
+ _evm_contract_deployment_address =
90
+ _libevm_contract_deployment_address_module._evm_contract_deployment_address;
91
+
92
+ function
93
+ _global_variables() {
94
+ /* global
95
+ app_name:
96
+ writable */
97
+ app_name =
98
+ "evm-contract-deployments-address.js";
99
+ /* global
100
+ app_opts:
101
+ writable */
102
+ app_opts =
103
+ [];
104
+ /* global
105
+ runtime_environment:
106
+ writable */
107
+ runtime_environment =
108
+ "";
109
+ /* global
110
+ resolve_date:
111
+ writable */
112
+ resolve_date =
113
+ "";
114
+ /* global
115
+ user_level:
116
+ writable */
117
+ user_level =
118
+ "";
119
+ /* global
120
+ target_networks:
121
+ writable */
122
+ target_networks =
123
+ [];
124
+ /* global
125
+ network_ids:
126
+ writable */
127
+ network_ids =
128
+ [];
129
+ /* global
130
+ networks_all:
131
+ writable */
132
+ networks_all =
133
+ "";
134
+ /* global
135
+ target_app:
136
+ writable */
137
+ target_app =
138
+ "";
139
+ /* global
140
+ target_contract:
141
+ writable */
142
+ target_contract =
143
+ "";
144
+ /* global
145
+ contract_version:
146
+ writable */
147
+ contract_version =
148
+ "";
149
+ /* global
150
+ user_defined:
151
+ writable */
152
+ user_defined =
153
+ "";
154
+ /* global
155
+ deployments_dir:
156
+ writable */
157
+ deployments_dir =
158
+ "";
159
+ quiet =
160
+ "";
161
+ /* global
162
+ verbose:
163
+ writable */
164
+ verbose =
165
+ "";
166
+ }
167
+
168
+ async function
169
+ _overrides_set(
170
+ _help_display) {
171
+ if ( resolve_date == "" ||
172
+ typeof(
173
+ resolve_date) == "undefined" ) {
174
+ resolve_date =
175
+ _get_date_human();
176
+ }
177
+ _networks_all_auto_detect();
178
+ if ( user_level == "" ) {
179
+ user_level =
180
+ "n";
181
+ }
182
+ }
183
+
184
+ function
185
+ _config_show() {
186
+ let
187
+ _line;
188
+ const
189
+ _text = [
190
+ `${app_name} configuration:`,
191
+ ` Resolve date: ${resolve_date}`,
192
+ ` Runtime environment: ${runtime_environment}`,
193
+ ` Target networks: ${target_networks}`,
194
+ ` Network ID (chain ID): ${network_ids}`,
195
+ ` All networks: ${networks_all}`,
196
+ ` Target application: ${target_app}`,
197
+ ` User-defined address: ${user_defined}`,
198
+ ` Deployments path: ${deployments_dir}`,
199
+ ];
200
+ for ( _line of _text ) {
201
+ _msg_info(
202
+ _line);
203
+ }
204
+ }
205
+
206
+ function
207
+ _usage(
208
+ _exit_code) {
209
+ let
210
+ _line;
211
+ const
212
+ _text = [
213
+ "",
214
+ "Returns an EVM network's contract deployment address",
215
+ "",
216
+ "Usage:",
217
+ "",
218
+ ` ${app_name}`,
219
+ " [options]",
220
+ " <target-contract>",
221
+ "",
222
+ " networks:",
223
+ " All those supported",
224
+ " by 'evm-chains-info'.",
225
+ "",
226
+ " options:",
227
+ "",
228
+ " -n, --network <network> EVM network name.",
229
+ " -i, --chain-id <number> EVM network id (chain ID).",
230
+ " -A, --networks-all Returns address for all",
231
+ " available networks.",
232
+ ` Default: '${networks_all}`,
233
+ " -V, --contract-version <version> Contract version.",
234
+ ` Default: '${contract_version}`,
235
+ " Returns contract address for",
236
+ " user-defined file system",
237
+ " deployment instead of the system",
238
+ " one.",
239
+ ` Default: '${user_defined}`,
240
+ " -d, --deployments-dir <dir> Specify contract deployments",
241
+ " directory path.",
242
+ ` Default: '${deployments_dir}`,
243
+ "",
244
+ " -h --help This message.",
245
+ " -v --verbose Enable verbose output.",
246
+ ""
247
+ ];
248
+ for ( _line of _text ) {
249
+ console.log(
250
+ _line);
251
+ }
252
+ _process_exit(
253
+ _exit_code);
254
+ }
255
+
256
+ async function
257
+ _cmdline_parse() {
258
+ let
259
+ _help_display,
260
+ _msg;
261
+ const
262
+ _argv_args = {
263
+ "booleans": [
264
+ "A",
265
+ "networks-all",
266
+ "u",
267
+ "user-defined",
268
+ "h",
269
+ "help",
270
+ "v",
271
+ "verbose"
272
+ ]
273
+ };
274
+ const
275
+ _argv =
276
+ _argv_get(
277
+ _argv_args);
278
+ const
279
+ _options =
280
+ _argv[
281
+ "_"];
282
+ quiet =
283
+ "y";
284
+ runtime_environment =
285
+ "node";
286
+ if ( _argv[
287
+ "h"] ) {
288
+ _help_display =
289
+ true;
290
+ }
291
+ if ( _argv[
292
+ "help"] ) {
293
+ _help_display =
294
+ true;
295
+ }
296
+ if ( ( _options.indexOf(
297
+ "--help") > -1 ||
298
+ _options.indexOf(
299
+ "-h") > -1) ) {
300
+ _help_display =
301
+ true;
302
+ }
303
+ if ( _help_display ) {
304
+ quiet =
305
+ "n";
306
+ await _overrides_set(
307
+ _help_display);
308
+ _usage(
309
+ 0);
310
+ }
311
+ if ( typeof(
312
+ _argv) == "undefined" ||
313
+ _argv[
314
+ "_"].length < 1 ) {
315
+ _msg =
316
+ "Target contract " +
317
+ "argument required.";
318
+ _msg_error(
319
+ _msg,
320
+ 0);
321
+ _usage(
322
+ 1);
323
+ }
324
+ target_contract =
325
+ _argv[
326
+ "_"][
327
+ 0];
328
+ if ( "u" in _argv ) {
329
+ user_level =
330
+ _argv[
331
+ "u"];
332
+ }
333
+ if ( "user_level" in _argv ) {
334
+ user_level =
335
+ _argv[
336
+ "user_level"];
337
+ }
338
+ if ( _argv[
339
+ "v"] ||
340
+ _argv[
341
+ "verbose"] ) {
342
+ quiet =
343
+ "n";
344
+ }
345
+ }
346
+
347
+ function
348
+ _url_parse() {
349
+ let
350
+ _method,
351
+ _network;
352
+ runtime_environment =
353
+ "browser";
354
+ target_networks =
355
+ _argv_url_get(
356
+ "network");
357
+ target_ids =
358
+ _argv_url_get(
359
+ "chain_id");
360
+ networks_all =
361
+ _argv_url_get(
362
+ "networks_all")[
363
+ 0];
364
+ target_app =
365
+ _argv_url_get(
366
+ "target_app")[
367
+ 0];
368
+ target_contract =
369
+ _argv_url_get(
370
+ "target_contract")[
371
+ 0];
372
+ contract_version =
373
+ _argv_url_get(
374
+ "contract_version")[
375
+ 0];
376
+ user_defined =
377
+ _argv_url_get(
378
+ "user_defined")[
379
+ 0];
380
+ deployments_dir =
381
+ _argv_url_get(
382
+ "deployments_dir")[
383
+ 0];
384
+ quiet =
385
+ _argv_url_get(
386
+ "quiet");
387
+ if ( quiet.length === 0 ) {
388
+ quiet =
389
+ "n";
390
+ }
391
+ }
392
+
393
+ async function
394
+ _evm_contract_deployment_address_cmdline(
395
+ _app_opts) {
396
+ let
397
+ _result;
398
+ const
399
+ _results =
400
+ await _evm_contract_deployment_address.apply(
401
+ null,
402
+ app_opts);
403
+ const
404
+ _results_type =
405
+ typeof(
406
+ _results);
407
+ if ( _results_type == "object" ) {
408
+ for ( _result of _results ) {
409
+ console.log(
410
+ _result);
411
+ }
412
+ }
413
+ else if ( _results_type == "string" ) {
414
+ _printf(
415
+ _results);
416
+ }
417
+ }
418
+
419
+ async function
420
+ _main() {
421
+ const
422
+ _overrides_set_up =
423
+ await _overrides_set();
424
+ _config_show();
425
+ const
426
+ app_opts = [
427
+ target_networks,
428
+ network_ids,
429
+ networks_all,
430
+ target_app,
431
+ target_contract,
432
+ contract_version,
433
+ user_defined,
434
+ deployments_dir,
435
+ ];
436
+ const
437
+ _address =
438
+ await _evm_contract_deployment_address.apply(
439
+ null,
440
+ app_opts);
441
+ }
442
+
443
+ _global_variables();
444
+ if ( _cmdline_check(
445
+ "evm-contract-deployment-address.js") ||
446
+ _cmdline_check(
447
+ "evm-contract-deployment-address") ) {
448
+ _cmdline_parse();
449
+ }
450
+ else{
451
+ _url_parse();
452
+ }
453
+ _main();