@leofcoin/chain 1.10.15 → 1.10.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/beacon-wire.js +2 -2
- package/exports/browser/{browser-DvU1xNFS-DmmNUdE-.js → browser-CCfR9KOM-CvhDZrGu.js} +3 -3
- package/exports/browser/{browser-crypto-B9N9KlL4.js → browser-crypto-CeE-yId5.js} +283 -158
- package/exports/browser/chain.js +28 -11
- package/exports/browser/{client-DDC8C510-3uaB70KL.js → client-CAC7RVMf-Dmz_2A_5.js} +4 -4
- package/exports/browser/{connection-monitor-GPztgSSJ.js → connection-monitor-Cmv00mwl.js} +4 -4
- package/exports/browser/{index-Ccn5sExe.js → index-BC-KRBgE.js} +55 -52
- package/exports/browser/{index-Bxr5Iztg-WbFIosyf.js → index-dTQVgkpf-CuHJWO2l.js} +3 -3
- package/exports/browser/{messages-DH0tgNM9-C2CtyLsf.js → messages-Dw86z0zq-DrPw_nlZ.js} +9 -4
- package/exports/browser/{node-browser-BYi7D_oa.js → node-browser-DWSdi-XP.js} +950 -482
- package/exports/browser/node-browser.js +3 -3
- package/exports/browser/workers/block-worker.js +5 -3
- package/exports/browser/workers/machine-worker.js +8 -8
- package/exports/{workers/worker-DMCj1e6z-CTYVa2yX.js → browser/workers/worker-BDTWOCzS-COrAszCt.js} +304 -168
- package/exports/chain.js +10 -5
- package/exports/{constants-CMYKv-Rt.js → constants-Dy9i9S_o.js} +1 -1
- package/exports/hash-format-state.js +17 -0
- package/exports/node.js +1 -1
- package/exports/workers/block-worker.js +5 -3
- package/exports/workers/machine-worker.js +8 -8
- package/exports/{browser/workers/worker-DMCj1e6z-CTYVa2yX.js → workers/worker-BDTWOCzS-COrAszCt.js} +304 -168
- package/package.json +2 -2
package/exports/browser/chain.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as FormatInterface, p as proto, a as proto$1, b as proto$2, T as TransactionMessage, j as jsonStringifyBigInt, c as jsonParseBigInt, C as ContractMessage, d as Codec } from './browser-crypto-
|
|
2
|
-
import { B as BlockMessage, L as LastBlockMessage, P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO, C as ConnectionMonitor, a as BWMessage, S as StateMessage } from './connection-monitor-
|
|
3
|
-
import { M as MAX_TRANSACTION_BYTES, a as MAX_BLOCK_TRANSACTION_BYTES, b as MAX_BLOCK_TRANSACTIONS, c as MultiWallet, d as createTransactionHash, e as calculateFee, f as createContractMessage, s as signTransaction, r as randombytes, g as distributeTransactionFee, h as supportsTransactionFees, i as supportsMonetaryPolicy, v as validateBlockResourceLimits, j as calculateMonetaryPolicy, k as distributeAmount, l as aggregateValidatorFees, m as MONETARY_POLICY_AUTHORITY, n as contractFactoryMessage, o as nativeTokenMessage, p as validatorsMessage, q as nameServiceMessage, t as parseUnits, u as formatUnits } from './index-
|
|
1
|
+
import { F as FormatInterface, p as proto, a as proto$1, b as proto$2, T as TransactionMessage, j as jsonStringifyBigInt, c as jsonParseBigInt, C as ContractMessage, d as Codec } from './browser-crypto-CeE-yId5.js';
|
|
2
|
+
import { B as BlockMessage, L as LastBlockMessage, P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO, C as ConnectionMonitor, a as BWMessage, S as StateMessage } from './connection-monitor-Cmv00mwl.js';
|
|
3
|
+
import { M as MAX_TRANSACTION_BYTES, a as MAX_BLOCK_TRANSACTION_BYTES, b as MAX_BLOCK_TRANSACTIONS, c as MultiWallet, d as createTransactionHash, e as calculateFee, f as createContractMessage, s as signTransaction, r as randombytes, g as distributeTransactionFee, h as supportsTransactionFees, i as supportsMonetaryPolicy, v as validateBlockResourceLimits, j as calculateMonetaryPolicy, k as distributeAmount, l as aggregateValidatorFees, m as MONETARY_POLICY_AUTHORITY, n as contractFactoryMessage, o as nativeTokenMessage, p as validatorsMessage, q as nameServiceMessage, t as parseUnits, u as formatUnits } from './index-BC-KRBgE.js';
|
|
4
4
|
import { f as fromBase58 } from './index-CvKt4UDE.js';
|
|
5
5
|
import { q as quorumThreshold } from './quorum-S_qdgiAY.js';
|
|
6
6
|
import './sha2-piimb6xL.js';
|
|
@@ -77,10 +77,10 @@ class ProposalMessage extends FormatInterface {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
var contractFactory$1 = "
|
|
81
|
-
var nativeToken$1 = "
|
|
82
|
-
var nameService$1 = "
|
|
83
|
-
var validators$1 = "
|
|
80
|
+
var contractFactory$1 = "B3OGRUBSBGSASFXWDZUI6AYITY76PYQZS4O5UDWVLSW56X5CSWTQGTGQHUGU";
|
|
81
|
+
var nativeToken$1 = "B3OGRUBSA5V74HIRRP6YPMZYDZ7YM3SR3MQX63XSYEZIZ7TWHBPDWRWVA2XA";
|
|
82
|
+
var nameService$1 = "B3OGRUBSBXX7EPFWHGZQGGSWBMMK7ATOSDICOW5CCFP25OMZBTRMHYGM4KFF";
|
|
83
|
+
var validators$1 = "B3OGRUBSBXLCYRTXG5SRL6XNINEJNAI7CLJBKSRCXY24GMFU5ZY7TXHAGJGT";
|
|
84
84
|
var addresses$1 = {
|
|
85
85
|
contractFactory: contractFactory$1,
|
|
86
86
|
nativeToken: nativeToken$1,
|
|
@@ -5176,6 +5176,19 @@ const pruneCanonicalTransactions = async (transactions, latestTransactionHashes,
|
|
|
5176
5176
|
return pending;
|
|
5177
5177
|
};
|
|
5178
5178
|
|
|
5179
|
+
const assertHashFormatState = async (chainStore, stateStore) => {
|
|
5180
|
+
if (await chainStore.has("version")) {
|
|
5181
|
+
const version = new TextDecoder().decode(await chainStore.get("version"));
|
|
5182
|
+
const parsed = /^(\d+)\.(\d+)\.\d+$/.exec(version);
|
|
5183
|
+
const current = PROTOCOL_VERSION.split(".");
|
|
5184
|
+
if (parsed && parsed[1] === current[0] && parsed[2] === current[1]) return;
|
|
5185
|
+
throw new Error(`stored protocol ${version} is incompatible with canonical hash protocol ${PROTOCOL_VERSION}; back up existing data and use a separate migrated data root`);
|
|
5186
|
+
}
|
|
5187
|
+
if (await chainStore.has("lastBlock") || await stateStore?.has("lastBlock")) {
|
|
5188
|
+
throw new Error("existing chainstate has no protocol version; explicit canonical hash migration required");
|
|
5189
|
+
}
|
|
5190
|
+
};
|
|
5191
|
+
|
|
5179
5192
|
const debug = createDebugger("leofcoin/chain");
|
|
5180
5193
|
class Chain extends VersionControl {
|
|
5181
5194
|
constructor(config) {
|
|
@@ -5223,8 +5236,9 @@ class Chain extends VersionControl {
|
|
|
5223
5236
|
this.#committingHeights = /* @__PURE__ */ new Set();
|
|
5224
5237
|
/** Prevents casting duplicate prevote/precommit per height:round */
|
|
5225
5238
|
this.#castedVotes = /* @__PURE__ */ new Set();
|
|
5226
|
-
this.ready = new Promise((resolve) => {
|
|
5239
|
+
this.ready = new Promise((resolve, reject) => {
|
|
5227
5240
|
this.readyResolve = resolve;
|
|
5241
|
+
this.readyReject = reject;
|
|
5228
5242
|
});
|
|
5229
5243
|
// ── Tendermint consensus handlers ────────────────────────────────────────
|
|
5230
5244
|
/**
|
|
@@ -5408,7 +5422,7 @@ class Chain extends VersionControl {
|
|
|
5408
5422
|
const hash = await this.#sendTransaction(message);
|
|
5409
5423
|
debug(`added ${hash}`);
|
|
5410
5424
|
};
|
|
5411
|
-
this.#init();
|
|
5425
|
+
this.#init().catch((error) => this.readyReject(error));
|
|
5412
5426
|
}
|
|
5413
5427
|
#state;
|
|
5414
5428
|
#slotTime;
|
|
@@ -5704,15 +5718,18 @@ class Chain extends VersionControl {
|
|
|
5704
5718
|
message: nameServiceMessage
|
|
5705
5719
|
}
|
|
5706
5720
|
];
|
|
5707
|
-
await Promise.all(
|
|
5721
|
+
const prepared = await Promise.all(
|
|
5708
5722
|
contracts.map(async ({ address, message }) => {
|
|
5709
5723
|
message = await new ContractMessage(Uint8Array.from(message.split(",").map((string) => Number(string))));
|
|
5710
|
-
await
|
|
5724
|
+
if (await message.hash() !== address) throw new Error(`genesis contract hash mismatch for ${address}`);
|
|
5725
|
+
return { address, encoded: message.encoded };
|
|
5711
5726
|
})
|
|
5712
5727
|
);
|
|
5728
|
+
await Promise.all(prepared.map(({ address, encoded }) => globalThis.contractStore.put(address, encoded)));
|
|
5713
5729
|
console.log("handle native contracts");
|
|
5714
5730
|
}
|
|
5715
5731
|
async #init() {
|
|
5732
|
+
await assertHashFormatState(globalThis.chainStore, globalThis.stateStore);
|
|
5716
5733
|
this.#participants = [];
|
|
5717
5734
|
this.#participating = false;
|
|
5718
5735
|
this.#connectionMonitor = new ConnectionMonitor();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-
|
|
2
|
-
import './browser-crypto-
|
|
3
|
-
import './connection-monitor-
|
|
1
|
+
import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-DWSdi-XP.js';
|
|
2
|
+
import './browser-crypto-CeE-yId5.js';
|
|
3
|
+
import './connection-monitor-Cmv00mwl.js';
|
|
4
4
|
import './index-CvKt4UDE.js';
|
|
5
5
|
import './sha2-piimb6xL.js';
|
|
6
6
|
|
|
@@ -233,7 +233,7 @@ class SocketRequestClient {
|
|
|
233
233
|
const init = async () => {
|
|
234
234
|
// @ts-ignore
|
|
235
235
|
if (!globalThis.WebSocket && !this.#experimentalWebsocket)
|
|
236
|
-
globalThis.WebSocket = (await import('./browser-
|
|
236
|
+
globalThis.WebSocket = (await import('./browser-CCfR9KOM-CvhDZrGu.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
237
237
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
238
238
|
if (this.#experimentalWebsocket) {
|
|
239
239
|
client.addEventListener('error', this.onerror);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormatInterface, o as proto$2, q as proto$3,
|
|
1
|
+
import { F as FormatInterface, o as proto$2, q as proto$3, r as encodeFrames, s as decodeFrames, t as proto$4 } from './browser-crypto-CeE-yId5.js';
|
|
2
2
|
|
|
3
3
|
class ValidatorMessage extends FormatInterface {
|
|
4
4
|
get messageName() {
|
|
@@ -33,13 +33,13 @@ class BlockMessage extends FormatInterface {
|
|
|
33
33
|
}
|
|
34
34
|
return super.encode({
|
|
35
35
|
...decoded,
|
|
36
|
-
validators:
|
|
36
|
+
validators: encodeFrames(validators)
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
decode(encoded) {
|
|
40
40
|
encoded = encoded || this.encoded;
|
|
41
41
|
super.decode(encoded);
|
|
42
|
-
this.decoded.validators =
|
|
42
|
+
this.decoded.validators = decodeFrames(this.decoded.validators, 0, { canonical: false }).map((validator) => new ValidatorMessage(validator).decoded);
|
|
43
43
|
return this.decoded;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -118,7 +118,7 @@ var networks$1 = /*#__PURE__*/Object.freeze({
|
|
|
118
118
|
default: networks
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
const PROTOCOL_VERSION = "0.
|
|
121
|
+
const PROTOCOL_VERSION = "0.4.0";
|
|
122
122
|
const REACHED_ONE_ZERO_ZERO = false;
|
|
123
123
|
const DEFAULT_NODE_OPTIONS = {
|
|
124
124
|
autoStart: false,
|