@xyo-network/xl1-cli-lib 1.20.28 → 1.21.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/dist/node/commands/index.d.ts +0 -7
- package/dist/node/commands/index.d.ts.map +1 -1
- package/dist/node/commands/start/startCommand.d.ts +1 -1
- package/dist/node/commands/start/startCommand.d.ts.map +1 -1
- package/dist/node/index.mjs +64 -249
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/xl1.mjs +82 -265
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +142 -140
- package/dist/node/commands/api/apiCommand.d.ts +0 -5
- package/dist/node/commands/api/apiCommand.d.ts.map +0 -1
- package/dist/node/commands/api/index.d.ts +0 -2
- package/dist/node/commands/api/index.d.ts.map +0 -1
- package/dist/node/commands/bridge/bridgeCommand.d.ts +0 -5
- package/dist/node/commands/bridge/bridgeCommand.d.ts.map +0 -1
- package/dist/node/commands/bridge/index.d.ts +0 -3
- package/dist/node/commands/bridge/index.d.ts.map +0 -1
- package/dist/node/commands/bridge/runBridge.d.ts +0 -6
- package/dist/node/commands/bridge/runBridge.d.ts.map +0 -1
- package/dist/node/commands/finalizer/index.d.ts +0 -2
- package/dist/node/commands/finalizer/index.d.ts.map +0 -1
- package/dist/node/commands/finalizer/runFinalizer.d.ts +0 -6
- package/dist/node/commands/finalizer/runFinalizer.d.ts.map +0 -1
- package/dist/node/commands/mempool/index.d.ts +0 -2
- package/dist/node/commands/mempool/index.d.ts.map +0 -1
- package/dist/node/commands/mempool/mempoolCommand.d.ts +0 -5
- package/dist/node/commands/mempool/mempoolCommand.d.ts.map +0 -1
- package/dist/node/commands/producer/index.d.ts +0 -2
- package/dist/node/commands/producer/index.d.ts.map +0 -1
- package/dist/node/commands/producer/producerCommand.d.ts +0 -5
- package/dist/node/commands/producer/producerCommand.d.ts.map +0 -1
- package/dist/node/commands/rewardRedemption/index.d.ts +0 -3
- package/dist/node/commands/rewardRedemption/index.d.ts.map +0 -1
- package/dist/node/commands/rewardRedemption/rewardRedemptionCommand.d.ts +0 -5
- package/dist/node/commands/rewardRedemption/rewardRedemptionCommand.d.ts.map +0 -1
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts +0 -6
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts.map +0 -1
- package/dist/node/commands/types.d.ts +0 -8
- package/dist/node/commands/types.d.ts.map +0 -1
- package/dist/node/waitForHostPort.d.ts +0 -2
- package/dist/node/waitForHostPort.d.ts.map +0 -1
package/dist/node/xl1.mjs
CHANGED
|
@@ -8,222 +8,44 @@ import { config } from "dotenv";
|
|
|
8
8
|
import { stdin as input, stdout as output } from "process";
|
|
9
9
|
import { createInterface } from "readline/promises";
|
|
10
10
|
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
11
|
+
import { apiCommand } from "@xyo-network/chain-api";
|
|
12
|
+
import { bridgeCommand } from "@xyo-network/chain-bridge";
|
|
13
|
+
import { finalizerCommand } from "@xyo-network/chain-finalizer";
|
|
14
|
+
import { mempoolCommand } from "@xyo-network/chain-mempool";
|
|
11
15
|
import { contextFromConfigWithoutLocator, detectDerivationPathCollisions, formatWalletReport, initializeResolvedWalletReport, locatorsFromConfig, Orchestrator } from "@xyo-network/chain-orchestration";
|
|
16
|
+
import { initHealthEndpoints } from "@xyo-network/chain-orchestration-express";
|
|
17
|
+
import { producerCommand } from "@xyo-network/chain-producer";
|
|
18
|
+
import { rewardRedemptionCommand } from "@xyo-network/chain-reward-redemption";
|
|
12
19
|
import { ActorConfigZod, ConfigZod as ConfigZod2 } from "@xyo-network/xl1-sdk";
|
|
13
20
|
import yargs from "yargs";
|
|
14
21
|
import { hideBin } from "yargs/helpers";
|
|
15
22
|
|
|
16
|
-
// src/commands/
|
|
23
|
+
// src/commands/start/startCommand.ts
|
|
17
24
|
import { getApiActor } from "@xyo-network/chain-api";
|
|
25
|
+
import { getBridgeActor } from "@xyo-network/chain-bridge";
|
|
26
|
+
import { getFinalizerActor } from "@xyo-network/chain-finalizer";
|
|
18
27
|
import { getMempoolActor } from "@xyo-network/chain-mempool";
|
|
19
|
-
import { ApiConfigZod, FinalizerConfigZod, MempoolConfigZod } from "@xyo-network/chain-orchestration";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { exists } from "@xylabs/sdk-js";
|
|
23
|
-
import { FinalizerActor, initActorWallet } from "@xyo-network/chain-orchestration";
|
|
24
|
-
var getFinalizerActor = /* @__PURE__ */ __name(async (config2, locator) => {
|
|
25
|
-
const account = await initActorWallet({
|
|
26
|
-
config: config2,
|
|
27
|
-
logger: locator.context.logger,
|
|
28
|
-
singletons: {},
|
|
29
|
-
caches: {}
|
|
30
|
-
});
|
|
31
|
-
return await FinalizerActor.create({
|
|
32
|
-
account,
|
|
33
|
-
config: config2,
|
|
34
|
-
locator
|
|
35
|
-
});
|
|
36
|
-
}, "getFinalizerActor");
|
|
37
|
-
|
|
38
|
-
// src/commands/api/apiCommand.ts
|
|
39
|
-
function apiCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
40
|
-
return {
|
|
41
|
-
command: "api",
|
|
42
|
-
deprecated: 'Use "start api" instead',
|
|
43
|
-
describe: "Run a XL1 API Node",
|
|
44
|
-
handler: /* @__PURE__ */ __name(async () => {
|
|
45
|
-
const configuration2 = getConfiguration2();
|
|
46
|
-
const { locators, orchestrator } = await getLocatorsFromConfig2([
|
|
47
|
-
"api",
|
|
48
|
-
"mempool",
|
|
49
|
-
"finalizer"
|
|
50
|
-
], configuration2);
|
|
51
|
-
const actors = await Promise.all([
|
|
52
|
-
getApiActor(ApiConfigZod.parse(locators["api"].context.config), locators["api"]),
|
|
53
|
-
getMempoolActor(MempoolConfigZod.parse(locators["mempool"].context.config), locators["mempool"]),
|
|
54
|
-
getFinalizerActor(FinalizerConfigZod.parse(locators["finalizer"].context.config), locators["finalizer"])
|
|
55
|
-
]);
|
|
56
|
-
for (const actor of actors) {
|
|
57
|
-
await orchestrator.registerActor(actor);
|
|
58
|
-
}
|
|
59
|
-
await orchestrator.start();
|
|
60
|
-
}, "handler")
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
__name(apiCommand, "apiCommand");
|
|
64
|
-
|
|
65
|
-
// src/commands/bridge/bridgeCommand.ts
|
|
66
|
-
import { BridgeConfigZod } from "@xyo-network/chain-orchestration";
|
|
28
|
+
import { ApiConfigZod, BridgeConfigZod, FinalizerConfigZod, MempoolConfigZod, ProducerConfigZod, RewardRedemptionConfigZod } from "@xyo-network/chain-orchestration";
|
|
29
|
+
import { getProducerActor } from "@xyo-network/chain-producer";
|
|
30
|
+
import { getRewardRedemptionActor } from "@xyo-network/chain-reward-redemption";
|
|
67
31
|
|
|
68
|
-
// src/
|
|
69
|
-
import {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
config: config2,
|
|
82
|
-
locator
|
|
83
|
-
});
|
|
84
|
-
}, "getBridgeActor");
|
|
85
|
-
var runBridge = /* @__PURE__ */ __name(async (config2, orchestrator, locator) => {
|
|
86
|
-
const bridge = await getBridgeActor(config2, locator);
|
|
87
|
-
const actors = [
|
|
88
|
-
bridge
|
|
89
|
-
].filter(exists2);
|
|
90
|
-
for (const actor of actors) {
|
|
91
|
-
await orchestrator.registerActor(actor);
|
|
92
|
-
}
|
|
93
|
-
await orchestrator.start();
|
|
94
|
-
}, "runBridge");
|
|
95
|
-
|
|
96
|
-
// src/commands/bridge/bridgeCommand.ts
|
|
97
|
-
function bridgeCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
98
|
-
return {
|
|
99
|
-
command: "bridge",
|
|
100
|
-
deprecated: 'Use "start bridge" instead',
|
|
101
|
-
describe: "Run a XL1 Bridge Node",
|
|
102
|
-
handler: /* @__PURE__ */ __name(async () => {
|
|
103
|
-
const configuration2 = getConfiguration2();
|
|
104
|
-
const { locators, orchestrator } = await getLocatorsFromConfig2([
|
|
105
|
-
"bridge"
|
|
106
|
-
], configuration2);
|
|
107
|
-
await runBridge(BridgeConfigZod.parse(locators["bridge"].context.config), orchestrator, locators["bridge"]);
|
|
108
|
-
}, "handler")
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
__name(bridgeCommand, "bridgeCommand");
|
|
112
|
-
|
|
113
|
-
// src/commands/mempool/mempoolCommand.ts
|
|
114
|
-
import { runMempool } from "@xyo-network/chain-mempool";
|
|
115
|
-
import { MempoolConfigZod as MempoolConfigZod2 } from "@xyo-network/chain-orchestration";
|
|
116
|
-
function mempoolCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
117
|
-
return {
|
|
118
|
-
command: "mempool",
|
|
119
|
-
deprecated: 'Use "start mempool" instead',
|
|
120
|
-
describe: "Run a XL1 Mempool Node",
|
|
121
|
-
handler: /* @__PURE__ */ __name(async () => {
|
|
122
|
-
const configuration2 = getConfiguration2();
|
|
123
|
-
const { locators, orchestrator } = await getLocatorsFromConfig2([
|
|
124
|
-
"mempool"
|
|
125
|
-
], configuration2);
|
|
126
|
-
await runMempool(MempoolConfigZod2.parse(locators["mempool"].context.config), orchestrator, locators["mempool"]);
|
|
127
|
-
}, "handler")
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
__name(mempoolCommand, "mempoolCommand");
|
|
131
|
-
|
|
132
|
-
// src/commands/producer/producerCommand.ts
|
|
133
|
-
import { ProducerConfigZod } from "@xyo-network/chain-orchestration";
|
|
134
|
-
import { runProducer } from "@xyo-network/chain-producer";
|
|
135
|
-
function producerCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
136
|
-
return {
|
|
137
|
-
command: "producer",
|
|
138
|
-
deprecated: 'Use "start producer" instead',
|
|
139
|
-
describe: "Run a XL1 Producer Node",
|
|
140
|
-
handler: /* @__PURE__ */ __name(async () => {
|
|
141
|
-
const configuration2 = getConfiguration2();
|
|
142
|
-
const { locators, orchestrator } = await getLocatorsFromConfig2([
|
|
143
|
-
"producer"
|
|
144
|
-
], configuration2);
|
|
145
|
-
await runProducer(ProducerConfigZod.parse(locators["producer"].context.config), orchestrator, locators["producer"]);
|
|
146
|
-
}, "handler")
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
__name(producerCommand, "producerCommand");
|
|
150
|
-
|
|
151
|
-
// src/commands/rewardRedemption/rewardRedemptionCommand.ts
|
|
152
|
-
import { RewardRedemptionConfigZod } from "@xyo-network/chain-orchestration";
|
|
153
|
-
|
|
154
|
-
// src/commands/rewardRedemption/runRewardRedemptionApi.ts
|
|
155
|
-
import { exists as exists3 } from "@xylabs/sdk-js";
|
|
156
|
-
import { initActorWallet as initActorWallet3 } from "@xyo-network/chain-orchestration";
|
|
157
|
-
import { RewardRedemptionActor } from "@xyo-network/chain-reward-redemption";
|
|
158
|
-
async function getRewardRedemptionActor(config2, locator) {
|
|
159
|
-
const account = await initActorWallet3({
|
|
160
|
-
config: config2,
|
|
161
|
-
logger: locator.context.logger,
|
|
162
|
-
singletons: {},
|
|
163
|
-
caches: {}
|
|
164
|
-
});
|
|
165
|
-
return await RewardRedemptionActor.create({
|
|
166
|
-
account,
|
|
167
|
-
config: config2,
|
|
168
|
-
locator
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
__name(getRewardRedemptionActor, "getRewardRedemptionActor");
|
|
172
|
-
async function runRewardRedemptionApi(config2, orchestrator, locator) {
|
|
173
|
-
const rewardRedemption = await getRewardRedemptionActor(config2, locator);
|
|
174
|
-
const actors = [
|
|
175
|
-
rewardRedemption
|
|
176
|
-
].filter(exists3);
|
|
177
|
-
for (const actor of actors) {
|
|
178
|
-
await orchestrator.registerActor(actor);
|
|
32
|
+
// src/initLogger.ts
|
|
33
|
+
import { Base, ConsoleLogger, isDefined, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
34
|
+
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
35
|
+
let logger;
|
|
36
|
+
if (config2.log.silent) {
|
|
37
|
+
logger = new SilentLogger();
|
|
38
|
+
} else {
|
|
39
|
+
let level;
|
|
40
|
+
if (isDefined(config2.log.logLevel)) {
|
|
41
|
+
const parsed = LogLevel[config2.log.logLevel.toLowerCase()];
|
|
42
|
+
if (isDefined(parsed)) level = parsed;
|
|
43
|
+
}
|
|
44
|
+
logger = new ConsoleLogger(level);
|
|
179
45
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// src/commands/rewardRedemption/rewardRedemptionCommand.ts
|
|
185
|
-
function rewardRedemptionCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
186
|
-
return {
|
|
187
|
-
command: "reward-redemption-api",
|
|
188
|
-
deprecated: 'Use "start rewardRedemption" instead',
|
|
189
|
-
describe: "Run a XL1 Rewards Redemption API Node",
|
|
190
|
-
handler: /* @__PURE__ */ __name(async () => {
|
|
191
|
-
const configuration2 = getConfiguration2();
|
|
192
|
-
const { locators, orchestrator } = await getLocatorsFromConfig2([
|
|
193
|
-
"rewardRedemption"
|
|
194
|
-
], configuration2);
|
|
195
|
-
await runRewardRedemptionApi(RewardRedemptionConfigZod.parse(locators["rewardRedemption"].context.config), orchestrator, locators["rewardRedemption"]);
|
|
196
|
-
}, "handler")
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
__name(rewardRedemptionCommand, "rewardRedemptionCommand");
|
|
200
|
-
|
|
201
|
-
// src/commands/start/startCommand.ts
|
|
202
|
-
import { getApiActor as getApiActor2 } from "@xyo-network/chain-api";
|
|
203
|
-
import { getMempoolActor as getMempoolActor2 } from "@xyo-network/chain-mempool";
|
|
204
|
-
import { ApiConfigZod as ApiConfigZod2, BridgeConfigZod as BridgeConfigZod2, FinalizerConfigZod as FinalizerConfigZod2, MempoolConfigZod as MempoolConfigZod3, ProducerConfigZod as ProducerConfigZod2, RewardRedemptionConfigZod as RewardRedemptionConfigZod2 } from "@xyo-network/chain-orchestration";
|
|
205
|
-
import { runProducer as runProducer2 } from "@xyo-network/chain-producer";
|
|
206
|
-
|
|
207
|
-
// src/waitForHostPort.ts
|
|
208
|
-
import net from "net";
|
|
209
|
-
var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
210
|
-
return new Promise((resolve) => {
|
|
211
|
-
const tryConnect = /* @__PURE__ */ __name(() => {
|
|
212
|
-
const socket = new net.Socket();
|
|
213
|
-
socket.setTimeout(1e3).once("error", () => {
|
|
214
|
-
socket.destroy();
|
|
215
|
-
setTimeout(tryConnect, 500);
|
|
216
|
-
}).once("timeout", () => {
|
|
217
|
-
socket.destroy();
|
|
218
|
-
setTimeout(tryConnect, 500);
|
|
219
|
-
}).connect(port, host, () => {
|
|
220
|
-
socket.end();
|
|
221
|
-
resolve();
|
|
222
|
-
});
|
|
223
|
-
}, "tryConnect");
|
|
224
|
-
tryConnect();
|
|
225
|
-
});
|
|
226
|
-
}, "waitForHostPort");
|
|
46
|
+
Base.defaultLogger = logger;
|
|
47
|
+
return logger;
|
|
48
|
+
}, "initLogger");
|
|
227
49
|
|
|
228
50
|
// src/commands/start/startCommand.ts
|
|
229
51
|
var KNOWN_ACTORS = [
|
|
@@ -234,6 +56,7 @@ var KNOWN_ACTORS = [
|
|
|
234
56
|
"producer",
|
|
235
57
|
"rewardRedemption"
|
|
236
58
|
];
|
|
59
|
+
var BOOT_TIMEOUT_MS = 6e4;
|
|
237
60
|
function getActorsFromConfig(configuration2) {
|
|
238
61
|
const enabledActors = configuration2.actors.filter((actor) => actor.enabled !== false).map((actor) => actor.name);
|
|
239
62
|
return enabledActors.length > 0 ? enabledActors : void 0;
|
|
@@ -247,56 +70,50 @@ function getDefaultActors() {
|
|
|
247
70
|
];
|
|
248
71
|
}
|
|
249
72
|
__name(getDefaultActors, "getDefaultActors");
|
|
250
|
-
async function
|
|
73
|
+
async function buildActor(name, locator) {
|
|
251
74
|
switch (name) {
|
|
252
75
|
case "api": {
|
|
253
|
-
const config2 =
|
|
254
|
-
|
|
255
|
-
await orchestrator.registerActor(actor);
|
|
256
|
-
await orchestrator.start();
|
|
257
|
-
await waitForHostPort(config2.host, config2.port);
|
|
258
|
-
break;
|
|
76
|
+
const config2 = ApiConfigZod.parse(locator.context.config);
|
|
77
|
+
return await getApiActor(config2, locator);
|
|
259
78
|
}
|
|
260
79
|
case "bridge": {
|
|
261
|
-
const config2 =
|
|
262
|
-
|
|
263
|
-
await orchestrator.registerActor(actor);
|
|
264
|
-
await orchestrator.start();
|
|
265
|
-
break;
|
|
80
|
+
const config2 = BridgeConfigZod.parse(locator.context.config);
|
|
81
|
+
return await getBridgeActor(config2, locator);
|
|
266
82
|
}
|
|
267
83
|
case "mempool": {
|
|
268
|
-
const config2 =
|
|
269
|
-
|
|
270
|
-
await orchestrator.registerActor(actor);
|
|
271
|
-
await orchestrator.start();
|
|
272
|
-
await waitForHostPort(config2.host, config2.port);
|
|
273
|
-
break;
|
|
84
|
+
const config2 = MempoolConfigZod.parse(locator.context.config);
|
|
85
|
+
return await getMempoolActor(config2, locator);
|
|
274
86
|
}
|
|
275
87
|
case "producer": {
|
|
276
|
-
const config2 =
|
|
277
|
-
await
|
|
278
|
-
break;
|
|
88
|
+
const config2 = ProducerConfigZod.parse(locator.context.config);
|
|
89
|
+
return await getProducerActor(config2, locator);
|
|
279
90
|
}
|
|
280
91
|
case "rewardRedemption": {
|
|
281
|
-
const config2 =
|
|
282
|
-
|
|
283
|
-
await orchestrator.registerActor(actor);
|
|
284
|
-
await orchestrator.start();
|
|
285
|
-
break;
|
|
92
|
+
const config2 = RewardRedemptionConfigZod.parse(locator.context.config);
|
|
93
|
+
return await getRewardRedemptionActor(config2, locator);
|
|
286
94
|
}
|
|
287
95
|
case "finalizer": {
|
|
288
|
-
const config2 =
|
|
289
|
-
|
|
290
|
-
await orchestrator.registerActor(actor);
|
|
291
|
-
await orchestrator.start();
|
|
292
|
-
break;
|
|
96
|
+
const config2 = FinalizerConfigZod.parse(locator.context.config);
|
|
97
|
+
return await getFinalizerActor(config2, locator);
|
|
293
98
|
}
|
|
294
99
|
default: {
|
|
295
100
|
throw new Error(`Unknown actor: ${name}`);
|
|
296
101
|
}
|
|
297
102
|
}
|
|
298
103
|
}
|
|
299
|
-
__name(
|
|
104
|
+
__name(buildActor, "buildActor");
|
|
105
|
+
async function bootActors(requestedActors, locators, orchestrator, configuration2) {
|
|
106
|
+
const startedAt = Date.now();
|
|
107
|
+
const actors = await Promise.all(requestedActors.map((name) => buildActor(name, locators[name])));
|
|
108
|
+
for (const actor of actors) {
|
|
109
|
+
await orchestrator.registerActor(actor);
|
|
110
|
+
}
|
|
111
|
+
await orchestrator.start();
|
|
112
|
+
await orchestrator.whenReady(BOOT_TIMEOUT_MS);
|
|
113
|
+
const ms = Date.now() - startedAt;
|
|
114
|
+
initLogger(configuration2).info(`[xl1] system ready (${requestedActors.length} actor${requestedActors.length === 1 ? "" : "s"}, ${ms}ms)`);
|
|
115
|
+
}
|
|
116
|
+
__name(bootActors, "bootActors");
|
|
300
117
|
function startCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
301
118
|
return {
|
|
302
119
|
command: [
|
|
@@ -322,9 +139,7 @@ function startCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
|
322
139
|
const configuration2 = getConfiguration2();
|
|
323
140
|
const requestedActors = argv.actors !== void 0 && argv.actors.length > 0 ? argv.actors : getActorsFromConfig(configuration2) ?? getDefaultActors();
|
|
324
141
|
const { locators, orchestrator } = await getLocatorsFromConfig2(requestedActors, configuration2);
|
|
325
|
-
|
|
326
|
-
await startActor(name, locators[name], orchestrator);
|
|
327
|
-
}
|
|
142
|
+
await bootActors(requestedActors, locators, orchestrator, configuration2);
|
|
328
143
|
}, "handler")
|
|
329
144
|
};
|
|
330
145
|
}
|
|
@@ -349,7 +164,7 @@ function withDeprecationWarning(module) {
|
|
|
349
164
|
__name(withDeprecationWarning, "withDeprecationWarning");
|
|
350
165
|
|
|
351
166
|
// src/configMiddleware.ts
|
|
352
|
-
import { createDeepMerge, isDefined } from "@xylabs/sdk-js";
|
|
167
|
+
import { createDeepMerge, isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
353
168
|
import { ActorMnemonicNotAllowedError, assertNoActorMnemonics, ConfigFileNotFoundError, tryParseConfig } from "@xyo-network/chain-orchestration";
|
|
354
169
|
import { ConfigZod, isZodError, resolveConfig } from "@xyo-network/xl1-sdk";
|
|
355
170
|
var deepMerge = createDeepMerge({
|
|
@@ -391,7 +206,7 @@ async function buildFinalConfig(argv) {
|
|
|
391
206
|
const mergedConfig = safeParseOrThrow(deepMerge(parsedConfigFile, parsedConfigArgs));
|
|
392
207
|
const validated = safeParseOrThrow(resolveConfig(safeParseOrThrow(mergedConfig)));
|
|
393
208
|
const rootMnemonic = rootMnemonicFromArgs ?? rootMnemonicFromFile;
|
|
394
|
-
return
|
|
209
|
+
return isDefined2(rootMnemonic) ? {
|
|
395
210
|
...validated,
|
|
396
211
|
mnemonic: rootMnemonic
|
|
397
212
|
} : validated;
|
|
@@ -446,24 +261,6 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
446
261
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;68;25;230m\u2560\x1B[0m\x1B[38;2;66;21;234m\u2560\x1B[0m
|
|
447
262
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;108;93;162m\xB2\x1B[0m\x1B[38;2;99;79;176m^\x1B[0m`;
|
|
448
263
|
|
|
449
|
-
// src/initLogger.ts
|
|
450
|
-
import { Base, ConsoleLogger, isDefined as isDefined2, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
451
|
-
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
452
|
-
let logger;
|
|
453
|
-
if (config2.log.silent) {
|
|
454
|
-
logger = new SilentLogger();
|
|
455
|
-
} else {
|
|
456
|
-
let level;
|
|
457
|
-
if (isDefined2(config2.log.logLevel)) {
|
|
458
|
-
const parsed = LogLevel[config2.log.logLevel.toLowerCase()];
|
|
459
|
-
if (isDefined2(parsed)) level = parsed;
|
|
460
|
-
}
|
|
461
|
-
logger = new ConsoleLogger(level);
|
|
462
|
-
}
|
|
463
|
-
Base.defaultLogger = logger;
|
|
464
|
-
return logger;
|
|
465
|
-
}, "initLogger");
|
|
466
|
-
|
|
467
264
|
// src/optionsFromGlobalZodRegistry.ts
|
|
468
265
|
import { isUsageMeta } from "@xyo-network/xl1-sdk";
|
|
469
266
|
import { globalRegistry } from "zod";
|
|
@@ -482,8 +279,10 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
482
279
|
}, "optionsFromGlobalZodRegistry");
|
|
483
280
|
|
|
484
281
|
// src/runCLI.ts
|
|
282
|
+
var DEFAULT_HEALTH_CHECK_PORT = 9090;
|
|
485
283
|
var configuration;
|
|
486
|
-
var
|
|
284
|
+
var skipInsecureConfirm = false;
|
|
285
|
+
var version = isDefined3("1.21.0") ? "1.21.0" : "unknown";
|
|
487
286
|
function getConfiguration() {
|
|
488
287
|
return configuration;
|
|
489
288
|
}
|
|
@@ -530,11 +329,23 @@ async function getLocatorsFromConfig(actors, configuration2) {
|
|
|
530
329
|
const walletReport = await initializeResolvedWalletReport(actors, configuration2);
|
|
531
330
|
logger.info(formatWalletReport(walletReport));
|
|
532
331
|
const context = await contextFromConfigWithoutLocator(config2, logger, "xl1-cli", version);
|
|
533
|
-
|
|
332
|
+
if (skipInsecureConfirm) {
|
|
333
|
+
logger.warn("Insecure genesis reward wallet is active. Interactive confirmation skipped via --skip-insecure-confirm.");
|
|
334
|
+
}
|
|
335
|
+
const onInsecureGenesisConfirm = skipInsecureConfirm ? void 0 : async () => await promptForInsecureGenesisConfirmation(logger);
|
|
336
|
+
const locators = await locatorsFromConfig(context, config2, onInsecureGenesisConfirm);
|
|
337
|
+
const healthCheckPort = configuration2.healthCheckPort ?? DEFAULT_HEALTH_CHECK_PORT;
|
|
338
|
+
const healthServer = healthCheckPort > 0 && context.statusReporter !== void 0 ? await initHealthEndpoints({
|
|
339
|
+
logger,
|
|
340
|
+
port: healthCheckPort,
|
|
341
|
+
readiness: orchestrator,
|
|
342
|
+
statusMonitor: context.statusReporter
|
|
343
|
+
}) : void 0;
|
|
534
344
|
process.on("SIGINT", () => {
|
|
535
345
|
void (async () => {
|
|
536
346
|
try {
|
|
537
347
|
logger.log("\nSIGINT received. Attempting graceful shutdown...");
|
|
348
|
+
healthServer?.close();
|
|
538
349
|
await orchestrator?.stop();
|
|
539
350
|
logger.log("Orchestrator stopped, exiting now.");
|
|
540
351
|
process.exit(0);
|
|
@@ -566,7 +377,8 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
566
377
|
await configMiddleware(argv2, (config2) => {
|
|
567
378
|
configuration = config2;
|
|
568
379
|
});
|
|
569
|
-
|
|
380
|
+
skipInsecureConfirm = Boolean(argv2["skip-insecure-confirm"]);
|
|
381
|
+
}).options(optionsFromGlobalZodRegistry()).wrap(y.terminalWidth()).command(withDeprecationWarning(apiCommand(getConfiguration, getLocatorsFromConfig))).command(withDeprecationWarning(bridgeCommand(getConfiguration, getLocatorsFromConfig))).command(withDeprecationWarning(finalizerCommand(getConfiguration, getLocatorsFromConfig))).command(withDeprecationWarning(mempoolCommand(getConfiguration, getLocatorsFromConfig))).command(withDeprecationWarning(producerCommand(getConfiguration, getLocatorsFromConfig))).command(withDeprecationWarning(rewardRedemptionCommand(getConfiguration, getLocatorsFromConfig))).command(startCommand(getConfiguration, getLocatorsFromConfig)).options({
|
|
570
382
|
"config": {
|
|
571
383
|
type: "string",
|
|
572
384
|
description: "Path to a config file to use instead of the default search.",
|
|
@@ -580,6 +392,11 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
580
392
|
type: "boolean",
|
|
581
393
|
description: "Just process the configuration and print the resolved config to stdout, then exit.",
|
|
582
394
|
default: false
|
|
395
|
+
},
|
|
396
|
+
"skip-insecure-confirm": {
|
|
397
|
+
type: "boolean",
|
|
398
|
+
description: "Skip the interactive RETURN confirmation when the built-in dev mnemonic / insecure genesis reward wallet is active.",
|
|
399
|
+
default: false
|
|
583
400
|
}
|
|
584
401
|
}).help().alias("help", "h").version(version).argv;
|
|
585
402
|
await argv;
|