@leofcoin/chain 1.9.4 → 1.9.5

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, 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-D_XqG46B.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, u as utils, b as PrevoteMessage, c as PrecommitMessage, d as ProposalMessage, e as BWMessage, S as StateMessage, f as BWRequestMessage } from './constants-M3qbPwZp.js';
2
2
  import { log } from 'console';
3
3
  import { log as log$1 } from 'node:console';
4
4
 
@@ -6149,7 +6149,7 @@ class ConnectionMonitor {
6149
6149
  const networkName = globalThis.peernet?.network;
6150
6150
  if (networkName && typeof networkName === 'string') {
6151
6151
  // Try to import network config
6152
- const { default: networks } = await import('./constants-D_XqG46B.js').then(function (n) { return n.n; });
6152
+ const { default: networks } = await import('./constants-M3qbPwZp.js').then(function (n) { return n.n; });
6153
6153
  const [mainKey, subKey] = networkName.split(':');
6154
6154
  const networkConfig = networks?.[mainKey]?.[subKey];
6155
6155
  if (networkConfig?.stars && Array.isArray(networkConfig.stars)) {
@@ -6241,6 +6241,20 @@ class ConnectionMonitor {
6241
6241
  }
6242
6242
  }
6243
6243
 
6244
+ const ensureCodec = (name, codec, hashAlg = 'keccak-256') => {
6245
+ if (!utils.codecs[name]) {
6246
+ utils.addCodec({ name, codec, hashAlg });
6247
+ }
6248
+ };
6249
+ // Backward compatibility for mixed deployments where some nodes still resolve
6250
+ // older @leofcoin/codecs versions that do not include these protocol codecs.
6251
+ ensureCodec('last-block-message', 0x6c626d);
6252
+ ensureCodec('last-block-request-message', 0x6c62726d);
6253
+ ensureCodec('state-message', 0x73746d);
6254
+ ensureCodec('publish-message', 0x70626d);
6255
+ ensureCodec('proposal-message', 0x70726d);
6256
+ ensureCodec('prevote-message', 0x70766d);
6257
+ ensureCodec('precommit-message', 0x7063636d);
6244
6258
  const debug = createDebugger('leofcoin/chain');
6245
6259
  // check if browser or local
6246
6260
  class Chain extends VersionControl {
@@ -9058,4 +9058,4 @@ const DEFAULT_NODE_OPTIONS = {
9058
9058
  stars: networks.leofcoin.peach.stars
9059
9059
  };
9060
9060
 
9061
- 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 };
9061
+ 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, utils as u };
@@ -1,5 +1,5 @@
1
1
  import Peernet from '@leofcoin/peernet/browser';
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-D_XqG46B.js';
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-M3qbPwZp.js';
3
3
 
4
4
  var nodeConfig = async (config = {
5
5
  network: 'leofcoin:peach',
package/exports/chain.js CHANGED
@@ -3,6 +3,7 @@ import { formatBytes, jsonStringifyBigInt, jsonParseBigInt, parseUnits, formatUn
3
3
  import { TransactionMessage, BlockMessage, ContractMessage, LastBlockMessage, PrevoteMessage, PrecommitMessage, ProposalMessage, BWMessage, StateMessage, BWRequestMessage } from '@leofcoin/messages';
4
4
  import addresses, { contractFactory } from '@leofcoin/addresses';
5
5
  import { calculateFee, createContractMessage, signTransaction, contractFactoryMessage, nativeTokenMessage, validatorsMessage, nameServiceMessage } from '@leofcoin/lib';
6
+ import codecs from '@leofcoin/codecs/utils';
6
7
  import semver from 'semver';
7
8
  import { randombytes } from '@leofcoin/crypto';
8
9
  import EasyWorker from '@vandeurenglenn/easy-worker';
@@ -2342,6 +2343,20 @@ class ConnectionMonitor {
2342
2343
  }
2343
2344
  }
2344
2345
 
2346
+ const ensureCodec = (name, codec, hashAlg = 'keccak-256') => {
2347
+ if (!codecs.codecs[name]) {
2348
+ codecs.addCodec({ name, codec, hashAlg });
2349
+ }
2350
+ };
2351
+ // Backward compatibility for mixed deployments where some nodes still resolve
2352
+ // older @leofcoin/codecs versions that do not include these protocol codecs.
2353
+ ensureCodec('last-block-message', 0x6c626d);
2354
+ ensureCodec('last-block-request-message', 0x6c62726d);
2355
+ ensureCodec('state-message', 0x73746d);
2356
+ ensureCodec('publish-message', 0x70626d);
2357
+ ensureCodec('proposal-message', 0x70726d);
2358
+ ensureCodec('prevote-message', 0x70766d);
2359
+ ensureCodec('precommit-message', 0x7063636d);
2345
2360
  const debug = createDebugger('leofcoin/chain');
2346
2361
  // check if browser or local
2347
2362
  class Chain extends VersionControl {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -62,6 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@leofcoin/addresses": "^1.0.56",
65
+ "@leofcoin/codecs": "^1.1.0",
65
66
  "@leofcoin/contracts": "^0.1.17",
66
67
  "@leofcoin/crypto": "^0.2.37",
67
68
  "@leofcoin/errors": "^1.0.26",