evm-contracts-tools 0.0.55 → 0.0.57

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.
@@ -2,32 +2,45 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- /** ----------------------------------------------------------------------
5
+ /** ---------------------------------------------------------------
6
+ * bytecode-runtime-get
7
+ * ---------------------------------------------------------------
6
8
  * Copyright ©
7
9
  * Pellegrino Prevete
8
10
  * 2024, 2025, 2026
9
11
  *
10
12
  * All rights reserved
11
- * ----------------------------------------------------------------------
13
+ * ---------------------------------------------------------------
12
14
  *
13
- * This program is free software: you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation, either version 3 of the License, or
16
- * (at your option) any later version.
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.
17
19
  *
18
20
  * This program is distributed in the hope that it will be useful,
19
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
23
  * GNU General Public License for more details.
22
24
  *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+ * You should have received a copy of the GNU General Public
26
+ * License along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
25
28
  */
26
29
 
27
30
  const
28
31
  _libcrash =
29
- require(
30
- "crash-js");
32
+ await import(
33
+ "libcrash-js");
34
+ /* global
35
+ _argv */
36
+ const
37
+ _argv =
38
+ _libcrash._argv;
39
+ /* global
40
+ _basename */
41
+ const
42
+ _basename =
43
+ _libcrash._basename;
31
44
  /* global
32
45
  _cmdline_check */
33
46
  const
@@ -53,6 +66,11 @@ const
53
66
  const
54
67
  _file_write =
55
68
  _libcrash._file_write;
69
+ /* global
70
+ _global_get */
71
+ const
72
+ _global_get =
73
+ _libcrash._global_get;
56
74
  /* global
57
75
  _msg_info */
58
76
  const
@@ -63,6 +81,11 @@ const
63
81
  const
64
82
  _msg_error =
65
83
  _libcrash._msg_error;
84
+ /* global
85
+ _override_set */
86
+ const
87
+ _override_set =
88
+ _libcrash._override_set;
66
89
  /* global
67
90
  _printf */
68
91
  const
@@ -73,6 +96,11 @@ const
73
96
  const
74
97
  _require =
75
98
  _libcrash._require;
99
+ /* global
100
+ _set */
101
+ const
102
+ _set =
103
+ _libcrash._set;
76
104
  const
77
105
  _evm_wallet_module =
