@leofcoin/chain 1.9.14 → 1.9.16
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/{browser-DTwbEd2v-BvEtTVTB.js → browser-8BFql6K9-BMRX6B2u.js} +3 -1
- package/exports/browser/{browser-AkMNdace-11JEjCcV.js → browser-FVp_QbaL-zB8FF4EN.js} +3 -1
- package/exports/browser/chain.js +27 -7
- package/exports/browser/client-lPe0SUWx-DR-mCTBz.js +2164 -0
- package/exports/browser/{index-C8MlQb3B-Cb0OaBTu.js → index-D6qd-AUn-CCzkkXys.js} +3 -1
- package/exports/browser/{messages-skO3uGkB-D-Ej3W9s.js → messages-BfDvXW-x-C-CI69S2.js} +2 -2
- package/exports/browser/{node-browser-Oq89xLSU.js → node-browser-y2adT6_R.js} +8370 -26
- package/exports/browser/node-browser.js +2 -2
- package/exports/chain.js +27 -7
- package/package.json +4 -4
- package/exports/browser/client-B5W9RVIn-DHAPaCMU.js +0 -1047
- package/exports/browser/identity-B8_RBemH-Dq17MYzU.js +0 -17530
- package/exports/browser/index-avzvc6cK-CDbEoIOc.js +0 -7595
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './node-browser-y2adT6_R.js';
|
|
2
|
+
import 'crypto';
|
|
3
|
+
import './constants-V2VjIc2r.js';
|
|
2
4
|
|
|
3
5
|
function _mergeNamespaces$1(n, m) {
|
|
4
6
|
m.forEach(function (e) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './node-browser-y2adT6_R.js';
|
|
2
|
+
import 'crypto';
|
|
3
|
+
import './constants-V2VjIc2r.js';
|
|
2
4
|
|
|
3
5
|
function _mergeNamespaces$1(n, m) {
|
|
4
6
|
m.forEach(function (e) {
|
package/exports/browser/chain.js
CHANGED
|
@@ -6309,9 +6309,11 @@ class Chain extends VersionControl {
|
|
|
6309
6309
|
});
|
|
6310
6310
|
await globalThis.peernet.addRequestHandler("transactionPool", this.#transactionPoolHandler.bind(this));
|
|
6311
6311
|
await globalThis.peernet.addRequestHandler("version", this.#versionHandler.bind(this));
|
|
6312
|
-
await globalThis.peernet.addRequestHandler("stateInfo", () => {
|
|
6312
|
+
await globalThis.peernet.addRequestHandler("stateInfo", async () => {
|
|
6313
|
+
const lastblock = await this.lastBlock || { index: 0, hash: "0x0", previousHash: "0x0" };
|
|
6314
|
+
const values = this.machine?.states?.info || {};
|
|
6313
6315
|
return new globalThis.peernet.protos["peernet-response"]({
|
|
6314
|
-
response: new StateMessage(
|
|
6316
|
+
response: new StateMessage({ lastblock, values }).encoded
|
|
6315
6317
|
});
|
|
6316
6318
|
});
|
|
6317
6319
|
globalThis.peernet.subscribe("add-block", this.#addBlock.bind(this));
|
|
@@ -6363,10 +6365,27 @@ class Chain extends VersionControl {
|
|
|
6363
6365
|
try {
|
|
6364
6366
|
let response = await peer.request(node.encoded);
|
|
6365
6367
|
response = await new globalThis.peernet.protos["peernet-response"](response);
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6368
|
+
const decodeResponse = async (payload) => {
|
|
6369
|
+
if (!(payload instanceof Uint8Array)) return payload;
|
|
6370
|
+
for (let i = 0; i < 3; i++) {
|
|
6371
|
+
try {
|
|
6372
|
+
const nested = await new globalThis.peernet.protos["peernet-response"](payload);
|
|
6373
|
+
payload = nested?.decoded?.response;
|
|
6374
|
+
if (!(payload instanceof Uint8Array)) break;
|
|
6375
|
+
} catch {
|
|
6376
|
+
break;
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
if (payload instanceof Uint8Array) {
|
|
6380
|
+
try {
|
|
6381
|
+
return JSON.parse(new TextDecoder().decode(payload));
|
|
6382
|
+
} catch {
|
|
6383
|
+
return payload;
|
|
6384
|
+
}
|
|
6385
|
+
}
|
|
6386
|
+
return payload;
|
|
6387
|
+
};
|
|
6388
|
+
return await decodeResponse(response.decoded.response);
|
|
6370
6389
|
} catch (error) {
|
|
6371
6390
|
const peerId = peer?.peerId || peer?.id || peer?.address || "unknown";
|
|
6372
6391
|
debug(`peernet request failed: ${request} -> ${peerId}:`, error?.message ?? error);
|
|
@@ -6553,7 +6572,8 @@ class Chain extends VersionControl {
|
|
|
6553
6572
|
try {
|
|
6554
6573
|
let stateInfo = await this.#makeRequest(peer, "stateInfo");
|
|
6555
6574
|
if (stateInfo instanceof Uint8Array) {
|
|
6556
|
-
|
|
6575
|
+
const decodedStateInfo = new StateMessage(stateInfo).decoded;
|
|
6576
|
+
stateInfo = decodedStateInfo?.values ?? decodedStateInfo;
|
|
6557
6577
|
}
|
|
6558
6578
|
debug(
|
|
6559
6579
|
`sync start with peer ${peerId}: local=${localBlock?.index ?? -1} remote=${lastBlock?.index ?? -1} hash=${lastBlock?.hash}`
|