@leofcoin/chain 1.9.21 → 1.9.22

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,6 +1,6 @@
1
- import { g as getDefaultExportFromCjs } from './node-browser-CYsu-WiL.js';
1
+ import { g as getDefaultExportFromCjs } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
4
4
 
5
5
  function _mergeNamespaces$1(n, m) {
6
6
  m.forEach(function (e) {
@@ -1,6 +1,6 @@
1
- import { g as getDefaultExportFromCjs } from './node-browser-CYsu-WiL.js';
1
+ import { g as getDefaultExportFromCjs } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
4
4
 
5
5
  function _mergeNamespaces$1(n, m) {
6
6
  m.forEach(function (e) {
@@ -1,4 +1,4 @@
1
- import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, L as LastBlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO, b as PrevoteMessage, c as PrecommitMessage, d as ProposalMessage, e as BWMessage, S as StateMessage, f as BWRequestMessage } from './constants-BCaq9RBn.js';
1
+ import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, L as LastBlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO, b as PrevoteMessage, c as PrecommitMessage, d as ProposalMessage, e as BWMessage, S as StateMessage, f as Codec, g as BWRequestMessage } from './constants-COpvMqFX.js';
2
2
 
3
3
  const getTargets = () => Array.from([]);
4
4
  const isEnabled = (target) => {
@@ -5833,7 +5833,7 @@ class ConnectionMonitor {
5833
5833
  try {
5834
5834
  const networkName = globalThis.peernet?.network;
5835
5835
  if (networkName && typeof networkName === "string") {
5836
- const { default: networks } = await import('./constants-BCaq9RBn.js').then(function (n) { return n.n; });
5836
+ const { default: networks } = await import('./constants-COpvMqFX.js').then(function (n) { return n.n; });
5837
5837
  const [mainKey, subKey] = networkName.split(":");
5838
5838
  const networkConfig = networks?.[mainKey]?.[subKey];
5839
5839
  if (networkConfig?.stars && Array.isArray(networkConfig.stars)) {
@@ -6407,6 +6407,8 @@ class Chain extends VersionControl {
6407
6407
  let bytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
6408
6408
  for (let i = 0; i < 3; i += 1) {
6409
6409
  try {
6410
+ const codec = new Codec(bytes);
6411
+ if (codec.name !== "peernet-response") break;
6410
6412
  const wrapped = await new globalThis.peernet.protos["peernet-response"](bytes);
6411
6413
  if (wrapped?.decoded?.response === void 0) break;
6412
6414
  const next = wrapped.decoded.response;
@@ -1,6 +1,6 @@
1
- import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-CYsu-WiL.js';
1
+ import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
4
4
 
5
5
  class Api {
6
6
  _pubsub;
@@ -231,7 +231,7 @@ class SocketRequestClient {
231
231
  const init = async () => {
232
232
  // @ts-ignore
233
233
  if (!globalThis.WebSocket && !this.#experimentalWebsocket)
234
- globalThis.WebSocket = (await import('./browser-8BFql6K9-Cfm2axSE.js').then(function (n) { return n.b; })).default.w3cwebsocket;
234
+ globalThis.WebSocket = (await import('./browser-8BFql6K9-BMXXABIY.js').then(function (n) { return n.b; })).default.w3cwebsocket;
235
235
  const client = new WebSocket(this.#url, this.#protocol);
236
236
  if (this.#experimentalWebsocket) {
237
237
  client.addEventListener('error', this.onerror);
@@ -1302,7 +1302,7 @@ class Client {
1302
1302
  }
1303
1303
  }
1304
1304
  async #loadNodeWebrtcImplementation() {
1305
- const koushWrtcModule = await import('./browser-FVp_QbaL-DShoEW2_.js').then(function (n) { return n.b; });
1305
+ const koushWrtcModule = await import('./browser-FVp_QbaL-C-GWIuv6.js').then(function (n) { return n.b; });
1306
1306
  const koushWrtc = koushWrtcModule.default;
1307
1307
  if (!isWrtcImplementation(koushWrtc)) {
1308
1308
  throw new Error('@koush/wrtc does not match required wrtc contract');
@@ -7802,7 +7802,7 @@ const utils = {
7802
7802
  codecs: registry
7803
7803
  };
7804
7804
 
7805
- class Codec extends BasicInterface {
7805
+ let Codec$1 = class Codec extends BasicInterface {
7806
7806
  codecBuffer;
7807
7807
  codec;
7808
7808
  hashAlg;
@@ -7902,7 +7902,7 @@ class Codec extends BasicInterface {
7902
7902
  this.encoded = index$4.encode(codec);
7903
7903
  return this.encoded;
7904
7904
  }
7905
- }
7905
+ };
7906
7906
 
7907
7907
  /*!
7908
7908
  * hash-wasm (https://www.npmjs.com/package/hash-wasm)
@@ -8517,7 +8517,7 @@ class CodecHash extends BasicInterface {
8517
8517
  // For large buffers, only check first bytes for codec prefix
8518
8518
  // Codec prefixes are small (varint encoded), so 100 bytes is more than enough
8519
8519
  const checkBuffer = uint8Array.length > 100 ? uint8Array.subarray(0, 100) : uint8Array;
8520
- this.discoCodec = new Codec(checkBuffer);
8520
+ this.discoCodec = new Codec$1(checkBuffer);
8521
8521
  const name = this.discoCodec.name;
8522
8522
  if (name) {
8523
8523
  this.name = name;
@@ -8550,7 +8550,7 @@ class CodecHash extends BasicInterface {
8550
8550
  this.name = name;
8551
8551
  if (!buffer)
8552
8552
  throw new Error('buffer is required for encoding');
8553
- this.discoCodec = new Codec(this.name);
8553
+ this.discoCodec = new Codec$1(this.name);
8554
8554
  let hashAlg = this.discoCodec.hashAlg;
8555
8555
  const hashVariant = Number(hashAlg.split('-')[hashAlg.split('-').length - 1]);
8556
8556
  if (hashAlg.includes('dbl')) {
@@ -8582,7 +8582,7 @@ class CodecHash extends BasicInterface {
8582
8582
  decode(buffer) {
8583
8583
  this.encoded = buffer;
8584
8584
  const codec = index$4.decode(buffer);
8585
- this.discoCodec = new Codec(codec, this.codecs);
8585
+ this.discoCodec = new Codec$1(codec, this.codecs);
8586
8586
  // TODO: validate codec
8587
8587
  buffer = buffer.slice(index$4.decode.bytes);
8588
8588
  this.size = index$4.decode(buffer);
@@ -8622,13 +8622,13 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
8622
8622
  hasCodec() {
8623
8623
  if (!this.encoded)
8624
8624
  return false;
8625
- const codec = new Codec(this.encoded);
8625
+ const codec = new Codec$1(this.encoded);
8626
8626
  if (codec.name)
8627
8627
  return true;
8628
8628
  }
8629
8629
  decode(encoded) {
8630
8630
  encoded = encoded || this.encoded;
8631
- const codec = new Codec(encoded);
8631
+ const codec = new Codec$1(encoded);
8632
8632
  if (codec.codecBuffer) {
8633
8633
  encoded = encoded.slice(codec.codecBuffer.length);
8634
8634
  this.name = codec.name;
@@ -8646,7 +8646,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
8646
8646
  encode(decoded) {
8647
8647
  let encoded;
8648
8648
  decoded = decoded || this.decoded;
8649
- const codec = new Codec(this.name);
8649
+ const codec = new Codec$1(this.name);
8650
8650
  if (decoded instanceof Uint8Array)
8651
8651
  encoded = decoded;
8652
8652
  else
@@ -8685,7 +8685,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
8685
8685
  get contentBytes() {
8686
8686
  if (!this.encoded)
8687
8687
  return new Uint8Array(0);
8688
- const codec = new Codec(this.encoded);
8688
+ const codec = new Codec$1(this.encoded);
8689
8689
  if (codec.codecBuffer) {
8690
8690
  return this.encoded.slice(codec.codecBuffer.length);
8691
8691
  }
@@ -8765,6 +8765,10 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
8765
8765
  * Interface for defining codec formats
8766
8766
  */
8767
8767
  const FormatInterface = FormatInterface$1;
8768
+ /**
8769
+ * Codec utility class
8770
+ */
8771
+ const Codec = Codec$1;
8768
8772
 
8769
8773
  var proto$b = {
8770
8774
  address: String(),
@@ -9040,4 +9044,4 @@ const DEFAULT_NODE_OPTIONS = {
9040
9044
  stars: networks.leofcoin.peach.stars
9041
9045
  };
9042
9046
 
9043
- export { BlockMessage as B, ContractMessage as C, DEFAULT_NODE_OPTIONS as D, LastBlockMessage as L, PROTOCOL_VERSION as P, RawTransactionMessage as R, StateMessage as S, TransactionMessage as T, ValidatorMessage as V, REACHED_ONE_ZERO_ZERO as a, PrevoteMessage as b, PrecommitMessage as c, ProposalMessage as d, BWMessage as e, BWRequestMessage as f, networks$1 as n, toBase58 as t };
9047
+ export { BlockMessage as B, ContractMessage as C, DEFAULT_NODE_OPTIONS as D, LastBlockMessage as L, PROTOCOL_VERSION as P, RawTransactionMessage as R, StateMessage as S, TransactionMessage as T, ValidatorMessage as V, REACHED_ONE_ZERO_ZERO as a, PrevoteMessage as b, PrecommitMessage as c, ProposalMessage as d, BWMessage as e, Codec as f, BWRequestMessage as g, networks$1 as n, toBase58 as t };
@@ -1,6 +1,6 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-CYsu-WiL.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
4
4
 
5
5
  /**
6
6
  * @params {String} network
@@ -1,6 +1,6 @@
1
- import { F as FormatInterface } from './node-browser-CYsu-WiL.js';
1
+ import { F as FormatInterface } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
4
4
 
5
5
  var proto$b = {
6
6
  data: new Uint8Array(),
@@ -1,5 +1,5 @@
1
1
  import { createHash as createHash$1 } from 'crypto';
2
- import { T as TransactionMessage, C as ContractMessage, B as BlockMessage, e as BWMessage, f as BWRequestMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS } from './constants-BCaq9RBn.js';
2
+ import { T as TransactionMessage, C as ContractMessage, B as BlockMessage, e as BWMessage, g as BWRequestMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS } from './constants-COpvMqFX.js';
3
3
 
4
4
  var nodeConfig = async (config = {
5
5
  network: "leofcoin:peach",
@@ -8337,7 +8337,7 @@ class Identity {
8337
8337
  this.selectedAccount = new TextDecoder().decode(selected);
8338
8338
  }
8339
8339
  else {
8340
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-D6qd-AUn-q2EQ9wfH.js');
8340
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-D6qd-AUn-cJS9xh8w.js');
8341
8341
  const { identity, accounts } = await importee.default(password, this.network);
8342
8342
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
8343
8343
  await globalThis.walletStore.put('version', String(1));
@@ -16998,7 +16998,7 @@ class Peernet {
16998
16998
  await getAddress();
16999
16999
  this.storePrefix = options.storePrefix;
17000
17000
  this.root = options.root;
17001
- const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-BfDvXW-x-CNuQ6tVL.js');
17001
+ const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-BfDvXW-x-BaHit_or.js');
17002
17002
  /**
17003
17003
  * proto Object containing protos
17004
17004
  * @type {Object}
@@ -17045,7 +17045,7 @@ class Peernet {
17045
17045
  if (this.#starting || this.#started)
17046
17046
  return;
17047
17047
  this.#starting = true;
17048
- const importee = await import('./client-lPe0SUWx-Cm8Ph6Z5.js');
17048
+ const importee = await import('./client-lPe0SUWx-DwxXCP5p.js');
17049
17049
  /**
17050
17050
  * @access public
17051
17051
  * @type {PeernetClient}
@@ -1,3 +1,3 @@
1
- export { N as default } from './node-browser-CYsu-WiL.js';
1
+ export { N as default } from './node-browser-Dc4HZiX0.js';
2
2
  import 'crypto';
3
- import './constants-BCaq9RBn.js';
3
+ import './constants-COpvMqFX.js';
package/exports/chain.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createDebugger } from '@vandeurenglenn/debug';
2
+ import { Codec } from '@leofcoin/codec-format-interface';
2
3
  import { jsonStringifyBigInt, jsonParseBigInt, formatBytes, parseUnits, formatUnits } from '@leofcoin/utils';
3
4
  import { TransactionMessage, BlockMessage, ContractMessage, LastBlockMessage, PrevoteMessage, PrecommitMessage, ProposalMessage, BWMessage, StateMessage, BWRequestMessage } from '@leofcoin/messages';
4
5
  import addresses, { contractFactory } from '@leofcoin/addresses';
@@ -2613,6 +2614,8 @@ class Chain extends VersionControl {
2613
2614
  let bytes = payload instanceof Uint8Array ? payload : new Uint8Array(payload);
2614
2615
  for (let i = 0; i < 3; i += 1) {
2615
2616
  try {
2617
+ const codec = new Codec(bytes);
2618
+ if (codec.name !== "peernet-response") break;
2616
2619
  const wrapped = await new globalThis.peernet.protos["peernet-response"](bytes);
2617
2620
  if (wrapped?.decoded?.response === void 0) break;
2618
2621
  const next = wrapped.decoded.response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.9.21",
3
+ "version": "1.9.22",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {