@leofcoin/chain 1.5.15 → 1.5.17

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,23 +1,23 @@
1
- import { C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-e8f03811.js';
1
+ import { C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index-5e385ee1.js';
2
2
 
3
3
  var nodeConfig = async (config = {
4
4
  network: 'leofcoin:peach',
5
5
  networkName: 'leofcoin:peach',
6
6
  networkVersion: 'v1.0.0'
7
7
  }) => {
8
- await globalThis.peernet.addProto('contract-message', ContractMessage);
9
- await globalThis.peernet.addProto('transaction-message', TransactionMessage);
10
- await globalThis.peernet.addProto('block-message', BlockMessage);
11
- await globalThis.peernet.addProto('bw-message', BWMessage);
12
- await globalThis.peernet.addProto('bw-request-message', BWRequestMessage);
13
- await globalThis.peernet.addProto('validator-message', ValidatorMessage);
8
+ await peernet.addProto('contract-message', ContractMessage);
9
+ await peernet.addProto('transaction-message', TransactionMessage);
10
+ await peernet.addProto('block-message', BlockMessage);
11
+ await peernet.addProto('bw-message', BWMessage);
12
+ await peernet.addProto('bw-request-message', BWRequestMessage);
13
+ await peernet.addProto('validator-message', ValidatorMessage);
14
14
  let name = `.${config.network}`;
15
15
  const parts = config.network.split(':');
16
16
  if (parts[1])
17
17
  name = `.${parts[0]}/${parts[1]}`;
18
- await globalThis.peernet.addStore('contract', 'lfc', name, false);
19
- await globalThis.peernet.addStore('accounts', 'lfc', name, false);
20
- await globalThis.peernet.addStore('transactionPool', 'lfc', name, false);
18
+ await peernet.addStore('contract', 'lfc', name, false);
19
+ await peernet.addStore('accounts', 'lfc', name, false);
20
+ await peernet.addStore('transactionPool', 'lfc', name, false);
21
21
  };
22
22
 
23
23
  const encode$9 = (string) => {
@@ -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-71fa9c50.js');
20219
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-329e0324-e2a4f639.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-88d5e15b.js');
20410
+ } = await import(/* webpackChunkName: "messages" */ './messages-000b7f84-ef0adf20.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-af58f01b.js';
2
- import './index-e8f03811.js';
1
+ export { N as default } from './node-browser-01f26631.js';
2
+ import './index-5e385ee1.js';
@@ -5931,21 +5931,21 @@ class BlockMessage extends FormatInterface {
5931
5931
  const name = 'block-message';
5932
5932
  super(buffer, proto, { name });
5933
5933
  }
5934
- encode() {
5935
- const decoded = this.decoded;
5934
+ encode(decoded) {
5935
+ decoded = decoded || this.decoded;
5936
5936
  const validators = [];
5937
5937
  const transactions = [];
5938
5938
  for (const validator of decoded.validators) {
5939
5939
  if (validator instanceof ValidatorMessage)
5940
- validators.push(validator.encoded);
5940
+ validators.push(validator.encode());
5941
5941
  else
5942
- validators.push(new ValidatorMessage(validator).encoded);
5942
+ validators.push(new ValidatorMessage(validator).encode());
5943
5943
  }
5944
5944
  for (const transaction of decoded.transactions) {
5945
5945
  if (transaction instanceof TransactionMessage)
5946
- transactions.push(transaction.encoded);
5946
+ transactions.push(transaction.encode());
5947
5947
  else
5948
- transactions.push(new TransactionMessage(transaction).encoded);
5948
+ transactions.push(new TransactionMessage(transaction).encode());
5949
5949
  }
5950
5950
  return super.encode({
5951
5951
  ...decoded,
@@ -5953,8 +5953,9 @@ class BlockMessage extends FormatInterface {
5953
5953
  transactions: index$5(transactions)
5954
5954
  });
5955
5955
  }
5956
- decode() {
5957
- super.decode();
5956
+ decode(encoded) {
5957
+ encoded = encoded || this.encoded;
5958
+ super.decode(encoded);
5958
5959
  // @ts-ignore
5959
5960
  this.decoded.transactions = index$4(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
5960
5961
  // @ts-ignore
@@ -6056,28 +6057,28 @@ class EasyWorker {
6056
6057
  }
6057
6058
  }
6058
6059
 
6059
- const worker = new EasyWorker();
6060
-
6061
- globalThis.BigNumber = BigNumber;
6062
- globalThis.contracts = {};
6063
-
6064
- const run = async (blocks) => {
6065
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
6066
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
6067
-
6068
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
6069
- // todo: tx worker or nah?
6070
- const size = block.encoded.length || block.encoded.byteLength;
6071
- console.log(`loaded block: ${await block.hash()} @${block.decoded.index} ${formatBytes(size)}`);
6072
- resolve(block);
6073
- })));
6074
- return blocks
6075
- };
6076
-
6077
- const tasks = async blocks => {
6078
- blocks = await run(blocks);
6079
- worker.postMessage(blocks);
6080
- };
6081
-
6082
-
6060
+ const worker = new EasyWorker();
6061
+
6062
+ globalThis.BigNumber = BigNumber;
6063
+ globalThis.contracts = {};
6064
+
6065
+ const run = async (blocks) => {
6066
+ blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
6067
+ blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
6068
+
6069
+ blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
6070
+ // todo: tx worker or nah?
6071
+ const size = block.encoded.length || block.encoded.byteLength;
6072
+ console.log(`loaded block: ${await block.hash()} @${block.decoded.index} ${formatBytes(size)}`);
6073
+ resolve(block);
6074
+ })));
6075
+ return blocks
6076
+ };
6077
+
6078
+ const tasks = async blocks => {
6079
+ blocks = await run(blocks);
6080
+ worker.postMessage(blocks);
6081
+ };
6082
+
6083
+
6083
6084
  worker.onmessage(data => tasks(data));