evm-transactions-tools 0.0.1111 → 0.0.111111

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.
@@ -31,22 +31,27 @@
31
31
 
32
32
  const
33
33
  _transaction_get_module =
34
- require(
34
+ await import(
35
35
  "./lib/transaction-get");
36
36
  const
37
37
  _transaction_get =
38
38
  _transaction_get_module._transaction_get;
39
39
  const
40
40
  _transaction_receipt_get_module =
41
- require(
41
+ await import(
42
42
  "./lib/transaction-receipt-get");
43
43
  const
44
44
  _transaction_receipt_get =
45
45
  _transaction_receipt_get_module._transaction_receipt_get;
46
46
 
47
- module.exports = {
48
- _transaction_get:
49
- _transaction_get,
50
- _transaction_receipt_get:
51
- _transaction_receipt_get
47
+ export {
48
+ _transaction_get,
49
+ _transaction_receipt_get
52
50
  };
51
+
52
+ // module.exports = {
53
+ // _transaction_get:
54
+ // _transaction_get,
55
+ // _transaction_receipt_get:
56
+ // _transaction_receipt_get
57
+ // };
@@ -33,73 +33,169 @@
33
33
 
34
34
  const
35
35
  _libcrash =
36
- require(
37
- "crash-js");
38
- _cmdline_check =
39
- _libcrash._cmdline_check;
40
- _dirname =
41
- _libcrash._dirname;
42
- _file_read =
43
- _libcrash._file_read;
44
- _file_write =
45
- _libcrash._file_write;
46
- _json_display =
47
- _libcrash._json_display;
48
- _path_join =
49
- _libcrash._path_join;
50
- _msg_info =
51
- _libcrash._msg_info;
52
- _msg_error =
53
- _libcrash._msg_error;
54
- _printf =
55
- _libcrash._printf;
36
+ await import(
37
+ "libcrash-js");
38
+ /* global
39
+ _argv */
40
+ const
41
+ _argv =
42
+ _libcrash._argv;
43
+ /* global
44
+ _cmdline_check */
45
+ const
46
+ _cmdline_check =
47
+ _libcrash._cmdline_check;
48
+ /* global
49
+ _dirname */
50
+ const
51
+ _dirname =
52
+ _libcrash._dirname;
53
+ /* global
54
+ _echo */
55
+ const
56
+ _echo =
57
+ _libcrash._echo;
58
+ /* global
59
+ _exit */
60
+ const
61
+ _exit =
62
+ _libcrash._exit;
63
+ /* global
64
+ _file_read */
65
+ const
66
+ _file_read =
67
+ _libcrash._file_read;
68
+ /* global
69
+ _file_write */
70
+ const
71
+ _file_write =
72
+ _libcrash._file_write;
73
+ /* global
74
+ _global_get */
75
+ const
76
+ _global_get =
77
+ _libcrash._global_get;
78
+ /* global
79
+ _globals */
80
+ const
81
+ _globals =
82
+ _libcrash._globals;
83
+ /* global
84
+ _json_display */
85
+ const
86
+ _json_display =
87
+ _libcrash._json_display;
88
+ /* global
89
+ _path_join */
90
+ const
91
+ _path_join =
92
+ _libcrash._path_join;
93
+ /* global
94
+ _msg_info */
95
+ const
96
+ _msg_info =
97
+ _libcrash._msg_info;
98
+ /* global
99
+ _msg_error */
100
+ const
101
+ _msg_error =
102
+ _libcrash._msg_error;
103
+ /* global
104
+ _override_set */
105
+ const
106
+ _override_set =
107
+ _libcrash._override_set;
108
+ /* global
109
+ _printf */
110
+ const
111
+ _printf =
112
+ _libcrash._printf;
113
+ /* global
114
+ _require */
115
+ const
116
+ _require =
117
+ _libcrash._require;
118
+ /* global
119
+ _set */
120
+ const
121
+ _set =
122
+ _libcrash._set;
56
123
  const
57
124
  _evm_wallet_module =
58
- require(
59
- "evm-wallet.js");
60
- _wallet_get =
61
- _evm_wallet_module._wallet_get;
62
- _provider_get =
63
- _evm_wallet_module._provider_get;
125
+ await _require(
126
+ "evm-wallet");
127
+ /* global
128
+ _wallet_get */
129
+ const
130
+ _wallet_get =
131
+ _evm_wallet_module._wallet_get;
132
+ /* global
133
+ _provider_get */
134
+ const
135
+ _provider_get =
136
+ _evm_wallet_module._provider_get;
64
137
 
65
138
  function
66
139
  _global_variables() {
67
- app_name =
68
- "transaction-get"
69
- retries_max =
70
- "";
71
- wallet_seed =
72
- "";
73
- wallet_password_path =
74
- "";
75
- transaction_address =
76
- "";
77
- chain_id =
78
- "";
79
- chain_name =
80
- "";
81
- target_network =
82
- "";
83
- api_key_path =
84
- "";
85
- output_path =
86
- "";
87
- quiet =
140
+ _set(
141
+ "app",
142
+ "name",
143
+ "transaction-get");
144
+ _set(
145
+ "retries",
146
+ "max",
147
+ "");
148
+ _set(
149
+ "wallet",
150
+ "seed",
151
+ "");
152
+ _set(
153
+ "wallet",
154
+ "password_path",
155
+ "");
156
+ _set(
157
+ "transaction",
158
+ "address",
159
+ "");
160
+ _set(
161
+ "chain",
162
+ "id",
163
+ "");
164
+ _set(
165
+ "chain",
166
+ "name",
167
+ "");
168
+ _set(
169
+ "target",
170
+ "network",
171
+ "");
172
+ _set(
173
+ "api",
174
+ "key_path",
175
+ "");
176
+ _set(
177
+ "output",
178
+ "path",
179
+ "");
180
+ const
181
+ _global =
182
+ _global_get();
183
+ _global[
184
+ "quiet"] =
88
185
  "";
89
186
  }
90
187
 
91
188
  function
92
189
  _msg_error_no_input_data() {
93
- let
94
- _msg,
95
- _text;
96
- _text = [
97
- "You need to provide either",
98
- "the bytecode or the data"
99
- ];
100
- _msg =
101
- _text.join(
102
- " ");
190
+ const
191
+ _text = [
192
+ "You need to provide either",
193
+ "the bytecode or the data"
194
+ ];
195
+ const
196
+ _msg =
197
+ _text.join(
198
+ " ");
103
199
  _msg_error(
104
200
  _msg,
105
201
  1);
@@ -108,15 +204,9 @@ function
108
204
  function
109
205
  _msg_info_wallet_selected(
110
206
  _wallet) {
111
- let
112
- _msg,
113
- _template;
114
- _template =
115
- "Wallet is '{_wallet}'.";
116
- _msg =
117
- _template.replaceAll(
118
- "{_wallet}",
119
- _wallet);
207
+ const
208
+ _msg =
209
+ `Wallet is '${_wallet}'.`;
120
210
  _msg_info(
121
211
  _msg);
122
212
  }
@@ -212,11 +302,13 @@ async function
212
302
  _tx);
213
303
  _file_write(
214
304
  _output_path,
215
- _json);
305
+ _json);
216
306
  }
217
- } catch (e) {
218
- console.error(
219
- e);
307
+ } catch (_error) {
308
+ _msg_error(
309
+ _error,
310
+ 0);
311
+ throw _error;
220
312
  }
