@leofcoin/chain 1.5.42 → 1.5.44

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 { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-ccc3409e.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-77f8d4c5.js';
2
2
  import './index-c3bd3090.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-ccc3409e.js';
1
+ import { F as FormatInterface } from './node-browser-77f8d4c5.js';
2
2
  import './index-c3bd3090.js';
3
3
 
4
4
  var proto$b = {
@@ -27178,7 +27178,7 @@ class Identity {
27178
27178
  this.selectedAccount = new TextDecoder().decode(selected);
27179
27179
  }
27180
27180
  else {
27181
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-7dedefe5-b92d7eab.js');
27181
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-2836cc96-40ed5df4.js');
27182
27182
  const { identity, accounts } = await importee.default(password, this.network);
27183
27183
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
27184
27184
  await globalThis.walletStore.put('version', String(1));
@@ -27369,7 +27369,7 @@ class Peernet {
27369
27369
  this.root = options.root;
27370
27370
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
27371
27371
  // FolderMessageResponse
27372
- } = await import(/* webpackChunkName: "messages" */ './messages-7cab2a51-aba26369.js');
27372
+ } = await import(/* webpackChunkName: "messages" */ './messages-554d2a85-ce06f6eb.js');
27373
27373
  /**
27374
27374
  * proto Object containing protos
27375
27375
  * @type {Object}
@@ -27594,7 +27594,7 @@ class Peernet {
27594
27594
  to: peerId,
27595
27595
  version
27596
27596
  });
27597
- peer.on('signal', (signal) => this.#peerSignal(peer, signal, star));
27597
+ peer.on('signal', (signal) => this.#peerSignal(peer, signal, star, this.version));
27598
27598
  peer.on('connect', () => this.#peerConnect(peer));
27599
27599
  peer.on('close', () => this.#peerClose(peer));
27600
27600
  peer.on('data', (data) => this.#peerData(peer, data));
@@ -27626,7 +27626,7 @@ class Peernet {
27626
27626
  console.warn(`channelNames don't match: got ${peer.channelName}, expected: ${channelName}`);
27627
27627
  peer.signal(signal);
27628
27628
  };
27629
- #peerSignal = (peer, signal, star) => {
27629
+ #peerSignal = (peer, signal, star, version) => {
27630
27630
  let client = this.#stars[star];
27631
27631
  if (!client)
27632
27632
  client = this.#stars[Object.keys(this.#stars)[0]];
@@ -27636,7 +27636,7 @@ class Peernet {
27636
27636
  from: this.peerId,
27637
27637
  to: peer.peerId,
27638
27638
  channelName: peer.channelName,
27639
- version: this.version,
27639
+ version,
27640
27640
  signal
27641
27641
  }
27642
27642
  });
@@ -28178,6 +28178,13 @@ var networks = {
28178
28178
  }
28179
28179
  };
28180
28180
 
28181
+ const DEFAULT_NODE_OPTIONS = {
28182
+ network: 'leofcoin:peach',
28183
+ networkVersion: 'peach',
28184
+ version: '1.2.0',
28185
+ stars: networks.leofcoin.peach.stars
28186
+ };
28187
+
28181
28188
  // import config from './config/config'
28182
28189
  class Node {
28183
28190
  #node;
@@ -28186,11 +28193,11 @@ class Node {
28186
28193
  }
28187
28194
  async _init(config = {
28188
28195
  network: 'leofcoin:peach',
28189
- networkName: 'leofcoin:peach',
28190
28196
  networkVersion: 'peach',
28191
28197
  version: '1.2.0',
28192
28198
  stars: networks.leofcoin.peach.stars
28193
28199
  }, password) {
28200
+ config = { ...DEFAULT_NODE_OPTIONS, ...config };
28194
28201
  this.#node = globalThis.Peernet
28195
28202
  ? await new globalThis.Peernet(config, password)
28196
28203
  : await new Peernet(config, password);
@@ -1,2 +1,2 @@
1
- export { N as default } from './node-browser-ccc3409e.js';
1
+ export { N as default } from './node-browser-77f8d4c5.js';
2
2
  import './index-c3bd3090.js';
package/exports/chain.js CHANGED
@@ -1124,16 +1124,19 @@ class VersionControl extends State {
1124
1124
  * in the future we want newer nodes to handle the new changes and still confirm old version transactions
1125
1125
  * unless there is a security issue!
1126
1126
  */
1127
+ if (semver.compare('1.1.1', this.version) === 1) {
1128
+ await this.clearAll();
1129
+ }
1127
1130
  if (semver.compare(this.#currentVersion, this.version) === 1) {
1128
1131
  // await this.clearAll()
1129
- this.#setCurrentVersion();
1132
+ await this.#setCurrentVersion();
1130
1133
  }
1131
1134
  // if (version)
1132
1135
  }
1133
1136
  catch (e) {
1134
1137
  console.log(e);
1135
1138
  // await this.clearAll()
1136
- this.#setCurrentVersion();
1139
+ return this.#setCurrentVersion();
1137
1140
  }
1138
1141
  }
1139
1142
  }
@@ -1290,7 +1293,9 @@ class Chain extends VersionControl {
1290
1293
  }
1291
1294
  return Promise.all(transactionsToGet);
1292
1295
  }
1293
- async #peerConnected(peer) {
1296
+ async #peerConnected(peerId) {
1297
+ const peer = peernet.getConnection(peerId);
1298
+ console.log({ peer });
1294
1299
  // todo handle version changes
1295
1300
  // for now just do nothing if version doesn't match
1296
1301
  console.log(`${peer.version}, ${this.version}`);
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_NODE_OPTIONS: {
2
+ network: string;
3
+ networkVersion: string;
4
+ version: string;
5
+ stars: string[];
6
+ };
@@ -3,7 +3,6 @@ export default class Node {
3
3
  constructor(config: any, password: string);
4
4
  _init(config: {
5
5
  network: string;
6
- networkName: string;
7
6
  networkVersion: string;
8
7
  version: string;
9
8
  stars: string[];
package/exports/node.js CHANGED
@@ -2,6 +2,13 @@ import Peernet from '@leofcoin/peernet';
2
2
  import nodeConfig from '@leofcoin/lib/node-config';
3
3
  import networks from '@leofcoin/networks';
4
4
 
5
+ const DEFAULT_NODE_OPTIONS = {
6
+ network: 'leofcoin:peach',
7
+ networkVersion: 'peach',
8
+ version: '1.2.0',
9
+ stars: networks.leofcoin.peach.stars
10
+ };
11
+
5
12
  // import config from './config/config'
6
13
  class Node {
7
14
  #node;
@@ -17,6 +24,7 @@ class Node {
17
24
  stars: networks.leofcoin.peach.stars,
18
25
  autoStart: false
19
26
  }, password) {
27
+ config = { ...DEFAULT_NODE_OPTIONS, ...config };
20
28
  this.#node = globalThis.Peernet
21
29
  ? await new globalThis.Peernet(config, password)
22
30
  : await new Peernet(config, password);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.5.42",
3
+ "version": "1.5.44",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": {