@leofcoin/chain 1.4.90 → 1.4.91

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.
@@ -2219,7 +2219,7 @@ class State extends Contract {
2219
2219
  #loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
2220
2220
  #getLastTransactions = async () => {
2221
2221
  let lastTransactions = (await Promise.all(this.#blocks.filter(block => block.loaded).slice(-128)
2222
- .map(block => this.#loadBlockTransactions(block))))
2222
+ .map(block => this.#loadBlockTransactions(block.transactions))))
2223
2223
  .reduce((all, transactions) => [...all, ...transactions], []);
2224
2224
  return Promise.all(lastTransactions.map(transaction => transaction.hash()));
2225
2225
  };
@@ -2233,8 +2233,8 @@ class State extends Contract {
2233
2233
  if (block && !block.loaded) {
2234
2234
  if (block.index === 0)
2235
2235
  this.#loaded = true;
2236
- block.transactions = await this.#loadBlockTransactions(block.transactions);
2237
- for (const transaction of block.transactions) {
2236
+ const transactions = await this.#loadBlockTransactions([...block.transactions] || []);
2237
+ for (const transaction of transactions) {
2238
2238
  const lastTransactions = await this.#getLastTransactions();
2239
2239
  const hash = await transaction.hash();
2240
2240
  if (poolTransactionKeys.includes(hash))
@@ -2245,20 +2245,21 @@ class State extends Contract {
2245
2245
  return this.#loadBlocks(blocks);
2246
2246
  }
2247
2247
  try {
2248
- await this.#machine.execute(transaction.to, transaction.method, transaction.params);
2249
- if (transaction.to === nativeToken$2) {
2248
+ await this.#machine.execute(transaction.decoded.to, transaction.decoded.method, transaction.decoded.params);
2249
+ if (transaction.decoded.to === nativeToken$2) {
2250
2250
  this.#nativeCalls += 1;
2251
- if (transaction.method === 'burn')
2251
+ if (transaction.decoded.method === 'burn')
2252
2252
  this.#nativeBurns += 1;
2253
- if (transaction.method === 'mint')
2253
+ if (transaction.decoded.method === 'mint')
2254
2254
  this.#nativeMints += 1;
2255
- if (transaction.method === 'transfer')
2255
+ if (transaction.decoded.method === 'transfer')
2256
2256
  this.#nativeTransfers += 1;
2257
2257
  }
2258
2258
  this.#totalTransactions += 1;
2259
2259
  }
2260
2260
  catch (error) {
2261
- await globalThis.transactionPoolStore.delete(transaction.hash ? transaction.hash : await (new TransactionMessage(transaction)).hash());
2261
+ console.log(error);
2262
+ await globalThis.transactionPoolStore.delete(hash);
2262
2263
  console.log('removing invalid transaction');
2263
2264
  console.log(error);
2264
2265
  return false;
@@ -2282,7 +2283,6 @@ class State extends Contract {
2282
2283
  clearTimeout(timeout);
2283
2284
  if (promises.length > 0) {
2284
2285
  promises = promises.map(async ({ value }) => {
2285
- console.log(value);
2286
2286
  const node = await new globalThis.peernet.protos['peernet-response'](value.result);
2287
2287
  return { value: node.decoded.response, peer: value.peer };
2288
2288
  });
@@ -2685,7 +2685,6 @@ class Chain extends State {
2685
2685
  // block.reward = block.reward.toString()
2686
2686
  // block.fees = block.fees.toString()
2687
2687
  try {
2688
- console.log(block.transactions);
2689
2688
  block.transactions = await Promise.all(block.transactions
2690
2689
  .map(async (transaction) => {
2691
2690
  await globalThis.transactionPoolStore.delete(await transaction.hash());
package/exports/chain.js CHANGED
@@ -839,7 +839,7 @@ class State extends Contract {
839
839
  #loadBlockTransactions = (transactions) => Promise.all(transactions.map((transaction) => new TransactionMessage(transaction)));
840
840
  #getLastTransactions = async () => {
841
841
  let lastTransactions = (await Promise.all(this.#blocks.filter(block => block.loaded).slice(-128)
842
- .map(block => this.#loadBlockTransactions(block))))
842
+ .map(block => this.#loadBlockTransactions(block.transactions))))
843
843
  .reduce((all, transactions) => [...all, ...transactions], []);
844
844
  return Promise.all(lastTransactions.map(transaction => transaction.hash()));
845
845
  };
@@ -853,8 +853,8 @@ class State extends Contract {
853
853
  if (block && !block.loaded) {
854
854
  if (block.index === 0)
855
855
  this.#loaded = true;
856
- block.transactions = await this.#loadBlockTransactions(block.transactions);
857
- for (const transaction of block.transactions) {
856
+ const transactions = await this.#loadBlockTransactions([...block.transactions] || []);
857
+ for (const transaction of transactions) {
858
858
  const lastTransactions = await this.#getLastTransactions();
859
859
  const hash = await transaction.hash();
860
860
  if (poolTransactionKeys.includes(hash))
@@ -865,20 +865,21 @@ class State extends Contract {
865
865
  return this.#loadBlocks(blocks);
866
866
  }
867
867
  try {
868
- await this.#machine.execute(transaction.to, transaction.method, transaction.params);
869
- if (transaction.to === nativeToken) {
868
+ await this.#machine.execute(transaction.decoded.to, transaction.decoded.method, transaction.decoded.params);
869
+ if (transaction.decoded.to === nativeToken) {
870
870
  this.#nativeCalls += 1;
871
- if (transaction.method === 'burn')
871
+ if (transaction.decoded.method === 'burn')
872
872
  this.#nativeBurns += 1;
873
- if (transaction.method === 'mint')
873
+ if (transaction.decoded.method === 'mint')
874
874
  this.#nativeMints += 1;
875
- if (transaction.method === 'transfer')
875
+ if (transaction.decoded.method === 'transfer')
876
876
  this.#nativeTransfers += 1;
877
877
  }
878
878
  this.#totalTransactions += 1;
879
879
  }
880
880
  catch (error) {
881
- await globalThis.transactionPoolStore.delete(transaction.hash ? transaction.hash : await (new TransactionMessage(transaction)).hash());
881
+ console.log(error);
882
+ await globalThis.transactionPoolStore.delete(hash);
882
883
  console.log('removing invalid transaction');
883
884
  console.log(error);
884
885
  return false;
@@ -902,7 +903,6 @@ class State extends Contract {
902
903
  clearTimeout(timeout);
903
904
  if (promises.length > 0) {
904
905
  promises = promises.map(async ({ value }) => {
905
- console.log(value);
906
906
  const node = await new globalThis.peernet.protos['peernet-response'](value.result);
907
907
  return { value: node.decoded.response, peer: value.peer };
908
908
  });
@@ -1305,7 +1305,6 @@ class Chain extends State {
1305
1305
  // block.reward = block.reward.toString()
1306
1306
  // block.fees = block.fees.toString()
1307
1307
  try {
1308
- console.log(block.transactions);
1309
1308
  block.transactions = await Promise.all(block.transactions
1310
1309
  .map(async (transaction) => {
1311
1310
  await globalThis.transactionPoolStore.delete(await transaction.hash());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.4.90",
3
+ "version": "1.4.91",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": "./exports/node.js",