@leofcoin/chain 1.5.35 → 1.5.36

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.
@@ -473,8 +473,10 @@ const transactionLimit = 1800;
473
473
  const requestTimeout = 30000;
474
474
  const syncTimeout = 30000;
475
475
  class Protocol {
476
- constructor() {
476
+ constructor(config) {
477
477
  this.resolveTimeout = 10000;
478
+ if (config.resolveTimeout)
479
+ this.resolveTimeout = config.resolveTimeout;
478
480
  }
479
481
  get limit() {
480
482
  return limit;
@@ -491,8 +493,8 @@ class Protocol {
491
493
  }
492
494
 
493
495
  class Transaction extends Protocol {
494
- constructor() {
495
- super();
496
+ constructor(config) {
497
+ super(config);
496
498
  }
497
499
  /**
498
500
  *
@@ -674,8 +676,8 @@ class Transaction extends Protocol {
674
676
  * @extends {Transaction}
675
677
  */
676
678
  class Contract extends Transaction {
677
- constructor() {
678
- super();
679
+ constructor(config) {
680
+ super(config);
679
681
  }
680
682
  async init() { }
681
683
  /**
@@ -1163,8 +1165,8 @@ class State extends Contract {
1163
1165
  get machine() {
1164
1166
  return this.#machine;
1165
1167
  }
1166
- constructor() {
1167
- super();
1168
+ constructor(config) {
1169
+ super(config);
1168
1170
  this.#lastResolvedTime = 0;
1169
1171
  this.#resolving = false;
1170
1172
  this.#resolveErrorCount = 0;
@@ -1663,8 +1665,8 @@ class State extends Contract {
1663
1665
  }
1664
1666
 
1665
1667
  class VersionControl extends State {
1666
- constructor() {
1667
- super();
1668
+ constructor(config) {
1669
+ super(config);
1668
1670
  }
1669
1671
  async init() {
1670
1672
  super.init && (await super.init());
@@ -1708,8 +1710,8 @@ class Chain extends VersionControl {
1708
1710
  #participants;
1709
1711
  #participating;
1710
1712
  #jail;
1711
- constructor() {
1712
- super();
1713
+ constructor(config) {
1714
+ super(config);
1713
1715
  this.#slotTime = 10000;
1714
1716
  this.utils = {};
1715
1717
  /** {Address[]} */
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-484d9d8b.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-1bc3977e.js';
2
2
  import './index-4420907d.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-484d9d8b.js';
1
+ import { F as FormatInterface } from './node-browser-1bc3977e.js';
2
2
  import './index-4420907d.js';
3
3
 
4
4
  var proto$b = {
@@ -12542,7 +12542,7 @@ const BufferToUint8Array = (data) => {
12542
12542
 
12543
12543
  const protoFor = (message) => {
12544
12544
  const codec = new Codec(message);
12545
- if (!codec.name) throw new Error('proto not found')
12545
+ if (!codec.name) throw new Error(`proto not found ${message}`)
12546
12546
  const Proto = globalThis.peernet.protos[codec.name];
12547
12547
  if (!Proto) throw new Error(`No proto defined for ${codec.name}`)
12548
12548
  return new Proto(message)
@@ -12816,9 +12816,13 @@ class MessageHandler {
12816
12816
  const dataHandler = async (message) => {
12817
12817
  if (!message) return
12818
12818
 
12819
- const { data, id, from, peer } = message;
12820
- const proto = await protoFor(data);
12821
- peernet._protoHandler({ id, proto }, peernet.connections[from] || peer, from);
12819
+ try {
12820
+ const { data, id, from, peer } = message;
12821
+ const proto = await protoFor(data);
12822
+ peernet._protoHandler({ id, proto }, peernet.connections[from] || peer, from);
12823
+ } catch (error) {
12824
+ console.error(error);
12825
+ }
12822
12826
  };
12823
12827
 
12824
12828
  const dhtError = (proto) => {
@@ -27169,7 +27173,7 @@ class Identity {
27169
27173
  this.selectedAccount = new TextDecoder().decode(selected);
27170
27174
  }
27171
27175
  else {
27172
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-3614702b-6244d21e.js');
27176
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-20ad607b-d0eaabce.js');
27173
27177
  const { identity, accounts } = await importee.default(password, this.network);
27174
27178
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
27175
27179
  await globalThis.walletStore.put('version', String(1));
@@ -27361,7 +27365,7 @@ class Peernet {
27361
27365
  this.root = options.root;
27362
27366
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
27363
27367
  // FolderMessageResponse
27364
- } = await import(/* webpackChunkName: "messages" */ './messages-92c1c441-6c77c6bd.js');
27368
+ } = await import(/* webpackChunkName: "messages" */ './messages-29f5675b-a1c47a58.js');
27365
27369
  /**
27366
27370
  * proto Object containing protos
27367
27371
  * @type {Object}
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-484d9d8b.js';
1
+ export { N as default } from './node-browser-1bc3977e.js';
2
2
  import './index-4420907d.js';
@@ -5,7 +5,7 @@ export default class Chain extends VersionControl {
5
5
  #private;
6
6
  id: any;
7
7
  utils: {};
8
- constructor();
8
+ constructor(config: any);
9
9
  get nativeToken(): string;
10
10
  get validators(): any[];
11
11
  hasTransactionToHandle(): Promise<boolean>;
package/exports/chain.js CHANGED
@@ -11,8 +11,10 @@ const transactionLimit = 1800;
11
11
  const requestTimeout = 30000;
12
12
  const syncTimeout = 30000;
13
13
  class Protocol {
14
- constructor() {
14
+ constructor(config) {
15
15
  this.resolveTimeout = 10000;
16
+ if (config.resolveTimeout)
17
+ this.resolveTimeout = config.resolveTimeout;
16
18
  }
17
19
  get limit() {
18
20
  return limit;
@@ -29,8 +31,8 @@ class Protocol {
29
31
  }
30
32
 
31
33
  class Transaction extends Protocol {
32
- constructor() {
33
- super();
34
+ constructor(config) {
35
+ super(config);
34
36
  }
35
37
  /**
36
38
  *
@@ -212,8 +214,8 @@ class Transaction extends Protocol {
212
214
  * @extends {Transaction}
213
215
  */
214
216
  class Contract extends Transaction {
215
- constructor() {
216
- super();
217
+ constructor(config) {
218
+ super(config);
217
219
  }
218
220
  async init() { }
219
221
  /**
@@ -599,8 +601,8 @@ class State extends Contract {
599
601
  get machine() {
600
602
  return this.#machine;
601
603
  }
602
- constructor() {
603
- super();
604
+ constructor(config) {
605
+ super(config);
604
606
  this.#lastResolvedTime = 0;
605
607
  this.#resolving = false;
606
608
  this.#resolveErrorCount = 0;
@@ -1099,8 +1101,8 @@ class State extends Contract {
1099
1101
  }
1100
1102
 
1101
1103
  class VersionControl extends State {
1102
- constructor() {
1103
- super();
1104
+ constructor(config) {
1105
+ super(config);
1104
1106
  }
1105
1107
  async init() {
1106
1108
  super.init && (await super.init());
@@ -1144,8 +1146,8 @@ class Chain extends VersionControl {
1144
1146
  #participants;
1145
1147
  #participating;
1146
1148
  #jail;
1147
- constructor() {
1148
- super();
1149
+ constructor(config) {
1150
+ super(config);
1149
1151
  this.#slotTime = 10000;
1150
1152
  this.utils = {};
1151
1153
  /** {Address[]} */
@@ -4,7 +4,7 @@ import type MultiWallet from '@leofcoin/multi-wallet';
4
4
  * @extends {Transaction}
5
5
  */
6
6
  export default class Contract extends Transaction {
7
- constructor();
7
+ constructor(config: any);
8
8
  init(): Promise<void>;
9
9
  /**
10
10
  *
@@ -1,3 +1,4 @@
1
+ import type { ChainConfig } from './types.js';
1
2
  export declare const limit = 1800;
2
3
  export declare const transactionLimit = 1800;
3
4
  export declare const requestTimeout = 30000;
@@ -5,6 +6,7 @@ export declare const syncTimeout = 30000;
5
6
  export declare class Protocol {
6
7
  version: string;
7
8
  resolveTimeout: EpochTimeStamp;
9
+ constructor(config: ChainConfig);
8
10
  get limit(): number;
9
11
  get transactionLimit(): number;
10
12
  get requestTimeout(): number;
@@ -29,7 +29,7 @@ export default class State extends Contract {
29
29
  };
30
30
  get totalSize(): number;
31
31
  get machine(): Machine;
32
- constructor();
32
+ constructor(config: any);
33
33
  clearPool(): Promise<void>;
34
34
  /**
35
35
  * drastic measurement, removes everything!
@@ -2,7 +2,7 @@ import Protocol from './protocol.js';
2
2
  import { TransactionMessage } from '@leofcoin/messages';
3
3
  export default class Transaction extends Protocol {
4
4
  #private;
5
- constructor();
5
+ constructor(config: any);
6
6
  /**
7
7
  *
8
8
  * @param {Address[]} transactions
@@ -1,5 +1,5 @@
1
1
  import State from './state.js';
2
2
  export declare class VersionControl extends State {
3
- constructor();
3
+ constructor(config: any);
4
4
  init(): Promise<void>;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.35",
3
+ "version": "1.5.36",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {