@leofcoin/chain 1.7.34 → 1.7.36

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.
@@ -226,6 +226,15 @@ class BrowerStore {
226
226
  values = await Promise.all(values);
227
227
  return Promise.all(values.map(async (file) => new Uint8Array(await file.arrayBuffer())));
228
228
  }
229
+ async size() {
230
+ let size = 0;
231
+ for await (const cursor of this.db.values()) {
232
+ // huh? Outdated typings?
233
+ // @ts-ignore
234
+ size += (await cursor.getFile()).size;
235
+ }
236
+ return size;
237
+ }
229
238
  async keys() {
230
239
  const keys = [];
231
240
  for await (const cursor of this.db.keys()) {
@@ -3546,6 +3546,12 @@ class Machine {
3546
3546
  });
3547
3547
  });
3548
3548
  }
3549
+ get contracts() {
3550
+ return this.#askWorker('contracts');
3551
+ }
3552
+ get totalContracts() {
3553
+ return this.#askWorker('totalContracts');
3554
+ }
3549
3555
  get nativeCalls() {
3550
3556
  return this.#askWorker('nativeCalls');
3551
3557
  }
@@ -3558,18 +3564,6 @@ class Machine {
3558
3564
  get nativeTransfers() {
3559
3565
  return this.#askWorker('nativeTransfers');
3560
3566
  }
3561
- get totalTransactions() {
3562
- return this.#askWorker('totalTransactions');
3563
- }
3564
- get blocks() {
3565
- return this.getBlocks();
3566
- }
3567
- get lastBlock() {
3568
- return this.#askWorker('lastBlock');
3569
- }
3570
- get totalBlocks() {
3571
- return this.#askWorker('totalBlocks');
3572
- }
3573
3567
  get totalBurnAmount() {
3574
3568
  return this.#askWorker('totalBurnAmount');
3575
3569
  }
@@ -3579,6 +3573,18 @@ class Machine {
3579
3573
  get totalTransferAmount() {
3580
3574
  return this.#askWorker('totalTransferAmount');
3581
3575
  }
3576
+ get totalTransactions() {
3577
+ return this.#askWorker('totalTransactions');
3578
+ }
3579
+ get totalBlocks() {
3580
+ return this.#askWorker('totalBlocks');
3581
+ }
3582
+ get blocks() {
3583
+ return this.getBlocks();
3584
+ }
3585
+ get lastBlock() {
3586
+ return this.#askWorker('lastBlock');
3587
+ }
3582
3588
  getBlocks(from, to) {
3583
3589
  return this.#askWorker('blocks', { from, to });
3584
3590
  }
@@ -3675,6 +3681,15 @@ class State extends Contract {
3675
3681
  get resolving() {
3676
3682
  return this.#resolving;
3677
3683
  }
3684
+ get contracts() {
3685
+ return this.#machine.contracts;
3686
+ }
3687
+ get totalContracts() {
3688
+ return this.#machine.totalContracts;
3689
+ }
3690
+ get nativeCalls() {
3691
+ return this.#machine.nativeCalls;
3692
+ }
3678
3693
  get nativeMints() {
3679
3694
  return this.#machine.nativeMints;
3680
3695
  }
@@ -3684,11 +3699,20 @@ class State extends Contract {
3684
3699
  get nativeTransfers() {
3685
3700
  return this.#machine.nativeTransfers;
3686
3701
  }
3702
+ get totalBurnAmouint() {
3703
+ return this.#machine.totalBurnAmount;
3704
+ }
3705
+ get totalMintAmount() {
3706
+ return this.#machine.totalMintAmount;
3707
+ }
3708
+ get totalTransferAmount() {
3709
+ return this.#machine.totalTransferAmount;
3710
+ }
3687
3711
  get totalTransactions() {
3688
3712
  return this.#machine.totalTransactions;
3689
3713
  }
3690
- get nativeCalls() {
3691
- return this.#machine.nativeCalls;
3714
+ get totalBlocks() {
3715
+ return this.#machine.totalBlocks;
3692
3716
  }
3693
3717
  get blocks() {
3694
3718
  return this.getBlocks();
@@ -123,6 +123,7 @@ let totalTransactions;
123
123
  let totalBurnAmount;
124
124
  let totalMintAmount;
125
125
  let totalTransferAmount;
126
+ let totalBlocks;
126
127
  let blocks = [];
127
128
  let contracts = {};
128
129
  let lastBlock = { index: -1, hash: '0x0', previousHash: '0x0' };
@@ -290,6 +291,7 @@ const _ = {
290
291
  totalBurnAmount = BigNumber.from(info?.totalBurnAmount ?? 0);
291
292
  totalMintAmount = BigNumber.from(info?.totalMintAmount ?? 0);
292
293
  totalTransferAmount = BigNumber.from(info?.totalTransferAmount ?? 0);
294
+ totalBlocks = BigNumber.from(info?.totalBlocks ?? 0);
293
295
  if (fromState) {
294
296
  lastBlock = message.lastBlock;
295
297
  const setState = async (address, state) => {
@@ -410,6 +412,7 @@ const _ = {
410
412
  addLoadedBlock: (block) => {
411
413
  blocks[block.index - 1] = block;
412
414
  lastBlock = blocks[blocks.length - 1];
415
+ totalBlocks = totalBlocks.add(1);
413
416
  return true;
414
417
  },
415
418
  loadBlock: (block) => {
@@ -440,6 +443,9 @@ worker.onmessage(({ id, type, input }) => {
440
443
  case 'contracts':
441
444
  respond(id, contracts);
442
445
  break;
446
+ case 'totalContracts':
447
+ respond(id, Object.keys(contracts).length);
448
+ break;
443
449
  case 'nativeMints':
444
450
  respond(id, nativeMints);
445
451
  break;
@@ -459,7 +465,7 @@ worker.onmessage(({ id, type, input }) => {
459
465
  respond(id, totalTransferAmount);
460
466
  break;
461
467
  case 'totalBlocks':
462
- respond(id, blocks.length);
468
+ respond(id, totalBlocks);
463
469
  break;
464
470
  case 'blocks':
465
471
  respond(id, input ? blocks.slice(input.from, input.to) : blocks);
package/exports/chain.js CHANGED
@@ -647,6 +647,12 @@ class Machine {
647
647
  });
648
648
  });
649
649
  }
650
+ get contracts() {
651
+ return this.#askWorker('contracts');
652
+ }
653
+ get totalContracts() {
654
+ return this.#askWorker('totalContracts');
655
+ }
650
656
  get nativeCalls() {
651
657
  return this.#askWorker('nativeCalls');
652
658
  }
@@ -659,18 +665,6 @@ class Machine {
659
665
  get nativeTransfers() {
660
666
  return this.#askWorker('nativeTransfers');
661
667
  }
662
- get totalTransactions() {
663
- return this.#askWorker('totalTransactions');
664
- }
665
- get blocks() {
666
- return this.getBlocks();
667
- }
668
- get lastBlock() {
669
- return this.#askWorker('lastBlock');
670
- }
671
- get totalBlocks() {
672
- return this.#askWorker('totalBlocks');
673
- }
674
668
  get totalBurnAmount() {
675
669
  return this.#askWorker('totalBurnAmount');
676
670
  }
@@ -680,6 +674,18 @@ class Machine {
680
674
  get totalTransferAmount() {
681
675
  return this.#askWorker('totalTransferAmount');
682
676
  }
677
+ get totalTransactions() {
678
+ return this.#askWorker('totalTransactions');
679
+ }
680
+ get totalBlocks() {
681
+ return this.#askWorker('totalBlocks');
682
+ }
683
+ get blocks() {
684
+ return this.getBlocks();
685
+ }
686
+ get lastBlock() {
687
+ return this.#askWorker('lastBlock');
688
+ }
683
689
  getBlocks(from, to) {
684
690
  return this.#askWorker('blocks', { from, to });
685
691
  }
@@ -776,6 +782,15 @@ class State extends Contract {
776
782
  get resolving() {
777
783
  return this.#resolving;
778
784
  }
785
+ get contracts() {
786
+ return this.#machine.contracts;
787
+ }
788
+ get totalContracts() {
789
+ return this.#machine.totalContracts;
790
+ }
791
+ get nativeCalls() {
792
+ return this.#machine.nativeCalls;
793
+ }
779
794
  get nativeMints() {
780
795
  return this.#machine.nativeMints;
781
796
  }
@@ -785,11 +800,20 @@ class State extends Contract {
785
800
  get nativeTransfers() {
786
801
  return this.#machine.nativeTransfers;
787
802
  }
803
+ get totalBurnAmouint() {
804
+ return this.#machine.totalBurnAmount;
805
+ }
806
+ get totalMintAmount() {
807
+ return this.#machine.totalMintAmount;
808
+ }
809
+ get totalTransferAmount() {
810
+ return this.#machine.totalTransferAmount;
811
+ }
788
812
  get totalTransactions() {
789
813
  return this.#machine.totalTransactions;
790
814
  }
791
- get nativeCalls() {
792
- return this.#machine.nativeCalls;
815
+ get totalBlocks() {
816
+ return this.#machine.totalBlocks;
793
817
  }
794
818
  get blocks() {
795
819
  return this.getBlocks();
@@ -35,17 +35,19 @@ export default class Machine {
35
35
  execute(contract: any, method: any, parameters: any): Promise<any>;
36
36
  get(contract: any, method: any, parameters?: any): Promise<any>;
37
37
  has(address: any): Promise<unknown>;
38
+ get contracts(): Promise<any>;
39
+ get totalContracts(): Promise<any>;
38
40
  get nativeCalls(): Promise<any>;
39
41
  get nativeMints(): Promise<any>;
40
42
  get nativeBurns(): Promise<any>;
41
43
  get nativeTransfers(): Promise<any>;
42
- get totalTransactions(): Promise<any>;
43
- get blocks(): Promise<[]>;
44
- get lastBlock(): Promise<any>;
45
- get totalBlocks(): Promise<any>;
46
44
  get totalBurnAmount(): Promise<any>;
47
45
  get totalMintAmount(): Promise<any>;
48
46
  get totalTransferAmount(): Promise<any>;
47
+ get totalTransactions(): Promise<any>;
48
+ get totalBlocks(): Promise<any>;
49
+ get blocks(): Promise<[]>;
50
+ get lastBlock(): Promise<any>;
49
51
  getBlocks(from?: any, to?: any): Promise<[]>;
50
52
  getBlock(index: any): Promise<any>;
51
53
  addLoadedBlock(block: any): Promise<any>;
@@ -21,11 +21,17 @@ export default class State extends Contract {
21
21
  get blockHashMap(): IterableIterator<[any, any]>;
22
22
  get loaded(): boolean;
23
23
  get resolving(): boolean;
24
+ get contracts(): Promise<any>;
25
+ get totalContracts(): Promise<any>;
26
+ get nativeCalls(): Promise<any>;
24
27
  get nativeMints(): Promise<any>;
25
28
  get nativeBurns(): Promise<any>;
26
29
  get nativeTransfers(): Promise<any>;
30
+ get totalBurnAmouint(): Promise<any>;
31
+ get totalMintAmount(): Promise<any>;
32
+ get totalTransferAmount(): Promise<any>;
27
33
  get totalTransactions(): Promise<any>;
28
- get nativeCalls(): Promise<any>;
34
+ get totalBlocks(): Promise<any>;
29
35
  get blocks(): Promise<[]>;
30
36
  get lastBlock(): Promise<any> | {
31
37
  index: number;
@@ -123,6 +123,7 @@ let totalTransactions;
123
123
  let totalBurnAmount;
124
124
  let totalMintAmount;
125
125
  let totalTransferAmount;
126
+ let totalBlocks;
126
127
  let blocks = [];
127
128
  let contracts = {};
128
129
  let lastBlock = { index: -1, hash: '0x0', previousHash: '0x0' };
@@ -290,6 +291,7 @@ const _ = {
290
291
  totalBurnAmount = BigNumber.from(info?.totalBurnAmount ?? 0);
291
292
  totalMintAmount = BigNumber.from(info?.totalMintAmount ?? 0);
292
293
  totalTransferAmount = BigNumber.from(info?.totalTransferAmount ?? 0);
294
+ totalBlocks = BigNumber.from(info?.totalBlocks ?? 0);
293
295
  if (fromState) {
294
296
  lastBlock = message.lastBlock;
295
297
  const setState = async (address, state) => {
@@ -410,6 +412,7 @@ const _ = {
410
412
  addLoadedBlock: (block) => {
411
413
  blocks[block.index - 1] = block;
412
414
  lastBlock = blocks[blocks.length - 1];
415
+ totalBlocks = totalBlocks.add(1);
413
416
  return true;
414
417
  },
415
418
  loadBlock: (block) => {
@@ -440,6 +443,9 @@ worker.onmessage(({ id, type, input }) => {
440
443
  case 'contracts':
441
444
  respond(id, contracts);
442
445
  break;
446
+ case 'totalContracts':
447
+ respond(id, Object.keys(contracts).length);
448
+ break;
443
449
  case 'nativeMints':
444
450
  respond(id, nativeMints);
445
451
  break;
@@ -459,7 +465,7 @@ worker.onmessage(({ id, type, input }) => {
459
465
  respond(id, totalTransferAmount);
460
466
  break;
461
467
  case 'totalBlocks':
462
- respond(id, blocks.length);
468
+ respond(id, totalBlocks);
463
469
  break;
464
470
  case 'blocks':
465
471
  respond(id, input ? blocks.slice(input.from, input.to) : blocks);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.34",
3
+ "version": "1.7.36",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -38,8 +38,7 @@
38
38
  "test": "node --inspect test",
39
39
  "pack": "webpack",
40
40
  "build": "rollup -c --silent error",
41
- "npm-check-updates": "npx npm-check-updates -i",
42
- "check-dependencies": "npx depcheck"
41
+ "npm-check-updates": "npx npm-check-updates -u --install always"
43
42
  },
44
43
  "np": {
45
44
  "yarn": false,
@@ -56,10 +55,10 @@
56
55
  "@rollup/plugin-typescript": "^11.1.6",
57
56
  "@types/semver": "^7.5.8",
58
57
  "@vandeurenglenn/debug": "^1.2.5",
59
- "rollup": "^4.21.0",
58
+ "rollup": "^4.21.2",
60
59
  "rollup-plugin-modify": "^3.0.0",
61
60
  "tape": "^5.8.1",
62
- "tslib": "^2.6.3"
61
+ "tslib": "^2.7.0"
63
62
  },
64
63
  "dependencies": {
65
64
  "@leofcoin/addresses": "^1.0.24",
@@ -71,9 +70,9 @@
71
70
  "@leofcoin/multi-wallet": "^3.1.8",
72
71
  "@leofcoin/networks": "^1.1.6",
73
72
  "@leofcoin/peernet": "^1.1.79",
74
- "@leofcoin/storage": "^3.5.30",
73
+ "@leofcoin/storage": "^3.5.31",
75
74
  "@leofcoin/utils": "^1.1.18",
76
- "@leofcoin/workers": "^1.5.2",
75
+ "@leofcoin/workers": "^1.5.3",
77
76
  "@vandeurenglenn/base58": "^1.1.9",
78
77
  "@vandeurenglenn/easy-worker": "^1.0.2",
79
78
  "semver": "^7.6.3"