@leofcoin/chain 1.6.16 → 1.7.0
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-Ei0BXMlu-_DPyExz0.js → browser-Ei0BXMlu-snXEaZGH.js} +2 -2
- package/exports/browser/chain.js +692 -671
- package/exports/browser/{client-A009z8av-Dw6NYFQr.js → client-A009z8av-BEuROKOy.js} +4 -4
- package/exports/browser/{index-G74WLzL7-BZ6_sy39.js → index-G74WLzL7-C4adPwed.js} +2 -2
- package/exports/browser/{index--C9N9ZXK.js → index-XTbRdu6H.js} +1 -10
- package/exports/browser/{index-YQrIDBUQ-CqYDmtzG.js → index-YQrIDBUQ-BfKWAaDQ.js} +8 -10
- package/exports/browser/{messages-lWRTai7t-3F-6Qszg.js → messages-lWRTai7t-BKY-q3u-.js} +2 -2
- package/exports/browser/{node-browser-DRoVQRWp.js → node-browser-BJ4SfCPo.js} +6 -15
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +5 -7
- package/exports/browser/workers/{worker-Cqj1ERFr.js → worker-Botf--mj.js} +1 -10
- package/exports/chain.js +18 -14
- package/exports/machine.d.ts +1 -1
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +5 -7
- package/exports/workers/{worker-Cqj1ERFr.js → worker-Botf--mj.js} +1 -10
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { L as LittlePubSub } from './node-browser-BJ4SfCPo.js';
|
|
2
|
+
import './index-XTbRdu6H.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
5
5
|
_pubsub;
|
|
@@ -206,7 +206,7 @@ class SocketRequestClient {
|
|
|
206
206
|
const init = async () => {
|
|
207
207
|
// @ts-ignore
|
|
208
208
|
if (!globalThis.WebSocket)
|
|
209
|
-
globalThis.WebSocket = (await import('./browser-Ei0BXMlu-
|
|
209
|
+
globalThis.WebSocket = (await import('./browser-Ei0BXMlu-snXEaZGH.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
210
210
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
211
211
|
client.onmessage = this.onmessage;
|
|
212
212
|
client.onerror = this.onerror;
|
|
@@ -280,7 +280,7 @@ const iceServers = [
|
|
|
280
280
|
credential: 'openrelayproject'
|
|
281
281
|
}
|
|
282
282
|
];
|
|
283
|
-
const SimplePeer = (await import('./index-YQrIDBUQ-
|
|
283
|
+
const SimplePeer = (await import('./index-YQrIDBUQ-BfKWAaDQ.js').then(function (n) { return n.i; })).default;
|
|
284
284
|
class Peer extends SimplePeer {
|
|
285
285
|
peerId;
|
|
286
286
|
channelName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-BJ4SfCPo.js';
|
|
2
|
+
import './index-XTbRdu6H.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @params {String} network
|
|
@@ -3838,9 +3838,6 @@ function isHexString(value, length) {
|
|
|
3838
3838
|
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
3839
3839
|
return false;
|
|
3840
3840
|
}
|
|
3841
|
-
if (length && value.length !== 2 + 2 * length) {
|
|
3842
|
-
return false;
|
|
3843
|
-
}
|
|
3844
3841
|
return true;
|
|
3845
3842
|
}
|
|
3846
3843
|
const HexCharacters = "0123456789abcdef";
|
|
@@ -4518,13 +4515,9 @@ var index$5 = (input, prefix) => {
|
|
|
4518
4515
|
total += current.length + encoded.length;
|
|
4519
4516
|
return total;
|
|
4520
4517
|
}, 0);
|
|
4521
|
-
const typedArray = new Uint8Array(
|
|
4518
|
+
const typedArray = new Uint8Array(length);
|
|
4522
4519
|
let currentIndex = 0;
|
|
4523
4520
|
let index = 0;
|
|
4524
|
-
if (prefix) {
|
|
4525
|
-
typedArray.set(prefix);
|
|
4526
|
-
currentIndex += prefix.length;
|
|
4527
|
-
}
|
|
4528
4521
|
for (const source of input) {
|
|
4529
4522
|
typedArray.set(encodedArray[index], currentIndex);
|
|
4530
4523
|
currentIndex += encodedArray[index].length;
|
|
@@ -4537,8 +4530,6 @@ var index$5 = (input, prefix) => {
|
|
|
4537
4530
|
|
|
4538
4531
|
var index$4 = (typedArray, prefix) => {
|
|
4539
4532
|
const set = [];
|
|
4540
|
-
if (prefix)
|
|
4541
|
-
typedArray = typedArray.subarray(prefix.length);
|
|
4542
4533
|
const varintAndSub = (typedArray) => {
|
|
4543
4534
|
const length = index$6.decode(typedArray);
|
|
4544
4535
|
// remove length
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-BJ4SfCPo.js';
|
|
2
|
+
import './index-XTbRdu6H.js';
|
|
3
3
|
|
|
4
4
|
var browser$2 = {exports: {}};
|
|
5
5
|
|
|
@@ -2881,15 +2881,13 @@ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
2881
2881
|
if (value > max || value < min) {
|
|
2882
2882
|
const n = typeof min === 'bigint' ? 'n' : '';
|
|
2883
2883
|
let range;
|
|
2884
|
-
|
|
2884
|
+
{
|
|
2885
2885
|
if (min === 0 || min === BigInt(0)) {
|
|
2886
2886
|
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
2887
2887
|
} else {
|
|
2888
2888
|
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
2889
2889
|
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
2890
2890
|
}
|
|
2891
|
-
} else {
|
|
2892
|
-
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
2893
2891
|
}
|
|
2894
2892
|
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
2895
2893
|
}
|
|
@@ -2905,15 +2903,15 @@ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
2905
2903
|
function boundsError (value, length, type) {
|
|
2906
2904
|
if (Math.floor(value) !== value) {
|
|
2907
2905
|
validateNumber(value, type);
|
|
2908
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2906
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
2909
2907
|
}
|
|
2910
2908
|
|
|
2911
2909
|
if (length < 0) {
|
|
2912
2910
|
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
2913
2911
|
}
|
|
2914
2912
|
|
|
2915
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
|
2916
|
-
`>= ${
|
|
2913
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
2914
|
+
`>= ${0} and <= ${length}`,
|
|
2917
2915
|
value)
|
|
2918
2916
|
}
|
|
2919
2917
|
|
|
@@ -3707,7 +3705,7 @@ function requireBuffer_list () {
|
|
|
3707
3705
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3708
3706
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3709
3707
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3710
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3708
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3711
3709
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3712
3710
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3713
3711
|
var _require = buffer,
|
|
@@ -4039,7 +4037,7 @@ function oneOf(expected, thing) {
|
|
|
4039
4037
|
|
|
4040
4038
|
|
|
4041
4039
|
function startsWith(str, search, pos) {
|
|
4042
|
-
return str.substr(
|
|
4040
|
+
return str.substr(0 , search.length) === search;
|
|
4043
4041
|
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
4044
4042
|
|
|
4045
4043
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index
|
|
1
|
+
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-XTbRdu6H.js';
|
|
2
2
|
|
|
3
3
|
var proto = {
|
|
4
4
|
lastblock: Object(),
|
|
@@ -512,13 +512,9 @@ var index$7 = (input, prefix) => {
|
|
|
512
512
|
total += current.length + encoded.length;
|
|
513
513
|
return total;
|
|
514
514
|
}, 0);
|
|
515
|
-
const typedArray = new Uint8Array(
|
|
515
|
+
const typedArray = new Uint8Array(length);
|
|
516
516
|
let currentIndex = 0;
|
|
517
517
|
let index = 0;
|
|
518
|
-
if (prefix) {
|
|
519
|
-
typedArray.set(prefix);
|
|
520
|
-
currentIndex += prefix.length;
|
|
521
|
-
}
|
|
522
518
|
for (const source of input) {
|
|
523
519
|
typedArray.set(encodedArray[index], currentIndex);
|
|
524
520
|
currentIndex += encodedArray[index].length;
|
|
@@ -531,8 +527,6 @@ var index$7 = (input, prefix) => {
|
|
|
531
527
|
|
|
532
528
|
var index$6 = (typedArray, prefix) => {
|
|
533
529
|
const set = [];
|
|
534
|
-
if (prefix)
|
|
535
|
-
typedArray = typedArray.subarray(prefix.length);
|
|
536
530
|
const varintAndSub = (typedArray) => {
|
|
537
531
|
const length = index$8.decode(typedArray);
|
|
538
532
|
// remove length
|
|
@@ -4570,9 +4564,6 @@ function isHexString(value, length) {
|
|
|
4570
4564
|
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
4571
4565
|
return false;
|
|
4572
4566
|
}
|
|
4573
|
-
if (length && value.length !== 2 + 2 * length) {
|
|
4574
|
-
return false;
|
|
4575
|
-
}
|
|
4576
4567
|
return true;
|
|
4577
4568
|
}
|
|
4578
4569
|
const HexCharacters = "0123456789abcdef";
|
|
@@ -22905,7 +22896,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
22905
22896
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22906
22897
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22907
22898
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22908
|
-
step((generator = generator.apply(thisArg,
|
|
22899
|
+
step((generator = generator.apply(thisArg, [])).next());
|
|
22909
22900
|
});
|
|
22910
22901
|
}
|
|
22911
22902
|
|
|
@@ -27217,7 +27208,7 @@ class Identity {
|
|
|
27217
27208
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
27218
27209
|
}
|
|
27219
27210
|
else {
|
|
27220
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-G74WLzL7-
|
|
27211
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-G74WLzL7-C4adPwed.js');
|
|
27221
27212
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
27222
27213
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
27223
27214
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -27409,7 +27400,7 @@ class Peernet {
|
|
|
27409
27400
|
this.root = options.root;
|
|
27410
27401
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
27411
27402
|
// FolderMessageResponse
|
|
27412
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-lWRTai7t-
|
|
27403
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-lWRTai7t-BKY-q3u-.js');
|
|
27413
27404
|
/**
|
|
27414
27405
|
* proto Object containing protos
|
|
27415
27406
|
* @type {Object}
|
|
@@ -27503,7 +27494,7 @@ class Peernet {
|
|
|
27503
27494
|
if (this.#starting || this.#started)
|
|
27504
27495
|
return;
|
|
27505
27496
|
this.#starting = true;
|
|
27506
|
-
const importee = await import('./client-A009z8av-
|
|
27497
|
+
const importee = await import('./client-A009z8av-BEuROKOy.js');
|
|
27507
27498
|
/**
|
|
27508
27499
|
* @access public
|
|
27509
27500
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
export { N as default } from './node-browser-BJ4SfCPo.js';
|
|
2
|
+
import './index-XTbRdu6H.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-Botf--mj.js';
|
|
2
2
|
|
|
3
3
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4
4
|
const formatBytes = (bytes, decimals = 2) => {
|
|
@@ -329,6 +329,7 @@ _.init = async (message) => {
|
|
|
329
329
|
// for (let i = 0; i < blocks.length; i++) {
|
|
330
330
|
|
|
331
331
|
// }
|
|
332
|
+
blocks = message.blocks;
|
|
332
333
|
for (const block of blocks) {
|
|
333
334
|
// we only revalidate the latest 24 blocks
|
|
334
335
|
// every 24 blocks a snapshot is taken and stored in state
|
|
@@ -336,10 +337,9 @@ _.init = async (message) => {
|
|
|
336
337
|
// this also means devs NEED to make sure the state can be restored
|
|
337
338
|
// on contract deploy an error will be thrown if state wasn't recoverable
|
|
338
339
|
if (block.index >= blocks.length - 24) {
|
|
339
|
-
const transactionCount = blocks[block.index
|
|
340
|
-
latestTransactions.splice(-
|
|
340
|
+
const transactionCount = blocks[block.index].transactions.length;
|
|
341
|
+
latestTransactions.splice(-transactionCount, latestTransactions.length);
|
|
341
342
|
}
|
|
342
|
-
|
|
343
343
|
if (!block.loaded && !fromState) {
|
|
344
344
|
const transactions = await Promise.all(
|
|
345
345
|
block.transactions.map(async (transaction) =>
|
|
@@ -361,9 +361,7 @@ _.init = async (message) => {
|
|
|
361
361
|
block.loaded = true;
|
|
362
362
|
worker.postMessage({
|
|
363
363
|
type: 'debug',
|
|
364
|
-
message: `loaded transactions for block: ${block.
|
|
365
|
-
block.blockInfo.size
|
|
366
|
-
)}`
|
|
364
|
+
message: `loaded transactions for block: ${block.hash} @${block.index}`
|
|
367
365
|
});
|
|
368
366
|
}
|
|
369
367
|
|
|
@@ -3782,9 +3782,6 @@ function isHexString(value, length) {
|
|
|
3782
3782
|
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
3783
3783
|
return false;
|
|
3784
3784
|
}
|
|
3785
|
-
if (length && value.length !== 2 + 2 * length) {
|
|
3786
|
-
return false;
|
|
3787
|
-
}
|
|
3788
3785
|
return true;
|
|
3789
3786
|
}
|
|
3790
3787
|
const HexCharacters = "0123456789abcdef";
|
|
@@ -4439,13 +4436,9 @@ var index$5 = (input, prefix) => {
|
|
|
4439
4436
|
total += current.length + encoded.length;
|
|
4440
4437
|
return total;
|
|
4441
4438
|
}, 0);
|
|
4442
|
-
const typedArray = new Uint8Array(
|
|
4439
|
+
const typedArray = new Uint8Array(length);
|
|
4443
4440
|
let currentIndex = 0;
|
|
4444
4441
|
let index = 0;
|
|
4445
|
-
if (prefix) {
|
|
4446
|
-
typedArray.set(prefix);
|
|
4447
|
-
currentIndex += prefix.length;
|
|
4448
|
-
}
|
|
4449
4442
|
for (const source of input) {
|
|
4450
4443
|
typedArray.set(encodedArray[index], currentIndex);
|
|
4451
4444
|
currentIndex += encodedArray[index].length;
|
|
@@ -4458,8 +4451,6 @@ var index$5 = (input, prefix) => {
|
|
|
4458
4451
|
|
|
4459
4452
|
var index$4 = (typedArray, prefix) => {
|
|
4460
4453
|
const set = [];
|
|
4461
|
-
if (prefix)
|
|
4462
|
-
typedArray = typedArray.subarray(prefix.length);
|
|
4463
4454
|
const varintAndSub = (typedArray) => {
|
|
4464
4455
|
const length = index$6.decode(typedArray);
|
|
4465
4456
|
// remove length
|
package/exports/chain.js
CHANGED
|
@@ -347,7 +347,7 @@ class Machine {
|
|
|
347
347
|
}
|
|
348
348
|
case 'ask': {
|
|
349
349
|
if (data.question === 'contract' || data.question === 'transaction') {
|
|
350
|
-
const input = await peernet.get(data.input
|
|
350
|
+
const input = await peernet.get(data.input);
|
|
351
351
|
this.worker.postMessage({ id: data.id, input });
|
|
352
352
|
}
|
|
353
353
|
}
|
|
@@ -358,16 +358,18 @@ class Machine {
|
|
|
358
358
|
if ((await this.lastBlock).index > this.states.lastBlock.index) {
|
|
359
359
|
// todo only get state for changed contracts
|
|
360
360
|
const blocks = (await this.blocks).slice(this.states.lastBlock.index);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
361
|
+
let transactions = [];
|
|
362
|
+
for (const block of blocks) {
|
|
363
|
+
transactions = [...transactions, ...block.transactions];
|
|
364
|
+
}
|
|
365
|
+
transactions = await Promise.all(transactions.map(async (transaction) => new TransactionMessage(await transactionStore.get(transaction))));
|
|
366
|
+
const contractsToGet = transactions.reduce((set, current) => {
|
|
367
|
+
const contract = current.decoded.to;
|
|
368
|
+
if (!set.includes(contract))
|
|
369
|
+
set.push(contract);
|
|
367
370
|
return set;
|
|
368
371
|
}, []);
|
|
369
372
|
const state = {};
|
|
370
|
-
console.log({ contractsToGet });
|
|
371
373
|
if (!contractsToGet.includes(addresses.contractFactory))
|
|
372
374
|
contractsToGet.push(addresses.contractFactory);
|
|
373
375
|
if (!contractsToGet.includes(addresses.nativeToken))
|
|
@@ -392,7 +394,7 @@ class Machine {
|
|
|
392
394
|
nativeTransfers: this.nativeTransfers,
|
|
393
395
|
totalTransactions: this.totalTransactions,
|
|
394
396
|
totalBurnAmount: this.totalBurnAmount,
|
|
395
|
-
|
|
397
|
+
totalMintAmount: this.totalMintAmount,
|
|
396
398
|
totalTransferAmount: this.totalTransferAmount,
|
|
397
399
|
totalBlocks: await blockStore.length
|
|
398
400
|
}))
|
|
@@ -626,8 +628,8 @@ class Machine {
|
|
|
626
628
|
get totalBurnAmount() {
|
|
627
629
|
return this.#askWorker('totalBurnAmount');
|
|
628
630
|
}
|
|
629
|
-
get
|
|
630
|
-
return this.#askWorker('
|
|
631
|
+
get totalMintAmount() {
|
|
632
|
+
return this.#askWorker('totalMintAmount');
|
|
631
633
|
}
|
|
632
634
|
get totalTransferAmount() {
|
|
633
635
|
return this.#askWorker('totalTransferAmount');
|
|
@@ -1478,7 +1480,6 @@ class Chain extends VersionControl {
|
|
|
1478
1480
|
try {
|
|
1479
1481
|
let result = await this.machine.execute(to, method, params);
|
|
1480
1482
|
// await accountsStore.put(to, nonce)
|
|
1481
|
-
await transactionPoolStore.delete(hash);
|
|
1482
1483
|
// if (!result) result = this.machine.state
|
|
1483
1484
|
globalThis.pubsub.publish(`transaction.completed.${hash}`, { status: 'fulfilled', hash });
|
|
1484
1485
|
return result || 'no state change';
|
|
@@ -1616,7 +1617,6 @@ class Chain extends VersionControl {
|
|
|
1616
1617
|
index: 0
|
|
1617
1618
|
};
|
|
1618
1619
|
const latestTransactions = await this.machine.latestTransactions();
|
|
1619
|
-
console.log({ latestTransactions });
|
|
1620
1620
|
// exclude failing tx
|
|
1621
1621
|
transactions = await this.promiseTransactions(transactions);
|
|
1622
1622
|
const normalTransactions = [];
|
|
@@ -1686,7 +1686,10 @@ class Chain extends VersionControl {
|
|
|
1686
1686
|
// block.reward = block.reward.toString()
|
|
1687
1687
|
// block.fees = block.fees.toString()
|
|
1688
1688
|
try {
|
|
1689
|
-
await Promise.all(block.transactions.map(async (transaction) =>
|
|
1689
|
+
await Promise.all(block.transactions.map(async (transaction) => {
|
|
1690
|
+
await globalThis.transactionStore.put(transaction, await transactionPoolStore.get(transaction));
|
|
1691
|
+
await globalThis.transactionPoolStore.delete(transaction);
|
|
1692
|
+
}));
|
|
1690
1693
|
let blockMessage = await new BlockMessage(block);
|
|
1691
1694
|
const hash = await blockMessage.hash();
|
|
1692
1695
|
await globalThis.peernet.put(hash, blockMessage.encoded, 'block');
|
|
@@ -1697,6 +1700,7 @@ class Chain extends VersionControl {
|
|
|
1697
1700
|
globalThis.pubsub.publish('add-block', blockMessage.decoded);
|
|
1698
1701
|
}
|
|
1699
1702
|
catch (error) {
|
|
1703
|
+
console.log(error);
|
|
1700
1704
|
throw new Error(`invalid block ${block}`);
|
|
1701
1705
|
}
|
|
1702
1706
|
// data = await this.machine.execute(to, method, params)
|
package/exports/machine.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export default class Machine {
|
|
|
39
39
|
get lastBlock(): Promise<any>;
|
|
40
40
|
get totalBlocks(): Promise<any>;
|
|
41
41
|
get totalBurnAmount(): Promise<any>;
|
|
42
|
-
get
|
|
42
|
+
get totalMintAmount(): Promise<any>;
|
|
43
43
|
get totalTransferAmount(): Promise<any>;
|
|
44
44
|
getBlocks(from?: any, to?: any): Promise<[]>;
|
|
45
45
|
getBlock(index: any): Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-Botf--mj.js';
|
|
2
2
|
|
|
3
3
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4
4
|
const formatBytes = (bytes, decimals = 2) => {
|
|
@@ -329,6 +329,7 @@ _.init = async (message) => {
|
|
|
329
329
|
// for (let i = 0; i < blocks.length; i++) {
|
|
330
330
|
|
|
331
331
|
// }
|
|
332
|
+
blocks = message.blocks;
|
|
332
333
|
for (const block of blocks) {
|
|
333
334
|
// we only revalidate the latest 24 blocks
|
|
334
335
|
// every 24 blocks a snapshot is taken and stored in state
|
|
@@ -336,10 +337,9 @@ _.init = async (message) => {
|
|
|
336
337
|
// this also means devs NEED to make sure the state can be restored
|
|
337
338
|
// on contract deploy an error will be thrown if state wasn't recoverable
|
|
338
339
|
if (block.index >= blocks.length - 24) {
|
|
339
|
-
const transactionCount = blocks[block.index
|
|
340
|
-
latestTransactions.splice(-
|
|
340
|
+
const transactionCount = blocks[block.index].transactions.length;
|
|
341
|
+
latestTransactions.splice(-transactionCount, latestTransactions.length);
|
|
341
342
|
}
|
|
342
|
-
|
|
343
343
|
if (!block.loaded && !fromState) {
|
|
344
344
|
const transactions = await Promise.all(
|
|
345
345
|
block.transactions.map(async (transaction) =>
|
|
@@ -361,9 +361,7 @@ _.init = async (message) => {
|
|
|
361
361
|
block.loaded = true;
|
|
362
362
|
worker.postMessage({
|
|
363
363
|
type: 'debug',
|
|
364
|
-
message: `loaded transactions for block: ${block.
|
|
365
|
-
block.blockInfo.size
|
|
366
|
-
)}`
|
|
364
|
+
message: `loaded transactions for block: ${block.hash} @${block.index}`
|
|
367
365
|
});
|
|
368
366
|
}
|
|
369
367
|
|
|
@@ -3782,9 +3782,6 @@ function isHexString(value, length) {
|
|
|
3782
3782
|
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
3783
3783
|
return false;
|
|
3784
3784
|
}
|
|
3785
|
-
if (length && value.length !== 2 + 2 * length) {
|
|
3786
|
-
return false;
|
|
3787
|
-
}
|
|
3788
3785
|
return true;
|
|
3789
3786
|
}
|
|
3790
3787
|
const HexCharacters = "0123456789abcdef";
|
|
@@ -4439,13 +4436,9 @@ var index$5 = (input, prefix) => {
|
|
|
4439
4436
|
total += current.length + encoded.length;
|
|
4440
4437
|
return total;
|
|
4441
4438
|
}, 0);
|
|
4442
|
-
const typedArray = new Uint8Array(
|
|
4439
|
+
const typedArray = new Uint8Array(length);
|
|
4443
4440
|
let currentIndex = 0;
|
|
4444
4441
|
let index = 0;
|
|
4445
|
-
if (prefix) {
|
|
4446
|
-
typedArray.set(prefix);
|
|
4447
|
-
currentIndex += prefix.length;
|
|
4448
|
-
}
|
|
4449
4442
|
for (const source of input) {
|
|
4450
4443
|
typedArray.set(encodedArray[index], currentIndex);
|
|
4451
4444
|
currentIndex += encodedArray[index].length;
|
|
@@ -4458,8 +4451,6 @@ var index$5 = (input, prefix) => {
|
|
|
4458
4451
|
|
|
4459
4452
|
var index$4 = (typedArray, prefix) => {
|
|
4460
4453
|
const set = [];
|
|
4461
|
-
if (prefix)
|
|
4462
|
-
typedArray = typedArray.subarray(prefix.length);
|
|
4463
4454
|
const varintAndSub = (typedArray) => {
|
|
4464
4455
|
const length = index$6.decode(typedArray);
|
|
4465
4456
|
// remove length
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@leofcoin/peernet": "^1.1.77",
|
|
74
74
|
"@leofcoin/storage": "^3.5.28",
|
|
75
75
|
"@leofcoin/utils": "^1.1.18",
|
|
76
|
-
"@leofcoin/workers": "^1.
|
|
76
|
+
"@leofcoin/workers": "^1.5.0",
|
|
77
77
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
78
78
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
79
79
|
"semver": "^7.6.0"
|