@leofcoin/workers 1.5.18 → 1.5.21

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.
@@ -1,4 +1,61 @@
1
- import { E as EasyWorker, C as ContractMessage, T as TransactionMessage } from './worker-2Vk145X_.js';
1
+ import { E as EasyWorker, C as ContractMessage, T as TransactionMessage } from './worker-4K8uC3xq.js';
2
+
3
+ /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
4
+ /**
5
+ * The current version of Ethers.
6
+ */
7
+ ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
8
+ try {
9
+ // General test for normalize
10
+ /* c8 ignore start */
11
+ if ("test".normalize(form) !== "test") {
12
+ throw new Error("bad");
13
+ }
14
+ ;
15
+ /* c8 ignore stop */
16
+ if (form === "NFD") {
17
+ const check = String.fromCharCode(0xe9).normalize("NFD");
18
+ const expected = String.fromCharCode(0x65, 0x0301);
19
+ /* c8 ignore start */
20
+ if (check !== expected) {
21
+ throw new Error("broken");
22
+ }
23
+ /* c8 ignore stop */
24
+ }
25
+ accum.push(form);
26
+ }
27
+ catch (error) { }
28
+ return accum;
29
+ }, []);
30
+
31
+ /**
32
+ * Some mathematic operations.
33
+ *
34
+ * @_subsection: api/utils:Math Helpers [about-maths]
35
+ */
36
+ BigInt(0);
37
+ BigInt(1);
38
+
39
+ /**
40
+ * The **FixedNumber** class permits using values with decimal places,
41
+ * using fixed-pont math.
42
+ *
43
+ * Fixed-point math is still based on integers under-the-hood, but uses an
44
+ * internal offset to store fractional components below, and each operation
45
+ * corrects for this after each operation.
46
+ *
47
+ * @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
48
+ */
49
+ BigInt(-1);
50
+ BigInt(0);
51
+ BigInt(1);
52
+ BigInt(5);
53
+ // Constant to pull zeros from for multipliers
54
+ let Zeros = "0000";
55
+ while (Zeros.length < 80) {
56
+ Zeros += Zeros;
57
+ }
58
+ const jsonParseBigInt = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
2
59
 
3
60
  const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
4
61
  const formatBytes = (bytes, decimals = 2) => {
@@ -263,22 +320,22 @@ const _ = {
263
320
  nativeCalls += 1n;
264
321
  if (method === 'burn') {
265
322
  nativeBurns = nativeBurns += 1n;
266
- totalBurnAmount = totalBurnAmount += params[1];
323
+ totalBurnAmount += BigInt(params[1]);
267
324
  }
268
325
  if (method === 'mint') {
269
326
  nativeMints = nativeMints += 1n;
270
- totalMintAmount = totalMintAmount += params[1];
327
+ totalMintAmount += BigInt(params[1]);
271
328
  }
272
329
  if (method === 'transfer') {
273
330
  nativeTransfers = nativeTransfers += 1n;
274
- totalTransferAmount = totalTransferAmount += params[2];
275
- }
276
- if (method === 'transferFrom') {
277
- nativeTransfers = nativeTransfers += 1n;
278
- totalTransferAmount = totalTransferAmount += params[1];
331
+ totalTransferAmount += BigInt(params[2]);
279
332
  }
333
+ // if (method === 'transferFrom') {
334
+ // nativeTransfers = nativeTransfers += 1n
335
+ // totalTransferAmount += params[1]
336
+ // }
280
337
  }
281
- totalTransactions = totalTransactions += 1n;
338
+ totalTransactions += 1n;
282
339
  // state.put(result)
283
340
  return result;
284
341
  }
@@ -293,6 +350,10 @@ const _ = {
293
350
  },
