@leofcoin/chain 1.10.21 → 1.11.0
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/README.md +95 -0
- package/exports/browser/beacon-wire.js +2 -2
- package/exports/browser/{browser-CCfR9KOM-BGMMnVsR.js → browser-CCfR9KOM-CNWKLusu.js} +3 -3
- package/exports/browser/{browser-crypto-CH0ua22L.js → browser-crypto-B_UJguhk.js} +453 -35
- package/exports/browser/chain.js +1275 -996
- package/exports/browser/client-DbZBfpG6-C1cXgvfr.js +5943 -0
- package/exports/browser/{connection-monitor-D-krNiRH.js → connection-monitor-BzbeYGEt.js} +153 -24
- package/exports/browser/{index-dTQVgkpf-DOL2rIjp.js → index-dTQVgkpf-CkoAiRNX.js} +3 -3
- package/exports/browser/{index-DCbLvMKL.js → index-phv5KvaE.js} +238 -234
- package/exports/browser/{messages-DCePyqKC-BSvJxDWZ.js → messages-DZYCxoZI-B472zldo.js} +3 -3
- package/exports/browser/{node-browser-Ha4Lvntj.js → node-browser-BmyPBkL5.js} +55 -11
- package/exports/browser/node-browser.js +3 -3
- package/exports/browser/workers/block-worker.js +8 -9
- package/exports/browser/workers/machine-worker.js +141 -1195
- package/exports/{workers/worker-BDTWOCzS-COrAszCt.js → browser/workers/proposal.proto-8zgMfutf-B3So_tnS.js} +910 -398
- package/exports/chain.js +296 -1078
- package/exports/connection-monitor-BdFLRh-J.js +465 -0
- package/exports/connection-monitor.js +2 -324
- package/exports/{constants-Dy9i9S_o.js → constants-BQ6f-_OT.js} +1 -1
- package/exports/hash-format-state.js +3 -3
- package/exports/machine.js +550 -0
- package/exports/node.js +35 -2
- package/exports/state-checkpoint-BiQ1EXzo.js +110 -0
- package/exports/state-checkpoint.js +3 -0
- package/exports/workers/block-worker.js +8 -9
- package/exports/workers/machine-worker.js +141 -1195
- package/exports/{browser/workers/worker-BDTWOCzS-COrAszCt.js → workers/proposal.proto-8zgMfutf-B3So_tnS.js} +910 -398
- package/package.json +9 -7
- package/exports/browser/client-DKKzPSlb-C_1ug6ux.js +0 -2401
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as FormatInterface } from './node-browser-
|
|
2
|
-
import './browser-crypto-
|
|
3
|
-
import './connection-monitor-
|
|
1
|
+
import { F as FormatInterface } from './node-browser-BmyPBkL5.js';
|
|
2
|
+
import './browser-crypto-B_UJguhk.js';
|
|
3
|
+
import './connection-monitor-BzbeYGEt.js';
|
|
4
4
|
import './index-CvKt4UDE.js';
|
|
5
5
|
import './sha2-BKcEJzgd.js';
|
|
6
6
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BlockMessage,
|
|
1
|
+
import { B as BinaryFormat, s as proto, T as TransactionMessage, d as ContractMessage, r as createHash$1 } from './browser-crypto-B_UJguhk.js';
|
|
2
|
+
import { B as BlockMessage, b as BWMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS, g as guardPeerMessages, c as guardProviderDiscovery } from './connection-monitor-BzbeYGEt.js';
|
|
3
3
|
import './index-CvKt4UDE.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class BWRequestMessage extends FormatInterface$2 {
|
|
5
|
+
class BWRequestMessage extends BinaryFormat {
|
|
8
6
|
get messageName() {
|
|
9
7
|
return "BWRequestMessage";
|
|
10
8
|
}
|
|
@@ -54,6 +52,29 @@ var nodeConfig = async (config = {
|
|
|
54
52
|
};
|
|
55
53
|
};
|
|
56
54
|
|
|
55
|
+
function installBinaryPeerProtocol(node) {
|
|
56
|
+
if (!node.protos) throw new Error("Peer message registry is unavailable");
|
|
57
|
+
for (const [name, Original] of Object.entries(node.protos)) {
|
|
58
|
+
const schema = { ...new Original({}).proto };
|
|
59
|
+
if (name === "peernet-response") schema.response = void 0;
|
|
60
|
+
Object.freeze(schema);
|
|
61
|
+
const byteFields = Object.keys(schema).filter((key) => schema[key] instanceof Uint8Array).map((key) => key.endsWith("?") ? key.slice(0, -1) : key);
|
|
62
|
+
node.protos[name] = class extends BinaryFormat {
|
|
63
|
+
constructor(value) {
|
|
64
|
+
if (value && typeof value === "object" && !(value instanceof Uint8Array) && !(value instanceof ArrayBuffer)) {
|
|
65
|
+
value = { ...value };
|
|
66
|
+
for (const field of byteFields) {
|
|
67
|
+
if (typeof value[field] === "string")
|
|
68
|
+
value[field] = new TextEncoder().encode(value[field]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
super(value, schema, { name });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
node.binaryApplicationProtocol = 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
57
78
|
// base-x encoding / decoding
|
|
58
79
|
// Copyright (c) 2018 base-x contributors
|
|
59
80
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
@@ -8510,7 +8531,7 @@ class Identity {
|
|
|
8510
8531
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
8511
8532
|
}
|
|
8512
8533
|
else {
|
|
8513
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-dTQVgkpf-
|
|
8534
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-dTQVgkpf-CkoAiRNX.js');
|
|
8514
8535
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
8515
8536
|
if (fresh) {
|
|
8516
8537
|
await globalThis.accountStore.clear();
|
|
@@ -16102,7 +16123,7 @@ const blockchainCodecs = [
|
|
|
16102
16123
|
},
|
|
16103
16124
|
{
|
|
16104
16125
|
name: 'raw-transaction-message',
|
|
16105
|
-
codec: '
|
|
16126
|
+
codec: '0x72746d',
|
|
16106
16127
|
hashAlg: 'keccak-256'
|
|
16107
16128
|
},
|
|
16108
16129
|
{
|
|
@@ -16147,6 +16168,21 @@ const blockchainCodecs = [
|
|
|
16147
16168
|
}
|
|
16148
16169
|
];
|
|
16149
16170
|
const consensusCodecs = [
|
|
16171
|
+
{
|
|
16172
|
+
name: 'beacon-activation-message',
|
|
16173
|
+
codec: '0x62616d',
|
|
16174
|
+
hashAlg: 'keccak-256'
|
|
16175
|
+
},
|
|
16176
|
+
{
|
|
16177
|
+
name: 'beacon-commitment-message',
|
|
16178
|
+
codec: '0x62636d',
|
|
16179
|
+
hashAlg: 'keccak-256'
|
|
16180
|
+
},
|
|
16181
|
+
{
|
|
16182
|
+
name: 'beacon-share-message',
|
|
16183
|
+
codec: '0x62736d',
|
|
16184
|
+
hashAlg: 'keccak-256'
|
|
16185
|
+
},
|
|
16150
16186
|
{
|
|
16151
16187
|
name: 'proposal-message',
|
|
16152
16188
|
codec: '0x70726d',
|
|
@@ -16225,7 +16261,7 @@ const peernetCodecs = [
|
|
|
16225
16261
|
},
|
|
16226
16262
|
{
|
|
16227
16263
|
name: 'peernet-ps',
|
|
16228
|
-
codec: '
|
|
16264
|
+
codec: '0x707073',
|
|
16229
16265
|
hashAlg: 'keccak-256'
|
|
16230
16266
|
},
|
|
16231
16267
|
{
|
|
@@ -17927,7 +17963,7 @@ class Peernet {
|
|
|
17927
17963
|
await getAddress();
|
|
17928
17964
|
this.storePrefix = options.storePrefix;
|
|
17929
17965
|
this.root = options.root;
|
|
17930
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-
|
|
17966
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-DZYCxoZI-B472zldo.js');
|
|
17931
17967
|
/**
|
|
17932
17968
|
* proto Object containing protos
|
|
17933
17969
|
* @type {Object}
|
|
@@ -17973,7 +18009,7 @@ class Peernet {
|
|
|
17973
18009
|
if (this.#starting || this.#started)
|
|
17974
18010
|
return;
|
|
17975
18011
|
this.#starting = true;
|
|
17976
|
-
const importee = await import('./client-
|
|
18012
|
+
const importee = await import('./client-DbZBfpG6-C1cXgvfr.js');
|
|
17977
18013
|
/**
|
|
17978
18014
|
* @access public
|
|
17979
18015
|
* @type {PeernetClient}
|
|
@@ -18774,9 +18810,17 @@ class Node {
|
|
|
18774
18810
|
}
|
|
18775
18811
|
async _init(config = {}, password) {
|
|
18776
18812
|
config = { ...DEFAULT_NODE_OPTIONS, ...config };
|
|
18813
|
+
const autoStart = config.autoStart;
|
|
18814
|
+
config = { ...config, autoStart: false };
|
|
18777
18815
|
this.#node = globalThis.Peernet ? await new globalThis.Peernet(config, password) : await new Peernet(config, password);
|
|
18816
|
+
installBinaryPeerProtocol(this.#node);
|
|
18778
18817
|
guardPeerMessages(this.#node);
|
|
18818
|
+
guardProviderDiscovery(this.#node);
|
|
18779
18819
|
await nodeConfig(config);
|
|
18820
|
+
if (autoStart) {
|
|
18821
|
+
this.#node.autoStart = true;
|
|
18822
|
+
await this.#node.start();
|
|
18823
|
+
}
|
|
18780
18824
|
globalThis.pubsub.subscribe("chain:ready", async () => {
|
|
18781
18825
|
if (!this.#node.autoStart) {
|
|
18782
18826
|
await this.#node.start();
|
|
@@ -18787,4 +18831,4 @@ class Node {
|
|
|
18787
18831
|
}
|
|
18788
18832
|
}
|
|
18789
18833
|
|
|
18790
|
-
export { FormatInterface as F, LittlePubSub as L, MultiWallet as M, Node as N, base58$1 as b, createDebugger as c,
|
|
18834
|
+
export { FormatInterface as F, LittlePubSub as L, MultiWallet as M, Node as N, base58$1 as b, createDebugger as c, encrypt as e, getDefaultExportFromCjs as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './browser-crypto-
|
|
3
|
-
import './connection-monitor-
|
|
1
|
+
export { N as default } from './node-browser-BmyPBkL5.js';
|
|
2
|
+
import './browser-crypto-B_UJguhk.js';
|
|
3
|
+
import './connection-monitor-BzbeYGEt.js';
|
|
4
4
|
import './index-CvKt4UDE.js';
|
|
5
5
|
import './sha2-BKcEJzgd.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as BinaryWorker, a as BinaryFormat, p as proto$2, e as encodeFrames, d as decodeFrames, b as proto$1 } from './proposal.proto-8zgMfutf-B3So_tnS.js';
|
|
2
2
|
|
|
3
|
-
class ValidatorMessage extends
|
|
3
|
+
class ValidatorMessage extends BinaryFormat {
|
|
4
4
|
get messageName() {
|
|
5
5
|
return 'ValidatorMessage';
|
|
6
6
|
}
|
|
@@ -8,11 +8,11 @@ class ValidatorMessage extends FormatInterface {
|
|
|
8
8
|
if (buffer instanceof ValidatorMessage)
|
|
9
9
|
return buffer;
|
|
10
10
|
const name = 'validator-message';
|
|
11
|
-
super(buffer, proto$
|
|
11
|
+
super(buffer, proto$1, { name });
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
class BlockMessage extends
|
|
15
|
+
class BlockMessage extends BinaryFormat {
|
|
16
16
|
get messageName() {
|
|
17
17
|
return 'BlockMessage';
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ class BlockMessage extends FormatInterface {
|
|
|
20
20
|
if (buffer instanceof BlockMessage)
|
|
21
21
|
return buffer;
|
|
22
22
|
const name = 'block-message';
|
|
23
|
-
super(buffer, proto$
|
|
23
|
+
super(buffer, proto$2, { name });
|
|
24
24
|
}
|
|
25
25
|
encode(decoded) {
|
|
26
26
|
decoded = decoded || this.decoded;
|
|
@@ -40,14 +40,13 @@ class BlockMessage extends FormatInterface {
|
|
|
40
40
|
encoded = encoded || this.encoded;
|
|
41
41
|
super.decode(encoded);
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
this.decoded.validators = decodeFrames(this.decoded.validators, 0, { canonical: false }).map((validator) => new ValidatorMessage(validator).decoded);
|
|
43
|
+
// Binary-only protocol also requires canonical validator frame lengths.
|
|
44
|
+
this.decoded.validators = decodeFrames(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
|
|
46
45
|
return this.decoded;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
const worker = new
|
|
49
|
+
const worker = new BinaryWorker();
|
|
51
50
|
globalThis.BigNumber = BigNumber;
|
|
52
51
|
globalThis.contracts = {};
|
|
53
52
|
const run = async (blocks) => {
|