78
106
  await _require(
@@ -84,7 +112,7 @@ const
84
112
  _evm_wallet_module._provider_get;
85
113
  const
86
114
  _contract_get_module =
87
- require(
115
+ await import(
88
116
  './contract-get');
89
117
  /* global
90
118
  _contract_get */
@@ -97,43 +125,59 @@ function
97
125
  /* global
98
126
  app_name:
99
127
  writable */
100
- app_name =
101
- "bytecode-runtime-get";
128
+ _set(
129
+ "app",
130
+ "name",
131
+ "bytecode-runtime-get");
102
132
  /* global
103
133
  wallet_seed:
104
134
  writable */
105
- wallet_seed =
106
- "";
135
+ _set(
136
+ "wallet",
137
+ "seed",
138
+ "");
107
139
  /* global
108
140
  retries_max:
109
141
  writable */
110
- retries_max =
111
- "";
142
+ _set(
143
+ "retries",
144
+ "max",
145
+ "");
112
146
  /* global
113
147
  api_key_path:
114
148
  writable */
115
- api_key_path =
116
- "";
149
+ _set(
150
+ "api_key",
151
+ "path",
152
+ "");
117
153
  /* global
118
154
  target_network:
119
155
  writable */
120
- target_network =
121
- "";
156
+ _set(
157
+ "target",
158
+ "network",
159
+ "");
122
160
  /* global
123
161
  contract_address:
124
162
  writable */
125
- contract_address =
126
- "";
163
+ _set(
164
+ "contract",
165
+ "address",
166
+ "");
127
167
  /* global
128
168
  contract_abi_path:
129
169
  writable */
130
- contract_abi_path =
131
- "";
170
+ _set(
171
+ "contract_abi",
172
+ "path",
173
+ "");
132
174
  /* global
133
175
  contract_bytecode_path:
134
176
  writable */
135
- contract_bytecode_path =
136
- "";
177
+ _set(
178
+ "contract_bytecode",
179
+ "path",
180
+ "");
137
181
  // contract_compiler_output_path =
138
182
  // "";
139
183
  // contract_method =
@@ -143,7 +187,11 @@ function
143
187
  /* global
144
188
  quiet:
145
189
  writable */
146
- quiet =
190
+ const
191
+ _global =
192
+ _global_get();
193
+ _global[
194
+ "quiet"] =
147
195
  "";
148
196
  }
149
197
 
@@ -258,9 +306,14 @@ function
258
306
  let
259
307
  _line,
260
308
  _method_args;
309
+ const
310
+ _program =
311
+ _basename(
312
+ _argv[
313
+ 0]);
261
314
  const
262
315
  _text = [
263
- " bytecode-runtime-get configuration:",
316
+ ` ${_program} configuration:`,
264
317
  ` Contract address: ${contract_address}`,
265
318
  ` Contract bytecode: ${contract_bytecode_path}`,
266
319
  ` Max retries: ${retries_max}`,
@@ -282,11 +335,16 @@ function
282
335
  let
283
336
  _line,
284
337
  _text;
338
+ const
339
+ _program =
340
+ _basename(
341
+ _argv[
342
+ 0]);
285
343
  _text = [
286
344
  "Retrieves the runtime bytecode for an address.",
287
345
  "",
288
346
  "Usage:",
289
- " bytecode-runtime-get",
347
+ ` ${_program}`,
290
348
  " <quiet>",
291
349
  " <wallet-seed>",
292
350
  " <retries-max>",
@@ -324,48 +382,66 @@ function
324
382
 
325
383
  function
326
384
  _overrides_set() {
327
- if ( retries_max == "" ) {
328
- retries_max =
329
- 100;
330
- }
385
+ _override_set(
386
+ "retries",
387
+ "max",
388
+ 100);
331
389
  }
332
390
 
333
391
  function
334
392
  _cmdline_parse() {
335
- quiet =
393
+ let
394
+ _msg;
395
+ const
396
+ _global =
397
+ _global_get();
398
+ _global[
399
+ "quiet"] =
336
400
  "y";
337
- process.argv.forEach(
401
+ _argv.forEach(
338
402
  function (
339
403
  _value,
340
- _index,
341
- _array) {
404
+ _index) {
342
405
  if ( _index == 2 ) {
343
- quiet =
406
+ _global[
407
+ "quiet"] =
344
408
  _value;
345
409
  }
346
410
  if ( _index == 3 ) {
347
- wallet_seed =
348
- _value;
411
+ _set(
412
+ "wallet",
413
+ "seed",
414
+ _value);
349
415
  }
350
416
  if ( _index == 4 ) {
351
- retries_max =
352
- _value;
417
+ _set(
418
+ "retries",
419
+ "max",
420
+ _value);
353
421
  }
354
422
  if ( _index == 5 ) {
355
- api_key_path =
356
- _value;
423
+ _set(
424
+ "api_key",
425
+ "path",
426
+ _value);
357
427
  }
358
428
  if ( _index == 6 ) {
359
- target_network =
360
- _value;
429
+ _set(
430
+ "target",
431
+ "network",
432
+ _value);
361
433
  }
362
434
  if ( _index == 7 ) {
363
- contract_address =
364
- _value;
435
+ _set(
436
+ "contract",
437
+ "address",
438
+ _value);
365
439
  }
366
440
  if ( _index == 8 ) {
367
- contract_bytecode_path =
368
- _value;
441
+ _set(
442
+ "contract_bytecode",
443
+ "path",
444
+ _value);
369
445
  }
370
446
  if ( _value == "-h" ||
371
447
  _value == "--help" ) {
@@ -374,33 +450,55 @@ function
374
450
  }
375
451
  }
376
452
  );
377
- if ( contract_address == "" ) {
378
- const
379
- _msg =
380
- "It is required to set a contract address.";
453
+ const
454
+ _contract_address =
455
+ _get(
456
+ "contract",
457
+ "address");
458
+ if ( _contract_address == "" ) {
459
+ _msg =
460
+ "It is required to set a contract address.";
381
461
  _msg_error(
382
462
  _msg,
383
463
  0);
384
- quiet =
464
+ _global[
465
+ "quiet"] =
385
466
  "n";
386
467
  _overrides_set();
387
468
  _usage(
388
469
  1);
389
470
  }
390
- if ( target_network == "" ) {
471
+ const
472
+ _target_network =
473
+ _get(
474
+ "target",
475
+ "network");
476
+ if ( _target_network == "" ) {
477
+ _msg =
478
+ "It is required to set a network.";
391
479
  _msg_error(
392
- "It is required to set a network.",
480
+ _msg,
393
481
  0);
394
- quiet =
482
+ _global[
483
+ "quiet"] =
395
484
  "n";
396
485
  _usage(
397
486
  1);
398
487
  }
399
- if ( contract_bytecode_path == "" ) {
488
+ const
489
+ _contract_bytecode_path =
490
+ _get(
491
+ "contract_bytecode",
492
+ "path");
493
+ if ( _contract_bytecode_path == "" ) {
494
+ _msg =
495
+ "It is required to set a path " +
496
+ "in which to save the bytecode.";
400
497
  _msg_error(
401
- "It is required to set a path in which to save the bytecode.",
498
+ _msg,
402
499
  0);
403
- quiet =
500
+ _global[
501
+ "quiet"] =
404
502
  "n";
405
503
  _usage(
406
504
  1);
@@ -410,15 +508,15 @@ function
410
508
  async function
411
509
  _bytecode_runtime_get_cmdline(
412
510
  _app_opts) {
413
- let
414
- _code;
511
+ let
512
+ _code;
415
513
  try {
416
514
  _code =
417
515
  await _bytecode_runtime_get.apply(
418
516
  null,
419
517
  _app_opts);
420
518
  if ( _code != undefined ) {
421
- _printf(
519
+ await _printf(
422
520
  typeof(
423
521
  _code));
424
522
  // _printf(
@@ -434,7 +532,7 @@ async function
434
532
  }
435
533
  }
436
534
 
437
- if ( _cmdline_check(
535
+ if ( await _cmdline_check(
438
536
  "bytecode-runtime-get") ) {
439
537
  _global_variables();
440
538
  _cmdline_parse();
@@ -452,8 +550,12 @@ if ( _cmdline_check(
452
550
  app_opts);
453
551
  }
454
552
 
455
- module.exports = {
456
- _bytecode_runtime_get:
457
- _bytecode_runtime_get
553
+ export {
554
+ _bytecode_runtime_get
458
555
  };
459
556
 
557
+ // module.exports = {
558
+ // _bytecode_runtime_get:
559
+ // _bytecode_runtime_get
560
+ // };
561
+