@leofcoin/chain 1.5.41 → 1.5.43
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.
- package/exports/browser/chain.js +10 -5
- package/exports/browser/{index-7dedefe5-b92d7eab.js → index-2836cc96-40ed5df4.js} +1 -1
- package/exports/browser/{messages-7cab2a51-aba26369.js → messages-554d2a85-ce06f6eb.js} +1 -1
- package/exports/browser/{node-browser-ccc3409e.js → node-browser-77f8d4c5.js} +13 -6
- package/exports/browser/node-browser.js +1 -1
- package/exports/chain.js +10 -5
- package/exports/constants.d.ts +6 -0
- package/exports/node-browser.d.ts +0 -1
- package/exports/node.js +8 -0
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -4696,7 +4696,7 @@ class VersionControl extends State {
|
|
|
4696
4696
|
constructor(config) {
|
|
4697
4697
|
super(config);
|
|
4698
4698
|
}
|
|
4699
|
-
#currentVersion;
|
|
4699
|
+
#currentVersion = '1.2.0';
|
|
4700
4700
|
async #setCurrentVersion() {
|
|
4701
4701
|
this.version = this.#currentVersion;
|
|
4702
4702
|
await globalThis.chainStore.put('version', this.version);
|
|
@@ -4706,23 +4706,26 @@ class VersionControl extends State {
|
|
|
4706
4706
|
try {
|
|
4707
4707
|
const version = await globalThis.chainStore.get('version');
|
|
4708
4708
|
this.version = new TextDecoder().decode(version);
|
|
4709
|
-
console.log(this.version);
|
|
4709
|
+
console.log(this.version, this.#currentVersion);
|
|
4710
4710
|
/**
|
|
4711
4711
|
* protocol version control!
|
|
4712
4712
|
* note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
|
|
4713
4713
|
* in the future we want newer nodes to handle the new changes and still confirm old version transactions
|
|
4714
4714
|
* unless there is a security issue!
|
|
4715
4715
|
*/
|
|
4716
|
+
if (semver$1.compare('1.1.1', this.version) === 1) {
|
|
4717
|
+
await this.clearAll();
|
|
4718
|
+
}
|
|
4716
4719
|
if (semver$1.compare(this.#currentVersion, this.version) === 1) {
|
|
4717
4720
|
// await this.clearAll()
|
|
4718
|
-
this.#setCurrentVersion();
|
|
4721
|
+
await this.#setCurrentVersion();
|
|
4719
4722
|
}
|
|
4720
4723
|
// if (version)
|
|
4721
4724
|
}
|
|
4722
4725
|
catch (e) {
|
|
4723
4726
|
console.log(e);
|
|
4724
4727
|
// await this.clearAll()
|
|
4725
|
-
this.#setCurrentVersion();
|
|
4728
|
+
return this.#setCurrentVersion();
|
|
4726
4729
|
}
|
|
4727
4730
|
}
|
|
4728
4731
|
}
|
|
@@ -4879,7 +4882,9 @@ class Chain extends VersionControl {
|
|
|
4879
4882
|
}
|
|
4880
4883
|
return Promise.all(transactionsToGet);
|
|
4881
4884
|
}
|
|
4882
|
-
async #peerConnected(
|
|
4885
|
+
async #peerConnected(peerId) {
|
|
4886
|
+
const peer = peernet.getConnection(peerId);
|
|
4887
|
+
console.log({ peer });
|
|
4883
4888
|
// todo handle version changes
|
|
4884
4889
|
// for now just do nothing if version doesn't match
|
|
4885
4890
|
console.log(`${peer.version}, ${this.version}`);
|
|
@@ -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-
|
|
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-
|
|
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
|
|
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-
|
|
1
|
+
export { N as default } from './node-browser-77f8d4c5.js';
|
|
2
2
|
import './index-c3bd3090.js';
|
package/exports/chain.js
CHANGED
|
@@ -1107,7 +1107,7 @@ class VersionControl extends State {
|
|
|
1107
1107
|
constructor(config) {
|
|
1108
1108
|
super(config);
|
|
1109
1109
|
}
|
|
1110
|
-
#currentVersion;
|
|
1110
|
+
#currentVersion = '1.2.0';
|
|
1111
1111
|
async #setCurrentVersion() {
|
|
1112
1112
|
this.version = this.#currentVersion;
|
|
1113
1113
|
await globalThis.chainStore.put('version', this.version);
|
|
@@ -1117,23 +1117,26 @@ class VersionControl extends State {
|
|
|
1117
1117
|
try {
|
|
1118
1118
|
const version = await globalThis.chainStore.get('version');
|
|
1119
1119
|
this.version = new TextDecoder().decode(version);
|
|
1120
|
-
console.log(this.version);
|
|
1120
|
+
console.log(this.version, this.#currentVersion);
|
|
1121
1121
|
/**
|
|
1122
1122
|
* protocol version control!
|
|
1123
1123
|
* note v1 and 1.1 delete everything because of big changes, this is not what we want in the future
|
|
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(
|
|
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}`);
|
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);
|