@leofcoin/chain 1.8.2 → 1.8.3

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 { g as getDefaultExportFromCjs } from './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { g as getDefaultExportFromCjs } from './identity-B6BHwSTU-5rsAWMHo.js';
2
2
 
3
3
  var browser$2 = {};
4
4
 
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs } from './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { g as getDefaultExportFromCjs } from './identity-B6BHwSTU-5rsAWMHo.js';
2
2
 
3
3
  var global;
4
4
  var hasRequiredGlobal;
@@ -1,33 +1,35 @@
1
1
  import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage } from './index-DUfUgiQY.js';
2
2
 
3
- let TARGETS = undefined;
4
- if (globalThis.localStorage && !TARGETS) {
5
- const DEBUG = globalThis.localStorage.getItem("DEBUG");
6
- if (DEBUG) {
7
- TARGETS = JSON.parse(DEBUG);
8
- }
9
- }
3
+ const getTargets = () => Array.from([]);
4
+ const isEnabled = (target) => {
5
+ return false;
6
+ };
7
+
10
8
  const getLogger = (trace) => (trace ? console.trace : console.log);
11
- const debug$3 = (target, text, trace) => {
12
- const _logger = getLogger(trace);
13
- if (!TARGETS)
14
- return;
15
- if (TARGETS === true ||
16
- TARGETS?.indexOf(target) !== -1 ||
17
- TARGETS?.indexOf("*") !== -1 ||
18
- TARGETS?.indexOf(target.split("/")[0]) !== -1)
9
+ const createDebugger = (target) => {
10
+ // Cache the enabled check on first call
11
+ let enabled = null;
12
+ let lastTargets = undefined;
13
+ return (text, trace) => {
14
+ const targets = getTargets();
15
+ if (lastTargets !== targets) {
16
+ enabled = targets ? isEnabled() : false;
17
+ lastTargets = targets;
18
+ }
19
+ if (!enabled)
20
+ return;
19
21
  if (text)
20
- _logger("\x1b[34m\x1b[1m%s", `${target}: ${text}`, "\x1b[0m");
22
+ getLogger(trace)('\x1b[34m\x1b[1m%s', `${target}: ${text}`, '\x1b[0m');
21
23
  else
22
- _logger("\x1b[34m\x1b[1m%s", `${target}`, "\x1b[0m");
24
+ getLogger(trace)('\x1b[34m\x1b[1m%s', `${target}`, '\x1b[0m');
25
+ };
23
26
  };
24
- const createDebugger = (target) => (text, trace) => debug$3(target, text, trace);
25
27
 
26
28
  /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
27
29
  /**
28
30
  * The current version of Ethers.
29
31
  */
30
- const version = "6.15.0";
32
+ const version = "6.16.0";
31
33
 
32
34
  /**
33
35
  * Property helper functions.
@@ -231,7 +233,8 @@ function _getBytes(value, name, copy) {
231
233
  if (value instanceof Uint8Array) {
232
234
  return value;
233
235
  }
234
- if (typeof (value) === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
236
+ if (typeof (value) === "string" && (value.length % 2) === 0 &&
237
+ value.match(/^0x[0-9a-f]*$/i)) {
235
238
  const result = new Uint8Array((value.length - 2) / 2);
236
239
  let offset = 2;
237
240
  for (let i = 0; i < result.length; i++) {
@@ -1,5 +1,5 @@
1
- import { L as LittlePubSub } from './node-browser-SPIwS-5O.js';
2
- import './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { c as createDebugger, i as inflate_1, d as deflate_1, L as LittlePubSub } from './node-browser-Bv-OkGUJ.js';
2
+ import './identity-B6BHwSTU-5rsAWMHo.js';
3
3
  import './index-DUfUgiQY.js';
4
4
  import './networks-BdMfU1ag.js';
5
5
 
@@ -232,7 +232,7 @@ class SocketRequestClient {
232
232
  const init = async () => {
233
233
  // @ts-ignore
234
234
  if (!globalThis.WebSocket && !this.#experimentalWebsocket)
235
- globalThis.WebSocket = (await import('./browser-CfYI-6aD-DHRKebpJ.js').then(function (n) { return n.b; })).default.w3cwebsocket;
235
+ globalThis.WebSocket = (await import('./browser-DQlwTLRn-h2IyYbfg.js').then(function (n) { return n.b; })).default.w3cwebsocket;
236
236
  const client = new WebSocket(this.#url, this.#protocol);
237
237
  if (this.#experimentalWebsocket) {
238
238
  client.addEventListener('error', this.onerror);
@@ -318,6 +318,17 @@ const defaultOptions = {
318
318
  connectEvent: 'peer:connected'
319
319
  };
320
320
 
321
+ // Simple CRC32 implementation
322
+ const crc32$1 = (data) => {
323
+ let crc = 0xffffffff;
324
+ for (let i = 0; i < data.length; i++) {
325
+ crc ^= data[i];
326
+ for (let j = 0; j < 8; j++) {
327
+ crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
328
+ }
329
+ }
330
+ return (crc ^ 0xffffffff) >>> 0;
331
+ };
321
332
  const iceServers = [
322
333
  {
323
334
  urls: 'stun:stun.l.google.com:19302' // Google's public STUN server
@@ -336,37 +347,81 @@ const iceServers = [
336
347
  credential: 'openrelayproject'
337
348
  }
338
349
  ];
339
- const SimplePeer = (await import('./index-DTbjK0sK-BK_5FT46.js').then(function (n) { return n.i; })).default;
350
+ const SimplePeer = (await import('./index-DYdP5D9L-D_bByMvp.js').then(function (n) { return n.i; })).default;
340
351
  class Peer extends SimplePeer {
341
352
  peerId;
342
353
  channelName;
343
354
  version;
355
+ compressionThreshold = 0.98;
344
356
  bw = { up: 0, down: 0 };
345
357
  get connected() {
346
358
  return super.connected;
347
359
  }
348
360
  constructor(options) {
349
- const { from, to, initiator, trickle, config, version } = options;
361
+ const { from, to, initiator, trickle, config, version, wrtc, compressionThreshold } = options;
350
362
  const channelName = initiator ? `${from}:${to}` : `${to}:${from}`;
351
363
  super({
352
364
  channelName,
353
365
  initiator,
354
- trickle: trickle || true,
366
+ trickle: trickle ?? true,
355
367
  config: { iceServers, ...config },
356
- wrtc: globalThis.wrtc
368
+ wrtc: wrtc ?? globalThis.wrtc
357
369
  });
358
370
  this.version = String(version);
359
371
  this.peerId = to;
360
372
  this.channelName = channelName;
373
+ if (compressionThreshold !== undefined)
374
+ this.compressionThreshold = compressionThreshold;
361
375
  }
362
376
  async #chunkit(data, id) {
363
377
  this.bw.up = data.length;
364
- const size = data.length;
378
+ // attempt compression; use compressed only if beneficial
379
+ let sendData = data;
380
+ try {
381
+ const c = deflate_1(data);
382
+ if (c?.length && c.length < data.length * this.compressionThreshold)
383
+ sendData = c;
384
+ }
385
+ catch (e) {
386
+ // ignore
387
+ }
388
+ const size = sendData.length;
389
+ const encodeFrame = (idStr, totalSize, index, count, payload, flags) => {
390
+ const te = new TextEncoder();
391
+ const idBytes = te.encode(idStr);
392
+ const crc = crc32$1(payload);
393
+ const headerLen = 1 + 1 + 4 + 4 + 4 + 4 + 2 + idBytes.length;
394
+ const buffer = new ArrayBuffer(headerLen + payload.length);
395
+ const view = new DataView(buffer);
396
+ const out = new Uint8Array(buffer);
397
+ let offset = 0;
398
+ view.setUint8(offset, 1); // version
399
+ offset += 1;
400
+ view.setUint8(offset, flags); // flags: bit0 chunked, bit1 compressed
401
+ offset += 1;
402
+ view.setUint32(offset, totalSize, true);
403
+ offset += 4;
404
+ view.setUint32(offset, index, true);
405
+ offset += 4;
406
+ view.setUint32(offset, count, true);
407
+ offset += 4;
408
+ view.setUint32(offset, crc, true); // CRC32
409
+ offset += 4;
410
+ view.setUint16(offset, idBytes.length, true);
411
+ offset += 2;
412
+ out.set(idBytes, offset);
413
+ offset += idBytes.length;
414
+ out.set(payload, offset);
415
+ return out;
416
+ };
365
417
  // no needles chunking, keep it simple, if data is smaller then max size just send it
366
- if (data.length <= MAX_MESSAGE_SIZE) {
367
- return super.send(JSON.stringify({ chunk: data, id, size: data.length }));
418
+ if (size <= MAX_MESSAGE_SIZE) {
419
+ const flags = ((size > MAX_MESSAGE_SIZE ? 1 : 0) << 0) |
420
+ ((sendData !== data ? 1 : 0) << 1);
421
+ super.send(encodeFrame(id, size, 0, 1, sendData, flags));
422
+ return;
368
423
  }
369
- async function* chunks(data) {
424
+ function* chunks(data) {
370
425
  while (data.length !== 0) {
371
426
  const amountToSlice = data.length >= MAX_MESSAGE_SIZE ? MAX_MESSAGE_SIZE : data.length;
372
427
  const subArray = data.subarray(0, amountToSlice);
@@ -382,8 +437,27 @@ class Peer extends SimplePeer {
382
437
  // data = data.subarray(amountToSlice, data.length)
383
438
  // super.send(JSON.stringify({ chunk: subArray, id, size }))
384
439
  // }
385
- for await (const chunk of chunks(data)) {
386
- super.send(JSON.stringify({ chunk, id, size }));
440
+ // backpressure-aware send loop with indexed chunks
441
+ const count = Math.ceil(size / MAX_MESSAGE_SIZE);
442
+ let index = 0;
443
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
444
+ const threshold = 4 * 1024 * 1024; // 4MB bufferedAmount threshold
445
+ const flags = (1 << 0) | ((sendData !== data ? 1 : 0) << 1);
446
+ for (const chunk of chunks(sendData)) {
447
+ // wait while channel is congested
448
+ // eslint-disable-next-line no-await-in-loop
449
+ while (
450
+ // @ts-ignore underlying channel is not part of public types
451
+ this._channel?.bufferedAmount > threshold) {
452
+ // if connection closed, abort
453
+ // eslint-disable-next-line no-await-in-loop
454
+ if (!this.connected)
455
+ return;
456
+ // eslint-disable-next-line no-await-in-loop
457
+ await sleep(10);
458
+ }
459
+ super.send(encodeFrame(id, size, index, count, chunk, flags));
460
+ index += 1;
387
461
  }
388
462
  }
389
463
  /**
@@ -403,12 +477,16 @@ class Peer extends SimplePeer {
403
477
  */
404
478
  request(data, id = crypto.randomUUID()) {
405
479
  return new Promise((resolve, reject) => {
406
- const timeout = setTimeout(() => reject(`request for ${id} timed out`), 30_000);
480
+ let timeout;
407
481
  const onrequest = ({ data }) => {
408
482
  clearTimeout(timeout);
409
483
  resolve(data);
410
484
  globalThis.pubsub.unsubscribe(id, onrequest);
411
485
  };
486
+ timeout = setTimeout(() => {
487
+ globalThis.pubsub.unsubscribe(id, onrequest);
488
+ reject(`request for ${id} timed out`);
489
+ }, 30_000);
412
490
  globalThis.pubsub.subscribe(id, onrequest);
413
491
  this.send(data, id);
414
492
  });
@@ -423,7 +501,18 @@ class Peer extends SimplePeer {
423
501
  }
424
502
  }
425
503
 
426
- const debug = globalThis.createDebugger('@netpeer/swarm/client');
504
+ // Simple CRC32 implementation
505
+ const crc32 = (data) => {
506
+ let crc = 0xffffffff;
507
+ for (let i = 0; i < data.length; i++) {
508
+ crc ^= data[i];
509
+ for (let j = 0; j < 8; j++) {
510
+ crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
511
+ }
512
+ }
513
+ return (crc ^ 0xffffffff) >>> 0;
514
+ };
515
+ const debug = createDebugger('@netpeer/swarm/client');
427
516
  class Client {
428
517
  #peerId;
429
518
  #connections = {};
@@ -528,7 +617,7 @@ class Client {
528
617
  }
529
618
  async _init() {
530
619
  if (!globalThis.RTCPeerConnection)
531
- globalThis.wrtc = (await import('./browser-Qcpp3EKK-DOtgsScX.js').then(function (n) { return n.b; })).default;
620
+ globalThis.wrtc = (await import('./browser-BHbuEZJu-DB_cOj5W.js').then(function (n) { return n.b; })).default;
532
621
  for (const star of this.starsConfig) {
533
622
  try {
534
623
  await this.setupStar(star);
@@ -706,9 +795,12 @@ class Client {
706
795
  globalThis.pubsub.publishVerbose(this.#connectEvent, peer.peerId);
707
796
  };
708
797
  #noticeMessage = (message, id, from, peer) => {
798
+ const dataOut = message instanceof Uint8Array
799
+ ? message
800
+ : new Uint8Array(Object.values(message));
709
801
  if (globalThis.pubsub.subscribers[id]) {
710
802
  globalThis.pubsub.publish(id, {
711
- data: new Uint8Array(Object.values(message)),
803
+ data: dataOut,
712
804
  id,
713
805
  from,
714
806
  peer
@@ -716,7 +808,7 @@ class Client {
716
808
  }
717
809
  else {
718
810
  globalThis.pubsub.publish('peer:data', {
719
- data: new Uint8Array(Object.values(message)),
811
+ data: dataOut,
720
812
  id,
721
813
  from,
722
814
  peer
@@ -724,22 +816,124 @@ class Client {
724
816
  }
725
817
  };
726
818
  #peerData = (peer, data) => {
727
- const { id, size, chunk } = JSON.parse(new TextDecoder().decode(data));
728
- peer.bw.down += size;
729
- if (size <= MAX_MESSAGE_SIZE) {
730
- this.#noticeMessage(chunk, id, peer.peerId, peer);
819
+ const tryJson = () => {
820
+ const parsed = JSON.parse(new TextDecoder().decode(data));
821
+ const { id, size, chunk, index, count } = parsed;
822
+ chunk ? Object.values(chunk).length : size;
823
+ return {
824
+ id,
825
+ size: Number(size),
826
+ index: Number(index ?? 0),
827
+ count: Number(count ?? 1),
828
+ chunk: new Uint8Array(Object.values(chunk)),
829
+ flags: 0,
830
+ crc: 0
831
+ };
832
+ };
833
+ const decodeBinary = () => {
834
+ let u8;
835
+ if (typeof data === 'string') {
836
+ // should not happen when sending binary, fallback to JSON
837
+ return tryJson();
838
+ }
839
+ else if (data instanceof ArrayBuffer) {
840
+ u8 = new Uint8Array(data);
841
+ }
842
+ else if (ArrayBuffer.isView(data)) {
843
+ const view = data;
844
+ const byteOffset = view.byteOffset || 0;
845
+ const byteLength = view.byteLength || data.length;
846
+ u8 = new Uint8Array(view.buffer, byteOffset, byteLength);
847
+ }
848
+ else if (data?.buffer) {
849
+ u8 = new Uint8Array(data.buffer);
850
+ }
851
+ else {
852
+ // last resort: attempt JSON
853
+ return tryJson();
854
+ }
855
+ const dv = new DataView(u8.buffer, u8.byteOffset, u8.byteLength);
856
+ let offset = 0;
857
+ dv.getUint8(offset);
858
+ offset += 1;
859
+ const flags = dv.getUint8(offset);
860
+ offset += 1;
861
+ const size = dv.getUint32(offset, true);
862
+ offset += 4;
863
+ const index = dv.getUint32(offset, true);
864
+ offset += 4;
865
+ const count = dv.getUint32(offset, true);
866
+ offset += 4;
867
+ const expectedCrc = dv.getUint32(offset, true);
868
+ offset += 4;
869
+ const idLen = dv.getUint16(offset, true);
870
+ offset += 2;
871
+ const idBytes = u8.subarray(offset, offset + idLen);
872
+ offset += idLen;
873
+ const id = new TextDecoder().decode(idBytes);
874
+ const chunk = u8.subarray(offset);
875
+ return { id, size, index, count, chunk, flags, crc: expectedCrc };
876
+ };
877
+ const frame = decodeBinary();
878
+ peer.bw.down += frame.chunk.length;
879
+ // Single frame path: if compressed, inflate before publish
880
+ if (frame.count === 1) {
881
+ let payload = frame.chunk;
882
+ const compressed = Boolean(frame.flags & (1 << 1));
883
+ if (compressed) {
884
+ const actualCrc = crc32(payload);
885
+ if (actualCrc !== frame.crc) {
886
+ console.warn(`CRC mismatch: expected ${frame.crc}, got ${actualCrc}`);
887
+ }
888
+ try {
889
+ payload = inflate_1(payload);
890
+ }
891
+ catch (e) {
892
+ console.warn('inflate failed, passing compressed payload');
893
+ }
894
+ }
895
+ this.#noticeMessage(payload, frame.id, peer.peerId, peer);
896
+ return;
731
897
  }
732
- else {
733
- if (!this.#messagesToHandle[id])
734
- this.#messagesToHandle[id] = [];
735
- this.#messagesToHandle[id] = [
736
- ...this.#messagesToHandle[id],
737
- ...Object.values(chunk)
738
- ];
739
- if (this.#messagesToHandle[id].length === Number(size)) {
740
- this.#noticeMessage(this.#messagesToHandle[id], id, peer.peerId, peer);
741
- delete this.#messagesToHandle[id];
898
+ // Chunked message handling with indexed reassembly
899
+ if (!this.#messagesToHandle[frame.id] ||
900
+ Array.isArray(this.#messagesToHandle[frame.id])) {
901
+ this.#messagesToHandle[frame.id] = {
902
+ chunks: new Array(frame.count),
903
+ receivedBytes: 0,
904
+ expectedSize: Number(frame.size),
905
+ expectedCount: Number(frame.count)
906
+ };
907
+ }
908
+ const state = this.#messagesToHandle[frame.id];
909
+ // Verify CRC for this chunk
910
+ const actualCrc = crc32(frame.chunk);
911
+ if (actualCrc !== frame.crc) {
912
+ console.warn(`Chunk CRC mismatch for ${frame.id}[${frame.index}]: expected ${frame.crc}, got ${actualCrc}`);
913
+ }
914
+ state.chunks[frame.index] = frame.chunk;
915
+ state.receivedBytes += frame.chunk.length;
916
+ // If all chunks present and total size matches, reassemble
917
+ const allPresent = state.chunks.every((c) => c instanceof Uint8Array);
918
+ if (allPresent && state.receivedBytes === state.expectedSize) {
919
+ const result = new Uint8Array(state.expectedSize);
920
+ let offset2 = 0;
921
+ for (const c of state.chunks) {
922
+ result.set(c, offset2);
923
+ offset2 += c.length;
924
+ }
925
+ let payload = result;
926
+ const compressed = Boolean(frame.flags & (1 << 1));
927
+ if (compressed) {
928
+ try {
929
+ payload = inflate_1(result);
930
+ }
931
+ catch (e) {
932
+ console.warn('inflate failed, passing compressed payload');
933
+ }
742
934
  }
935
+ this.#noticeMessage(payload, frame.id, peer.peerId, peer);
936
+ delete this.#messagesToHandle[frame.id];
743
937
  }
744
938
  };
745
939
  #peerError = (peer, error) => {
@@ -17150,7 +17150,7 @@ class Identity {
17150
17150
  this.selectedAccount = new TextDecoder().decode(selected);
17151
17151
  }
17152
17152
  else {
17153
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-ChRjMyiM-EjbBu23l.js');
17153
+ const importee = await import(/* webpackChunkName: "generate-account" */ '@leofcoin/generate-account');
17154
17154
  const { identity, accounts } = await importee.default(password, this.network);
17155
17155
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
17156
17156
  await globalThis.walletStore.put('version', String(1));
@@ -17196,4 +17196,4 @@ class Identity {
17196
17196
  }
17197
17197
  }
17198
17198
 
17199
- export { Identity as I, MultiWallet as M, index$5 as a, base$1 as b, base58$1 as c, index$3 as d, index$2 as e, encrypt as f, getDefaultExportFromCjs as g, commonjsGlobal as h, index$4 as i, requireInherits_browser as j, require$$3 as r };
17199
+ export { Identity as I, index$5 as a, base$1 as b, base58$1 as c, index$3 as d, index$2 as e, commonjsGlobal as f, getDefaultExportFromCjs as g, requireInherits_browser as h, index$4 as i, require$$3 as r };
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs, h as commonjsGlobal, r as require$$3, j as requireInherits_browser } from './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { g as getDefaultExportFromCjs, f as commonjsGlobal, r as require$$3, h as requireInherits_browser } from './identity-B6BHwSTU-5rsAWMHo.js';
2
2
  import require$$0 from 'events';
3
3
 
4
4
  var browser$2 = {exports: {}};
@@ -1,5 +1,5 @@
1
- import { F as FormatInterface } from './node-browser-SPIwS-5O.js';
2
- import './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { F as FormatInterface } from './node-browser-Bv-OkGUJ.js';
2
+ import './identity-B6BHwSTU-5rsAWMHo.js';
3
3
  import './index-DUfUgiQY.js';
4
4
  import './networks-BdMfU1ag.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { b as base$1, I as Identity, i as index$4, a as index$5, c as base58$1, d as index$3, e as index$2 } from './identity-nIyW_Xm8-BU8xakCv.js';
1
+ import { b as base$1, I as Identity, i as index$4, a as index$5, c as base58$1, d as index$3, e as index$2 } from './identity-B6BHwSTU-5rsAWMHo.js';
2
2
  import { F as FormatInterface$2, T as TransactionMessage, C as ContractMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage, V as ValidatorMessage } from './index-DUfUgiQY.js';
3
3
  import networks from './networks-BdMfU1ag.js';
4
4
 
@@ -126,42 +126,31 @@ class KeyValue {
126
126
  }
127
127
  }
128
128
 
129
- if (!globalThis.DEBUG) {
130
- globalThis.DEBUG = [];
131
- if (globalThis.localStorage) {
132
- const DEBUG = globalThis.localStorage.getItem("DEBUG");
133
- if (DEBUG) {
134
- globalThis.DEBUG = DEBUG.startsWith("[")
135
- ? JSON.parse(DEBUG).split(",")
136
- : [DEBUG];
137
- }
138
- }
139
- }
129
+ const getTargets = () => Array.from([]);
130
+ const isEnabled = (target) => {
131
+ return false;
132
+ };
140
133
 
141
134
  const getLogger = (trace) => (trace ? console.trace : console.log);
142
-
143
- const debug$1 = (target, text, trace) => {
144
- const _logger = getLogger(trace);
145
- if (!globalThis.DEBUG || globalThis.DEBUG?.length === 0) return;
146
- if (
147
- globalThis.DEBUG === "true" ||
148
- globalThis.DEBUG === true ||
149
- globalThis.DEBUG?.indexOf(target) !== -1 ||
150
- globalThis.DEBUG?.indexOf("*") !== -1 ||
151
- globalThis.DEBUG?.indexOf(target.split("/")[0]) !== -1
152
- )
153
- if (text) _logger("\x1b[34m\x1b[1m%s", `${target}: ${text}`, "\x1b[0m");
154
- else _logger("\x1b[34m\x1b[1m%s", `${target}`, "\x1b[0m");
135
+ const createDebugger = (target) => {
136
+ // Cache the enabled check on first call
137
+ let enabled = null;
138
+ let lastTargets = undefined;
139
+ return (text, trace) => {
140
+ const targets = getTargets();
141
+ if (lastTargets !== targets) {
142
+ enabled = targets ? isEnabled() : false;
143
+ lastTargets = targets;
144
+ }
145
+ if (!enabled)
146
+ return;
147
+ if (text)
148
+ getLogger(trace)('\x1b[34m\x1b[1m%s', `${target}: ${text}`, '\x1b[0m');
149
+ else
150
+ getLogger(trace)('\x1b[34m\x1b[1m%s', `${target}`, '\x1b[0m');
151
+ };
155
152
  };
156
153
 
157
- const createDebugger = (target) => (text) => debug$1(target, text);
158
-
159
- if (!globalThis.debug) {
160
- globalThis.debug = debug$1;
161
- // todo: deprecate
162
- globalThis.createDebugger = createDebugger;
163
- }
164
-
165
154
  class LittlePubSub {
166
155
  subscribers = {};
167
156
  verbose;
@@ -8491,7 +8480,7 @@ class Peernet {
8491
8480
  this.root = options.root;
8492
8481
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
8493
8482
  // FolderMessageResponse
8494
- } = await import(/* webpackChunkName: "messages" */ './messages-CC7UR5ol-BvFNyHjv.js');
8483
+ } = await import(/* webpackChunkName: "messages" */ './messages-CiR1YiV5-BOjOxVgq.js');
8495
8484
  /**
8496
8485
  * proto Object containing protos
8497
8486
  * @type {Object}
@@ -8585,7 +8574,7 @@ class Peernet {
8585
8574
  if (this.#starting || this.#started)
8586
8575
  return;
8587
8576
  this.#starting = true;
8588
- const importee = await import('./client-q0JXZnpu-ChkF_Pn_.js');
8577
+ const importee = await import('./client-DCeU_UX5-CR7iKpxy.js');
8589
8578
  /**
8590
8579
  * @access public
8591
8580
  * @type {PeernetClient}
@@ -9135,4 +9124,4 @@ class Node {
9135
9124
  }
9136
9125
  }
9137
9126
 
9138
- export { FormatInterface as F, LittlePubSub as L, Node as N };
9127
+ export { FormatInterface as F, LittlePubSub as L, Node as N, createDebugger as c, deflate_1 as d, inflate_1 as i };
@@ -1,4 +1,4 @@
1
- export { N as default } from './node-browser-SPIwS-5O.js';
2
- import './identity-nIyW_Xm8-BU8xakCv.js';
1
+ export { N as default } from './node-browser-Bv-OkGUJ.js';
2
+ import './identity-B6BHwSTU-5rsAWMHo.js';
3
3
  import './index-DUfUgiQY.js';
4
4
  import './networks-BdMfU1ag.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {
@@ -54,8 +54,8 @@
54
54
  "@rollup/plugin-node-resolve": "^16.0.3",
55
55
  "@rollup/plugin-typescript": "^12.3.0",
56
56
  "@types/semver": "^7.7.1",
57
- "@vandeurenglenn/debug": "^1.2.7",
58
- "rollup": "^4.53.4",
57
+ "@vandeurenglenn/debug": "^1.4.0",
58
+ "rollup": "^4.54.0",
59
59
  "rollup-plugin-modify": "^3.0.0",
60
60
  "tape": "^5.9.0",
61
61
  "tslib": "^2.8.1"
@@ -69,7 +69,7 @@
69
69
  "@leofcoin/messages": "^1.4.40",
70
70
  "@leofcoin/multi-wallet": "^3.1.8",
71
71
  "@leofcoin/networks": "^1.1.25",
72
- "@leofcoin/peernet": "^1.1.105",
72
+ "@leofcoin/peernet": "^1.2.0",
73
73
  "@leofcoin/storage": "^3.5.38",
74
74
  "@leofcoin/utils": "^1.1.40",
75
75
  "@leofcoin/workers": "^1.5.27",
@@ -1,36 +0,0 @@
1
- import { M as MultiWallet, f as encrypt, c as base58$1 } from './identity-nIyW_Xm8-BU8xakCv.js';
2
-
3
- /**
4
- * @params {String} network
5
- * @return {object} { identity, accounts, config }
6
- */
7
- var index = async (password, network) => {
8
- if (!password)
9
- throw new Error('wallets need to be password protected.');
10
- let wallet = new MultiWallet(network);
11
- /**
12
- * @type {string}
13
- */
14
- let mnemonic = await wallet.generate(password);
15
- wallet = new MultiWallet(network);
16
- await wallet.recover(mnemonic, password, network);
17
- mnemonic = new Uint8Array(await encrypt(password, mnemonic));
18
- const multiWIF = new Uint8Array(await encrypt(password, await wallet.multiWIF));
19
- /**
20
- * @type {object}
21
- */
22
- const external = await wallet.account(1).external(1);
23
- const externalAddress = await external.address;
24
- const internal = await wallet.account(1).internal(1);
25
- const internalAddress = await internal.address;
26
- return {
27
- identity: {
28
- mnemonic: base58$1.encode(mnemonic),
29
- multiWIF: base58$1.encode(multiWIF),
30
- walletId: await external.id
31
- },
32
- accounts: [['main account', externalAddress, internalAddress]]
33
- };
34
- };
35
-
36
- export { index as default };