@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/browser/chain.js
CHANGED
|
@@ -3183,12 +3183,15 @@ class Machine {
|
|
|
3183
3183
|
},
|
|
3184
3184
|
accounts: {},
|
|
3185
3185
|
info: {
|
|
3186
|
-
nativeCalls: 0,
|
|
3187
|
-
nativeMints: 0,
|
|
3188
|
-
nativeBurns: 0,
|
|
3189
|
-
nativeTransfers: 0,
|
|
3190
|
-
|
|
3191
|
-
|
|
3186
|
+
nativeCalls: BigNumber.from(0),
|
|
3187
|
+
nativeMints: BigNumber.from(0),
|
|
3188
|
+
nativeBurns: BigNumber.from(0),
|
|
3189
|
+
nativeTransfers: BigNumber.from(0),
|
|
3190
|
+
totalBurnAmount: BigNumber.from(0),
|
|
3191
|
+
totalMintAmount: BigNumber.from(0),
|
|
3192
|
+
totalTransferAmount: BigNumber.from(0),
|
|
3193
|
+
totalTransactions: BigNumber.from(0),
|
|
3194
|
+
totalBlocks: BigNumber.from(0)
|
|
3192
3195
|
}
|
|
3193
3196
|
};
|
|
3194
3197
|
this.wantList = [];
|
|
@@ -3265,7 +3268,8 @@ class Machine {
|
|
|
3265
3268
|
}
|
|
3266
3269
|
async updateState() {
|
|
3267
3270
|
try {
|
|
3268
|
-
if ((await this.lastBlock).index > this.states.lastBlock.index
|
|
3271
|
+
if ((await this.lastBlock).index > this.states.lastBlock.index ||
|
|
3272
|
+
((await this.lastBlock).hash !== this.states.lastBlock.hash && (await this.lastBlock).index === 0)) {
|
|
3269
3273
|
// todo only get state for changed contracts
|
|
3270
3274
|
const blocks = (await this.blocks).slice(this.states.lastBlock.index);
|
|
3271
3275
|
let transactions = [];
|
|
@@ -3369,21 +3373,28 @@ class Machine {
|
|
|
3369
3373
|
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')));
|
|
3370
3374
|
try {
|
|
3371
3375
|
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
3372
|
-
|
|
3376
|
+
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')));
|
|
3377
|
+
for (const key in info) {
|
|
3378
|
+
info[key] = BigNumber.from(info[key]);
|
|
3379
|
+
}
|
|
3380
|
+
this.states.info = info;
|
|
3373
3381
|
}
|
|
3374
|
-
catch {
|
|
3382
|
+
catch (error) {
|
|
3383
|
+
console.error(error);
|
|
3375
3384
|
this.states.accounts = {};
|
|
3376
3385
|
// todo try fetching info from fully synced peer
|
|
3377
3386
|
this.states.info = {
|
|
3378
|
-
nativeCalls: 0,
|
|
3379
|
-
nativeMints: 0,
|
|
3380
|
-
nativeBurns: 0,
|
|
3381
|
-
nativeTransfers: 0,
|
|
3382
|
-
|
|
3383
|
-
|
|
3387
|
+
nativeCalls: BigNumber.from(0),
|
|
3388
|
+
nativeMints: BigNumber.from(0),
|
|
3389
|
+
nativeBurns: BigNumber.from(0),
|
|
3390
|
+
nativeTransfers: BigNumber.from(0),
|
|
3391
|
+
totalBurnAmount: BigNumber.from(0),
|
|
3392
|
+
totalMintAmount: BigNumber.from(0),
|
|
3393
|
+
totalTransferAmount: BigNumber.from(0),
|
|
3394
|
+
totalTransactions: BigNumber.from(0),
|
|
3395
|
+
totalBlocks: BigNumber.from(0)
|
|
3384
3396
|
};
|
|
3385
3397
|
}
|
|
3386
|
-
console.log({ balances: this.states.states[addresses.nativeToken].balances });
|
|
3387
3398
|
}
|
|
3388
3399
|
const message = {
|
|
3389
3400
|
type: 'init',
|
|
@@ -3468,6 +3479,7 @@ class Machine {
|
|
|
3468
3479
|
type: 'execute',
|
|
3469
3480
|
id,
|
|
3470
3481
|
input: {
|
|
3482
|
+
to: contract,
|
|
3471
3483
|
contract,
|
|
3472
3484
|
method,
|
|
3473
3485
|
params: parameters
|
|
@@ -4497,10 +4509,7 @@ class Chain extends VersionControl {
|
|
|
4497
4509
|
// // await transactionStore.put(transaction.hash, transaction.encoded)
|
|
4498
4510
|
// if (!contracts.includes(transaction.to)) {
|
|
4499
4511
|
// contracts.push(transaction.to)
|
|
4500
|
-
//
|
|
4501
|
-
// //@ts-ignore
|
|
4502
|
-
// promises.push(this.#executeTransaction(transaction))
|
|
4503
|
-
// }
|
|
4512
|
+
// }
|
|
4504
4513
|
// // Todo: go trough all accounts
|
|
4505
4514
|
// //@ts-ignore
|
|
4506
4515
|
// promises.push(this.#executeTransaction(transaction))
|