221
313
  return _tx;
222
314
  }
@@ -224,41 +316,20 @@ async function
224
316
  function
225
317
  _config_show() {
226
318
  let
227
- _line,
228
- _text;
229
- _text = [];
230
- _text.push(
231
- " Maximum retries: {retries_max}".replace(
232
- "{retries_max}",
233
- retries_max));
234
- _text.push(
235
- " Wallet seed: {wallet_seed}".replace(
236
- "{wallet_seed}",
237
- wallet_seed));
238
- _text.push(
239
- " Chain ID: {chain_id}".replace(
240
- "{chain_id}",
241
- chain_id));
242
- _text.push(
243
- " Chain Name: {chain_name}".replace(
244
- "{chain_name}",
245
- chain_name));
246
- _text.push(
247
- " Target network: {target_network}".replace(
248
- "{target_network}",
249
- target_network));
250
- _text.push(
251
- " API Key: {api_key_path}".replace(
252
- "{api_key_path}",
253
- api_key_path));
254
- _text.push(
255
- " Output path: {output_path}".replace(
256
- "{output_path}",
257
- output_path));
258
- _text.push(
259
- " Transaction address: {transaction_address}".replace(
260
- "{transaction_address}",
261
- transaction_address));
319
+ _line;
320
+ const
321
+ _text = [
322
+ ` Maximum retries: ${retries_max}`,
323
+ ` Wallet seed: ${wallet_seed}`,
324
+ ` Wallet seed: ${wallet_seed}`,
325
+ ` Chain ID: ${chain_id}`,
326
+ ` Chain Name: ${chain_name}`,
327
+ ` Target network: ${target_network}`,
328
+ ` API Key: ${api_key_path}`,
329
+ ` Output path: ${output_path}`,
330
+ ` Output path: ${output_path}`,
331
+ ` Transaction address: ${transaction_address}`,
332
+ ];
262
333
  for ( _line of _text ) {
263
334
  _msg_info(
264
335
  _line);
@@ -269,109 +340,147 @@ function
269
340
  _usage(
270
341
  _exit_code) {
271
342
  let
272
- _line,
273
- _text;
274
- _text = [
275
- "Usage:",
276
- " contract-get",
277
- " <quiet>",
278
- " <retries_max>",
279
- " <wallet_seed>",
280
- " <wallet_password_path>",
281
- " <chain_id>",
282
- " <chain_name>",
283
- " <target_network>",
284
- " <api_key_path>",
285
- " <output_path>",
286
- " <transaction_address>",
287
- "",
288
- "Args:",
289
- " <quiet> Can be 'y' or 'n'",
290
- " Default: y",
291
- " <retries_max> Maximum number of retries before",
292
- " failing.",
293
- " <wallet_seed> Path of the seed phrase.",
294
- " <wallet_password_path> Wallet password path.",
295
- " <chain_id> Chain ID for the network.",
296
- " <chain_name> Name for the network.",
297
- " <target_network> Network on which the transaction",
298
- " resides.",
299
- " <api_key_path> Path of the API key for the",
300
- " network provider service.",
301
- " <output_path> File on which to optionally save",
302
- " the output.",
303
- " <transaction_address> Transaction one wants to retrieve.",
304
- "",
305
- " Options:",
306
- " -h This help."
307
- ];
343
+ _line;
344
+ const
345
+ _app_name =
346
+ _get(
347
+ "app",
348
+ "name");
349
+ const
350
+ _text = [
351
+ "",
352
+ "Retrieve EVM networks transactions",
353
+ "",
354
+ "Usage:",
355
+ ` ${_app_name}`,
356
+ " <quiet>",
357
+ " <retries-max>",
358
+ " <wallet-seed>",
359
+ " <wallet-password-path>",
360
+ " <chain-id>",
361
+ " <chain-name>",
362
+ " <target-network>",
363
+ " <api-key-path>",
364
+ " <output-path>",
365
+ " <transaction-address>",
366
+ "",
367
+ "Args:",
368
+ " <quiet> Can be 'y' or 'n'",
369
+ " Default: y",
370
+ " <retries-max> Maximum number of retries before",
371
+ " failing.",
372
+ " <wallet-seed> Path of the seed phrase.",
373
+ " <wallet-password-path> Wallet password path.",
374
+ " <chain-id> Chain ID for the network.",
375
+ " <chain-name> Name for the network.",
376
+ " <target-network> Network on which the transaction",
377
+ " resides.",
378
+ " <api-key-path> Path of the API key for the",
379
+ " network provider service.",
380
+ " <output-path> File on which to optionally save",
381
+ " the output.",
382
+ " <transaction-address> Transaction one wants to retrieve.",
383
+ "",
384
+ " Options:",
385
+ " -h This help.",
386
+ ""
387
+ ];
308
388
  for ( _line of _text ) {
309
- _msg_info(
389
+ _echo(
310
390
  _line);
311
391
  }
312
- process.exit(
392
+ _exit(
313
393
  _exit_code);
314
394
  }
315
395
 
316
396
  function _cmdline_parse() {
317
- quiet =
397
+ const
398
+ _global =
399
+ _global_get();
400
+ _global[
401
+ "quiet"] =
318
402
  "y";
319
- process.argv.forEach(
403
+ _argv.forEach(
320
404
  function (
321
405
  _value,
322
- _index,
323
- _array) {
406
+ _index) {
324
407
  if ( _index == 2 ) {
325
- quiet =
408
+ _global[
409
+ "quiet"] =
326
410
  _value;
327
411
  }
328
412
  if ( _index == 3 ) {
329
- retries_max =
330
- _value;
413
+ _set(
414
+ "retries",
415
+ "max",
416
+ _value);
331
417
  }
332
418
  if ( _index == 4 ) {
333
- wallet_seed =
334
- _value;
419
+ _set(
420
+ "wallet",
421
+ "seed",
422
+ _value);
335
423
  }
336
424
  if ( _index == 5 ) {
337
- wallet_password_path =
338
- _value;
425
+ _set(
426
+ "wallet",
427
+ "password_path",
428
+ _value);
339
429
  }
340
430
  if ( _index == 6 ) {
341
- chain_id =
342
- _value;
431
+ _set(
432
+ "chain",
433
+ "id",
434
+ _value);
343
435
  }
344
436
  if ( _index == 7 ) {
345
- chain_name =
346
- _value;
437
+ _set(
438
+ "chain",
439
+ "name",
440
+ _value);
347
441
  }
348
442
  if ( _index == 8 ) {
349
- target_network =
350
- _value;
443
+ _set(
444
+ "target",
445
+ "network",
446
+ _value);
351
447
  }
352
448
  if ( _index == 9 ) {
353
- api_key_path =
354
- _value;
449
+ _set(
450
+ "api",
451
+ "key_path",
452
+ _value);
355
453
  }
356
454
  if ( _index == 10 ) {
357
- output_path =
358
- _value;
455
+ _set(
456
+ "output",
457
+ "path",
458
+ _value);
359
459
  }
360
460
  if ( _index == 11 ) {
361
- transaction_address =
362
- _value;
461
+ _set(
462
+ "transaction",
463
+ "address",
464
+ _value);
363
465
  }
364
466
  if ( _value == "-h" ||
365
467
  _value == "--help" ) {
366
- quiet =
468
+ _global[
469
+ "quiet"] =
367
470
  "n";
368
471
  _usage(
369
472
  0);
370
473
  }
371
474
  }
372
475
  );
373
- if ( transaction_address == "" ) {
374
- quiet =
476
+ const
477
+ _transaction_address =
478
+ _get(
479
+ "transaction",
480
+ "address");
481
+ if ( _transaction_address == "" ) {
482
+ _global[
483
+ "quiet"] =
375
484
  "n";
376
485
  _usage(
377
486
  1);
@@ -380,10 +489,10 @@ function _cmdline_parse() {
380
489
 
381
490
  function
382
491
  _overrides_set() {
383
- if ( retries_max == "" ) {
384
- retries_max =
385
- 100;
386
- }
492
+ _override_set(
493
+ "retries",
494
+ "max",
495
+ 100);
387
496
  if ( chain_id == "" ) {
388
497
  _msg_info(
389
498
  "TODO: use evm_chains_info_module");
@@ -413,18 +522,29 @@ async function
413
522
  _json);
414
523
  }
415
524
  else {
416
- throw "Transaction Get returned undefined value."
525
+ const
526
+ _msg =
527
+ "Function 'transaction-get' returned undefined value.";
528
+ const
529
+ _exception = {
530
+ "msg":
531
+ _msg
532
+ };
533
+ throw _exception;
417
534
  }
418
- } catch (error) {
535
+ } catch (
536
+ _error) {
419
537
  _msg_error(
420
- error,
538
+ _error,
421
539
  1);
422
540
  }
423
541
  }
424
542
 
425
-
426
- if ( _cmdline_check(
427
- "transaction-get") ) {
543
+ if ( await _cmdline_check(
544
+ "transaction-get") ||
545
+ await _cmdline_check(
546
+ "transaction-info") ) {
547
+ _globals;
428
548
  _global_variables();
429
549
  _cmdline_parse();
430
550
  _overrides_set();
@@ -444,7 +564,11 @@ if ( _cmdline_check(
444
564
  app_opts);
445
565
  }
446
566
 
447
- module.exports = {
448
- _transaction_get:
449
- _transaction_get
567
+ export {
568
+ _transaction_get
450
569
  };
570
+
571
+ // module.exports = {
572
+ // _transaction_get:
573
+ // _transaction_get
574
+ // };