@witnet/sdk 1.2.7 → 3.0.2

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 (89) hide show
  1. package/.env_witnet +18 -18
  2. package/LICENSE +21 -21
  3. package/README.md +116 -116
  4. package/dist/package.json +14 -3
  5. package/dist/src/bin/helpers.d.ts +1 -0
  6. package/dist/src/bin/helpers.d.ts.map +1 -1
  7. package/dist/src/bin/helpers.js +31 -54
  8. package/dist/src/lib/crypto/account.d.ts.map +1 -1
  9. package/dist/src/lib/crypto/account.js +3 -9
  10. package/dist/src/lib/crypto/coinbase.d.ts.map +1 -1
  11. package/dist/src/lib/crypto/coinbase.js +2 -2
  12. package/dist/src/lib/crypto/interfaces.d.ts.map +1 -1
  13. package/dist/src/lib/crypto/interfaces.js +1 -1
  14. package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts +4 -6
  15. package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts.map +1 -1
  16. package/dist/src/lib/crypto/payloads/DataRequestPayload.js +20 -71
  17. package/dist/src/lib/crypto/payloads/StakePayload.d.ts.map +1 -1
  18. package/dist/src/lib/crypto/payloads/StakePayload.js +4 -9
  19. package/dist/src/lib/crypto/payloads/UnstakePayload.d.ts.map +1 -1
  20. package/dist/src/lib/crypto/payloads/UnstakePayload.js +4 -7
  21. package/dist/src/lib/crypto/payloads/ValueTransferPayload.d.ts.map +1 -1
  22. package/dist/src/lib/crypto/payloads/ValueTransferPayload.js +4 -9
  23. package/dist/src/lib/crypto/payloads.d.ts.map +1 -1
  24. package/dist/src/lib/crypto/payloads.js +6 -13
  25. package/dist/src/lib/crypto/signer.d.ts.map +1 -1
  26. package/dist/src/lib/crypto/signer.js +2 -2
  27. package/dist/src/lib/crypto/transmitters/DataRequests.d.ts.map +1 -1
  28. package/dist/src/lib/crypto/transmitters/DataRequests.js +2 -2
  29. package/dist/src/lib/crypto/transmitters/StakeDeposits.d.ts.map +1 -1
  30. package/dist/src/lib/crypto/transmitters/StakeDeposits.js +2 -2
  31. package/dist/src/lib/crypto/transmitters/StakeWithdrawals.d.ts.map +1 -1
  32. package/dist/src/lib/crypto/transmitters/StakeWithdrawals.js +2 -2
  33. package/dist/src/lib/crypto/transmitters/ValueTransfers.d.ts.map +1 -1
  34. package/dist/src/lib/crypto/transmitters/ValueTransfers.js +2 -2
  35. package/dist/src/lib/crypto/transmitters.d.ts.map +1 -1
  36. package/dist/src/lib/crypto/transmitters.js +22 -31
  37. package/dist/src/lib/crypto/types.d.ts.map +1 -1
  38. package/dist/src/lib/crypto/types.js +6 -13
  39. package/dist/src/lib/crypto/utils.d.ts.map +1 -1
  40. package/dist/src/lib/crypto/utils.js +5 -9
  41. package/dist/src/lib/crypto/wallet.d.ts.map +1 -1
  42. package/dist/src/lib/crypto/wallet.js +9 -23
  43. package/dist/src/lib/radon/ccdr/eth.d.ts.map +1 -1
  44. package/dist/src/lib/radon/ccdr/eth.js +12 -32
  45. package/dist/src/lib/radon/ccdr/wit.d.ts.map +1 -1
  46. package/dist/src/lib/radon/ccdr/wit.js +3 -6
  47. package/dist/src/lib/radon/index.d.ts.map +1 -1
  48. package/dist/src/lib/radon/index.js +18 -41
  49. package/dist/src/lib/radon/reducers.js +2 -2
  50. package/dist/src/lib/radon/types.d.ts.map +1 -1
  51. package/dist/src/lib/radon/types.js +6 -32
  52. package/dist/src/lib/radon/utils.d.ts +1 -1
  53. package/dist/src/lib/radon/utils.d.ts.map +1 -1
  54. package/dist/src/lib/radon/utils.js +8 -9
  55. package/dist/src/lib/rest/kermit.d.ts.map +1 -1
  56. package/dist/src/lib/rest/kermit.js +1 -1
  57. package/dist/src/lib/rpc/nodes.d.ts.map +1 -1
  58. package/dist/src/lib/rpc/nodes.js +8 -28
  59. package/dist/src/lib/rpc/provider.d.ts.map +1 -1
  60. package/dist/src/lib/rpc/provider.js +16 -38
  61. package/dist/src/lib/rpc/types.d.ts.map +1 -1
  62. package/dist/src/lib/rpc/types.js +1 -1
  63. package/dist/src/lib/utils.d.ts.map +1 -1
  64. package/dist/src/lib/utils.js +2 -5
  65. package/dist/witnet/assets/index.cjs +1 -1
  66. package/dist/witnet/assets/modals/index.cjs +1 -1
  67. package/dist/witnet/assets/modals/web3/eth.cjs +2 -2
  68. package/dist/witnet/assets/modals/web3/ipfs.cjs +2 -2
  69. package/dist/witnet/assets/modals/web3/wit.cjs +4 -11
  70. package/dist/witnet/assets/requests.cjs +3 -11
  71. package/package.json +7 -3
  72. package/src/bin/bots/watcher.cjs +27 -93
  73. package/src/bin/cli/inspect.js +30 -119
  74. package/src/bin/cli/network.js +46 -202
  75. package/src/bin/cli/nodes.js +12 -58
  76. package/src/bin/cli/radon.js +161 -396
  77. package/src/bin/cli/wallet.js +69 -241
  78. package/src/bin/helpers.js +66 -162
  79. package/src/bin/index.js +23 -52
  80. package/witnet/assets/_index.cjs +5 -5
  81. package/witnet/assets/_requests.cjs +25 -25
  82. package/witnet/assets/_sources.cjs +36 -36
  83. package/witnet/assets/_templates.cjs +36 -36
  84. package/witnet/assets/index.cjs +4 -4
  85. package/witnet/assets/modals/index.cjs +7 -7
  86. package/witnet/assets/modals/web3/eth.cjs +22 -27
  87. package/witnet/assets/modals/web3/ipfs.cjs +17 -22
  88. package/witnet/assets/modals/web3/wit.cjs +16 -28
  89. package/witnet/assets/requests.cjs +41 -49
