@leofcoin/chain 1.8.14 → 1.8.16

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 { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO, b as BWMessage, c as BWRequestMessage } from './constants-ByuwyBVy.js';
1
+ import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, u as utils, L as LastBlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO, b as BWMessage, c as BWRequestMessage } from './constants-BKKQytjd.js';
2
2
  import { log } from 'console';
3
3
  import { log as log$1 } from 'node:console';
4
4
 
@@ -4994,6 +4994,11 @@ class Jobber {
4994
4994
  }
4995
4995
  }
4996
4996
 
4997
+ utils.addCodec({
4998
+ name: 'last-block-message',
4999
+ codec: 0x6c626d,
5000
+ hashAlg: 'keccak-256'
5001
+ });
4997
5002
  const debug$1 = createDebugger('leofcoin/state');
4998
5003
  class State extends Contract {
4999
5004
  #resolveErrored;
@@ -5107,7 +5112,7 @@ class State extends Contract {
5107
5112
  };
5108
5113
  this.#lastBlockHandler = async () => {
5109
5114
  return new globalThis.peernet.protos['peernet-response']({
5110
- response: await this.lastBlock
5115
+ response: new LastBlockMessage(await this.lastBlock).encoded
5111
5116
  });
5112
5117
  };
5113
5118
  this.#knownBlocksHandler = async () => {
