@leofcoin/chain 1.6.2 → 1.6.4

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.
@@ -4467,7 +4467,7 @@ class State extends Contract {
4467
4467
  if (block !== undefined) {
4468
4468
  block = await new BlockMessage(block);
4469
4469
  const { index } = block.decoded;
4470
- if (this.#blocks[index - 1] && this.#blocks[index - 1].hash !== block.hash)
4470
+ if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
4471
4471
  throw `invalid block ${hash} @${index}`;
4472
4472
  if (!(await globalThis.peernet.has(hash)))
4473
4473
  await globalThis.peernet.put(hash, block.encoded, 'block');
@@ -4881,9 +4881,9 @@ class Chain extends VersionControl {
4881
4881
  this.#jail = [];
4882
4882
  this.#addTransaction = async (message) => {
4883
4883
  const transaction = new TransactionMessage(message);
4884
- await transaction.hash();
4884
+ const hash = await transaction.hash();
4885
4885
  // if (await transactionPoolStore.has(hash)) await transactionPoolStore.delete(hash)
4886
- debug(`added ${transaction}`);
4886
+ debug(`added ${hash}`);
4887
4887
  };
4888
4888
  // @ts-ignore
4889
4889
  return this.#init();
@@ -1,5 +1,4 @@
1
1
  import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-CFrwP8cD.js';
2
- import { randomUUID } from 'crypto';
3
2
 
4
3
  const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
5
4
  const formatBytes = (bytes, decimals = 2) => {
@@ -363,7 +362,7 @@ _.loadBlock = (block) => {
363
362
 
364
363
  const askFor = (question, input) =>
365
364
  new Promise((resolve) => {
366
- const id = randomUUID();
365
+ const id = globalThis.crypto.randomUUID();
367
366
  pubsub.subscribe(id, resolve);
368
367
  worker.postMessage({
369
368
  type: 'ask',
package/exports/chain.js CHANGED
@@ -835,7 +835,7 @@ class State extends Contract {
835
835
  if (block !== undefined) {
836
836
  block = await new BlockMessage(block);
837
837
  const { index } = block.decoded;
838
- if (this.#blocks[index - 1] && this.#blocks[index - 1].hash !== block.hash)
838
+ if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
839
839
  throw `invalid block ${hash} @${index}`;
840
840
  if (!(await globalThis.peernet.has(hash)))
841
841
  await globalThis.peernet.put(hash, block.encoded, 'block');
@@ -1249,9 +1249,9 @@ class Chain extends VersionControl {
1249
1249
  this.#jail = [];
1250
1250
  this.#addTransaction = async (message) => {
1251
1251
  const transaction = new TransactionMessage(message);
1252
- await transaction.hash();
1252
+ const hash = await transaction.hash();
1253
1253
  // if (await transactionPoolStore.has(hash)) await transactionPoolStore.delete(hash)
1254
- debug(`added ${transaction}`);
1254
+ debug(`added ${hash}`);
1255
1255
  };
1256
1256
  // @ts-ignore
1257
1257
  return this.#init();
@@ -1,5 +1,4 @@
1
1
  import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-CFrwP8cD.js';
2
- import { randomUUID } from 'crypto';
3
2
 
4
3
  const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
5
4
  const formatBytes = (bytes, decimals = 2) => {
@@ -363,7 +362,7 @@ _.loadBlock = (block) => {
363
362
 
364
363
  const askFor = (question, input) =>
365
364
  new Promise((resolve) => {
366
- const id = randomUUID();
365
+ const id = globalThis.crypto.randomUUID();
367
366
  pubsub.subscribe(id, resolve);
368
367
  worker.postMessage({
369
368
  type: 'ask',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -73,7 +73,7 @@
73
73
  "@leofcoin/peernet": "^1.1.77",
74
74
  "@leofcoin/storage": "^3.5.24",
75
75
  "@leofcoin/utils": "^1.1.17",
76
- "@leofcoin/workers": "^1.4.17",
76
+ "@leofcoin/workers": "^1.4.18",
77
77
  "@vandeurenglenn/base58": "^1.1.9",
78
78
  "@vandeurenglenn/easy-worker": "^1.0.2",
79
79
  "semver": "^7.6.0"