@@ -5,25 +5,13 @@ const FLAGS_LIMIT_MAX = 2048;
5
5
  const FLAGS_LIMIT_DEFAULT = 64;
6
6
  const OPTIONS_DEFAULT_SINCE = -2048;
7
7
 
8
- const {
9
- cyan,
10
- white,
11
- gray,
12
- green,
13
- lcyan,
14
- lyellow,
15
- mgreen,
16
- mred,
17
- myellow,
18
- yellow,
19
- } = helpers.colors;
8
+ const { cyan, white, gray, green, lcyan, lyellow, mgreen, mred, myellow, yellow } = helpers.colors;
20
9
 
21
10
  /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22
11
  /// CLI SUBMODULE CONSTANTS ===========================================================================================
23
12
 
24
13
  export const envars = {
25
- WITNET_SDK_PROVIDER_URL:
26
- "=> Wit/Oracle RPC provider(s) to connect to, if no otherwise specified.",
14
+ WITNET_SDK_PROVIDER_URL: "=> Wit/Oracle RPC provider(s) to connect to, if no otherwise specified.",
27
15
  };
28
16
  export const flags = {
29
17
  limit: {
@@ -166,16 +154,10 @@ export const subcommands = {
166
154
  /// CLI SUBMODULE COMMANDS ============================================================================================
167
155
 
168
156
  async function blocks(options = {}) {
169
- options.limit = Math.min(
170
- parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT,
171
- FLAGS_LIMIT_MAX,
172
- );
157
+ options.limit = Math.min(parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT, FLAGS_LIMIT_MAX);
173
158
  const provider = new Witnet.JsonRpcProvider(options?.provider);
174
159
  // todo: use prompter?
175
- const records = await provider.blocks(
176
- parseInt(options?.since, 10) || -options.limit - 2,
177
- options.limit,
178
- );
160
+ const records = await provider.blocks(parseInt(options?.since, 10) || -options.limit - 2, options.limit);
179
161
  if (records.length > 0) {
180
162
  helpers.traceTable(
181
163
  records.slice(0, options.limit).map((record) => [record[0], record[1]]),
@@ -185,14 +167,10 @@ async function blocks(options = {}) {
185
167
  colors: [undefined, helpers.colors.gray],
186
168
  },
187
169
  );
188
- console.info(
189
- `^ Listed ${records.length} blocks for a range of ${options.limit} epochs.`,
190
- );
170
+ console.info(`^ Listed ${records.length} blocks for a range of ${options.limit} epochs.`);
191
171
  } else {
192
172
  console.info(
193
- `> No blocks found in specified range (since: ${
194
- options?.since || -options.limit
195
- }, limit: ${options.limit}).`,
173
+ `> No blocks found in specified range (since: ${options?.since || -options.limit}, limit: ${options.limit}).`,
196
174
  );
197
175
  }
198
176
  }
@@ -203,10 +181,7 @@ async function constants(options = {}) {
203
181
  }
204
182
 
205
183
  async function holders(options = {}) {
206
- options.limit = Math.min(
207
- parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT,
208
- FLAGS_LIMIT_MAX,
209
- );
184
+ options.limit = Math.min(parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT, FLAGS_LIMIT_MAX);
210
185
  const provider = new Witnet.JsonRpcProvider(options?.provider);
211
186
  const records = Object.entries(
212
187
  await helpers.prompter(
@@ -230,39 +205,21 @@ async function holders(options = {}) {
230
205
  Witnet.Coins.fromNanowits(balance.unlocked).wits,
231
206
  ]
232
207
  : []),
233
- Witnet.Coins.fromNanowits(
234
- balance.locked + balance.staked + balance.unlocked,
235
- ).wits,
208
+ Witnet.Coins.fromNanowits(balance.locked + balance.staked + balance.unlocked).wits,
236
209
  ]),
237
210
  {
238
211
  headlines: [
239
212
  "RANK",
240
213
  "HOLDERS",
241
- ...(options?.verbose
242
- ? ["Locked ($WIT)", "Staked ($WIT)", "Available ($WIT)"]
243
- : []),
214
+ ...(options?.verbose ? ["Locked ($WIT)", "Staked ($WIT)", "Available ($WIT)"] : []),
244
215
  "BALANCE ($WIT)",
245
216
  ],
246
- humanizers: [
247
- undefined,
248
- undefined,
249
- helpers.commas,
250
- helpers.commas,
251
- helpers.commas,
252
- helpers.commas,
253
- ],
254
- colors: [
255
- undefined,
256
- mgreen,
257
- ...(options?.verbose ? [gray, yellow, myellow] : []),
258
- lyellow,
259
- ],
217
+ humanizers: [undefined, undefined, helpers.commas, helpers.commas, helpers.commas, helpers.commas],
218
+ colors: [undefined, mgreen, ...(options?.verbose ? [gray, yellow, myellow] : []), lyellow],
260
219
  },
261
220
  );
262
221
  if (options.limit < totalRecords) {
263
- console.info(
264
- `^ Listed ${Math.min(options.limit, totalRecords)} out of ${totalRecords} records.`,
265
- );
222
+ console.info(`^ Listed ${Math.min(options.limit, totalRecords)} out of ${totalRecords} records.`);
266
223
  }
267
224
  }
268
225
 
@@ -307,25 +264,15 @@ async function powers(options = {}) {
307
264
  undefined,
308
265
  helpers.colors.green,
309
266
  ...(options?.verbose ? [helpers.colors.mgreen] : []),
310
- query.orderBy === "mining"
311
- ? helpers.colors.mcyan
312
- : helpers.colors.mmagenta,
313
- ],
314
- humanizers: [
315
- helpers.commas,
316
- undefined,
317
- ...(options?.verbose
318
- ? [undefined, helpers.commas]
319
- : [helpers.commas]),
267
+ query.orderBy === "mining" ? helpers.colors.mcyan : helpers.colors.mmagenta,
320
268
  ],
269
+ humanizers: [helpers.commas, undefined, ...(options?.verbose ? [undefined, helpers.commas] : [helpers.commas])],
321
270
  },
