@leofcoin/chain 1.7.35 → 1.7.37
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.
- package/exports/browser/browser-store.js +9 -0
- package/exports/browser/chain.js +18 -0
- package/exports/browser/workers/machine-worker.js +7 -1
- package/exports/chain.js +18 -0
- package/exports/machine.d.ts +3 -0
- package/exports/state.d.ts +3 -0
- package/exports/workers/machine-worker.js +7 -1
- package/package.json +4 -4
|
@@ -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()) {
|
package/exports/browser/chain.js
CHANGED
|
@@ -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
|
}
|
|
@@ -3579,6 +3585,9 @@ class Machine {
|
|
|
3579
3585
|
get lastBlock() {
|
|
3580
3586
|
return this.#askWorker('lastBlock');
|
|
3581
3587
|
}
|
|
3588
|
+
get lastBlockHeight() {
|
|
3589
|
+
return this.#askWorker('lastBlockHeight');
|
|
3590
|
+
}
|
|
3582
3591
|
getBlocks(from, to) {
|
|
3583
3592
|
return this.#askWorker('blocks', { from, to });
|
|
3584
3593
|
}
|
|
@@ -3675,6 +3684,12 @@ class State extends Contract {
|
|
|
3675
3684
|
get resolving() {
|
|
3676
3685
|
return this.#resolving;
|
|
3677
3686
|
}
|
|
3687
|
+
get contracts() {
|
|
3688
|
+
return this.#machine.contracts;
|
|
3689
|
+
}
|
|
3690
|
+
get totalContracts() {
|
|
3691
|
+
return this.#machine.totalContracts;
|
|
3692
|
+
}
|
|
3678
3693
|
get nativeCalls() {
|
|
3679
3694
|
return this.#machine.nativeCalls;
|
|
3680
3695
|
}
|
|
@@ -3708,6 +3723,9 @@ class State extends Contract {
|
|
|
3708
3723
|
get lastBlock() {
|
|
3709
3724
|
return this.#machine ? this.#machine.lastBlock : { index: 0, hash: '0x0', previousHash: '0x0' };
|
|
3710
3725
|
}
|
|
3726
|
+
get lastBlockHeight() {
|
|
3727
|
+
return this.#machine ? this.#machine.lastBlockHeight : 0;
|
|
3728
|
+
}
|
|
3711
3729
|
getBlock(index) {
|
|
3712
3730
|
return this.#machine.getBlock(index);
|
|
3713
3731
|
}
|
|
@@ -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,
|
|
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
|
}
|
|
@@ -680,6 +686,9 @@ class Machine {
|
|
|
680
686
|
get lastBlock() {
|
|
681
687
|
return this.#askWorker('lastBlock');
|
|
682
688
|
}
|
|
689
|
+
get lastBlockHeight() {
|
|
690
|
+
return this.#askWorker('lastBlockHeight');
|
|
691
|
+
}
|
|
683
692
|
getBlocks(from, to) {
|
|
684
693
|
return this.#askWorker('blocks', { from, to });
|
|
685
694
|
}
|
|
@@ -776,6 +785,12 @@ class State extends Contract {
|
|
|
776
785
|
get resolving() {
|
|
777
786
|
return this.#resolving;
|
|
778
787
|
}
|
|
788
|
+
get contracts() {
|
|
789
|
+
return this.#machine.contracts;
|
|
790
|
+
}
|
|
791
|
+
get totalContracts() {
|
|
792
|
+
return this.#machine.totalContracts;
|
|
793
|
+
}
|
|
779
794
|
get nativeCalls() {
|
|
780
795
|
return this.#machine.nativeCalls;
|
|
781
796
|
}
|
|
@@ -809,6 +824,9 @@ class State extends Contract {
|
|
|
809
824
|
get lastBlock() {
|
|
810
825
|
return this.#machine ? this.#machine.lastBlock : { index: 0, hash: '0x0', previousHash: '0x0' };
|
|
811
826
|
}
|
|
827
|
+
get lastBlockHeight() {
|
|
828
|
+
return this.#machine ? this.#machine.lastBlockHeight : 0;
|
|
829
|
+
}
|
|
812
830
|
getBlock(index) {
|
|
813
831
|
return this.#machine.getBlock(index);
|
|
814
832
|
}
|
package/exports/machine.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -46,6 +48,7 @@ export default class Machine {
|
|
|
46
48
|
get totalBlocks(): Promise<any>;
|
|
47
49
|
get blocks(): Promise<[]>;
|
|
48
50
|
get lastBlock(): Promise<any>;
|
|
51
|
+
get lastBlockHeight(): Promise<any>;
|
|
49
52
|
getBlocks(from?: any, to?: any): Promise<[]>;
|
|
50
53
|
getBlock(index: any): Promise<any>;
|
|
51
54
|
addLoadedBlock(block: any): Promise<any>;
|
package/exports/state.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -36,6 +38,7 @@ export default class State extends Contract {
|
|
|
36
38
|
hash: string;
|
|
37
39
|
previousHash: string;
|
|
38
40
|
};
|
|
41
|
+
get lastBlockHeight(): 0 | Promise<any>;
|
|
39
42
|
getBlock(index: any): Promise<any>;
|
|
40
43
|
getBlocks(from?: any, to?: any): Promise<[]>;
|
|
41
44
|
get totalSize(): 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,
|
|
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.
|
|
3
|
+
"version": "1.7.37",
|
|
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.
|
|
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,9 +70,9 @@
|
|
|
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.
|
|
73
|
+
"@leofcoin/storage": "^3.5.31",
|
|
74
74
|
"@leofcoin/utils": "^1.1.18",
|
|
75
|
-
"@leofcoin/workers": "^1.5.
|
|
75
|
+
"@leofcoin/workers": "^1.5.4",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
78
|
"semver": "^7.6.3"
|