@leofcoin/chain 1.5.23 → 1.5.25

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.
@@ -1,4 +1,4 @@
1
- import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, C as ContractMessage, T as TransactionMessage, t as toBase58, R as RawTransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-de7cd283.js';
1
+ import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-73138caf.js';
2
2
 
3
3
  const logger$1 = new Logger(version$1);
4
4
  const _constructorGuard = {};
@@ -474,7 +474,7 @@ const requestTimeout = 30000;
474
474
  const syncTimeout = 30000;
475
475
  class Protocol {
476
476
  constructor() {
477
- this.resolveTimeout = 30000;
477
+ this.resolveTimeout = 10000;
478
478
  }
479
479
  get limit() {
480
480
  return limit;
@@ -1060,7 +1060,7 @@ class Jobber {
1060
1060
  const timeout = setTimeout(() => {
1061
1061
  reject('timeout');
1062
1062
  }, this.timeout);
1063
- this.stop = () => {
1063
+ this.destroy = () => {
1064
1064
  clearTimeout(timeout);
1065
1065
  this.busy = false;
1066
1066
  resolve('stopped');
@@ -1072,6 +1072,7 @@ class Jobber {
1072
1072
  resolve(result);
1073
1073
  }
1074
1074
  catch (error) {
1075
+ clearTimeout(timeout);
1075
1076
  reject(error);
1076
1077
  }
1077
1078
  });
@@ -1085,6 +1086,7 @@ class State extends Contract {
1085
1086
  #resolving;
1086
1087
  #resolveErrorCount;
1087
1088
  #syncState;
1089
+ #chainState;
1088
1090
  #lastBlockInQue;
1089
1091
  #syncErrorCount;
1090
1092
  #blockHashMap;
@@ -1094,6 +1096,12 @@ class State extends Contract {
1094
1096
  #totalSize;
1095
1097
  #machine;
1096
1098
  #loaded;
1099
+ get state() {
1100
+ return {
1101
+ sync: this.#syncState,
1102
+ chain: this.#chainState
1103
+ };
1104
+ }
1097
1105
  get blockHashMap() {
1098
1106
  return this.#blockHashMap.entries();
1099
1107
  }
@@ -1155,8 +1163,10 @@ class State extends Contract {
1155
1163
  }
1156
1164
  constructor() {
1157
1165
  super();
1166
+ this.#lastResolvedTime = 0;
1158
1167
  this.#resolving = false;
1159
1168
  this.#resolveErrorCount = 0;
1169
+ this.#chainState = 'loading';
1160
1170
  this.#syncErrorCount = 0;
1161
1171
  this.#blockHashMap = new Map();
1162
1172
  this.#chainSyncing = false;
@@ -1188,6 +1198,15 @@ class State extends Contract {
1188
1198
  * {Number}
1189
1199
  */
1190
1200
  this.#totalTransactions = 0;
1201
+ this.#chainStateHandler = () => {
1202
+ return new globalThis.peernet.protos['peernet-response']({ response: this.#chainState });
1203
+ };
1204
+ this.#lastBlockHandler = async () => {
1205
+ return new globalThis.peernet.protos['peernet-response']({ response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index } });
1206
+ };
1207
+ this.#knownBlocksHandler = async () => {
1208
+ return new globalThis.peernet.protos['peernet-response']({ response: { blocks: this.#blocks.map((block) => block.hash) } });
1209
+ };
1191
1210
  this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
1192
1211
  this.#getLastTransactions = async () => {
1193
1212
  let lastTransactions = (await Promise.all(this.#blocks.filter(block => block.loaded).slice(-128)
@@ -1196,12 +1215,28 @@ class State extends Contract {
1196
1215
  return Promise.all(lastTransactions.map(transaction => transaction.hash()));
1197
1216
  };
1198
1217
  }
1218
+ async clearPool() {
1219
+ await globalThis.transactionPoolStore.clear();
1220
+ }
1221
+ /**
1222
+ * drastic measurement, removes everything!
1223
+ */
1224
+ async clearAll() {
1225
+ await globalThis.accountsStore.clear();
1226
+ await globalThis.chainStore.clear();
1227
+ await globalThis.blockStore.clear();
1228
+ await globalThis.transactionPoolStore.clear();
1229
+ }
1230
+ #chainStateHandler;
1231
+ #lastBlockHandler;
1232
+ #knownBlocksHandler;
1199
1233
  async init() {
1200
- this.jobber = new Jobber(30000);
1234
+ this.jobber = new Jobber(this.resolveTimeout);
1201
1235
  if (super.init)
1202
1236
  await super.init();
1203
- await globalThis.peernet.addRequestHandler('lastBlock', this.#lastBlockHandler.bind(this));
1204
- await globalThis.peernet.addRequestHandler('knownBlocks', this.#knownBlocksHandler.bind(this));
1237
+ await globalThis.peernet.addRequestHandler('lastBlock', this.#lastBlockHandler);
1238
+ await globalThis.peernet.addRequestHandler('knownBlocks', this.#knownBlocksHandler);
1239
+ await globalThis.peernet.addRequestHandler('chainState', this.#chainStateHandler);
1205
1240
  try {
1206
1241
  let localBlock;
1207
1242
  try {
@@ -1256,12 +1291,6 @@ class State extends Contract {
1256
1291
  await globalThis.chainStore.put('lastBlock', hash);
1257
1292
  globalThis.pubsub.publish('lastBlock', this.#lastBlock);
1258
1293
  }
1259
- async #lastBlockHandler() {
1260
- return new globalThis.peernet.protos['peernet-response']({ response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index } });
1261
- }
1262
- async #knownBlocksHandler() {
1263
- return new globalThis.peernet.protos['peernet-response']({ response: { blocks: this.#blocks.map((block) => block.hash) } });
1264
- }
1265
1294
  getLatestBlock() {
1266
1295
  // @ts-ignore
1267
1296
  return this.#getLatestBlock();
@@ -1302,8 +1331,6 @@ class State extends Contract {
1302
1331
  this.#lastResolvedTime = Date.now();
1303
1332
  }
1304
1333
  catch (error) {
1305
- this.#resolving = false;
1306
- this.#chainSyncing = false;
1307
1334
  throw new ResolveError(`block: ${hash}@${index}`);
1308
1335
  }
1309
1336
  return;
@@ -1316,6 +1343,8 @@ class State extends Contract {
1316
1343
  if (this.#resolving)
1317
1344
  return 'already resolving';
1318
1345
  this.#resolving = true;
1346
+ if (this.jobber.busy && this.jobber.destroy)
1347
+ await this.jobber.destroy();
1319
1348
  try {
1320
1349
  await this.jobber.add(() => this.#resolveBlock(hash));
1321
1350
  this.#resolving = false;
@@ -1325,6 +1354,7 @@ class State extends Contract {
1325
1354
  catch (error) {
1326
1355
  console.log({ error });
1327
1356
  this.#resolveErrorCount += 1;
1357
+ this.#resolving = false;
1328
1358
  if (this.#resolveErrorCount < 3)
1329
1359
  return this.resolveBlock(hash);
1330
1360
  this.#resolveErrorCount = 0;
@@ -1333,8 +1363,8 @@ class State extends Contract {
1333
1363
  }
1334
1364
  async resolveBlocks() {
1335
1365
  try {
1336
- if (this.jobber.busy && this.jobber.stop) {
1337
- await this.jobber.stop();
1366
+ if (this.jobber.busy && this.jobber.destroy) {
1367
+ await this.jobber.destroy();
1338
1368
  }
1339
1369
  }
1340
1370
  catch (error) {
@@ -1350,10 +1380,10 @@ class State extends Contract {
1350
1380
  }
1351
1381
  catch (error) {
1352
1382
  console.log(error);
1383
+ this.#chainSyncing = false;
1384
+ this.#syncState = 'errored';
1353
1385
  this.#resolveErrored = true;
1354
- this.#resolveErrorCount += 1;
1355
- this.#resolving = false;
1356
- this.restoreChain();
1386
+ return this.restoreChain();
1357
1387
  // console.log(e);
1358
1388
  }
1359
1389
  }
@@ -1371,23 +1401,25 @@ class State extends Contract {
1371
1401
  this.#resolveErrored = true;
1372
1402
  this.#resolveErrorCount += 1;
1373
1403
  this.#resolving = false;
1374
- this.restoreChain();
1404
+ return this.restoreChain();
1375
1405
  // console.log(e);
1376
1406
  }
1377
1407
  }
1408
+ destroyResolveJob() {
1409
+ }
1378
1410
  async syncChain(lastBlock) {
1379
- if (!this.shouldSync) {
1411
+ if (!this.shouldSync)
1380
1412
  return;
1381
- }
1413
+ this.#syncState;
1414
+ this.#chainSyncing = true;
1382
1415
  try {
1383
- if (this.jobber.busy && this.jobber.stop) {
1384
- await this.jobber.stop();
1416
+ if (this.jobber.busy && this.jobber.destroy) {
1417
+ await this.jobber.destroy();
1385
1418
  }
1386
1419
  }
1387
1420
  catch (error) {
1388
1421
  console.error(error);
1389
1422
  }
1390
- this.#chainSyncing = true;
1391
1423
  if (!lastBlock)
1392
1424
  lastBlock = await this.#getLatestBlock();
1393
1425
  console.log('starting sync');
@@ -1402,7 +1434,8 @@ class State extends Contract {
1402
1434
  return this.syncChain(lastBlock);
1403
1435
  this.#syncErrorCount = 0;
1404
1436
  this.#chainSyncing = false;
1405
- return 'errored';
1437
+ this.#syncState = 'errored';
1438
+ return this.#syncState;
1406
1439
  }
1407
1440
  if (lastBlock.index === this.#lastBlockInQue?.index)
1408
1441
  this.#lastBlockInQue = undefined;
@@ -1410,7 +1443,8 @@ class State extends Contract {
1410
1443
  this.#chainSyncing = false;
1411
1444
  if (this.#lastBlockInQue)
1412
1445
  return this.syncChain(this.#lastBlockInQue);
1413
- return 'synced';
1446
+ this.#syncState = 'synced';
1447
+ return this.#syncState;
1414
1448
  }
1415
1449
  async #syncChain(lastBlock) {
1416
1450
  try {
@@ -1492,6 +1526,7 @@ class State extends Contract {
1492
1526
  * @param {Block[]} blocks
1493
1527
  */
1494
1528
  async #loadBlocks(blocks) {
1529
+ this.#chainState = 'loading';
1495
1530
  let poolTransactionKeys = await globalThis.transactionPoolStore.keys();
1496
1531
  for (const block of blocks) {
1497
1532
  if (block && !block.loaded) {
@@ -1544,6 +1579,7 @@ class State extends Contract {
1544
1579
  globalThis.pubsub.publish('block-loaded', { ...block });
1545
1580
  }
1546
1581
  }
1582
+ this.#chainState = 'loaded';
1547
1583
  return true;
1548
1584
  }
1549
1585
  promiseRequests(promises) {
@@ -1574,9 +1610,12 @@ class State extends Contract {
1574
1610
  return true;
1575
1611
  }
1576
1612
  get shouldSync() {
1577
- if (this.canSync ||
1578
- this.#resolveErrored ||
1579
- !this.canSync && this.#lastResolvedTime + this.resolveTimeout > new Date().getTime())
1613
+ if (this.#chainSyncing)
1614
+ return false;
1615
+ if (this.#resolveErrored ||
1616
+ this.#syncState === 'errored' ||
1617
+ this.#syncState === 'connectionless' ||
1618
+ !this.canSync && this.#lastResolvedTime + this.resolveTimeout > Date.now())
1580
1619
  return true;
1581
1620
  return false;
1582
1621
  }
@@ -1591,10 +1630,43 @@ class State extends Contract {
1591
1630
  }
1592
1631
  }
1593
1632
 
1633
+ class VersionControl extends State {
1634
+ constructor() {
1635
+ super();
1636
+ }
1637
+ async init() {
1638
+ super.init && await super.init();
1639
+ console.log('init');
1640
+ try {
1641
+ const version = await globalThis.chainStore.get('version');
1642
+ this.version = new TextDecoder().decode(version);
1643
+ console.log(this.version);
1644
+ /**
1645
+ * protocol version control!
1646
+ * note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
1647
+ * in the future we want newer nodes to handle the new changes and still confirm old version transactions
1648
+ * unless there is a security issue!
1649
+ */
1650
+ if (this.version !== '1.1.1') {
1651
+ this.version = '1.1.1';
1652
+ await this.clearAll();
1653
+ await globalThis.chainStore.put('version', this.version);
1654
+ }
1655
+ // if (version)
1656
+ }
1657
+ catch (e) {
1658
+ console.log(e);
1659
+ this.version = '1.1.1';
1660
+ await this.clearAll();
1661
+ await globalThis.chainStore.put('version', this.version);
1662
+ }
1663
+ }
1664
+ }
1665
+
1594
1666
  globalThis.BigNumber = BigNumber;
1595
1667
  const ignorelist = [];
1596
1668
  // check if browser or local
1597
- class Chain extends State {
1669
+ class Chain extends VersionControl {
1598
1670
  #state;
1599
1671
  #slotTime;
1600
1672
  /** {Address[]} */
@@ -1674,46 +1746,7 @@ class Chain extends State {
1674
1746
  console.log('handle native contracts');
1675
1747
  // handle native contracts
1676
1748
  }
1677
- async clearPool() {
1678
- await globalThis.transactionPoolStore.clear();
1679
- }
1680
- /**
1681
- * drastic measurement, removes everything!
1682
- */
1683
- async #clearAll() {
1684
- await globalThis.accountsStore.clear();
1685
- await globalThis.chainStore.clear();
1686
- await globalThis.blockStore.clear();
1687
- await globalThis.transactionPoolStore.clear();
1688
- }
1689
1749
  async #init() {
1690
- try {
1691
- const version = await globalThis.chainStore.get('version');
1692
- this.version = new TextDecoder().decode(version);
1693
- /**
1694
- * protocol version control!
1695
- * note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
1696
- * in the future we want newer nodes to handle the new changes and still confirm old version transactions
1697
- * unless there is a security issue!
1698
- */
1699
- if (this.version !== '1.0.0') {
1700
- this.version = '1.0.0';
1701
- await this.#clearAll();
1702
- await globalThis.chainStore.put('version', this.version);
1703
- }
1704
- else if (this.version !== '1.1.1') {
1705
- this.version = '1.1.1';
1706
- await this.#clearAll();
1707
- await globalThis.chainStore.put('version', this.version);
1708
- }
1709
- // if (version)
1710
- }
1711
- catch (e) {
1712
- console.log(e);
1713
- this.version = '1.0.0';
1714
- await this.#clearAll();
1715
- await globalThis.chainStore.put('version', new TextEncoder().encode(this.version));
1716
- }
1717
1750
  // this.node = await new Node()
1718
1751
  this.#participants = [];
1719
1752
  this.#participating = false;
@@ -1722,6 +1755,8 @@ class Chain extends State {
1722
1755
  await this.#setup();
1723
1756
  this.utils = { BigNumber, formatUnits, parseUnits };
1724
1757
  // this.#state = new State()
1758
+ // todo some functions rely on state
1759
+ await super.init();
1725
1760
  await globalThis.peernet.addRequestHandler('bw-request-message', () => {
1726
1761
  return new BWMessage(globalThis.peernet.client.bw) || { up: 0, down: 0 };
1727
1762
  });
@@ -1737,8 +1772,6 @@ class Chain extends State {
1737
1772
  globalThis.peernet.subscribe('add-transaction', this.#addTransaction.bind(this));
1738
1773
  globalThis.peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this));
1739
1774
  globalThis.pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
1740
- // todo some functions rely on state
1741
- await super.init();
1742
1775
  globalThis.pubsub.publish('chain:ready', true);
1743
1776
  return this;
1744
1777
  }
@@ -1765,31 +1798,36 @@ class Chain extends State {
1765
1798
  response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
1766
1799
  return response.decoded.response;
1767
1800
  }
1801
+ async getPeerTransactionPool(peer) {
1802
+ const transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
1803
+ // todo iterate vs getting all keys?
1804
+ const transactions = await globalThis.transactionPoolStore.keys();
1805
+ const transactionsToGet = [];
1806
+ for (const key of transactionsInPool) {
1807
+ !transactions.includes(key) &&
1808
+ !ignorelist.includes(key) &&
1809
+ transactionsToGet.push(transactionPoolStore.put(key, await peernet.get(key, 'transaction')));
1810
+ }
1811
+ return Promise.all(transactionsToGet);
1812
+ }
1768
1813
  async #peerConnected(peer) {
1769
1814
  // todo handle version changes
1770
1815
  // for now just do nothing if version doesn't match
1771
1816
  if (!peer.version || peer.version !== this.version)
1772
1817
  return;
1773
1818
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
1774
- let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
1775
- const transactions = await globalThis.transactionPoolStore.keys();
1776
- const transactionsToGet = [];
1777
- for (const key of transactionsInPool) {
1778
- if (!transactions.includes(key) && !ignorelist.includes(key))
1779
- transactionsToGet.push(transactionPoolStore.put(key, (await peernet.get(key, 'transaction'))));
1780
- }
1781
- await Promise.all(transactionsToGet);
1819
+ const higherThenCurrentLocal = lastBlock.index > this.lastBlock?.index;
1820
+ const peerTransactionPool = higherThenCurrentLocal && await this.getPeerTransactionPool(peer) || [];
1782
1821
  if (Object.keys(lastBlock).length > 0) {
1783
- if (!this.lastBlock || !this.blocks[this.blocks.length - 1]?.loaded || lastBlock && lastBlock.index > this.lastBlock?.index || !this.loaded && !this.resolving) {
1822
+ if (!this.lastBlock || higherThenCurrentLocal) {
1784
1823
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1785
1824
  await this.syncChain(lastBlock);
1786
- // if (await this.hasTransactionToHandle() && this.#participating) this.#runEpoch()
1787
1825
  }
1788
1826
  else if (!this.knownBlocks)
1789
1827
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1790
1828
  }
1791
- if (this.#participating)
1792
- this.#runEpoch();
1829
+ if (this.#participating && peerTransactionPool.length > 0)
1830
+ return this.#runEpoch();
1793
1831
  }
1794
1832
  #epochTimeout;
1795
1833
  async #transactionPoolHandler() {
@@ -1,5 +1,5 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-f8484520.js';
2
- import './index-de7cd283.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-19707bf6.js';
2
+ import './index-73138caf.js';
3
3
 
4
4
  /**
5
5
  * @params {String} network
@@ -5568,6 +5568,8 @@ class TransactionMessage extends FormatInterface {
5568
5568
  return 'TransactionMessage';
5569
5569
  }
5570
5570
  constructor(buffer) {
5571
+ if (buffer instanceof TransactionMessage)
5572
+ return buffer;
5571
5573
  const name = 'transaction-message';
5572
5574
  super(buffer, proto$6, { name });
5573
5575
  }
@@ -5583,6 +5585,8 @@ class ValidatorMessage extends FormatInterface {
5583
5585
  return 'ValidatorMessage';
5584
5586
  }
5585
5587
  constructor(buffer) {
5588
+ if (buffer instanceof ValidatorMessage)
5589
+ return buffer;
5586
5590
  const name = 'validator-message';
5587
5591
  super(buffer, proto$5, { name });
5588
5592
  }
@@ -5603,6 +5607,8 @@ class BlockMessage extends FormatInterface {
5603
5607
  return 'BlockMessage';
5604
5608
  }
5605
5609
  constructor(buffer) {
5610
+ if (buffer instanceof BlockMessage)
5611
+ return buffer;
5606
5612
  const name = 'block-message';
5607
5613
  super(buffer, proto$4, { name });
5608
5614
  }
@@ -5649,6 +5655,8 @@ class BWMessage extends FormatInterface {
5649
5655
  return 'BWMessage';
5650
5656
  }
5651
5657
  constructor(buffer) {
5658
+ if (buffer instanceof BWMessage)
5659
+ return buffer;
5652
5660
  const name = 'bw-message';
5653
5661
  super(buffer, proto$3, { name });
5654
5662
  }
@@ -5661,6 +5669,8 @@ class BWRequestMessage extends FormatInterface {
5661
5669
  return 'BWRequestMessage';
5662
5670
  }
5663
5671
  constructor(buffer) {
5672
+ if (buffer instanceof BWRequestMessage)
5673
+ return buffer;
5664
5674
  const name = 'bw-request-message';
5665
5675
  super(buffer, proto$2, { name });
5666
5676
  }
@@ -5677,6 +5687,8 @@ class ContractMessage extends FormatInterface {
5677
5687
  return 'ContractMessage';
5678
5688
  }
5679
5689
  constructor(buffer) {
5690
+ if (buffer instanceof ContractMessage)
5691
+ return buffer;
5680
5692
  super(buffer, proto$1, { name: 'contract-message' });
5681
5693
  }
5682
5694
  }
@@ -5695,6 +5707,8 @@ class RawTransactionMessage extends FormatInterface {
5695
5707
  return 'RawTransactionMessage';
5696
5708
  }
5697
5709
  constructor(buffer) {
5710
+ if (buffer instanceof RawTransactionMessage)
5711
+ return buffer;
5698
5712
  const name = 'raw-transaction-message';
5699
5713
  super(buffer, proto, { name });
5700
5714
  }
@@ -1,5 +1,5 @@
1
- import { F as FormatInterface } from './node-browser-f8484520.js';
2
- import './index-de7cd283.js';
1
+ import { F as FormatInterface } from './node-browser-19707bf6.js';
2
+ import './index-73138caf.js';
3
3
 
4
4
  var proto$b = {
5
5
  data: new Uint8Array(),
@@ -1,4 +1,4 @@
1
- import { C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-de7cd283.js';
1
+ import { C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-73138caf.js';
2
2
 
3
3
  var nodeConfig = async (config = {
4
4
  network: 'leofcoin:peach',
@@ -20216,7 +20216,7 @@ class Identity {
20216
20216
  this.selectedAccount = new TextDecoder().decode(selected);
20217
20217
  }
20218
20218
  else {
20219
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-329e0324-a0469bb9.js');
20219
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-329e0324-835f93a9.js');
20220
20220
  const { identity, accounts } = await importee.default(password, this.network);
20221
20221
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
20222
20222
  await globalThis.walletStore.put('version', String(1));
@@ -20407,7 +20407,7 @@ class Peernet {
20407
20407
  this.root = options.root;
20408
20408
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
20409
20409
  // FolderMessageResponse
20410
- } = await import(/* webpackChunkName: "messages" */ './messages-000b7f84-8465e629.js');
20410
+ } = await import(/* webpackChunkName: "messages" */ './messages-000b7f84-b6b8b755.js');
20411
20411
  /**
20412
20412
  * proto Object containing protos
20413
20413
  * @type {Object}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-f8484520.js';
2
- import './index-de7cd283.js';
1
+ export { N as default } from './node-browser-19707bf6.js';
2
+ import './index-73138caf.js';
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-156dda16.js';
1
+ import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-0f66935f.js';
2
2
 
3
3
  const worker = new EasyWorker();
4
4
 
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-156dda16.js';
1
+ import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-0f66935f.js';
2
2
 
3
3
  var contractFactory = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,173,5,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
4
4
  var nativeToken = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,163,26,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,34,79,87,78,69,82,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,77,73,78,84,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,66,85,82,78,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,34,48,120,48,48,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,34,48,120,48,48,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,34,48,120,48,48,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,34,65,114,116,79,110,108,105,110,101,34,44,34,65,82,84,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,2,91,93";
@@ -5500,6 +5500,8 @@ class TransactionMessage extends FormatInterface {
5500
5500
  return 'TransactionMessage';
5501
5501
  }
5502
5502
  constructor(buffer) {
5503
+ if (buffer instanceof TransactionMessage)
5504
+ return buffer;
5503
5505
  const name = 'transaction-message';
5504
5506
  super(buffer, proto$3, { name });
5505
5507
  }
@@ -5515,6 +5517,8 @@ class ValidatorMessage extends FormatInterface {
5515
5517
  return 'ValidatorMessage';
5516
5518
  }
5517
5519
  constructor(buffer) {
5520
+ if (buffer instanceof ValidatorMessage)
5521
+ return buffer;
5518
5522
  const name = 'validator-message';
5519
5523
  super(buffer, proto$2, { name });
5520
5524
  }
@@ -5535,6 +5539,8 @@ class BlockMessage extends FormatInterface {
5535
5539
  return 'BlockMessage';
5536
5540
  }
5537
5541
  constructor(buffer) {
5542
+ if (buffer instanceof BlockMessage)
5543
+ return buffer;
5538
5544
  const name = 'block-message';
5539
5545
  super(buffer, proto$1, { name });
5540
5546
  }
@@ -5582,6 +5588,8 @@ class ContractMessage extends FormatInterface {
5582
5588
  return 'ContractMessage';
5583
5589
  }
5584
5590
  constructor(buffer) {
5591
+ if (buffer instanceof ContractMessage)
5592
+ return buffer;
5585
5593
  super(buffer, proto, { name: 'contract-message' });
5586
5594
  }
5587
5595
  }
@@ -1,8 +1,8 @@
1
1
  import { BigNumber } from '@leofcoin/utils';
2
2
  import { BigNumberish } from '@ethersproject/bignumber';
3
- import State from './state.js';
4
3
  import { Address } from './types.js';
5
- export default class Chain extends State {
4
+ import { VersionControl } from './version-control.js';
5
+ export default class Chain extends VersionControl {
6
6
  #private;
7
7
  id: any;
8
8
  utils: {};
@@ -10,7 +10,7 @@ export default class Chain extends State {
10
10
  get nativeToken(): string;
11
11
  get validators(): any[];
12
12
  hasTransactionToHandle(): Promise<boolean>;
13
- clearPool(): Promise<void>;
13
+ getPeerTransactionPool(peer: any): Promise<any[]>;
14
14
  participate(address: any): Promise<void>;
15
15
  /**
16
16
  * every tx done is trough contracts so no need for amount
package/exports/chain.js CHANGED
@@ -12,7 +12,7 @@ const requestTimeout = 30000;
12
12
  const syncTimeout = 30000;
13
13
  class Protocol {
14
14
  constructor() {
15
- this.resolveTimeout = 30000;
15
+ this.resolveTimeout = 10000;
16
16
  }
17
17
  get limit() {
18
18
  return limit;
@@ -496,7 +496,7 @@ class Jobber {
496
496
  const timeout = setTimeout(() => {
497
497
  reject('timeout');
498
498
  }, this.timeout);
499
- this.stop = () => {
499
+ this.destroy = () => {
500
500
  clearTimeout(timeout);
501
501
  this.busy = false;
502
502
  resolve('stopped');
@@ -508,6 +508,7 @@ class Jobber {
508
508
  resolve(result);
509
509
  }
510
510
  catch (error) {
511
+ clearTimeout(timeout);
511
512
  reject(error);
512
513
  }
513
514
  });
@@ -521,6 +522,7 @@ class State extends Contract {
521
522
  #resolving;
522
523
  #resolveErrorCount;
523
524
  #syncState;
525
+ #chainState;
524
526
  #lastBlockInQue;
525
527
  #syncErrorCount;
526
528
  #blockHashMap;
@@ -530,6 +532,12 @@ class State extends Contract {
530
532
  #totalSize;
531
533
  #machine;
532
534
  #loaded;
535
+ get state() {
536
+ return {
537
+ sync: this.#syncState,
538
+ chain: this.#chainState
539
+ };
540
+ }
533
541
  get blockHashMap() {
534
542
  return this.#blockHashMap.entries();
535
543
  }
@@ -591,8 +599,10 @@ class State extends Contract {
591
599
  }
592
600
  constructor() {
593
601
  super();
602
+ this.#lastResolvedTime = 0;
594
603
  this.#resolving = false;
595
604
  this.#resolveErrorCount = 0;
605
+ this.#chainState = 'loading';
596
606
  this.#syncErrorCount = 0;
597
607
  this.#blockHashMap = new Map();
598
608
  this.#chainSyncing = false;
@@ -624,6 +634,15 @@ class State extends Contract {
624
634
  * {Number}
625
635
  */
626
636
  this.#totalTransactions = 0;
637
+ this.#chainStateHandler = () => {
638
+ return new globalThis.peernet.protos['peernet-response']({ response: this.#chainState });
639
+ };
640
+ this.#lastBlockHandler = async () => {
641
+ return new globalThis.peernet.protos['peernet-response']({ response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index } });
642
+ };
643
+ this.#knownBlocksHandler = async () => {
644
+ return new globalThis.peernet.protos['peernet-response']({ response: { blocks: this.#blocks.map((block) => block.hash) } });
645
+ };
627
646
  this.#loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
628
647
  this.#getLastTransactions = async () => {
629
648
  let lastTransactions = (await Promise.all(this.#blocks.filter(block => block.loaded).slice(-128)
@@ -632,12 +651,28 @@ class State extends Contract {
632
651
  return Promise.all(lastTransactions.map(transaction => transaction.hash()));
633
652
  };
634
653
  }
654
+ async clearPool() {
655
+ await globalThis.transactionPoolStore.clear();
656
+ }
657
+ /**
658
+ * drastic measurement, removes everything!
659
+ */
660
+ async clearAll() {
661
+ await globalThis.accountsStore.clear();
662
+ await globalThis.chainStore.clear();
663
+ await globalThis.blockStore.clear();
664
+ await globalThis.transactionPoolStore.clear();
665
+ }
666
+ #chainStateHandler;
667
+ #lastBlockHandler;
668
+ #knownBlocksHandler;
635
669
  async init() {
636
- this.jobber = new Jobber(30000);
670
+ this.jobber = new Jobber(this.resolveTimeout);
637
671
  if (super.init)
638
672
  await super.init();
639
- await globalThis.peernet.addRequestHandler('lastBlock', this.#lastBlockHandler.bind(this));
640
- await globalThis.peernet.addRequestHandler('knownBlocks', this.#knownBlocksHandler.bind(this));
673
+ await globalThis.peernet.addRequestHandler('lastBlock', this.#lastBlockHandler);
674
+ await globalThis.peernet.addRequestHandler('knownBlocks', this.#knownBlocksHandler);
675
+ await globalThis.peernet.addRequestHandler('chainState', this.#chainStateHandler);
641
676
  try {
642
677
  let localBlock;
643
678
  try {
@@ -692,12 +727,6 @@ class State extends Contract {
692
727
  await globalThis.chainStore.put('lastBlock', hash);
693
728
  globalThis.pubsub.publish('lastBlock', this.#lastBlock);
694
729
  }
695
- async #lastBlockHandler() {
696
- return new globalThis.peernet.protos['peernet-response']({ response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index } });
697
- }
698
- async #knownBlocksHandler() {
699
- return new globalThis.peernet.protos['peernet-response']({ response: { blocks: this.#blocks.map((block) => block.hash) } });
700
- }
701
730
  getLatestBlock() {
702
731
  // @ts-ignore
703
732
  return this.#getLatestBlock();
@@ -738,8 +767,6 @@ class State extends Contract {
738
767
  this.#lastResolvedTime = Date.now();
739
768
  }
740
769
  catch (error) {
741
- this.#resolving = false;
742
- this.#chainSyncing = false;
743
770
  throw new ResolveError(`block: ${hash}@${index}`);
744
771
  }
745
772
  return;
@@ -752,6 +779,8 @@ class State extends Contract {
752
779
  if (this.#resolving)
753
780
  return 'already resolving';
754
781
  this.#resolving = true;
782
+ if (this.jobber.busy && this.jobber.destroy)
783
+ await this.jobber.destroy();
755
784
  try {
756
785
  await this.jobber.add(() => this.#resolveBlock(hash));
757
786
  this.#resolving = false;
@@ -761,6 +790,7 @@ class State extends Contract {
761
790
  catch (error) {
762
791
  console.log({ error });
763
792
  this.#resolveErrorCount += 1;
793
+ this.#resolving = false;
764
794
  if (this.#resolveErrorCount < 3)
765
795
  return this.resolveBlock(hash);
766
796
  this.#resolveErrorCount = 0;
@@ -769,8 +799,8 @@ class State extends Contract {
769
799
  }
770
800
  async resolveBlocks() {
771
801
  try {
772
- if (this.jobber.busy && this.jobber.stop) {
773
- await this.jobber.stop();
802
+ if (this.jobber.busy && this.jobber.destroy) {
803
+ await this.jobber.destroy();
774
804
  }
775
805
  }
776
806
  catch (error) {
@@ -786,10 +816,10 @@ class State extends Contract {
786
816
  }
787
817
  catch (error) {
788
818
  console.log(error);
819
+ this.#chainSyncing = false;
820
+ this.#syncState = 'errored';
789
821
  this.#resolveErrored = true;
790
- this.#resolveErrorCount += 1;
791
- this.#resolving = false;
792
- this.restoreChain();
822
+ return this.restoreChain();
793
823
  // console.log(e);
794
824
  }
795
825
  }
@@ -807,23 +837,25 @@ class State extends Contract {
807
837
  this.#resolveErrored = true;
808
838
  this.#resolveErrorCount += 1;
809
839
  this.#resolving = false;
810
- this.restoreChain();
840
+ return this.restoreChain();
811
841
  // console.log(e);
812
842
  }
813
843
  }
844
+ destroyResolveJob() {
845
+ }
814
846
  async syncChain(lastBlock) {
815
- if (!this.shouldSync) {
847
+ if (!this.shouldSync)
816
848
  return;
817
- }
849
+ this.#syncState;
850
+ this.#chainSyncing = true;
818
851
  try {
819
- if (this.jobber.busy && this.jobber.stop) {
820
- await this.jobber.stop();
852
+ if (this.jobber.busy && this.jobber.destroy) {
853
+ await this.jobber.destroy();
821
854
  }
822
855
  }
823
856
  catch (error) {
824
857
  console.error(error);
825
858
  }
826
- this.#chainSyncing = true;
827
859
  if (!lastBlock)
828
860
  lastBlock = await this.#getLatestBlock();
829
861
  console.log('starting sync');
@@ -838,7 +870,8 @@ class State extends Contract {
838
870
  return this.syncChain(lastBlock);
839
871
  this.#syncErrorCount = 0;
840
872
  this.#chainSyncing = false;
841
- return 'errored';
873
+ this.#syncState = 'errored';
874
+ return this.#syncState;
842
875
  }
843
876
  if (lastBlock.index === this.#lastBlockInQue?.index)
844
877
  this.#lastBlockInQue = undefined;
@@ -846,7 +879,8 @@ class State extends Contract {
846
879
  this.#chainSyncing = false;
847
880
  if (this.#lastBlockInQue)
848
881
  return this.syncChain(this.#lastBlockInQue);
849
- return 'synced';
882
+ this.#syncState = 'synced';
883
+ return this.#syncState;
850
884
  }
851
885
  async #syncChain(lastBlock) {
852
886
  try {
@@ -928,6 +962,7 @@ class State extends Contract {
928
962
  * @param {Block[]} blocks
929
963
  */
930
964
  async #loadBlocks(blocks) {
965
+ this.#chainState = 'loading';
931
966
  let poolTransactionKeys = await globalThis.transactionPoolStore.keys();
932
967
  for (const block of blocks) {
933
968
  if (block && !block.loaded) {
@@ -980,6 +1015,7 @@ class State extends Contract {
980
1015
  globalThis.pubsub.publish('block-loaded', { ...block });
981
1016
  }
982
1017
  }
1018
+ this.#chainState = 'loaded';
983
1019
  return true;
984
1020
  }
985
1021
  promiseRequests(promises) {
@@ -1010,9 +1046,12 @@ class State extends Contract {
1010
1046
  return true;
1011
1047
  }
1012
1048
  get shouldSync() {
1013
- if (this.canSync ||
1014
- this.#resolveErrored ||
1015
- !this.canSync && this.#lastResolvedTime + this.resolveTimeout > new Date().getTime())
1049
+ if (this.#chainSyncing)
1050
+ return false;
1051
+ if (this.#resolveErrored ||
1052
+ this.#syncState === 'errored' ||
1053
+ this.#syncState === 'connectionless' ||
1054
+ !this.canSync && this.#lastResolvedTime + this.resolveTimeout > Date.now())
1016
1055
  return true;
1017
1056
  return false;
1018
1057
  }
@@ -1027,10 +1066,43 @@ class State extends Contract {
1027
1066
  }
1028
1067
  }
1029
1068
 
1069
+ class VersionControl extends State {
1070
+ constructor() {
1071
+ super();
1072
+ }
1073
+ async init() {
1074
+ super.init && await super.init();
1075
+ console.log('init');
1076
+ try {
1077
+ const version = await globalThis.chainStore.get('version');
1078
+ this.version = new TextDecoder().decode(version);
1079
+ console.log(this.version);
1080
+ /**
1081
+ * protocol version control!
1082
+ * note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
1083
+ * in the future we want newer nodes to handle the new changes and still confirm old version transactions
1084
+ * unless there is a security issue!
1085
+ */
1086
+ if (this.version !== '1.1.1') {
1087
+ this.version = '1.1.1';
1088
+ await this.clearAll();
1089
+ await globalThis.chainStore.put('version', this.version);
1090
+ }
1091
+ // if (version)
1092
+ }
1093
+ catch (e) {
1094
+ console.log(e);
1095
+ this.version = '1.1.1';
1096
+ await this.clearAll();
1097
+ await globalThis.chainStore.put('version', this.version);
1098
+ }
1099
+ }
1100
+ }
1101
+
1030
1102
  globalThis.BigNumber = BigNumber;
1031
1103
  const ignorelist = [];
1032
1104
  // check if browser or local
1033
- class Chain extends State {
1105
+ class Chain extends VersionControl {
1034
1106
  #state;
1035
1107
  #slotTime;
1036
1108
  /** {Address[]} */
@@ -1110,46 +1182,7 @@ class Chain extends State {
1110
1182
  console.log('handle native contracts');
1111
1183
  // handle native contracts
1112
1184
  }
1113
- async clearPool() {
1114
- await globalThis.transactionPoolStore.clear();
1115
- }
1116
- /**
1117
- * drastic measurement, removes everything!
1118
- */
1119
- async #clearAll() {
1120
- await globalThis.accountsStore.clear();
1121
- await globalThis.chainStore.clear();
1122
- await globalThis.blockStore.clear();
1123
- await globalThis.transactionPoolStore.clear();
1124
- }
1125
1185
  async #init() {
1126
- try {
1127
- const version = await globalThis.chainStore.get('version');
1128
- this.version = new TextDecoder().decode(version);
1129
- /**
1130
- * protocol version control!
1131
- * note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
1132
- * in the future we want newer nodes to handle the new changes and still confirm old version transactions
1133
- * unless there is a security issue!
1134
- */
1135
- if (this.version !== '1.0.0') {
1136
- this.version = '1.0.0';
1137
- await this.#clearAll();
1138
- await globalThis.chainStore.put('version', this.version);
1139
- }
1140
- else if (this.version !== '1.1.1') {
1141
- this.version = '1.1.1';
1142
- await this.#clearAll();
1143
- await globalThis.chainStore.put('version', this.version);
1144
- }
1145
- // if (version)
1146
- }
1147
- catch (e) {
1148
- console.log(e);
1149
- this.version = '1.0.0';
1150
- await this.#clearAll();
1151
- await globalThis.chainStore.put('version', new TextEncoder().encode(this.version));
1152
- }
1153
1186
  // this.node = await new Node()
1154
1187
  this.#participants = [];
1155
1188
  this.#participating = false;
@@ -1158,6 +1191,8 @@ class Chain extends State {
1158
1191
  await this.#setup();
1159
1192
  this.utils = { BigNumber, formatUnits, parseUnits };
1160
1193
  // this.#state = new State()
1194
+ // todo some functions rely on state
1195
+ await super.init();
1161
1196
  await globalThis.peernet.addRequestHandler('bw-request-message', () => {
1162
1197
  return new BWMessage(globalThis.peernet.client.bw) || { up: 0, down: 0 };
1163
1198
  });
@@ -1173,8 +1208,6 @@ class Chain extends State {
1173
1208
  globalThis.peernet.subscribe('add-transaction', this.#addTransaction.bind(this));
1174
1209
  globalThis.peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this));
1175
1210
  globalThis.pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
1176
- // todo some functions rely on state
1177
- await super.init();
1178
1211
  globalThis.pubsub.publish('chain:ready', true);
1179
1212
  return this;
1180
1213
  }
@@ -1201,31 +1234,36 @@ class Chain extends State {
1201
1234
  response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
1202
1235
  return response.decoded.response;
1203
1236
  }
1237
+ async getPeerTransactionPool(peer) {
1238
+ const transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
1239
+ // todo iterate vs getting all keys?
1240
+ const transactions = await globalThis.transactionPoolStore.keys();
1241
+ const transactionsToGet = [];
1242
+ for (const key of transactionsInPool) {
1243
+ !transactions.includes(key) &&
1244
+ !ignorelist.includes(key) &&
1245
+ transactionsToGet.push(transactionPoolStore.put(key, await peernet.get(key, 'transaction')));
1246
+ }
1247
+ return Promise.all(transactionsToGet);
1248
+ }
1204
1249
  async #peerConnected(peer) {
1205
1250
  // todo handle version changes
1206
1251
  // for now just do nothing if version doesn't match
1207
1252
  if (!peer.version || peer.version !== this.version)
1208
1253
  return;
1209
1254
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
1210
- let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
1211
- const transactions = await globalThis.transactionPoolStore.keys();
1212
- const transactionsToGet = [];
1213
- for (const key of transactionsInPool) {
1214
- if (!transactions.includes(key) && !ignorelist.includes(key))
1215
- transactionsToGet.push(transactionPoolStore.put(key, (await peernet.get(key, 'transaction'))));
1216
- }
1217
- await Promise.all(transactionsToGet);
1255
+ const higherThenCurrentLocal = lastBlock.index > this.lastBlock?.index;
1256
+ const peerTransactionPool = higherThenCurrentLocal && await this.getPeerTransactionPool(peer) || [];
1218
1257
  if (Object.keys(lastBlock).length > 0) {
1219
- if (!this.lastBlock || !this.blocks[this.blocks.length - 1]?.loaded || lastBlock && lastBlock.index > this.lastBlock?.index || !this.loaded && !this.resolving) {
1258
+ if (!this.lastBlock || higherThenCurrentLocal) {
1220
1259
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1221
1260
  await this.syncChain(lastBlock);
1222
- // if (await this.hasTransactionToHandle() && this.#participating) this.#runEpoch()
1223
1261
  }
1224
1262
  else if (!this.knownBlocks)
1225
1263
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
1226
1264
  }
1227
- if (this.#participating)
1228
- this.#runEpoch();
1265
+ if (this.#participating && peerTransactionPool.length > 0)
1266
+ return this.#runEpoch();
1229
1267
  }
1230
1268
  #epochTimeout;
1231
1269
  async #transactionPoolHandler() {
@@ -1,7 +1,7 @@
1
1
  export default class Jobber {
2
2
  timeout: EpochTimeStamp;
3
3
  busy: boolean;
4
- stop: Function;
4
+ destroy: Function;
5
5
  constructor(timeout: any);
6
6
  add(fn: any): Promise<unknown>;
7
7
  }
@@ -4,10 +4,15 @@ import Machine from './machine.js';
4
4
  import Jobber from './jobs/jobber.js';
5
5
  import { BlockHash } from './types.js';
6
6
  declare type SyncState = 'syncing' | 'synced' | 'errored' | 'connectionless';
7
+ declare type ChainState = 'loading' | 'loaded';
7
8
  export default class State extends Contract {
8
9
  #private;
9
10
  knownBlocks: BlockHash[];
10
11
  jobber: Jobber;
12
+ get state(): {
13
+ sync: SyncState;
14
+ chain: ChainState;
15
+ };
11
16
  get blockHashMap(): IterableIterator<[any, any]>;
12
17
  get loaded(): boolean;
13
18
  get resolving(): boolean;
@@ -25,13 +30,19 @@ export default class State extends Contract {
25
30
  get totalSize(): number;
26
31
  get machine(): Machine;
27
32
  constructor();
33
+ clearPool(): Promise<void>;
34
+ /**
35
+ * drastic measurement, removes everything!
36
+ */
37
+ clearAll(): Promise<void>;
28
38
  init(): Promise<void>;
29
39
  updateState(message: any): Promise<void>;
30
40
  getLatestBlock(): Promise<BlockMessage['decoded']>;
31
41
  getAndPutBlock(hash: string): Promise<BlockMessage>;
32
42
  resolveBlock(hash: any): any;
33
- resolveBlocks(): Promise<void>;
34
- restoreChain(): Promise<void>;
43
+ resolveBlocks(): Promise<any>;
44
+ restoreChain(): any;
45
+ destroyResolveJob(): void;
35
46
  syncChain(lastBlock?: any): Promise<SyncState>;
36
47
  promiseRequests(promises: any): Promise<unknown>;
37
48
  get canSync(): boolean;
@@ -0,0 +1,5 @@
1
+ import State from "./state.js";
2
+ export declare class VersionControl extends State {
3
+ constructor();
4
+ init(): Promise<void>;
5
+ }
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-156dda16.js';
1
+ import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-0f66935f.js';
2
2
 
3
3
  const worker = new EasyWorker();
4
4
 
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-156dda16.js';
1
+ import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-0f66935f.js';
2
2
 
3
3
  var contractFactory = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,173,5,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
4
4
  var nativeToken = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,163,26,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,34,79,87,78,69,82,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,77,73,78,84,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,66,85,82,78,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,34,48,120,48,48,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,34,48,120,48,48,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,34,48,120,48,48,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,34,65,114,116,79,110,108,105,110,101,34,44,34,65,82,84,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,2,91,93";
@@ -5500,6 +5500,8 @@ class TransactionMessage extends FormatInterface {
5500
5500
  return 'TransactionMessage';
5501
5501
  }
5502
5502
  constructor(buffer) {
5503
+ if (buffer instanceof TransactionMessage)
5504
+ return buffer;
5503
5505
  const name = 'transaction-message';
5504
5506
  super(buffer, proto$3, { name });
5505
5507
  }
@@ -5515,6 +5517,8 @@ class ValidatorMessage extends FormatInterface {
5515
5517
  return 'ValidatorMessage';
5516
5518
  }
5517
5519
  constructor(buffer) {
5520
+ if (buffer instanceof ValidatorMessage)
5521
+ return buffer;
5518
5522
  const name = 'validator-message';
5519
5523
  super(buffer, proto$2, { name });
5520
5524
  }
@@ -5535,6 +5539,8 @@ class BlockMessage extends FormatInterface {
5535
5539
  return 'BlockMessage';
5536
5540
  }
5537
5541
  constructor(buffer) {
5542
+ if (buffer instanceof BlockMessage)
5543
+ return buffer;
5538
5544
  const name = 'block-message';
5539
5545
  super(buffer, proto$1, { name });
5540
5546
  }
@@ -5582,6 +5588,8 @@ class ContractMessage extends FormatInterface {
5582
5588
  return 'ContractMessage';
5583
5589
  }
5584
5590
  constructor(buffer) {
5591
+ if (buffer instanceof ContractMessage)
5592
+ return buffer;
5585
5593
  super(buffer, proto, { name: 'contract-message' });
5586
5594
  }
5587
5595
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.23",
3
+ "version": "1.5.25",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {
@@ -54,6 +54,7 @@
54
54
  "@types/bs58check": "^2.1.0",
55
55
  "@types/pako": "^2.0.0",
56
56
  "@types/randombytes": "^2.0.0",
57
+ "@types/semver": "^7.5.6",
57
58
  "@types/varint": "^6.0.1",
58
59
  "@vandeurenglenn/debug": "^1.0.0",
59
60
  "eslint": "^8.28.0",
@@ -89,6 +90,7 @@
89
90
  "p-queue": "^7.3.4",
90
91
  "p2pt": "^1.5.1",
91
92
  "pako": "^2.0.4",
93
+ "semver": "^7.5.4",
92
94
  "simple-peer": "^9.11.1"
93
95
  },
94
96
  "eslintConfig": {