@leofcoin/chain 1.9.6 → 1.9.9
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 +3932 -4500
- package/exports/browser/{constants-M3qbPwZp.js → constants-BCaq9RBn.js} +408 -426
- package/exports/browser/node-browser.js +50 -57
- package/exports/chain.js +3185 -3567
- package/exports/constants-C83ZCYKa.js +12 -0
- package/exports/node.js +19 -24
- package/package.json +2 -1
- package/exports/chain.d.ts +0 -73
- package/exports/config/config.d.ts +0 -1
- package/exports/config/main.d.ts +0 -5
- package/exports/config/protocol.d.ts +0 -6
- package/exports/connection-monitor.d.ts +0 -14
- package/exports/consensus/consensus.d.ts +0 -1
- package/exports/consensus/helpers/sort-transactions.d.ts +0 -1
- package/exports/constants-eo0U5-D_.js +0 -12
- package/exports/constants.d.ts +0 -15
- package/exports/contract-registry.d.ts +0 -106
- package/exports/contract-utils.d.ts +0 -49
- package/exports/contract.d.ts +0 -90
- package/exports/examples/contract-inheritance-example.d.ts +0 -58
- package/exports/examples/hash-based-contracts.d.ts +0 -82
- package/exports/fee/config.d.ts +0 -4
- package/exports/helpers/contract.d.ts +0 -4
- package/exports/jobs/jobber.d.ts +0 -7
- package/exports/machine-state.d.ts +0 -6
- package/exports/machine.d.ts +0 -64
- package/exports/node-browser.d.ts +0 -6
- package/exports/node.d.ts +0 -8
- package/exports/protocol.d.ts +0 -15
- package/exports/simplifiers/state.d.ts +0 -3
- package/exports/state.d.ts +0 -66
- package/exports/sync-controller.d.ts +0 -14
- package/exports/transaction.d.ts +0 -41
- package/exports/types.d.ts +0 -24
- package/exports/version-control.d.ts +0 -7
|
@@ -1,68 +1,61 @@
|
|
|
1
1
|
import Peernet from '@leofcoin/peernet/browser';
|
|
2
|
-
import { T as TransactionMessage, C as ContractMessage, B as BlockMessage, e as BWMessage, f as BWRequestMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS } from './constants-
|
|
2
|
+
import { T as TransactionMessage, C as ContractMessage, B as BlockMessage, e as BWMessage, f as BWRequestMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS } from './constants-BCaq9RBn.js';
|
|
3
3
|
|
|
4
4
|
var nodeConfig = async (config = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
network: "leofcoin:peach",
|
|
6
|
+
networkVersion: "v1.0.0"
|
|
7
7
|
}) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const protos = [
|
|
9
|
+
{ name: "transaction-message", handler: TransactionMessage },
|
|
10
|
+
{ name: "contract-message", handler: ContractMessage },
|
|
11
|
+
{ name: "block-message", handler: BlockMessage },
|
|
12
|
+
{ name: "bw-message", handler: BWMessage },
|
|
13
|
+
{ name: "bw-request-message", handler: BWRequestMessage },
|
|
14
|
+
{ name: "validator-message", handler: ValidatorMessage },
|
|
15
|
+
{ name: "state-message", handler: StateMessage },
|
|
16
|
+
{ name: "last-block", handler: LastBlockMessage }
|
|
17
|
+
];
|
|
18
|
+
for (const proto of protos) {
|
|
19
|
+
peernet.addProto(proto.name, proto.handler);
|
|
20
|
+
}
|
|
21
|
+
let name = `.${config.network}`;
|
|
22
|
+
const parts = config.network.split(":");
|
|
23
|
+
if (parts[1])
|
|
24
|
+
name = `.${parts[0]}/${parts[1]}`;
|
|
25
|
+
if (typeof config.storeNamespace === "string" && config.storeNamespace.length > 0) {
|
|
26
|
+
name = `${name}/${config.storeNamespace}`;
|
|
27
|
+
}
|
|
28
|
+
const stores = ["transactionPool", "state", "accounts", "contract", { name: "wallet", private: true }];
|
|
29
|
+
for (const store of stores) {
|
|
30
|
+
if (typeof store === "string") {
|
|
31
|
+
await peernet.addStore(store, "lfc", name, false);
|
|
32
|
+
} else {
|
|
33
|
+
await peernet.addStore(store.name, "lfc", name, store.private);
|
|
20
34
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// e.g., '.leofcoin/peach/dev-validator-1'
|
|
27
|
-
if (typeof config.storeNamespace === 'string' && config.storeNamespace.length > 0) {
|
|
28
|
-
name = `${name}/${config.storeNamespace}`;
|
|
29
|
-
}
|
|
30
|
-
const stores = ['transactionPool', 'state', 'accounts', 'contract', { name: 'wallet', private: true }];
|
|
31
|
-
for (const store of stores) {
|
|
32
|
-
if (typeof store === 'string') {
|
|
33
|
-
await peernet.addStore(store, 'lfc', name, false);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
await peernet.addStore(store.name, 'lfc', name, store.private);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
stores,
|
|
41
|
-
protos
|
|
42
|
-
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
stores,
|
|
38
|
+
protos
|
|
39
|
+
};
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
// import config from './config/config'
|
|
46
42
|
class Node {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return this;
|
|
64
|
-
// this.config = await config()
|
|
65
|
-
}
|
|
43
|
+
#node;
|
|
44
|
+
constructor(config, password) {
|
|
45
|
+
return this._init(config, password);
|
|
46
|
+
}
|
|
47
|
+
async _init(config = {}, password) {
|
|
48
|
+
config = { ...DEFAULT_NODE_OPTIONS, ...config };
|
|
49
|
+
this.#node = globalThis.Peernet ? await new globalThis.Peernet(config, password) : await new Peernet(config, password);
|
|
50
|
+
await nodeConfig(config);
|
|
51
|
+
globalThis.pubsub.subscribe("chain:ready", async () => {
|
|
52
|
+
if (!this.#node.autoStart) {
|
|
53
|
+
await this.#node.start();
|
|
54
|
+
pubsub.publish("node:ready", true);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
66
59
|
}
|
|
67
60
|
|
|
68
61
|
export { Node as default };
|