322
271
  );
323
272
  if (records.length === query.limit || query.offset === 0) {
324
273
  console.info(`^ Listed ${records.length} records.`);
325
274
  } else if (query.offset !== 0) {
326
- console.info(
327
- `^ Listed ${records.length} out of ${records.length + query.offset} records.`,
328
- );
275
+ console.info(`^ Listed ${records.length} out of ${records.length + query.offset} records.`);
329
276
  }
330
277
  } else {
331
278
  if (query.offset === 0) {
@@ -353,19 +300,14 @@ async function provider(options = {}) {
353
300
  : mred("Unknown")
354
301
  }`,
355
302
  );
356
- console.info(
357
- `> Witnet network id: ${green(`0x${provider.networkId.toString(16).toUpperCase()}`)}`,
358
- );
303
+ console.info(`> Witnet network id: ${green(`0x${provider.networkId.toString(16).toUpperCase()}`)}`);
359
304
  }
360
305
 
361
306
  async function senate(options = {}) {
362
307
  const provider = new Witnet.JsonRpcProvider(options?.provider);
363
308
  const params = {
364
309
  distinct: true,
365
- limit: Math.min(
366
- parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT,
367
- FLAGS_LIMIT_MAX,
368
- ),
310
+ limit: Math.min(parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT, FLAGS_LIMIT_MAX),
369
311
  offset: parseInt(options?.offset || 0, 10),
370
312
  order: { by: "mining" },
371
313
  since: -Math.abs(parseInt(options?.since, 10) || OPTIONS_DEFAULT_SINCE) - 1,
@@ -375,60 +317,34 @@ async function senate(options = {}) {
375
317
  helpers.traceTable(
376
318
  records.map((record, index) => [
377
319
  ...(options?.verbose
378
- ? [
379
- index + 1,
380
- record.key.validator,
381
- record.value.nonce,
382
- record.value.epochs.witnessing,
383
- ]
320
+ ? [index + 1, record.key.validator, record.value.nonce, record.value.epochs.witnessing]
384
321
  : [record.key.validator]),
385
322
  record.value.epochs.mining,
386
323
  ]),
387
324
  {
388
325
  headlines: [
389
326
  ...(options?.verbose
390
- ? [
391
- "INDEX",
392
- `Superblock Voting Committee ${params.since + 1}`,
393
- "Nonce",
394
- "LW_Epoch",
395
- ]
327
+ ? ["INDEX", `Superblock Voting Committee ${params.since + 1}`, "Nonce", "LW_Epoch"]
396
328
  : [`Superblock Voting Committee ${params.since + 1}`]),
397
329
  "LM_Epoch",
398
330
  ],
399
331
  humanizers: [
400
332
  ...(options?.verbose
401
- ? [
402
- helpers.commas,
403
- undefined,
404
- helpers.commas,
405
- helpers.commas,
406
- helpers.commas,
407
- ]
333
+ ? [helpers.commas, undefined, helpers.commas, helpers.commas, helpers.commas]
408
334
  : [undefined, helpers.commas, helpers.commas, helpers.commas]),
409
335
  ],
410
336
  colors: [
411
337
  ...(options?.verbose
412
- ? [
413
- undefined,
414
- undefined,
415
- undefined,
416
- helpers.colors.magenta,
417
- helpers.colors.mcyan,
418
- ]
338
+ ? [undefined, undefined, undefined, helpers.colors.magenta, helpers.colors.mcyan]
419
339
  : [undefined, helpers.colors.mcyan]),
420
340
  ],
421
341
  },
422
342
  );
423
343
  if (records.length < params.limit) {
424
344
  if (params.offset === 0) {
425
- console.info(
426
- `^ Only ${records.length} qualified members out of ${params.limit} seats.`,
427
- );
345
+ console.info(`^ Only ${records.length} qualified members out of ${params.limit} seats.`);
428
346
  } else {
429
- console.info(
430
- `^ Listed ${records.length} out of ${records.length + params.offset} members.`,
431
- );
347
+ console.info(`^ Listed ${records.length} out of ${records.length + params.offset} members.`);
432
348
  }
433
349
  } else {
434
350
  console.info(`^ Listed ${records.length} members.`);
@@ -446,16 +362,12 @@ async function stakes(options = {}) {
446
362
  const provider = new Witnet.JsonRpcProvider(options?.provider);
447
363
  const query = {
448
364
  params: {
449
- limit: Math.min(
450
- parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT,
451
- FLAGS_LIMIT_MAX,
452
- ),
365
+ limit: Math.min(parseInt(options.limit, 10) || FLAGS_LIMIT_DEFAULT, FLAGS_LIMIT_MAX),
453
366
  offset: parseInt(options?.offset || 0, 10),
454
367
  },
455
368
  };
456
369
  if (options?.validator) query.filter = { validator: options.validator };
457
- if (options?.withdrawer)
458
- query.filter = { ...query.filter, withdrawer: options.withdrawer };
370
+ if (options?.withdrawer) query.filter = { ...query.filter, withdrawer: options.withdrawer };
459
371
  const records = await provider.stakes(query); // todo: use prompter?
460
372
  if (records.length > 0) {
461
373
  helpers.traceTable(
@@ -463,13 +375,7 @@ async function stakes(options = {}) {
463
375
  1 + index + query.params.offset,
464
376
  record.key.withdrawer,
465
377
  record.key.validator,
466
- ...(options?.verbose
467
- ? [
468
- record.value.nonce,
469
- record.value.epochs.witnessing,
470
- record.value.epochs.mining,
471
- ]
472
- : []),
378
+ ...(options?.verbose ? [record.value.nonce, record.value.epochs.witnessing, record.value.epochs.mining] : []),
473
379
  Witnet.Coins.fromNanowits(record.value.coins).wits,
474
380
  ]),
475
381
  {
@@ -484,18 +390,14 @@ async function stakes(options = {}) {
484
390
  undefined,
485
391
  undefined,
486
392
  undefined,
487
- ...(options?.verbose
488
- ? [helpers.commas, helpers.commas, helpers.commas]
489
- : []),
393
+ ...(options?.verbose ? [helpers.commas, helpers.commas, helpers.commas] : []),
490
394
  (x) => helpers.commas(Math.floor(parseFloat(x))),
491
395
  ],
492
396
  colors: [
493
397
  undefined,
494
398
  helpers.colors.mgreen,
495
399
  undefined,
496
- ...(options?.verbose
497
- ? [undefined, helpers.colors.magenta, helpers.colors.cyan]
498
- : []),
400
+ ...(options?.verbose ? [undefined, helpers.colors.magenta, helpers.colors.cyan] : []),
499
401
  helpers.colors.myellow,
500
402
  ],
501
403
  },
@@ -503,9 +405,7 @@ async function stakes(options = {}) {
503
405
  if (records.length === query.params.limit || query.params.offset === 0) {
504
406
  console.info(`^ Listed ${records.length} records.`);
505
407
  } else if (query.params.offset !== 0) {
506
- console.info(
507
- `^ Listed ${records.length} out of ${records.length + query.params.offset} records.`,
508
- );
408
+ console.info(`^ Listed ${records.length} out of ${records.length + query.params.offset} records.`);
509
409
  }
510
410
  } else {
511
411
  if (query.params.offset === 0) {
@@ -517,41 +417,22 @@ async function stakes(options = {}) {
517
417
  }
518
418
 
519
419
  async function supplyInfo(options = {}) {
520
- const reporter = new Witnet.JsonRpcProvider(
521
- options?.provider || process.env.WITNET_SDK_PROVIDER_URL,
522
- );
420
+ const reporter = new Witnet.JsonRpcProvider(options?.provider || process.env.WITNET_SDK_PROVIDER_URL);
523
421
  const data = await reporter.supplyInfo();
524
- console.info(
525
- `> Supply info at epoch ${helpers.colors.white(helpers.commas(data.epoch))}:`,
526
- );
422
+ console.info(`> Supply info at epoch ${helpers.colors.white(helpers.commas(data.epoch))}:`);
527
423
  const records = [];
528
- records.push([
529
- "Minted blocks",
530
- `${helpers.toFixedTrunc((100 * data.blocks_minted) / (data.epoch - 1), 1)} %`,
531
- ]);
532
- records.push([
533
- "Minted rewards",
534
- helpers.whole_wits(data.blocks_minted_reward, 2),
535
- ]);
424
+ records.push(["Minted blocks", `${helpers.toFixedTrunc((100 * data.blocks_minted) / (data.epoch - 1), 1)} %`]);
425
+ records.push(["Minted rewards", helpers.whole_wits(data.blocks_minted_reward, 2)]);
536
426
  if (data.burnt_supply) {
537
427
  records.push(["Burnt supply", helpers.whole_wits(data.burnt_supply, 2)]);
538
428
  }
539
429
  if (data.current_locked_supply) {
540
- records.push([
541
- "Locked supply",
542
- helpers.whole_wits(data.current_locked_supply, 2),
543
- ]);
430
+ records.push(["Locked supply", helpers.whole_wits(data.current_locked_supply, 2)]);
544
431
  }
545
432
  if (data.current_staked_supply) {
546
- records.push([
547
- "Staked supply",
548
- helpers.whole_wits(data.current_staked_supply, 2),
549
- ]);
433
+ records.push(["Staked supply", helpers.whole_wits(data.current_staked_supply, 2)]);
550
434
  }
551
- records.push([
552
- "Circulating supply",
553
- helpers.whole_wits(data.current_unlocked_supply, 2),
554
- ]);
435
+ records.push(["Circulating supply", helpers.whole_wits(data.current_unlocked_supply, 2)]);
555
436
  helpers.traceTable(records, {
556
437
  headlines: [":KPI", "VALUE"],
557
438
  colors: [helpers.colors.mgreen, helpers.colors.myellow],
@@ -564,9 +445,7 @@ async function syncStatus(options = {}) {
564
445
  helpers.traceTable(
565
446
  [
566
447
  [
567
- provider.network === "mainnet"
568
- ? "Mainnet"
569
- : `Testnet (${provider.networkId.toString(16).toUpperCase()})`,
448
+ provider.network === "mainnet" ? "Mainnet" : `Testnet (${provider.networkId.toString(16).toUpperCase()})`,
570
449
  syncStatus.node_state || "",
571
450
  syncStatus.current_epoch,
572
451
  syncStatus.chain_beacon.checkpoint,
@@ -574,21 +453,9 @@ async function syncStatus(options = {}) {
574
453
  ],
575
454
  ],
576
455
  {
577
- headlines: [
578
- "NETWORK",
579
- ":STATUS",
580
- "Current epoch",
581
- "Checkpoint epoch",
582
- "Checkpoint block hash",
583
- ],
456
+ headlines: ["NETWORK", ":STATUS", "Current epoch", "Checkpoint epoch", "Checkpoint block hash"],
584
457
  humanizers: [undefined, undefined, helpers.commas, helpers.commas],
585
- colors: [
586
- helpers.colors.mgreen,
587
- helpers.colors.lgreen,
588
- helpers.colors.white,
589
- undefined,
590
- helpers.colors.gray,
591
- ],
458
+ colors: [helpers.colors.mgreen, helpers.colors.lgreen, helpers.colors.white, undefined, helpers.colors.gray],
592
459
  },
593
460
  );
594
461
  }
@@ -610,25 +477,15 @@ async function versions(options = {}) {
610
477
  if (records[key]) records[key].epoch = epoch;
611
478
  });
612
479
  helpers.traceTable(
613
- Object.entries(records).map(([key, props]) => [
614
- key === "V1_7" ? "V1_0" : key,
615
- props?.epoch,
616
- props?.period,
617
- ]),
480
+ Object.entries(records).map(([key, props]) => [key === "V1_7" ? "V1_0" : key, props?.epoch, props?.period]),
618
481
  {
619
482
  headlines: [":Version", "Activation epoch", ":Block time (secs)"],
620
483
  humanizers: [undefined, helpers.commas],
621
- colors: [
622
- helpers.colors.mgreen,
623
- helpers.colors.white,
624
- helpers.colors.normal,
625
- ],
484
+ colors: [helpers.colors.mgreen, helpers.colors.white, helpers.colors.normal],
626
485
  },
627
486
  );
628
487
  }
629
- console.info(
630
- `Current protocol version is ${helpers.colors.mgreen(protocolInfo.current_version)}.`,
631
- );
488
+ console.info(`Current protocol version is ${helpers.colors.mgreen(protocolInfo.current_version)}.`);
632
489
  }
633
490
 
634
491
  async function wips(options = {}) {
@@ -636,9 +493,7 @@ async function wips(options = {}) {
636
493
  const wips = await provider.wips();
637
494
  if (!options?.pending) {
638
495
  // console.info(`> Active WIP upgrades at epoch ${helpers.colors.white(helpers.commas(wips.epoch))}:`)
639
- const active_upgrades = Object.entries(wips.active_upgrades).map(
640
- ([wip, epoch]) => [wip, epoch],
641
- );
496
+ const active_upgrades = Object.entries(wips.active_upgrades).map(([wip, epoch]) => [wip, epoch]);
642
497
  helpers.traceTable(active_upgrades, {
643
498
  headlines: [":WIP", "Activation epoch"],
644
499
  humanizers: [undefined, helpers.commas],
@@ -647,13 +502,9 @@ async function wips(options = {}) {
647
502
  }
648
503
  if (wips.pending_upgrades || options?.pending) {
649
504
  if (wips.pending_upgrades.length === 0) {
650
- console.info(
651
- `> No pending WIP upgrades at epoch ${helpers.colors.white(helpers.commas(wips.epoch))}.`,
652
- );
505
+ console.info(`> No pending WIP upgrades at epoch ${helpers.colors.white(helpers.commas(wips.epoch))}.`);
653
506
  } else {
654
- console.info(
655
- `Pending WIP upgrades at epoch ${helpers.colors.white(helpers.commas(wips.epoch))}:`,
656
- );
507
+ console.info(`Pending WIP upgrades at epoch ${helpers.colors.white(helpers.commas(wips.epoch))}:`);
657
508
  const pending_upgrades = wips.pending_upgrades.map((upgrade) => {
658
509
  return [
659
510
  upgrade.wip,
@@ -673,14 +524,7 @@ async function wips(options = {}) {
673
524
  "Duration",
674
525
  // "Deadline",
675
526
  ],
676
- humanizers: [
677
- undefined,
678
- undefined,
679
- helpers.commas,
680
- helpers.commas,
681
- helpers.commas,
682
- helpers.commas,
683
- ],
527
+ humanizers: [undefined, undefined, helpers.commas, helpers.commas, helpers.commas, helpers.commas],
684
528
  colors: [
685
529
  helpers.colors.lcyan,
686
530
  helpers.colors.mcyan,
@@ -1,12 +1,6 @@
1
1
  import * as qrcode from "qrcode-terminal";
2
2
  import { Witnet } from "../../../dist/src/index.js";
3
- import {
4
- colors as _colors,
5
- commas,
6
- prompt,
7
- traceChecklists,
8
- traceTable,
9
- } from "../helpers.js";
3
+ import { colors as _colors, commas, prompt, traceChecklists, traceTable } from "../helpers.js";
10
4
 
11
5
  const {
12
6
  cyan,
@@ -30,8 +24,7 @@ const {
30
24
  /// CLI SUBMODULE CONSTANTS ===========================================================================================
31
25
 
32
26
  export const envars = {
33
- WITNET_TOOLKIT_FARM_NODES:
34
- "=> URLs to your own nodes' HTTP/JSON private endpoints, if no otherwise specified.",
27
+ WITNET_TOOLKIT_FARM_NODES: "=> URLs to your own nodes' HTTP/JSON private endpoints, if no otherwise specified.",
35
28
  };
36
29
 
37
30
  export const flags = {
@@ -181,11 +174,7 @@ async function balance(options = {}) {
181
174
  gray(Witnet.Coins.fromNanowits(balance.locked).wits),
182
175
  yellow(Witnet.Coins.fromNanowits(balance.staked).wits),
183
176
  myellow(Witnet.Coins.fromNanowits(balance.unlocked).wits),
184
- lyellow(
185
- Witnet.Coins.fromNanowits(
186
- balance.locked + balance.staked + balance.unlocked,
187
- ).wits,
188
- ),
177
+ lyellow(Witnet.Coins.fromNanowits(balance.locked + balance.staked + balance.unlocked).wits),
189
178
  ]),
190
179
  ]),
191
180
  {
@@ -244,9 +233,7 @@ async function publicKeys(options = {}) {
244
233
  traceTable(
245
234
  Object.entries(publicKeys).map(([, [pkh, publicKey]]) => [
246
235
  pkh instanceof Error ? red(pkh) : mcyan(pkh),
247
- publicKey instanceof Error
248
- ? mred(publicKey.toString())
249
- : cyan(publicKey.toString()),
236
+ publicKey instanceof Error ? mred(publicKey.toString()) : cyan(publicKey.toString()),
250
237
  ]),
251
238
  {
252
239
  headlines: [":Public key hash", "Public key"],
@@ -279,27 +266,15 @@ async function rankings(options = {}) {
279
266
  traceTable(
280
267
  records
281
268
  .filter((record) => validators.includes(record.validator))
282
- .map(({ power, ranking, validator, withdrawer }) => [
283
- validator,
284
- withdrawer,
285
- power,
286
- ranking,
287
- ]),
269
+ .map(({ power, ranking, validator, withdrawer }) => [validator, withdrawer, power, ranking]),
288
270
  {
289
- headlines: [
290
- "VALIDATORS",
291
- "Withdrawer",
292
- `${capability} POWER`,
293
- "G_RANK",
294
- ],
271
+ headlines: ["VALIDATORS", "Withdrawer", `${capability} POWER`, "G_RANK"],
295
272
  humanizers: [undefined, undefined, commas, commas],
296
273
  colors: [lcyan, mmagenta, green, lgreen],
297
274
  },
298
275
  );
299
276
  } else {
300
- console.info(
301
- `> No ${capability} power is currently treasured on the farm.`,
302
- );
277
+ console.info(`> No ${capability} power is currently treasured on the farm.`);
303
278
  }
304
279
  } else {
305
280
  console.info("> No nodes currently available to interact with.");
@@ -311,9 +286,7 @@ async function rewind(options = {}, args = []) {
311
286
  throw Error("No rewind epoch was provided");
312
287
  }
313
288
  if (!options?.force) {
314
- const will = await prompt(
315
- "Rewinding will reset some stats. Do you want to proceed anyways? (y/N)",
316
- );
289
+ const will = await prompt("Rewinding will reset some stats. Do you want to proceed anyways? (y/N)");
317
290
  // Abort if not confirmed
318
291
  if (!["y"].includes(will.toLowerCase())) {
319
292
  console.error("Aborted by user.");
@@ -334,25 +307,14 @@ async function stats(options = {}) {
334
307
  traceTable(
335
308
  Object.entries(stats).map(([url, stats]) => [
336
309
  ...(stats instanceof Error
337
- ? [
338
- red(url),
339
- gray("n/a"),
340
- gray("n/a"),
341
- gray("n/a"),
342
- gray("n/a"),
343
- gray("n/a"),
344
- gray("n/a"),
345
- ]
310
+ ? [red(url), gray("n/a"), gray("n/a"), gray("n/a"), gray("n/a"), gray("n/a"), gray("n/a")]
346
311
  : [
347
312
  mcyan(url),
348
313
  stats.block_mined_count,
349
314
  stats.commits_count,
350
315
  (stats.block_mined_count / stats.block_proposed_count).toFixed(3),
351
316
  (stats.commits_count / stats.commits_proposed_count).toFixed(3),
352
- (
353
- (stats.dr_eligibility_count - stats.commits_proposed_count) /
354
- stats.dr_eligibility_count
355
- ).toFixed(3),
317
+ ((stats.dr_eligibility_count - stats.commits_proposed_count) / stats.dr_eligibility_count).toFixed(3),
356
318
  (stats.slashed_count / stats.commits_count).toFixed(3),
357
319
  ]),
358
320
  ]),
@@ -380,22 +342,14 @@ async function syncStatus(options) {
380
342
  ...(status instanceof Error
381
343
  ? [red(status), "", "", ""]
382
344
  : [
383
- status.node_state.trim() === "Synced"
384
- ? mgreen(status.node_state)
385
- : myellow(status.node_state),
345
+ status.node_state.trim() === "Synced" ? mgreen(status.node_state) : myellow(status.node_state),
386
346
  status.current_epoch,
387
347
  status.chain_beacon.checkpoint,
388
348
  status.chain_beacon.hashPrevBlock,
389
349
  ]),
390
350
  ]),
391
351
  {
392
- headlines: [
393
- ":NODES",
394
- ":Status",
395
- "Current epoch",
396
- "Checkpoint epoch",
397
- ":Checkpoint block hash",
398
- ],
352
+ headlines: [":NODES", ":Status", "Current epoch", "Checkpoint epoch", ":Checkpoint block hash"],
399
353
  humanizers: [undefined, undefined, commas, commas],
400
354
  colors: [undefined, undefined, white, undefined, gray], // gray, gray ],
401
355
  },