@@ -6016,7 +6021,7 @@ class ConnectionMonitor {
6016
6021
  const networkName = globalThis.peernet?.network;
6017
6022
  if (networkName && typeof networkName === 'string') {
6018
6023
  // Try to import network config
6019
- const { default: networks } = await import('./constants-ByuwyBVy.js').then(function (n) { return n.n; });
6024
+ const { default: networks } = await import('./constants-BKKQytjd.js').then(function (n) { return n.n; });
6020
6025
  const [mainKey, subKey] = networkName.split(':');
6021
6026
  const networkConfig = networks?.[mainKey]?.[subKey];
6022
6027
  if (networkConfig?.stars && Array.isArray(networkConfig.stars)) {
@@ -6114,6 +6119,16 @@ class ConnectionMonitor {
6114
6119
  }
6115
6120
  }
6116
6121
 
6122
+ utils.addCodec({
6123
+ name: 'last-block-message',
6124
+ codec: 0x6c626d,
6125
+ hashAlg: 'keccak-256'
6126
+ });
6127
+ utils.addCodec({
6128
+ name: 'last-block-request-message',
6129
+ codec: 0x6c62726d,
6130
+ hashAlg: 'keccak-256'
6131
+ });
6117
6132
  const debug = createDebugger('leofcoin/chain');
6118
6133
  // check if browser or local
6119
6134
  class Chain extends VersionControl {
@@ -6344,7 +6359,7 @@ class Chain extends VersionControl {
6344
6359
  }
6345
6360
  let lastBlock;
6346
6361
  try {
6347
- lastBlock = await this.#makeRequest(peer, 'lastBlock');
6362
+ lastBlock = new LastBlockMessage(await this.#makeRequest(peer, 'lastBlock')).encoded;
6348
6363
  }
6349
6364
  catch (error) {
6350
6365
  const peerName = peer?.peerId || peer?.id || peer?.address || peerId || 'unknown';
@@ -8701,7 +8701,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
8701
8701
  */
8702
8702
  const FormatInterface = FormatInterface$1;
8703
8703
 
8704
- var proto$6 = {
8704
+ var proto$7 = {
8705
8705
  address: String(),
8706
8706
  reward: BigInt(0)
8707
8707
  };
@@ -8714,11 +8714,11 @@ class ValidatorMessage extends FormatInterface {
8714
8714
  if (buffer instanceof ValidatorMessage)
8715
8715
  return buffer;
8716
8716
  const name = 'validator-message';
8717
- super(buffer, proto$6, { name });
8717
+ super(buffer, proto$7, { name });
8718
8718
  }
8719
8719
  }
8720
8720
 
8721
- var proto$5 = {
8721
+ var proto$6 = {
8722
8722
  index: BigInt(0),
8723
8723
  previousHash: String(),
8724
8724
  timestamp: Number(),
@@ -8736,7 +8736,7 @@ class BlockMessage extends FormatInterface {
8736
8736
  if (buffer instanceof BlockMessage)
8737
8737
  return buffer;
8738
8738
  const name = 'block-message';
8739
- super(buffer, proto$5, { name });
8739
+ super(buffer, proto$6, { name });
8740
8740
  }
8741
8741
  encode(decoded) {
8742
8742
  decoded = decoded || this.decoded;
@@ -8761,7 +8761,7 @@ class BlockMessage extends FormatInterface {
8761
8761
  }
8762
8762
  }
8763
8763
 
8764
- var proto$4 = {
8764
+ var proto$5 = {
8765
8765
  up: Number(),
8766
8766
  down: Number()
8767
8767
  };
@@ -8774,11 +8774,11 @@ class BWMessage extends FormatInterface {
8774
8774
  if (buffer instanceof BWMessage)
8775
8775
  return buffer;
8776
8776
  const name = 'bw-message';
8777
- super(buffer, proto$4, { name });
8777
+ super(buffer, proto$5, { name });
8778
8778
  }
8779
8779
  }
8780
8780
 
8781
- var proto$3 = {};
8781
+ var proto$4 = {};
8782
8782
 
8783
8783
  class BWRequestMessage extends FormatInterface {
8784
8784
  get messageName() {
@@ -8788,11 +8788,11 @@ class BWRequestMessage extends FormatInterface {
8788
8788
  if (buffer instanceof BWRequestMessage)
8789
8789
  return buffer;
8790
8790
  const name = 'bw-request-message';
8791
- super(buffer, proto$3, { name });
8791
+ super(buffer, proto$4, { name });
8792
8792
  }
8793
8793
  }
8794
8794
 
8795
- var proto$2 = {
8795
+ var proto$3 = {
8796
8796
  creator: String(),
8797
8797
  contract: new Uint8Array(),
8798
8798
  constructorParameters: Array()
@@ -8805,13 +8805,26 @@ class ContractMessage extends FormatInterface {
8805
8805
  constructor(buffer) {
8806
8806
  if (buffer instanceof ContractMessage)
8807
8807
  return buffer;
8808
- super(buffer, proto$2, { name: 'contract-message' });
8808
+ super(buffer, proto$3, { name: 'contract-message' });
8809
8809
  }
8810
8810
  }
8811
8811
 
8812
- ({
8812
+ var proto$2 = {
8813
+ hash: String(),
8813
8814
  index: BigInt(0)
8814
- });
8815
+ };
8816
+
8817
+ class LastBlockMessage extends FormatInterface {
8818
+ get messageName() {
8819
+ return 'LastBlockMessage';
8820
+ }
8821
+ constructor(buffer) {
8822
+ if (buffer instanceof LastBlockMessage)
8823
+ return buffer;
8824
+ const name = 'last-block-message';
8825
+ super(buffer, proto$2, { name });
8826
+ }
8827
+ }
8815
8828
 
8816
8829
  var proto$1 = {
8817
8830
  timestamp: Number(),
@@ -8903,4 +8916,4 @@ const DEFAULT_NODE_OPTIONS = {
8903
8916
  stars: networks.leofcoin.peach.stars
8904
8917
  };
8905
8918
 
8906
- export { BlockMessage as B, ContractMessage as C, DEFAULT_NODE_OPTIONS as D, FormatInterface as F, PROTOCOL_VERSION as P, RawTransactionMessage as R, TransactionMessage as T, ValidatorMessage as V, REACHED_ONE_ZERO_ZERO as a, BWMessage as b, BWRequestMessage as c, networks$1 as n, toBase58 as t };
8919
+ export { BlockMessage as B, ContractMessage as C, DEFAULT_NODE_OPTIONS as D, FormatInterface as F, LastBlockMessage as L, PROTOCOL_VERSION as P, RawTransactionMessage as R, TransactionMessage as T, ValidatorMessage as V, REACHED_ONE_ZERO_ZERO as a, BWMessage as b, BWRequestMessage as c, networks$1 as n, toBase58 as t, utils as u };
@@ -1,5 +1,5 @@
1
1
  import Peernet from '@leofcoin/peernet/browser';
2
- import { F as FormatInterface, T as TransactionMessage, C as ContractMessage, B as BlockMessage, b as BWMessage, c as BWRequestMessage, V as ValidatorMessage, D as DEFAULT_NODE_OPTIONS } from './constants-ByuwyBVy.js';
2
+ import { F as FormatInterface, T as TransactionMessage, C as ContractMessage, B as BlockMessage, b as BWMessage, c as BWRequestMessage, V as ValidatorMessage, D as DEFAULT_NODE_OPTIONS } from './constants-BKKQytjd.js';
3
3
 
4
4
  var proto = {
5
5
  lastblock: Object(),