@leofcoin/chain 1.5.33 → 1.5.34

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, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-3e3995e1.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-4420907d.js';
2
2
 
3
3
  const logger$1 = new Logger(version$1);
4
4
  const _constructorGuard = {};
@@ -1538,7 +1538,7 @@ class State extends Contract {
1538
1538
  #loadBlockTransactions;
1539
1539
  #getLastTransactions;
1540
1540
  // todo throw error
1541
- async #executeTransaction(transaction) {
1541
+ async #_executeTransaction(transaction) {
1542
1542
  try {
1543
1543
  await this.#machine.execute(transaction.decoded.to, transaction.decoded.method, transaction.decoded.params);
1544
1544
  await globalThis.accountsStore.put(transaction.decoded.from, String(transaction.decoded.nonce));
@@ -1584,24 +1584,26 @@ class State extends Contract {
1584
1584
  let priority = [];
1585
1585
  for (const transaction of transactions) {
1586
1586
  const hash = await transaction.hash();
1587
- if (transaction.decoded.priority)
1588
- priority.push(transaction);
1589
- if (poolTransactionKeys.includes(hash))
1590
- await globalThis.transactionPoolStore.delete(hash);
1591
1587
  if (lastTransactions.includes(hash)) {
1592
1588
  console.log('removing invalid block');
1593
1589
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
1594
1590
  blocks.splice(block.index - 1, 1);
1595
1591
  return this.#loadBlocks(blocks);
1596
1592
  }
1593
+ if (transaction.decoded.priority)
1594
+ priority.push(transaction);
1595
+ if (poolTransactionKeys.includes(hash))
1596
+ await globalThis.transactionPoolStore.delete(hash);
1597
1597
  }
1598
+ // prority blocks execution from the rest so result in higher fees.
1598
1599
  if (priority.length > 0) {
1599
1600
  priority = priority.sort((a, b) => a.nonce - b.nonce);
1600
1601
  for (const transaction of priority) {
1601
- await this.#executeTransaction(transaction);
1602
+ await this.#_executeTransaction(transaction);
1602
1603
  }
1603
1604
  }
1604
- transactions = transactions.filter((transaction) => !transaction.priority);
1605
+ transactions = transactions.filter((transaction) => !transaction.decoded.priority);
1606
+ await Promise.all(transactions.map((transaction) => this.#_executeTransaction(transaction)));
1605
1607
  this.#blocks[block.index - 1].loaded = true;
1606
1608
  // @ts-ignore
1607
1609
  globalThis.debug(`loaded block: ${block.hash} @${block.index}`);
@@ -1852,10 +1854,8 @@ class Chain extends VersionControl {
1852
1854
  if (!peer.version || peer.version !== this.version)
1853
1855
  return;
1854
1856
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
1855
- console.log(lastBlock);
1856
1857
  const higherThenCurrentLocal = !this.lastBlock?.index ? true : lastBlock.index > this.lastBlock?.index;
1857
1858
  const peerTransactionPool = (higherThenCurrentLocal && (await this.getPeerTransactionPool(peer))) || [];
1858
- console.log(this.lastBlock);
1859
1859
  if (Object.keys(lastBlock).length > 0) {
1860
1860
  if (!this.lastBlock || higherThenCurrentLocal) {
1861
1861
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
@@ -1,5 +1,5 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-634c6b24.js';
2
- import './index-3e3995e1.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-484d9d8b.js';
2
+ import './index-4420907d.js';
3
3
 
4
4
  /**
5
5
  * @params {String} network
@@ -11673,25 +11673,23 @@ var pako = {
11673
11673
  };
11674
11674
 
11675
11675
  const { fromString, toString } = index$1;
11676
- const isJson = (type) => type === "object" || "array";
11677
- const isString = (type) => type === "string";
11678
- const isNumber = (type) => type === "number";
11679
- const isBoolean = (type) => type === "boolean";
11680
- const isUint8Array = (type) => type === "uint8Array";
11681
- const isBigNumber = (type) => type === "bigNumber";
11676
+ const isJson = (type) => type === 'object' || 'array';
11677
+ const isString = (type) => type === 'string';
11678
+ const isNumber = (type) => type === 'number';
11679
+ const isBoolean = (type) => type === 'boolean';
11680
+ const isUint8Array = (type) => type === 'uint8Array';
11681
+ const isBigNumber = (type) => type === 'bigNumber';
11682
11682
  const tokenize = (key, value) => {
11683
- const optional = key.endsWith("?");
11683
+ const optional = key.endsWith('?');
11684
11684
  let type = value === undefined ? key : value;
11685
11685
  if (type instanceof Uint8Array)
11686
- type = "uint8Array";
11686
+ type = 'uint8Array';
11687
11687
  else if (type instanceof BigNumber)
11688
- type = "bigNumber";
11688
+ type = 'bigNumber';
11689
11689
  else
11690
- type = Array.isArray(type) ? "array" : typeof type;
11691
- const parts = key.split("?");
11692
- const minimumLength = parts[2]?.includes("min")
11693
- ? parts[2].split["min:"][1]
11694
- : 0;
11690
+ type = Array.isArray(type) ? 'array' : typeof type;
11691
+ const parts = key.split('?');
11692
+ const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
11695
11693
  return { type, optional, key: parts[0], minimumLength };
11696
11694
  };
11697
11695
  const toType = (data) => {
@@ -11705,13 +11703,13 @@ const toType = (data) => {
11705
11703
  if (data instanceof BigNumber)
11706
11704
  return new TextEncoder().encode(data._hex || data.toHexString());
11707
11705
  // returns the string as a UintArray
11708
- if (typeof data === "string")
11706
+ if (typeof data === 'string')
11709
11707
  return new TextEncoder().encode(data);
11710
11708
  // returns the object as a UintArray
11711
- if (typeof data === "object")
11709
+ if (typeof data === 'object')
11712
11710
  return new TextEncoder().encode(JSON.stringify(data));
11713
11711
  // returns the number as a UintArray
11714
- if (typeof data === "number" || typeof data === "boolean")
11712
+ if (typeof data === 'number' || typeof data === 'boolean')
11715
11713
  return new TextEncoder().encode(data.toString());
11716
11714
  throw new Error(`unsuported type ${typeof data || data}`);
11717
11715
  };
@@ -11724,17 +11722,14 @@ const encode = (proto, input, compress) => {
11724
11722
  const data = input[token.key];
11725
11723
  if (!token.optional && data === undefined)
11726
11724
  throw new Error(`missing required property: ${token.key}`);
11727
- if ((token.type === "array" && token.minimumLength > data?.length) ||
11728
- (token.type === "object" &&
11729
- token.minimumLength > Object.keys(data).length))
11725
+ if ((token.type === 'array' && token.minimumLength > data?.length) ||
11726
+ (token.type === 'object' && token.minimumLength > Object.keys(data).length))
11730
11727
  throw new Error(`minimumLength for ${token.key} is set to ${token.minimumLength} but got ${data.length}`);
11731
11728
  // always push data to the set.
11732
11729
  // when data is undefined push the default value of the proto
11733
11730
  set.push(toType(data || values[i]));
11734
11731
  }
11735
- return compress
11736
- ? pako.deflate(index$5(set))
11737
- : index$5(set);
11732
+ return compress ? pako.deflate(index$5(set)) : index$5(set);
11738
11733
  };
11739
11734
  const decode = (proto, uint8Array, compressed) => {
11740
11735
  if (compressed)
@@ -11752,7 +11747,7 @@ const decode = (proto, uint8Array, compressed) => {
11752
11747
  else if (isString(token.type))
11753
11748
  output[token.key] = toString(deconcated[i]);
11754
11749
  else if (isBoolean(token.type))
11755
- output[token.key] = Boolean(new TextDecoder().decode(deconcated[i]));
11750
+ output[token.key] = new TextDecoder().decode(deconcated[i]) === 'true';
11756
11751
  else if (isNumber(token.type))
11757
11752
  output[token.key] = Number(new TextDecoder().decode(deconcated[i]));
11758
11753
  else if (isBigNumber(token.type))
@@ -11770,15 +11765,19 @@ const decode = (proto, uint8Array, compressed) => {
11770
11765
  };
11771
11766
  var index = {
11772
11767
  encode,
11773
- decode,
11768
+ decode
11774
11769
  };
11775
11770
 
11776
11771
  class BasicInterface {
11777
11772
  #encoded;
11778
11773
  #decoded;
11779
- keys;
11780
11774
  name;
11781
11775
  #proto;
11776
+ get keys() {
11777
+ // handles proto keys
11778
+ // protokey -> key
11779
+ return Object.keys(this.#proto).map((key) => (key.endsWith('?') ? key.split('?')[0] : key));
11780
+ }
11782
11781
  get encoded() {
11783
11782
  if (!this.#encoded)
11784
11783
  this.#encoded = this.encode();
@@ -11797,7 +11796,6 @@ class BasicInterface {
11797
11796
  }
11798
11797
  set proto(value) {
11799
11798
  this.#proto = value;
11800
- this.keys = Object.keys(value);
11801
11799
  }
11802
11800
  get proto() {
11803
11801
  return this.#proto;
@@ -11843,7 +11841,7 @@ class BasicInterface {
11843
11841
  }
11844
11842
  fromString(string) {
11845
11843
  const array = string.split(',');
11846
- const arrayLike = array.map(string => Number(string));
11844
+ const arrayLike = array.map((string) => Number(string));
11847
11845
  return this.decode(Uint8Array.from(arrayLike));
11848
11846
  }
11849
11847
  fromHex(string) {
@@ -11863,7 +11861,10 @@ class BasicInterface {
11863
11861
  toHex() {
11864
11862
  if (!this.encoded)
11865
11863
  this.encode();
11866
- return toHex(this.encoded.toString().split(',').map(number => Number(number)));
11864
+ return toHex(this.encoded
11865
+ .toString()
11866
+ .split(',')
11867
+ .map((number) => Number(number)));
11867
11868
  }
11868
11869
  /**
11869
11870
  * @return {String} encoded
@@ -12322,7 +12323,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12322
12323
  this.fromUint8Array(buffer);
12323
12324
  else if (buffer instanceof ArrayBuffer)
12324
12325
  this.fromArrayBuffer(buffer);
12325
- else if (typeof buffer === "string") {
12326
+ else if (typeof buffer === 'string') {
12326
12327
  if (this.isHex(buffer))
12327
12328
  this.fromHex(buffer);
12328
12329
  else if (this.isBase58(buffer))
@@ -12388,7 +12389,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12388
12389
  constructor(buffer, proto, options) {
12389
12390
  super();
12390
12391
  this.proto = proto;
12391
- this.hashFormat = options?.hashFormat ? options.hashFormat : "bs32";
12392
+ this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
12392
12393
  if (options?.name)
12393
12394
  this.name = options.name;
12394
12395
  this.init(buffer);
@@ -12397,13 +12398,16 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12397
12398
  const upper = this.hashFormat.charAt(0).toUpperCase();
12398
12399
  return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
12399
12400
  }
12401
+ beforeHashing(decoded) {
12402
+ delete decoded.hash;
12403
+ return decoded;
12404
+ }
12400
12405
  /**
12401
12406
  * @return {PeernetHash}
12402
12407
  */
12403
12408
  get peernetHash() {
12404
- const decoded = this.decoded;
12409
+ const decoded = this.beforeHashing({ ...this.decoded });
12405
12410
  // @ts-ignore
12406
- delete decoded.hash;
12407
12411
  return new CodecHash(decoded, { name: this.name });
12408
12412
  }
12409
12413
  /**
@@ -12471,6 +12475,13 @@ class TransactionMessage extends FormatInterface {
12471
12475
  const name = 'transaction-message';
12472
12476
  super(buffer, proto$6, { name });
12473
12477
  }
12478
+ beforeHashing(decoded) {
12479
+ decoded = super.beforeHashing(decoded);
12480
+ delete decoded.signature;
12481
+ delete decoded.priority;
12482
+ delete decoded.dependsOn;
12483
+ return decoded;
12484
+ }
12474
12485
  }
12475
12486
 
12476
12487
  var proto$5 = {
@@ -1,5 +1,5 @@
1
- import { F as FormatInterface } from './node-browser-634c6b24.js';
2
- import './index-3e3995e1.js';
1
+ import { F as FormatInterface } from './node-browser-484d9d8b.js';
2
+ import './index-4420907d.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-3e3995e1.js';
1
+ import { C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-4420907d.js';
2
2
 
3
3
  var nodeConfig = async (config = {
4
4
  network: 'leofcoin:peach',
@@ -11853,9 +11853,13 @@ var index$2 = {
11853
11853
  class BasicInterface {
11854
11854
  #encoded;
11855
11855
  #decoded;
11856
- keys;
11857
11856
  name;
11858
11857
  #proto;
11858
+ get keys() {
11859
+ // handles proto keys
11860
+ // protokey -> key
11861
+ return Object.keys(this.#proto).map((key) => (key.endsWith('?') ? key.split('?')[0] : key));
11862
+ }
11859
11863
  get encoded() {
11860
11864
  if (!this.#encoded)
11861
11865
  this.#encoded = this.encode();
@@ -11874,7 +11878,6 @@ class BasicInterface {
11874
11878
  }
11875
11879
  set proto(value) {
11876
11880
  this.#proto = value;
11877
- this.keys = Object.keys(value);
11878
11881
  }
11879
11882
  get proto() {
11880
11883
  return this.#proto;
@@ -11920,7 +11923,7 @@ class BasicInterface {
11920
11923
  }
11921
11924
  fromString(string) {
11922
11925
  const array = string.split(',');
11923
- const arrayLike = array.map(string => Number(string));
11926
+ const arrayLike = array.map((string) => Number(string));
11924
11927
  return this.decode(Uint8Array.from(arrayLike));
11925
11928
  }
11926
11929
  fromHex(string) {
@@ -11940,7 +11943,10 @@ class BasicInterface {
11940
11943
  toHex() {
11941
11944
  if (!this.encoded)
11942
11945
  this.encode();
11943
- return toHex$2(this.encoded.toString().split(',').map(number => Number(number)));
11946
+ return toHex$2(this.encoded
11947
+ .toString()
11948
+ .split(',')
11949
+ .map((number) => Number(number)));
11944
11950
  }
11945
11951
  /**
11946
11952
  * @return {String} encoded
@@ -27163,7 +27169,7 @@ class Identity {
27163
27169
  this.selectedAccount = new TextDecoder().decode(selected);
27164
27170
  }
27165
27171
  else {
27166
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-5cd0a662-ec7ad917.js');
27172
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-3614702b-6244d21e.js');
27167
27173
  const { identity, accounts } = await importee.default(password, this.network);
27168
27174
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
27169
27175
  await globalThis.walletStore.put('version', String(1));
@@ -27355,7 +27361,7 @@ class Peernet {
27355
27361
  this.root = options.root;
27356
27362
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
27357
27363
  // FolderMessageResponse
27358
- } = await import(/* webpackChunkName: "messages" */ './messages-638774c5-3f49413d.js');
27364
+ } = await import(/* webpackChunkName: "messages" */ './messages-92c1c441-6c77c6bd.js');
27359
27365
  /**
27360
27366
  * proto Object containing protos
27361
27367
  * @type {Object}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-634c6b24.js';
2
- import './index-3e3995e1.js';
1
+ export { N as default } from './node-browser-484d9d8b.js';
2
+ import './index-4420907d.js';
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-49e99af0.js';
1
+ import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-b84221fa.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-49e99af0.js';
1
+ import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-b84221fa.js';
2
2
 
3
3
  var contractFactory = "237,198,141,3,53,89,84,113,122,51,88,88,85,49,74,65,100,88,82,119,109,84,82,115,85,109,71,57,117,104,104,77,75,88,52,121,117,109,53,122,112,55,66,107,80,120,120,83,68,66,116,65,122,81,67,122,118,52,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,122,51,88,88,85,49,74,65,100,88,82,119,109,84,82,115,85,109,71,57,117,104,104,77,75,88,52,121,117,109,53,122,112,55,66,107,80,120,120,83,68,66,116,65,122,81,67,122,118,52,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";
@@ -11605,25 +11605,23 @@ var pako = {
11605
11605
  };
11606
11606
 
11607
11607
  const { fromString, toString } = index$1;
11608
- const isJson = (type) => type === "object" || "array";
11609
- const isString = (type) => type === "string";
11610
- const isNumber = (type) => type === "number";
11611
- const isBoolean = (type) => type === "boolean";
11612
- const isUint8Array = (type) => type === "uint8Array";
11613
- const isBigNumber = (type) => type === "bigNumber";
11608
+ const isJson = (type) => type === 'object' || 'array';
11609
+ const isString = (type) => type === 'string';
11610
+ const isNumber = (type) => type === 'number';
11611
+ const isBoolean = (type) => type === 'boolean';
11612
+ const isUint8Array = (type) => type === 'uint8Array';
11613
+ const isBigNumber = (type) => type === 'bigNumber';
11614
11614
  const tokenize = (key, value) => {
11615
- const optional = key.endsWith("?");
11615
+ const optional = key.endsWith('?');
11616
11616
  let type = value === undefined ? key : value;
11617
11617
  if (type instanceof Uint8Array)
11618
- type = "uint8Array";
11618
+ type = 'uint8Array';
11619
11619
  else if (type instanceof BigNumber)
11620
- type = "bigNumber";
11620
+ type = 'bigNumber';
11621
11621
  else
11622
- type = Array.isArray(type) ? "array" : typeof type;
11623
- const parts = key.split("?");
11624
- const minimumLength = parts[2]?.includes("min")
11625
- ? parts[2].split["min:"][1]
11626
- : 0;
11622
+ type = Array.isArray(type) ? 'array' : typeof type;
11623
+ const parts = key.split('?');
11624
+ const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
11627
11625
  return { type, optional, key: parts[0], minimumLength };
11628
11626
  };
11629
11627
  const toType = (data) => {
@@ -11637,13 +11635,13 @@ const toType = (data) => {
11637
11635
  if (data instanceof BigNumber)
11638
11636
  return new TextEncoder().encode(data._hex || data.toHexString());
11639
11637
  // returns the string as a UintArray
11640
- if (typeof data === "string")
11638
+ if (typeof data === 'string')
11641
11639
  return new TextEncoder().encode(data);
11642
11640
  // returns the object as a UintArray
11643
- if (typeof data === "object")
11641
+ if (typeof data === 'object')
11644
11642
  return new TextEncoder().encode(JSON.stringify(data));
11645
11643
  // returns the number as a UintArray
11646
- if (typeof data === "number" || typeof data === "boolean")
11644
+ if (typeof data === 'number' || typeof data === 'boolean')
11647
11645
  return new TextEncoder().encode(data.toString());
11648
11646
  throw new Error(`unsuported type ${typeof data || data}`);
11649
11647
  };
@@ -11656,17 +11654,14 @@ const encode = (proto, input, compress) => {
11656
11654
  const data = input[token.key];
11657
11655
  if (!token.optional && data === undefined)
11658
11656
  throw new Error(`missing required property: ${token.key}`);
11659
- if ((token.type === "array" && token.minimumLength > data?.length) ||
11660
- (token.type === "object" &&
11661
- token.minimumLength > Object.keys(data).length))
11657
+ if ((token.type === 'array' && token.minimumLength > data?.length) ||
11658
+ (token.type === 'object' && token.minimumLength > Object.keys(data).length))
11662
11659
  throw new Error(`minimumLength for ${token.key} is set to ${token.minimumLength} but got ${data.length}`);
11663
11660
  // always push data to the set.
11664
11661
  // when data is undefined push the default value of the proto
11665
11662
  set.push(toType(data || values[i]));
11666
11663
  }
11667
- return compress
11668
- ? pako.deflate(index$5(set))
11669
- : index$5(set);
11664
+ return compress ? pako.deflate(index$5(set)) : index$5(set);
11670
11665
  };
11671
11666
  const decode = (proto, uint8Array, compressed) => {
11672
11667
  if (compressed)
@@ -11684,7 +11679,7 @@ const decode = (proto, uint8Array, compressed) => {
11684
11679
  else if (isString(token.type))
11685
11680
  output[token.key] = toString(deconcated[i]);
11686
11681
  else if (isBoolean(token.type))
11687
- output[token.key] = Boolean(new TextDecoder().decode(deconcated[i]));
11682
+ output[token.key] = new TextDecoder().decode(deconcated[i]) === 'true';
11688
11683
  else if (isNumber(token.type))
11689
11684
  output[token.key] = Number(new TextDecoder().decode(deconcated[i]));
11690
11685
  else if (isBigNumber(token.type))
@@ -11702,15 +11697,19 @@ const decode = (proto, uint8Array, compressed) => {
11702
11697
  };
11703
11698
  var index = {
11704
11699
  encode,
11705
- decode,
11700
+ decode
11706
11701
  };
11707
11702
 
11708
11703
  class BasicInterface {
11709
11704
  #encoded;
11710
11705
  #decoded;
11711
- keys;
11712
11706
  name;
11713
11707
  #proto;
11708
+ get keys() {
11709
+ // handles proto keys
11710
+ // protokey -> key
11711
+ return Object.keys(this.#proto).map((key) => (key.endsWith('?') ? key.split('?')[0] : key));
11712
+ }
11714
11713
  get encoded() {
11715
11714
  if (!this.#encoded)
11716
11715
  this.#encoded = this.encode();
@@ -11729,7 +11728,6 @@ class BasicInterface {
11729
11728
  }
11730
11729
  set proto(value) {
11731
11730
  this.#proto = value;
11732
- this.keys = Object.keys(value);
11733
11731
  }
11734
11732
  get proto() {
11735
11733
  return this.#proto;
@@ -11775,7 +11773,7 @@ class BasicInterface {
11775
11773
  }
11776
11774
  fromString(string) {
11777
11775
  const array = string.split(',');
11778
- const arrayLike = array.map(string => Number(string));
11776
+ const arrayLike = array.map((string) => Number(string));
11779
11777
  return this.decode(Uint8Array.from(arrayLike));
11780
11778
  }
11781
11779
  fromHex(string) {
@@ -11795,7 +11793,10 @@ class BasicInterface {
11795
11793
  toHex() {
11796
11794
  if (!this.encoded)
11797
11795
  this.encode();
11798
- return toHex(this.encoded.toString().split(',').map(number => Number(number)));
11796
+ return toHex(this.encoded
11797
+ .toString()
11798
+ .split(',')
11799
+ .map((number) => Number(number)));
11799
11800
  }
11800
11801
  /**
11801
11802
  * @return {String} encoded
@@ -12254,7 +12255,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12254
12255
  this.fromUint8Array(buffer);
12255
12256
  else if (buffer instanceof ArrayBuffer)
12256
12257
  this.fromArrayBuffer(buffer);
12257
- else if (typeof buffer === "string") {
12258
+ else if (typeof buffer === 'string') {
12258
12259
  if (this.isHex(buffer))
12259
12260
  this.fromHex(buffer);
12260
12261
  else if (this.isBase58(buffer))
@@ -12320,7 +12321,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12320
12321
  constructor(buffer, proto, options) {
12321
12322
  super();
12322
12323
  this.proto = proto;
12323
- this.hashFormat = options?.hashFormat ? options.hashFormat : "bs32";
12324
+ this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
12324
12325
  if (options?.name)
12325
12326
  this.name = options.name;
12326
12327
  this.init(buffer);
@@ -12329,13 +12330,16 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12329
12330
  const upper = this.hashFormat.charAt(0).toUpperCase();
12330
12331
  return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
12331
12332
  }
12333
+ beforeHashing(decoded) {
12334
+ delete decoded.hash;
12335
+ return decoded;
12336
+ }
12332
12337
  /**
12333
12338
  * @return {PeernetHash}
12334
12339
  */
12335
12340
  get peernetHash() {
12336
- const decoded = this.decoded;
12341
+ const decoded = this.beforeHashing({ ...this.decoded });
12337
12342
  // @ts-ignore
12338
- delete decoded.hash;
12339
12343
  return new CodecHash(decoded, { name: this.name });
12340
12344
  }
12341
12345
  /**
@@ -12403,6 +12407,13 @@ class TransactionMessage extends FormatInterface {
12403
12407
  const name = 'transaction-message';
12404
12408
  super(buffer, proto$3, { name });
12405
12409
  }
12410
+ beforeHashing(decoded) {
12411
+ decoded = super.beforeHashing(decoded);
12412
+ delete decoded.signature;
12413
+ delete decoded.priority;
12414
+ delete decoded.dependsOn;
12415
+ return decoded;
12416
+ }
12406
12417
  }
12407
12418
 
12408
12419
  var proto$2 = {
package/exports/chain.js CHANGED
@@ -974,7 +974,7 @@ class State extends Contract {
974
974
  #loadBlockTransactions;
975
975
  #getLastTransactions;
976
976
  // todo throw error
977
- async #executeTransaction(transaction) {
977
+ async #_executeTransaction(transaction) {
978
978
  try {
979
979
  await this.#machine.execute(transaction.decoded.to, transaction.decoded.method, transaction.decoded.params);
980
980
  await globalThis.accountsStore.put(transaction.decoded.from, String(transaction.decoded.nonce));
@@ -1020,24 +1020,26 @@ class State extends Contract {
1020
1020
  let priority = [];
1021
1021
  for (const transaction of transactions) {
1022
1022
  const hash = await transaction.hash();
1023
- if (transaction.decoded.priority)
1024
- priority.push(transaction);
1025
- if (poolTransactionKeys.includes(hash))
1026
- await globalThis.transactionPoolStore.delete(hash);
1027
1023
  if (lastTransactions.includes(hash)) {
1028
1024
  console.log('removing invalid block');
1029
1025
  await globalThis.blockStore.delete(await (await new BlockMessage(block)).hash());
1030
1026
  blocks.splice(block.index - 1, 1);
1031
1027
  return this.#loadBlocks(blocks);
1032
1028
  }
1029
+ if (transaction.decoded.priority)
1030
+ priority.push(transaction);
1031
+ if (poolTransactionKeys.includes(hash))
1032
+ await globalThis.transactionPoolStore.delete(hash);
1033
1033
  }
1034
+ // prority blocks execution from the rest so result in higher fees.
1034
1035
  if (priority.length > 0) {
1035
1036
  priority = priority.sort((a, b) => a.nonce - b.nonce);
1036
1037
  for (const transaction of priority) {
1037
- await this.#executeTransaction(transaction);
1038
+ await this.#_executeTransaction(transaction);
1038
1039
  }
1039
1040
  }
1040
- transactions = transactions.filter((transaction) => !transaction.priority);
1041
+ transactions = transactions.filter((transaction) => !transaction.decoded.priority);
1042
+ await Promise.all(transactions.map((transaction) => this.#_executeTransaction(transaction)));
1041
1043
  this.#blocks[block.index - 1].loaded = true;
1042
1044
  // @ts-ignore
1043
1045
  globalThis.debug(`loaded block: ${block.hash} @${block.index}`);
@@ -1288,10 +1290,8 @@ class Chain extends VersionControl {
1288
1290
  if (!peer.version || peer.version !== this.version)
1289
1291
  return;
1290
1292
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
1291
- console.log(lastBlock);
1292
1293
  const higherThenCurrentLocal = !this.lastBlock?.index ? true : lastBlock.index > this.lastBlock?.index;
1293
1294
  const peerTransactionPool = (higherThenCurrentLocal && (await this.getPeerTransactionPool(peer))) || [];
1294
- console.log(this.lastBlock);
1295
1295
  if (Object.keys(lastBlock).length > 0) {
1296
1296
  if (!this.lastBlock || higherThenCurrentLocal) {
1297
1297
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
@@ -1,4 +1,4 @@
1
- import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-49e99af0.js';
1
+ import { E as EasyWorker, B as BigNumber, a as BlockMessage, f as formatBytes } from './worker-b84221fa.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-49e99af0.js';
1
+ import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-b84221fa.js';
2
2
 
3
3
  var contractFactory = "237,198,141,3,53,89,84,113,122,51,88,88,85,49,74,65,100,88,82,119,109,84,82,115,85,109,71,57,117,104,104,77,75,88,52,121,117,109,53,122,112,55,66,107,80,120,120,83,68,66,116,65,122,81,67,122,118,52,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,122,51,88,88,85,49,74,65,100,88,82,119,109,84,82,115,85,109,71,57,117,104,104,77,75,88,52,121,117,109,53,122,112,55,66,107,80,120,120,83,68,66,116,65,122,81,67,122,118,52,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";
@@ -11605,25 +11605,23 @@ var pako = {
11605
11605
  };
11606
11606
 
11607
11607
  const { fromString, toString } = index$1;
11608
- const isJson = (type) => type === "object" || "array";
11609
- const isString = (type) => type === "string";
11610
- const isNumber = (type) => type === "number";
11611
- const isBoolean = (type) => type === "boolean";
11612
- const isUint8Array = (type) => type === "uint8Array";
11613
- const isBigNumber = (type) => type === "bigNumber";
11608
+ const isJson = (type) => type === 'object' || 'array';
11609
+ const isString = (type) => type === 'string';
11610
+ const isNumber = (type) => type === 'number';
11611
+ const isBoolean = (type) => type === 'boolean';
11612
+ const isUint8Array = (type) => type === 'uint8Array';
11613
+ const isBigNumber = (type) => type === 'bigNumber';
11614
11614
  const tokenize = (key, value) => {
11615
- const optional = key.endsWith("?");
11615
+ const optional = key.endsWith('?');
11616
11616
  let type = value === undefined ? key : value;
11617
11617
  if (type instanceof Uint8Array)
11618
- type = "uint8Array";
11618
+ type = 'uint8Array';
11619
11619
  else if (type instanceof BigNumber)
11620
- type = "bigNumber";
11620
+ type = 'bigNumber';
11621
11621
  else
11622
- type = Array.isArray(type) ? "array" : typeof type;
11623
- const parts = key.split("?");
11624
- const minimumLength = parts[2]?.includes("min")
11625
- ? parts[2].split["min:"][1]
11626
- : 0;
11622
+ type = Array.isArray(type) ? 'array' : typeof type;
11623
+ const parts = key.split('?');
11624
+ const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
11627
11625
  return { type, optional, key: parts[0], minimumLength };
11628
11626
  };
11629
11627
  const toType = (data) => {
@@ -11637,13 +11635,13 @@ const toType = (data) => {
11637
11635
  if (data instanceof BigNumber)
11638
11636
  return new TextEncoder().encode(data._hex || data.toHexString());
11639
11637
  // returns the string as a UintArray
11640
- if (typeof data === "string")
11638
+ if (typeof data === 'string')
11641
11639
  return new TextEncoder().encode(data);
11642
11640
  // returns the object as a UintArray
11643
- if (typeof data === "object")
11641
+ if (typeof data === 'object')
11644
11642
  return new TextEncoder().encode(JSON.stringify(data));
11645
11643
  // returns the number as a UintArray
11646
- if (typeof data === "number" || typeof data === "boolean")
11644
+ if (typeof data === 'number' || typeof data === 'boolean')
11647
11645
  return new TextEncoder().encode(data.toString());
11648
11646
  throw new Error(`unsuported type ${typeof data || data}`);
11649
11647
  };
@@ -11656,17 +11654,14 @@ const encode = (proto, input, compress) => {
11656
11654
  const data = input[token.key];
11657
11655
  if (!token.optional && data === undefined)
11658
11656
  throw new Error(`missing required property: ${token.key}`);
11659
- if ((token.type === "array" && token.minimumLength > data?.length) ||
11660
- (token.type === "object" &&
11661
- token.minimumLength > Object.keys(data).length))
11657
+ if ((token.type === 'array' && token.minimumLength > data?.length) ||
11658
+ (token.type === 'object' && token.minimumLength > Object.keys(data).length))
11662
11659
  throw new Error(`minimumLength for ${token.key} is set to ${token.minimumLength} but got ${data.length}`);
11663
11660
  // always push data to the set.
11664
11661
  // when data is undefined push the default value of the proto
11665
11662
  set.push(toType(data || values[i]));
11666
11663
  }
11667
- return compress
11668
- ? pako.deflate(index$5(set))
11669
- : index$5(set);
11664
+ return compress ? pako.deflate(index$5(set)) : index$5(set);
11670
11665
  };
11671
11666
  const decode = (proto, uint8Array, compressed) => {
11672
11667
  if (compressed)
@@ -11684,7 +11679,7 @@ const decode = (proto, uint8Array, compressed) => {
11684
11679
  else if (isString(token.type))
11685
11680
  output[token.key] = toString(deconcated[i]);
11686
11681
  else if (isBoolean(token.type))
11687
- output[token.key] = Boolean(new TextDecoder().decode(deconcated[i]));
11682
+ output[token.key] = new TextDecoder().decode(deconcated[i]) === 'true';
11688
11683
  else if (isNumber(token.type))
11689
11684
  output[token.key] = Number(new TextDecoder().decode(deconcated[i]));
11690
11685
  else if (isBigNumber(token.type))
@@ -11702,15 +11697,19 @@ const decode = (proto, uint8Array, compressed) => {
11702
11697
  };
11703
11698
  var index = {
11704
11699
  encode,
11705
- decode,
11700
+ decode
11706
11701
  };
11707
11702
 
11708
11703
  class BasicInterface {
11709
11704
  #encoded;
11710
11705
  #decoded;
11711
- keys;
11712
11706
  name;
11713
11707
  #proto;
11708
+ get keys() {
11709
+ // handles proto keys
11710
+ // protokey -> key
11711
+ return Object.keys(this.#proto).map((key) => (key.endsWith('?') ? key.split('?')[0] : key));
11712
+ }
11714
11713
  get encoded() {
11715
11714
  if (!this.#encoded)
11716
11715
  this.#encoded = this.encode();
@@ -11729,7 +11728,6 @@ class BasicInterface {
11729
11728
  }
11730
11729
  set proto(value) {
11731
11730
  this.#proto = value;
11732
- this.keys = Object.keys(value);
11733
11731
  }
11734
11732
  get proto() {
11735
11733
  return this.#proto;
@@ -11775,7 +11773,7 @@ class BasicInterface {
11775
11773
  }
11776
11774
  fromString(string) {
11777
11775
  const array = string.split(',');
11778
- const arrayLike = array.map(string => Number(string));
11776
+ const arrayLike = array.map((string) => Number(string));
11779
11777
  return this.decode(Uint8Array.from(arrayLike));
11780
11778
  }
11781
11779
  fromHex(string) {
@@ -11795,7 +11793,10 @@ class BasicInterface {
11795
11793
  toHex() {
11796
11794
  if (!this.encoded)
11797
11795
  this.encode();
11798
- return toHex(this.encoded.toString().split(',').map(number => Number(number)));
11796
+ return toHex(this.encoded
11797
+ .toString()
11798
+ .split(',')
11799
+ .map((number) => Number(number)));
11799
11800
  }
11800
11801
  /**
11801
11802
  * @return {String} encoded
@@ -12254,7 +12255,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12254
12255
  this.fromUint8Array(buffer);
12255
12256
  else if (buffer instanceof ArrayBuffer)
12256
12257
  this.fromArrayBuffer(buffer);
12257
- else if (typeof buffer === "string") {
12258
+ else if (typeof buffer === 'string') {
12258
12259
  if (this.isHex(buffer))
12259
12260
  this.fromHex(buffer);
12260
12261
  else if (this.isBase58(buffer))
@@ -12320,7 +12321,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12320
12321
  constructor(buffer, proto, options) {
12321
12322
  super();
12322
12323
  this.proto = proto;
12323
- this.hashFormat = options?.hashFormat ? options.hashFormat : "bs32";
12324
+ this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
12324
12325
  if (options?.name)
12325
12326
  this.name = options.name;
12326
12327
  this.init(buffer);
@@ -12329,13 +12330,16 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12329
12330
  const upper = this.hashFormat.charAt(0).toUpperCase();
12330
12331
  return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
12331
12332
  }
12333
+ beforeHashing(decoded) {
12334
+ delete decoded.hash;
12335
+ return decoded;
12336
+ }
12332
12337
  /**
12333
12338
  * @return {PeernetHash}
12334
12339
  */
12335
12340
  get peernetHash() {
12336
- const decoded = this.decoded;
12341
+ const decoded = this.beforeHashing({ ...this.decoded });
12337
12342
  // @ts-ignore
12338
- delete decoded.hash;
12339
12343
  return new CodecHash(decoded, { name: this.name });
12340
12344
  }
12341
12345
  /**
@@ -12403,6 +12407,13 @@ class TransactionMessage extends FormatInterface {
12403
12407
  const name = 'transaction-message';
12404
12408
  super(buffer, proto$3, { name });
12405
12409
  }
12410
+ beforeHashing(decoded) {
12411
+ decoded = super.beforeHashing(decoded);
12412
+ delete decoded.signature;
12413
+ delete decoded.priority;
12414
+ delete decoded.dependsOn;
12415
+ return decoded;
12416
+ }
12406
12417
  }
12407
12418
 
12408
12419
  var proto$2 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.33",
3
+ "version": "1.5.34",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "np": "np",
31
- "watch": "rollup -c -w",
31
+ "watch": "rollup -c -w --silent error --cache true",
32
32
  "lint": "eslint src --fix",
33
33
  "prettier": "prettier src --config ./../../.prettierrc --write",
34
34
  "w": "rollup -c -w",