@leofcoin/chain 1.7.35 → 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
  }
@@ -3675,6 +3681,12 @@ 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
+ }
3678
3690
  get nativeCalls() {
3679
3691
  return this.#machine.nativeCalls;
3680
3692
  }
@@ -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
  }
@@ -776,6 +782,12 @@ 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
+ }
779
791
  get nativeCalls() {
780
792
  return this.#machine.nativeCalls;
781
793
  }
@@ -35,6 +35,8 @@ 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>;
@@ -21,6 +21,8 @@ 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>;
24
26
  get nativeCalls(): Promise<any>;
25
27
  get nativeMints(): Promise<any>;
26
28
  get nativeBurns(): Promise<any>;
@@ -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.35",
3
+ "version": "1.7.36",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -55,7 +55,7 @@
55
55
  "@rollup/plugin-typescript": "^11.1.6",
56
56
  "@types/semver": "^7.5.8",
57
57
  "@vandeurenglenn/debug": "^1.2.5",
58
- "rollup": "^4.21.1",
58
+ "rollup": "^4.21.2",
59
59
  "rollup-plugin-modify": "^3.0.0",
60
60
  "tape": "^5.8.1",
61
61
  "tslib": "^2.7.0"
@@ -70,7 +70,7 @@
70
70
  "@leofcoin/multi-wallet": "^3.1.8",
71
71
  "@leofcoin/networks": "^1.1.6",
72
72
  "@leofcoin/peernet": "^1.1.79",
73
- "@leofcoin/storage": "^3.5.30",
73
+ "@leofcoin/storage": "^3.5.31",
74
74
  "@leofcoin/utils": "^1.1.18",
75
75
  "@leofcoin/workers": "^1.5.3",
76
76
  "@vandeurenglenn/base58": "^1.1.9",