@leofcoin/chain 1.7.29 → 1.7.31
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/chain.js +29 -20
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +380 -410
- package/exports/browser/workers/{worker-Botf--mj.js → worker-Botf--mj-BUK2CMT9.js} +0 -2
- package/exports/chain.js +29 -20
- package/exports/machine.d.ts +10 -6
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +380 -410
- package/exports/workers/{worker-Botf--mj.js → worker-Botf--mj-BUK2CMT9.js} +0 -2
- package/package.json +2 -2
package/exports/chain.js
CHANGED
|
@@ -284,12 +284,15 @@ class Machine {
|
|
|
284
284
|
},
|
|
285
285
|
accounts: {},
|
|
286
286
|
info: {
|
|
287
|
-
nativeCalls: 0,
|
|
288
|
-
nativeMints: 0,
|
|
289
|
-
nativeBurns: 0,
|
|
290
|
-
nativeTransfers: 0,
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
nativeCalls: BigNumber.from(0),
|
|
288
|
+
nativeMints: BigNumber.from(0),
|
|
289
|
+
nativeBurns: BigNumber.from(0),
|
|
290
|
+
nativeTransfers: BigNumber.from(0),
|
|
291
|
+
totalBurnAmount: BigNumber.from(0),
|
|
292
|
+
totalMintAmount: BigNumber.from(0),
|
|
293
|
+
totalTransferAmount: BigNumber.from(0),
|
|
294
|
+
totalTransactions: BigNumber.from(0),
|
|
295
|
+
totalBlocks: BigNumber.from(0)
|
|
293
296
|
}
|
|
294
297
|
};
|
|
295
298
|
this.wantList = [];
|
|
@@ -366,7 +369,8 @@ class Machine {
|
|
|
366
369
|
}
|
|
367
370
|
async updateState() {
|
|
368
371
|
try {
|
|
369
|
-
if ((await this.lastBlock).index > this.states.lastBlock.index
|
|
372
|
+
if ((await this.lastBlock).index > this.states.lastBlock.index ||
|
|
373
|
+
((await this.lastBlock).hash !== this.states.lastBlock.hash && (await this.lastBlock).index === 0)) {
|
|
370
374
|
// todo only get state for changed contracts
|
|
371
375
|
const blocks = (await this.blocks).slice(this.states.lastBlock.index);
|
|
372
376
|
let transactions = [];
|
|
@@ -470,21 +474,28 @@ class Machine {
|
|
|
470
474
|
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')));
|
|
471
475
|
try {
|
|
472
476
|
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
473
|
-
|
|
477
|
+
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')));
|
|
478
|
+
for (const key in info) {
|
|
479
|
+
info[key] = BigNumber.from(info[key]);
|
|
480
|
+
}
|
|
481
|
+
this.states.info = info;
|
|
474
482
|
}
|
|
475
|
-
catch {
|
|
483
|
+
catch (error) {
|
|
484
|
+
console.error(error);
|
|
476
485
|
this.states.accounts = {};
|
|
477
486
|
// todo try fetching info from fully synced peer
|
|
478
487
|
this.states.info = {
|
|
479
|
-
nativeCalls: 0,
|
|
480
|
-
nativeMints: 0,
|
|
481
|
-
nativeBurns: 0,
|
|
482
|
-
nativeTransfers: 0,
|
|
483
|
-
|
|
484
|
-
|
|
488
|
+
nativeCalls: BigNumber.from(0),
|
|
489
|
+
nativeMints: BigNumber.from(0),
|
|
490
|
+
nativeBurns: BigNumber.from(0),
|
|
491
|
+
nativeTransfers: BigNumber.from(0),
|
|
492
|
+
totalBurnAmount: BigNumber.from(0),
|
|
493
|
+
totalMintAmount: BigNumber.from(0),
|
|
494
|
+
totalTransferAmount: BigNumber.from(0),
|
|
495
|
+
totalTransactions: BigNumber.from(0),
|
|
496
|
+
totalBlocks: BigNumber.from(0)
|
|
485
497
|
};
|
|
486
498
|
}
|
|
487
|
-
console.log({ balances: this.states.states[addresses.nativeToken].balances });
|
|
488
499
|
}
|
|
489
500
|
const message = {
|
|
490
501
|
type: 'init',
|
|
@@ -569,6 +580,7 @@ class Machine {
|
|
|
569
580
|
type: 'execute',
|
|
570
581
|
id,
|
|
571
582
|
input: {
|
|
583
|
+
to: contract,
|
|
572
584
|
contract,
|
|
573
585
|
method,
|
|
574
586
|
params: parameters
|
|
@@ -1598,10 +1610,7 @@ class Chain extends VersionControl {
|
|
|
1598
1610
|
// // await transactionStore.put(transaction.hash, transaction.encoded)
|
|
1599
1611
|
// if (!contracts.includes(transaction.to)) {
|
|
1600
1612
|
// contracts.push(transaction.to)
|
|
1601
|
-
//
|
|
1602
|
-
// //@ts-ignore
|
|
1603
|
-
// promises.push(this.#executeTransaction(transaction))
|
|
1604
|
-
// }
|
|
1613
|
+
// }
|
|
1605
1614
|
// // Todo: go trough all accounts
|
|
1606
1615
|
// //@ts-ignore
|
|
1607
1616
|
// promises.push(this.#executeTransaction(transaction))
|
package/exports/machine.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
2
|
+
import { BigNumber } from '@leofcoin/utils';
|
|
2
3
|
export default class Machine {
|
|
3
4
|
#private;
|
|
4
5
|
worker: EasyWorker;
|
|
@@ -10,12 +11,15 @@ export default class Machine {
|
|
|
10
11
|
};
|
|
11
12
|
accounts: {};
|
|
12
13
|
info: {
|
|
13
|
-
nativeCalls:
|
|
14
|
-
nativeMints:
|
|
15
|
-
nativeBurns:
|
|
16
|
-
nativeTransfers:
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
nativeCalls: BigNumber;
|
|
15
|
+
nativeMints: BigNumber;
|
|
16
|
+
nativeBurns: BigNumber;
|
|
17
|
+
nativeTransfers: BigNumber;
|
|
18
|
+
totalBurnAmount: BigNumber;
|
|
19
|
+
totalMintAmount: BigNumber;
|
|
20
|
+
totalTransferAmount: BigNumber;
|
|
21
|
+
totalTransactions: BigNumber;
|
|
22
|
+
totalBlocks: BigNumber;
|
|
19
23
|
};
|
|
20
24
|
};
|
|
21
25
|
wantList: string[];
|