@leofcoin/chain 1.7.30 → 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 +63 -62
- 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
|
@@ -1419,55 +1419,47 @@ const coerce$1 = (version, options) => {
|
|
|
1419
1419
|
};
|
|
1420
1420
|
var coerce_1 = coerce$1;
|
|
1421
1421
|
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
hasRequiredLrucache = 1;
|
|
1428
|
-
class LRUCache {
|
|
1429
|
-
constructor () {
|
|
1430
|
-
this.max = 1000;
|
|
1431
|
-
this.map = new Map();
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
get (key) {
|
|
1435
|
-
const value = this.map.get(key);
|
|
1436
|
-
if (value === undefined) {
|
|
1437
|
-
return undefined
|
|
1438
|
-
} else {
|
|
1439
|
-
// Remove the key from the map and add it to the end
|
|
1440
|
-
this.map.delete(key);
|
|
1441
|
-
this.map.set(key, value);
|
|
1442
|
-
return value
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1422
|
+
class LRUCache {
|
|
1423
|
+
constructor () {
|
|
1424
|
+
this.max = 1000;
|
|
1425
|
+
this.map = new Map();
|
|
1426
|
+
}
|
|
1445
1427
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1428
|
+
get (key) {
|
|
1429
|
+
const value = this.map.get(key);
|
|
1430
|
+
if (value === undefined) {
|
|
1431
|
+
return undefined
|
|
1432
|
+
} else {
|
|
1433
|
+
// Remove the key from the map and add it to the end
|
|
1434
|
+
this.map.delete(key);
|
|
1435
|
+
this.map.set(key, value);
|
|
1436
|
+
return value
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1449
1439
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1440
|
+
delete (key) {
|
|
1441
|
+
return this.map.delete(key)
|
|
1442
|
+
}
|
|
1452
1443
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
if (this.map.size >= this.max) {
|
|
1456
|
-
const firstKey = this.map.keys().next().value;
|
|
1457
|
-
this.delete(firstKey);
|
|
1458
|
-
}
|
|
1444
|
+
set (key, value) {
|
|
1445
|
+
const deleted = this.delete(key);
|
|
1459
1446
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1447
|
+
if (!deleted && value !== undefined) {
|
|
1448
|
+
// If cache is full, delete the least recently used item
|
|
1449
|
+
if (this.map.size >= this.max) {
|
|
1450
|
+
const firstKey = this.map.keys().next().value;
|
|
1451
|
+
this.delete(firstKey);
|
|
1452
|
+
}
|
|
1462
1453
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
}
|
|
1454
|
+
this.map.set(key, value);
|
|
1455
|
+
}
|
|
1466
1456
|
|
|
1467
|
-
|
|
1468
|
-
|
|
1457
|
+
return this
|
|
1458
|
+
}
|
|
1469
1459
|
}
|
|
1470
1460
|
|
|
1461
|
+
var lrucache = LRUCache;
|
|
1462
|
+
|
|
1471
1463
|
var range;
|
|
1472
1464
|
var hasRequiredRange;
|
|
1473
1465
|
|
|
@@ -1688,7 +1680,7 @@ function requireRange () {
|
|
|
1688
1680
|
|
|
1689
1681
|
range = Range;
|
|
1690
1682
|
|
|
1691
|
-
const LRU =
|
|
1683
|
+
const LRU = lrucache;
|
|
1692
1684
|
const cache = new LRU();
|
|
1693
1685
|
|
|
1694
1686
|
const parseOptions = parseOptions_1;
|
|
@@ -3191,12 +3183,15 @@ class Machine {
|
|
|
3191
3183
|
},
|
|
3192
3184
|
accounts: {},
|
|
3193
3185
|
info: {
|
|
3194
|
-
nativeCalls: 0,
|
|
3195
|
-
nativeMints: 0,
|
|
3196
|
-
nativeBurns: 0,
|
|
3197
|
-
nativeTransfers: 0,
|
|
3198
|
-
|
|
3199
|
-
|
|
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)
|
|
3200
3195
|
}
|
|
3201
3196
|
};
|
|
3202
3197
|
this.wantList = [];
|
|
@@ -3273,7 +3268,8 @@ class Machine {
|
|
|
3273
3268
|
}
|
|
3274
3269
|
async updateState() {
|
|
3275
3270
|
try {
|
|
3276
|
-
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)) {
|
|
3277
3273
|
// todo only get state for changed contracts
|
|
3278
3274
|
const blocks = (await this.blocks).slice(this.states.lastBlock.index);
|
|
3279
3275
|
let transactions = [];
|
|
@@ -3377,21 +3373,28 @@ class Machine {
|
|
|
3377
3373
|
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')));
|
|
3378
3374
|
try {
|
|
3379
3375
|
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
3380
|
-
|
|
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;
|
|
3381
3381
|
}
|
|
3382
|
-
catch {
|
|
3382
|
+
catch (error) {
|
|
3383
|
+
console.error(error);
|
|
3383
3384
|
this.states.accounts = {};
|
|
3384
3385
|
// todo try fetching info from fully synced peer
|
|
3385
3386
|
this.states.info = {
|
|
3386
|
-
nativeCalls: 0,
|
|
3387
|
-
nativeMints: 0,
|
|
3388
|
-
nativeBurns: 0,
|
|
3389
|
-
nativeTransfers: 0,
|
|
3390
|
-
|
|
3391
|
-
|
|
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)
|
|
3392
3396
|
};
|
|
3393
3397
|
}
|
|
3394
|
-
console.log({ balances: this.states.states[addresses.nativeToken].balances });
|
|
3395
3398
|
}
|
|
3396
3399
|
const message = {
|
|
3397
3400
|
type: 'init',
|
|
@@ -3476,6 +3479,7 @@ class Machine {
|
|
|
3476
3479
|
type: 'execute',
|
|
3477
3480
|
id,
|
|
3478
3481
|
input: {
|
|
3482
|
+
to: contract,
|
|
3479
3483
|
contract,
|
|
3480
3484
|
method,
|
|
3481
3485
|
params: parameters
|
|
@@ -4505,10 +4509,7 @@ class Chain extends VersionControl {
|
|
|
4505
4509
|
// // await transactionStore.put(transaction.hash, transaction.encoded)
|
|
4506
4510
|
// if (!contracts.includes(transaction.to)) {
|
|
4507
4511
|
// contracts.push(transaction.to)
|
|
4508
|
-
//
|
|
4509
|
-
// //@ts-ignore
|
|
4510
|
-
// promises.push(this.#executeTransaction(transaction))
|
|
4511
|
-
// }
|
|
4512
|
+
// }
|
|
4512
4513
|
// // Todo: go trough all accounts
|
|
4513
4514
|
// //@ts-ignore
|
|
4514
4515
|
// promises.push(this.#executeTransaction(transaction))
|