294
351
  init: async (message) => {
295
352
  let { peerid, fromState, state, info } = message;
353
+ if (info)
354
+ info = JSON.parse(info, jsonParseBigInt);
355
+ if (state)
356
+ state = JSON.parse(state, jsonParseBigInt);
296
357
  globalThis.peerid = peerid;
297
358
  console.log({ fromState, info });
298
359
  nativeCalls = BigInt(info?.nativeCalls ?? 0);
@@ -305,7 +366,9 @@ const _ = {
305
366
  totalTransferAmount = BigInt(info?.totalTransferAmount ?? 0);
306
367
  totalBlocks = BigInt(info?.totalBlocks ?? 0);
307
368
  if (fromState) {
308
- lastBlock = message.lastBlock;
369
+ if (message.lastBlock) {
370
+ lastBlock = JSON.parse(message.lastBlock, jsonParseBigInt);
371
+ }
309
372
  const setState = async (address, state) => {
310
373
  const contractBytes = await resolveContract(address);
311
374
  if (contractBytes === address) {
@@ -378,6 +441,7 @@ const _ = {
378
441
  latestTransactions.splice(-transactionCount, latestTransactions.length);
379
442
  }
380
443
  if (!block.loaded && !fromState) {
444
+ totalBlocks += 1n;
381
445
  try {
382
446
  const transactions = await Promise.all(block.transactions.map(async (transaction) => {
383
447
  const message = new TransactionMessage(await resolveTransaction(transaction)).decode();
@@ -449,36 +513,9 @@ worker.onmessage(({ id, type, input }) => {
449
513
  case 'addLoadedBlock':
450
514
  runTask(id, 'addLoadedBlock', input);
451
515
  break;
452
- case 'nativeCalls':
453
- respond(id, nativeCalls);
454
- break;
455
516
  case 'contracts':
456
517
  respond(id, contracts);
457
518
  break;
458
- case 'totalContracts':
459
- respond(id, Object.keys(contracts).length);
460
- break;
461
- case 'nativeMints':
462
- respond(id, nativeMints);
463
- break;
464
- case 'nativeBurns':
465
- respond(id, nativeBurns);
466
- break;
467
- case 'nativeTransfers':
468
- respond(id, nativeTransfers);
469
- break;
470
- case 'totalBurnAmount':
471
- respond(id, totalBurnAmount);
472
- break;
473
- case 'totalMintAmount':
474
- respond(id, totalMintAmount);
475
- break;
476
- case 'totalTransferAmount':
477
- respond(id, totalTransferAmount);
478
- break;
479
- case 'totalBlocks':
480
- respond(id, totalBlocks);
481
- break;
482
519
  case 'blocks':
483
520
  respond(id, input ? blocks.slice(input.from, input.to) : blocks);
484
521
  break;
@@ -494,15 +531,42 @@ worker.onmessage(({ id, type, input }) => {
494
531
  case 'latestTransactions':
495
532
  respond(id, latestTransactions);
496
533
  break;
497
- case 'totalTransactions':
498
- respond(id, totalTransactions);
499
- break;
500
534
  case 'has':
501
535
  respond(id, has(input.address));
502
536
  break;
503
537
  case 'get':
504
538
  respond(id, get(input));
505
539
  break;
540
+ case 'totalContracts':
541
+ respond(id, Object.keys(contracts).length);
542
+ break;
543
+ case 'nativeCalls':
544
+ respond(id, nativeCalls.toString());
545
+ break;
546
+ case 'nativeMints':
547
+ respond(id, nativeMints.toString());
548
+ break;
549
+ case 'nativeBurns':
550
+ respond(id, nativeBurns.toString());
551
+ break;
552
+ case 'nativeTransfers':
553
+ respond(id, nativeTransfers.toString());
554
+ break;
555
+ case 'totalBurnAmount':
556
+ respond(id, totalBurnAmount.toString());
557
+ break;
558
+ case 'totalMintAmount':
559
+ respond(id, totalMintAmount.toString());
560
+ break;
561
+ case 'totalTransferAmount':
562
+ respond(id, totalTransferAmount.toString());
563
+ break;
564
+ case 'totalBlocks':
565
+ respond(id, totalBlocks.toString());
566
+ break;
567
+ case 'totalTransactions':
568
+ respond(id, totalTransactions.toString());
569
+ break;
506
570
  default:
507
571
  console.log(`machine-worker: unsupported taskType: ${type}`);
508
572
  break;