@xyo-network/xl1-cli-lib 1.22.0 → 1.23.2
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/configMiddleware.d.ts +6 -0
- package/dist/node/configMiddleware.d.ts.map +1 -1
- package/dist/node/dumpProviders.d.ts +17 -0
- package/dist/node/dumpProviders.d.ts.map +1 -0
- package/dist/node/index.mjs +257 -105
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/xl1.mjs +256 -105
- package/dist/node/xl1.mjs.map +7 -1
- package/package.json +37 -47
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Config } from '@xyo-network/xl1-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a deep clone of `config` with secret-bearing leaf values replaced by
|
|
4
|
+
* `'[REDACTED]'`. Walks plain objects and arrays. Leaves primitives, dates,
|
|
5
|
+
* and other non-plain values untouched (other than via `structuredClone`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function redactConfig<T>(config: T): T;
|
|
2
8
|
export declare function configMiddleware(argv: Record<string, unknown>, setConfiguration: (config: Config) => void): Promise<void>;
|
|
3
9
|
//# sourceMappingURL=configMiddleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configMiddleware.d.ts","sourceRoot":"","sources":["../../src/configMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"configMiddleware.d.ts","sourceRoot":"","sources":["../../src/configMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AA2BlD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAI5C;AAgED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/H"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Renders the locator map as a tree grouped by registry identity, annotating
|
|
4
|
+
* any moniker that appears in more than one *registry* with `⚠ also in: ...`.
|
|
5
|
+
*
|
|
6
|
+
* - When all input locators share one registry (shared-locator path), a single
|
|
7
|
+
* "Providers shared by actors: …" section is rendered.
|
|
8
|
+
* - When some actors have distinct registries (legacy `_root` + per-actor
|
|
9
|
+
* child architecture), each registry is rendered separately. `_root` is
|
|
10
|
+
* ordered first.
|
|
11
|
+
*
|
|
12
|
+
* The "Duplicate monikers" summary at the bottom only flags monikers
|
|
13
|
+
* registered by *different* registries — duplicates within one registry are
|
|
14
|
+
* already collapsed into per-entry `(×N)` counts by `enumerateLocator`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatProviderTree(locators: Record<string, ProviderFactoryLocatorInstance>): string;
|
|
17
|
+
//# sourceMappingURL=dumpProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dumpProviders.d.ts","sourceRoot":"","sources":["../../src/dumpProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAA;AA0J1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,GAAG,MAAM,CA+BnG"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,42 +1,63 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/configMiddleware.ts
|
|
5
2
|
import { createDeepMerge, isDefined } from "@xylabs/sdk-js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import {
|
|
4
|
+
ActorMnemonicNotAllowedError,
|
|
5
|
+
assertNoActorMnemonics,
|
|
6
|
+
ConfigFileNotFoundError,
|
|
7
|
+
tryParseConfig
|
|
8
|
+
} from "@xyo-network/chain-orchestration";
|
|
9
|
+
import {
|
|
10
|
+
ConfigZod,
|
|
11
|
+
isZodError,
|
|
12
|
+
resolveConfig
|
|
13
|
+
} from "@xyo-network/xl1-sdk";
|
|
14
|
+
var deepMerge = createDeepMerge({ arrayStrategy: "concat" });
|
|
15
|
+
var REDACTED = "[REDACTED]";
|
|
16
|
+
var REDACTED_KEY_NAMES = /* @__PURE__ */ new Set(["mnemonic", "connectionString"]);
|
|
17
|
+
var REDACTED_KEY_SUFFIX = /(PrivateKey|Secret|Password)$/i;
|
|
18
|
+
function shouldRedactKey(key) {
|
|
19
|
+
if (REDACTED_KEY_NAMES.has(key)) return true;
|
|
20
|
+
return REDACTED_KEY_SUFFIX.test(key);
|
|
21
|
+
}
|
|
22
|
+
function redactConfig(config2) {
|
|
23
|
+
const cloned = structuredClone(config2);
|
|
24
|
+
redactInPlace(cloned);
|
|
25
|
+
return cloned;
|
|
26
|
+
}
|
|
27
|
+
function redactInPlace(node) {
|
|
28
|
+
if (Array.isArray(node)) {
|
|
29
|
+
for (const item of node) redactInPlace(item);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (node === null || typeof node !== "object") return;
|
|
33
|
+
const obj = node;
|
|
34
|
+
for (const key of Object.keys(obj)) {
|
|
35
|
+
if (shouldRedactKey(key) && obj[key] !== void 0 && obj[key] !== null) {
|
|
36
|
+
obj[key] = REDACTED;
|
|
37
|
+
} else {
|
|
38
|
+
redactInPlace(obj[key]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
11
42
|
function coerceActorsArray(argv) {
|
|
12
43
|
const actors = argv.actors;
|
|
13
44
|
if (actors === void 0 || Array.isArray(actors)) return argv;
|
|
14
45
|
if (typeof actors !== "object" || actors === null) return argv;
|
|
15
46
|
const entries = Object.entries(actors);
|
|
16
|
-
const numericEntries = entries.map(([key, value]) => [
|
|
17
|
-
Number(key),
|
|
18
|
-
value
|
|
19
|
-
]).filter(([key]) => Number.isInteger(key) && key >= 0);
|
|
47
|
+
const numericEntries = entries.map(([key, value]) => [Number(key), value]).filter(([key]) => Number.isInteger(key) && key >= 0);
|
|
20
48
|
if (numericEntries.length !== entries.length) return argv;
|
|
21
49
|
const asArray = [];
|
|
22
50
|
for (const [key, value] of numericEntries) asArray[key] = value;
|
|
23
|
-
return {
|
|
24
|
-
...argv,
|
|
25
|
-
actors: asArray
|
|
26
|
-
};
|
|
51
|
+
return { ...argv, actors: asArray };
|
|
27
52
|
}
|
|
28
|
-
__name(coerceActorsArray, "coerceActorsArray");
|
|
29
53
|
function safeParseOrThrow(input2) {
|
|
30
54
|
const result = ConfigZod.safeParse(input2);
|
|
31
55
|
if (!result.success) throw result.error;
|
|
32
56
|
return result.data;
|
|
33
57
|
}
|
|
34
|
-
__name(safeParseOrThrow, "safeParseOrThrow");
|
|
35
58
|
async function buildFinalConfig(argv) {
|
|
36
59
|
const configPath = argv.config;
|
|
37
|
-
const parsedConfigFile = await tryParseConfig({
|
|
38
|
-
configPath
|
|
39
|
-
});
|
|
60
|
+
const parsedConfigFile = await tryParseConfig({ configPath });
|
|
40
61
|
const rootMnemonicFromFile = typeof parsedConfigFile.mnemonic === "string" ? parsedConfigFile.mnemonic : void 0;
|
|
41
62
|
const normalizedArgv = coerceActorsArray(argv);
|
|
42
63
|
const parsedConfigArgs = ConfigZod.safeParse(normalizedArgv).data ?? {};
|
|
@@ -44,19 +65,17 @@ async function buildFinalConfig(argv) {
|
|
|
44
65
|
const mergedConfig = safeParseOrThrow(deepMerge(parsedConfigFile, parsedConfigArgs));
|
|
45
66
|
const validated = safeParseOrThrow(resolveConfig(safeParseOrThrow(mergedConfig)));
|
|
46
67
|
const rootMnemonic = rootMnemonicFromArgs ?? rootMnemonicFromFile;
|
|
47
|
-
return isDefined(rootMnemonic) ? {
|
|
48
|
-
...validated,
|
|
49
|
-
mnemonic: rootMnemonic
|
|
50
|
-
} : validated;
|
|
68
|
+
return isDefined(rootMnemonic) ? { ...validated, mnemonic: rootMnemonic } : validated;
|
|
51
69
|
}
|
|
52
|
-
__name(buildFinalConfig, "buildFinalConfig");
|
|
53
70
|
async function configMiddleware(argv, setConfiguration) {
|
|
54
71
|
try {
|
|
55
72
|
const finalConfig = await buildFinalConfig(argv);
|
|
56
73
|
assertNoActorMnemonics(finalConfig);
|
|
57
74
|
setConfiguration(finalConfig);
|
|
58
75
|
if (argv["dump-config"]) {
|
|
59
|
-
|
|
76
|
+
const withSecrets = Boolean(argv["with-secrets"]);
|
|
77
|
+
const output2 = withSecrets ? finalConfig : redactConfig(finalConfig);
|
|
78
|
+
console.log(JSON.stringify(output2, null, 2));
|
|
60
79
|
process.exit(0);
|
|
61
80
|
}
|
|
62
81
|
} catch (err) {
|
|
@@ -72,16 +91,19 @@ async function configMiddleware(argv, setConfiguration) {
|
|
|
72
91
|
if (!(err instanceof ConfigFileNotFoundError) && !(err instanceof ActorMnemonicNotAllowedError)) {
|
|
73
92
|
console.error(`Stack: ${err instanceof Error ? err.stack : "N/A"}`);
|
|
74
93
|
}
|
|
75
|
-
throw new Error("Invalid configuration", {
|
|
76
|
-
cause: err
|
|
77
|
-
});
|
|
94
|
+
throw new Error("Invalid configuration", { cause: err });
|
|
78
95
|
}
|
|
79
96
|
}
|
|
80
|
-
__name(configMiddleware, "configMiddleware");
|
|
81
97
|
|
|
82
98
|
// src/initLogger.ts
|
|
83
|
-
import {
|
|
84
|
-
|
|
99
|
+
import {
|
|
100
|
+
Base,
|
|
101
|
+
ConsoleLogger,
|
|
102
|
+
isDefined as isDefined2,
|
|
103
|
+
LogLevel,
|
|
104
|
+
SilentLogger
|
|
105
|
+
} from "@xylabs/sdk-js";
|
|
106
|
+
var initLogger = (config2) => {
|
|
85
107
|
let logger;
|
|
86
108
|
if (config2.log.silent) {
|
|
87
109
|
logger = new SilentLogger();
|
|
@@ -95,21 +117,32 @@ var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
|
95
117
|
}
|
|
96
118
|
Base.defaultLogger = logger;
|
|
97
119
|
return logger;
|
|
98
|
-
}
|
|
120
|
+
};
|
|
99
121
|
|
|
100
122
|
// src/runCLI.ts
|
|
101
|
-
import { stdin as input, stdout as output } from "process";
|
|
102
|
-
import { createInterface } from "readline/promises";
|
|
123
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
124
|
+
import { createInterface } from "node:readline/promises";
|
|
103
125
|
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
104
126
|
import { apiCommand } from "@xyo-network/chain-api";
|
|
105
127
|
import { bridgeCommand } from "@xyo-network/chain-bridge";
|
|
106
128
|
import { finalizerCommand } from "@xyo-network/chain-finalizer";
|
|
107
129
|
import { mempoolCommand } from "@xyo-network/chain-mempool";
|
|
108
|
-
import {
|
|
130
|
+
import {
|
|
131
|
+
contextFromConfigWithoutLocator,
|
|
132
|
+
detectDerivationPathCollisions,
|
|
133
|
+
formatWalletReport,
|
|
134
|
+
initializeResolvedWalletReport,
|
|
135
|
+
locatorsFromConfig,
|
|
136
|
+
Orchestrator
|
|
137
|
+
} from "@xyo-network/chain-orchestration";
|
|
109
138
|
import { initHealthEndpoints } from "@xyo-network/chain-orchestration-express";
|
|
110
139
|
import { producerCommand } from "@xyo-network/chain-producer";
|
|
111
140
|
import { rewardRedemptionCommand } from "@xyo-network/chain-reward-redemption";
|
|
112
|
-
import {
|
|
141
|
+
import {
|
|
142
|
+
ActorConfigZod,
|
|
143
|
+
ConfigZod as ConfigZod2,
|
|
144
|
+
DefaultMetricsScrapePorts
|
|
145
|
+
} from "@xyo-network/xl1-sdk";
|
|
113
146
|
import yargs from "yargs";
|
|
114
147
|
import { hideBin } from "yargs/helpers";
|
|
115
148
|
|
|
@@ -118,31 +151,25 @@ import { getApiActor } from "@xyo-network/chain-api";
|
|
|
118
151
|
import { getBridgeActor } from "@xyo-network/chain-bridge";
|
|
119
152
|
import { getFinalizerActor } from "@xyo-network/chain-finalizer";
|
|
120
153
|
import { getMempoolActor } from "@xyo-network/chain-mempool";
|
|
121
|
-
import {
|
|
154
|
+
import {
|
|
155
|
+
ApiConfigZod,
|
|
156
|
+
BridgeConfigZod,
|
|
157
|
+
FinalizerConfigZod,
|
|
158
|
+
MempoolConfigZod,
|
|
159
|
+
ProducerConfigZod,
|
|
160
|
+
RewardRedemptionConfigZod
|
|
161
|
+
} from "@xyo-network/chain-orchestration";
|
|
122
162
|
import { getProducerActor } from "@xyo-network/chain-producer";
|
|
123
163
|
import { getRewardRedemptionActor } from "@xyo-network/chain-reward-redemption";
|
|
124
|
-
var KNOWN_ACTORS = [
|
|
125
|
-
"api",
|
|
126
|
-
"bridge",
|
|
127
|
-
"finalizer",
|
|
128
|
-
"mempool",
|
|
129
|
-
"producer",
|
|
130
|
-
"rewardRedemption"
|
|
131
|
-
];
|
|
164
|
+
var KNOWN_ACTORS = ["api", "bridge", "finalizer", "mempool", "producer", "rewardRedemption"];
|
|
132
165
|
var BOOT_TIMEOUT_MS = 6e4;
|
|
133
166
|
function getActorsFromConfig(configuration2) {
|
|
134
167
|
const enabledActors = configuration2.actors.filter((actor) => actor.enabled !== false).map((actor) => actor.name);
|
|
135
168
|
return enabledActors.length > 0 ? enabledActors : void 0;
|
|
136
169
|
}
|
|
137
|
-
__name(getActorsFromConfig, "getActorsFromConfig");
|
|
138
170
|
function getDefaultActors() {
|
|
139
|
-
return [
|
|
140
|
-
"api",
|
|
141
|
-
"producer",
|
|
142
|
-
"finalizer"
|
|
143
|
-
];
|
|
171
|
+
return ["api", "producer", "finalizer"];
|
|
144
172
|
}
|
|
145
|
-
__name(getDefaultActors, "getDefaultActors");
|
|
146
173
|
async function buildActor(name, locator) {
|
|
147
174
|
switch (name) {
|
|
148
175
|
case "api": {
|
|
@@ -174,7 +201,6 @@ async function buildActor(name, locator) {
|
|
|
174
201
|
}
|
|
175
202
|
}
|
|
176
203
|
}
|
|
177
|
-
__name(buildActor, "buildActor");
|
|
178
204
|
async function bootActors(requestedActors, locators, orchestrator, configuration2) {
|
|
179
205
|
const startedAt = Date.now();
|
|
180
206
|
const actors = await Promise.all(requestedActors.map((name) => buildActor(name, locators[name])));
|
|
@@ -184,39 +210,34 @@ async function bootActors(requestedActors, locators, orchestrator, configuration
|
|
|
184
210
|
await orchestrator.start();
|
|
185
211
|
await orchestrator.whenReady(BOOT_TIMEOUT_MS);
|
|
186
212
|
const ms = Date.now() - startedAt;
|
|
187
|
-
initLogger(configuration2).info(`[xl1] system ready (${requestedActors.
|
|
213
|
+
initLogger(configuration2).info(`[xl1] system ready (${requestedActors.join("/")} in ${ms}ms)`);
|
|
188
214
|
}
|
|
189
|
-
__name(bootActors, "bootActors");
|
|
190
215
|
function startCommand(getConfiguration2, getLocatorsFromConfig2) {
|
|
191
216
|
return {
|
|
192
|
-
command: [
|
|
193
|
-
"start [actors..]",
|
|
194
|
-
"$0"
|
|
195
|
-
],
|
|
217
|
+
command: ["start [actors..]", "$0"],
|
|
196
218
|
describe: "Run a full XL1 Node",
|
|
197
|
-
builder:
|
|
219
|
+
builder: (yargs2) => {
|
|
198
220
|
return yargs2.positional("actors", {
|
|
199
221
|
type: "string",
|
|
200
222
|
array: true,
|
|
201
223
|
choices: KNOWN_ACTORS,
|
|
202
224
|
description: "Actors to start (e.g. xl1 start api producer or xl1 start api,producer)",
|
|
203
|
-
coerce:
|
|
225
|
+
coerce: (values) => values.flatMap((v) => v.split(","))
|
|
204
226
|
}).option("actors", {
|
|
205
227
|
type: "array",
|
|
206
228
|
string: true,
|
|
207
229
|
choices: KNOWN_ACTORS,
|
|
208
230
|
description: "List of actors to start (e.g. --actors api producer finalizer). Defaults to api, producer, and finalizer."
|
|
209
231
|
});
|
|
210
|
-
},
|
|
211
|
-
handler:
|
|
232
|
+
},
|
|
233
|
+
handler: async (argv) => {
|
|
212
234
|
const configuration2 = getConfiguration2();
|
|
213
235
|
const requestedActors = argv.actors !== void 0 && argv.actors.length > 0 ? argv.actors : getActorsFromConfig(configuration2) ?? getDefaultActors();
|
|
214
236
|
const { locators, orchestrator } = await getLocatorsFromConfig2(requestedActors, configuration2);
|
|
215
237
|
await bootActors(requestedActors, locators, orchestrator, configuration2);
|
|
216
|
-
}
|
|
238
|
+
}
|
|
217
239
|
};
|
|
218
240
|
}
|
|
219
|
-
__name(startCommand, "startCommand");
|
|
220
241
|
|
|
221
242
|
// src/commands/withDeprecationWarning.ts
|
|
222
243
|
import { delay } from "@xylabs/sdk-js";
|
|
@@ -225,16 +246,147 @@ function withDeprecationWarning(module) {
|
|
|
225
246
|
if (typeof deprecated === "string") {
|
|
226
247
|
return {
|
|
227
248
|
...module,
|
|
228
|
-
handler:
|
|
249
|
+
handler: async (argv) => {
|
|
229
250
|
console.warn(`[deprecated] ${deprecated}`);
|
|
230
251
|
await delay(3e3);
|
|
231
252
|
return handler(argv);
|
|
232
|
-
}
|
|
253
|
+
}
|
|
233
254
|
};
|
|
234
255
|
}
|
|
235
256
|
return module;
|
|
236
257
|
}
|
|
237
|
-
|
|
258
|
+
|
|
259
|
+
// src/dumpProviders.ts
|
|
260
|
+
var CANONICAL_ACTOR_ORDER = [
|
|
261
|
+
"_root",
|
|
262
|
+
"producer",
|
|
263
|
+
"finalizer",
|
|
264
|
+
"api",
|
|
265
|
+
"mempool",
|
|
266
|
+
"bridge",
|
|
267
|
+
"rewardRedemption"
|
|
268
|
+
];
|
|
269
|
+
function enumerateLocator(locator) {
|
|
270
|
+
const collapsed = /* @__PURE__ */ new Map();
|
|
271
|
+
const registry = locator.registry;
|
|
272
|
+
for (const moniker of Object.keys(registry)) {
|
|
273
|
+
const factories = registry[moniker];
|
|
274
|
+
if (!factories) continue;
|
|
275
|
+
for (const factory of factories) {
|
|
276
|
+
const f = factory;
|
|
277
|
+
const providerName = f.providerName ?? "<unknown>";
|
|
278
|
+
const scope = f.scope ?? "<unknown>";
|
|
279
|
+
const dependencies = f.dependencies ?? [];
|
|
280
|
+
const fingerprint = `${moniker}|${providerName}|${scope}|${dependencies.join(",")}`;
|
|
281
|
+
const existing = collapsed.get(fingerprint);
|
|
282
|
+
if (existing) {
|
|
283
|
+
existing.count += 1;
|
|
284
|
+
} else {
|
|
285
|
+
collapsed.set(fingerprint, {
|
|
286
|
+
count: 1,
|
|
287
|
+
dependencies,
|
|
288
|
+
moniker,
|
|
289
|
+
providerName,
|
|
290
|
+
scope
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return [...collapsed.values()].toSorted((a, b) => a.moniker.localeCompare(b.moniker) || a.providerName.localeCompare(b.providerName));
|
|
296
|
+
}
|
|
297
|
+
function buildOwnerIndex(perActor) {
|
|
298
|
+
const monikerOwners = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const [actorName, entries] of perActor) {
|
|
300
|
+
for (const entry of entries) {
|
|
301
|
+
let owners = monikerOwners.get(entry.moniker);
|
|
302
|
+
if (!owners) {
|
|
303
|
+
owners = /* @__PURE__ */ new Set();
|
|
304
|
+
monikerOwners.set(entry.moniker, owners);
|
|
305
|
+
}
|
|
306
|
+
owners.add(actorName);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return monikerOwners;
|
|
310
|
+
}
|
|
311
|
+
function renderDuplicatesSummary(monikerOwners) {
|
|
312
|
+
const duplicates = [...monikerOwners.entries()].filter(([, owners]) => owners.size > 1).map(([moniker, owners]) => ({ moniker, owners: [...owners].toSorted().map(formatGroupForDisplay) })).toSorted((a, b) => a.moniker.localeCompare(b.moniker));
|
|
313
|
+
if (duplicates.length === 0) return [];
|
|
314
|
+
const lines = ["Duplicate monikers (registered by more than one locator):"];
|
|
315
|
+
for (const { moniker, owners } of duplicates) {
|
|
316
|
+
lines.push(` - ${moniker}: ${owners.join(", ")}`);
|
|
317
|
+
}
|
|
318
|
+
lines.push("");
|
|
319
|
+
return lines;
|
|
320
|
+
}
|
|
321
|
+
function groupActorsBySharedRegistry(locators) {
|
|
322
|
+
const groups = [];
|
|
323
|
+
for (const actorName of Object.keys(locators)) {
|
|
324
|
+
const locator = locators[actorName];
|
|
325
|
+
const existing = groups.find((g) => g.registry === locator.registry);
|
|
326
|
+
if (existing) {
|
|
327
|
+
existing.actorNames.push(actorName);
|
|
328
|
+
} else {
|
|
329
|
+
groups.push({
|
|
330
|
+
actorNames: [actorName],
|
|
331
|
+
locator,
|
|
332
|
+
registry: locator.registry
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return groups;
|
|
337
|
+
}
|
|
338
|
+
function groupId(actorNames) {
|
|
339
|
+
return [...actorNames].toSorted().join(",");
|
|
340
|
+
}
|
|
341
|
+
function formatGroupForDisplay(groupKey) {
|
|
342
|
+
const members = groupKey.split(",");
|
|
343
|
+
return members.length === 1 ? members[0] : `(${members.join(", ")})`;
|
|
344
|
+
}
|
|
345
|
+
function renderGroupSection(actorNames, entries, monikerOwners) {
|
|
346
|
+
const sortedActors = [...actorNames].toSorted();
|
|
347
|
+
const ownGroupKey = groupId(sortedActors);
|
|
348
|
+
const heading = sortedActors.length === 1 ? `Providers for actor: ${sortedActors[0]} (${entries.length} registered)` : `Providers shared by actors: ${sortedActors.join(", ")} (${entries.length} registered)`;
|
|
349
|
+
const lines = [heading];
|
|
350
|
+
if (entries.length === 0) {
|
|
351
|
+
lines.push(" (none)", "");
|
|
352
|
+
return lines;
|
|
353
|
+
}
|
|
354
|
+
for (let i = 0; i < entries.length; i++) {
|
|
355
|
+
const entry = entries[i];
|
|
356
|
+
const isLast = i === entries.length - 1;
|
|
357
|
+
const branch = isLast ? "\u2514\u2500\u2500" : "\u251C\u2500\u2500";
|
|
358
|
+
const owners = monikerOwners.get(entry.moniker) ?? /* @__PURE__ */ new Set();
|
|
359
|
+
const otherOwners = [...owners].filter((o) => o !== ownGroupKey).toSorted().map(formatGroupForDisplay);
|
|
360
|
+
const dupNote = otherOwners.length > 0 ? ` \u26A0 also in: ${otherOwners.join(", ")}` : "";
|
|
361
|
+
const depsNote = entry.dependencies.length > 0 ? `, deps: [${entry.dependencies.join(", ")}]` : "";
|
|
362
|
+
const countNote = entry.count > 1 ? ` (\xD7${entry.count})` : "";
|
|
363
|
+
lines.push(` ${branch} ${entry.moniker}${countNote} [impl: ${entry.providerName}, scope: ${entry.scope}${depsNote}]${dupNote}`);
|
|
364
|
+
}
|
|
365
|
+
lines.push("");
|
|
366
|
+
return lines;
|
|
367
|
+
}
|
|
368
|
+
function formatProviderTree(locators) {
|
|
369
|
+
const groups = groupActorsBySharedRegistry(locators);
|
|
370
|
+
const groupKeys = groups.map((g) => ({ ...g, key: groupId(g.actorNames) }));
|
|
371
|
+
const perGroup = /* @__PURE__ */ new Map();
|
|
372
|
+
for (const g of groupKeys) perGroup.set(g.key, enumerateLocator(g.locator));
|
|
373
|
+
const monikerOwners = buildOwnerIndex(perGroup);
|
|
374
|
+
const orderedGroups = [...groupKeys].toSorted((a, b) => {
|
|
375
|
+
const aHasRoot = a.actorNames.includes("_root");
|
|
376
|
+
const bHasRoot = b.actorNames.includes("_root");
|
|
377
|
+
if (aHasRoot !== bHasRoot) return aHasRoot ? -1 : 1;
|
|
378
|
+
const ai = CANONICAL_ACTOR_ORDER.indexOf(a.actorNames[0]);
|
|
379
|
+
const bi = CANONICAL_ACTOR_ORDER.indexOf(b.actorNames[0]);
|
|
380
|
+
if (ai !== bi) return (ai === -1 ? Number.MAX_SAFE_INTEGER : ai) - (bi === -1 ? Number.MAX_SAFE_INTEGER : bi);
|
|
381
|
+
return a.key.localeCompare(b.key);
|
|
382
|
+
});
|
|
383
|
+
const lines = ["XL1 Provider Dump", "=================", ""];
|
|
384
|
+
for (const g of orderedGroups) {
|
|
385
|
+
lines.push(...renderGroupSection(g.actorNames.toSorted(), perGroup.get(g.key) ?? [], monikerOwners));
|
|
386
|
+
}
|
|
387
|
+
lines.push(...renderDuplicatesSummary(monikerOwners));
|
|
388
|
+
return lines.join("\n");
|
|
389
|
+
}
|
|
238
390
|
|
|
239
391
|
// src/images.ts
|
|
240
392
|
var XL1LogoColorizedAscii = `\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\xA0\x1B[0m\x1B[38;2;118;111;144m_\x1B[0m
|
|
@@ -259,10 +411,10 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
259
411
|
// src/optionsFromGlobalZodRegistry.ts
|
|
260
412
|
import { isUsageMeta } from "@xyo-network/xl1-sdk";
|
|
261
413
|
import { globalRegistry } from "zod";
|
|
262
|
-
var usageMetaToOptions =
|
|
414
|
+
var usageMetaToOptions = (meta) => {
|
|
263
415
|
return meta;
|
|
264
|
-
}
|
|
265
|
-
var optionsFromGlobalZodRegistry =
|
|
416
|
+
};
|
|
417
|
+
var optionsFromGlobalZodRegistry = () => {
|
|
266
418
|
const opts = {};
|
|
267
419
|
for (const schema of Object.values(globalRegistry._map)) {
|
|
268
420
|
if (isUsageMeta(schema)) {
|
|
@@ -271,7 +423,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
271
423
|
}
|
|
272
424
|
}
|
|
273
425
|
return opts;
|
|
274
|
-
}
|
|
426
|
+
};
|
|
275
427
|
|
|
276
428
|
// src/runCLI.ts
|
|
277
429
|
var DEFAULT_HEALTH_CHECK_PORT = 9090;
|
|
@@ -280,30 +432,25 @@ function defaultScrapePortForActors(actors) {
|
|
|
280
432
|
const key = primary === "rewardRedemption" ? "rewardRedemptionApi" : primary;
|
|
281
433
|
return DefaultMetricsScrapePorts[key] ?? DefaultMetricsScrapePorts.producer;
|
|
282
434
|
}
|
|
283
|
-
__name(defaultScrapePortForActors, "defaultScrapePortForActors");
|
|
284
435
|
var configuration;
|
|
285
436
|
var skipInsecureConfirm = false;
|
|
286
|
-
var
|
|
437
|
+
var dumpProviders = false;
|
|
438
|
+
var version = isDefined3("1.23.2") ? "1.23.2" : "unknown";
|
|
287
439
|
function getConfiguration() {
|
|
288
440
|
return configuration;
|
|
289
441
|
}
|
|
290
|
-
__name(getConfiguration, "getConfiguration");
|
|
291
442
|
async function promptForInsecureGenesisConfirmation(logger) {
|
|
292
443
|
if (!input.isTTY || !output.isTTY) {
|
|
293
444
|
logger.warn("Insecure genesis reward wallet is active. Interactive confirmation skipped because this session is not a TTY.");
|
|
294
445
|
return;
|
|
295
446
|
}
|
|
296
|
-
const rl = createInterface({
|
|
297
|
-
input,
|
|
298
|
-
output
|
|
299
|
-
});
|
|
447
|
+
const rl = createInterface({ input, output });
|
|
300
448
|
try {
|
|
301
449
|
await rl.question("Insecure genesis reward wallet is active. Hit RETURN to continue.");
|
|
302
450
|
} finally {
|
|
303
451
|
rl.close();
|
|
304
452
|
}
|
|
305
453
|
}
|
|
306
|
-
__name(promptForInsecureGenesisConfirmation, "promptForInsecureGenesisConfirmation");
|
|
307
454
|
async function getLocatorsFromConfig(actors, configuration2) {
|
|
308
455
|
const actorConfigs = [];
|
|
309
456
|
for (const actorName of actors) {
|
|
@@ -311,20 +458,13 @@ async function getLocatorsFromConfig(actors, configuration2) {
|
|
|
311
458
|
if (existingConfig) {
|
|
312
459
|
actorConfigs.push(existingConfig);
|
|
313
460
|
} else {
|
|
314
|
-
const actorConfig = ActorConfigZod.loose().parse({
|
|
315
|
-
name: actorName
|
|
316
|
-
});
|
|
461
|
+
const actorConfig = ActorConfigZod.loose().parse({ name: actorName });
|
|
317
462
|
actorConfigs.push(actorConfig);
|
|
318
463
|
}
|
|
319
464
|
}
|
|
320
|
-
const config2 = ConfigZod2.parse({
|
|
321
|
-
...configuration2,
|
|
322
|
-
actors: actorConfigs
|
|
323
|
-
});
|
|
465
|
+
const config2 = ConfigZod2.parse({ ...configuration2, actors: actorConfigs });
|
|
324
466
|
const logger = initLogger(configuration2);
|
|
325
|
-
const orchestrator = await Orchestrator.create({
|
|
326
|
-
logger
|
|
327
|
-
});
|
|
467
|
+
const orchestrator = await Orchestrator.create({ logger });
|
|
328
468
|
const collision = detectDerivationPathCollisions(actors, configuration2);
|
|
329
469
|
if (collision) throw collision;
|
|
330
470
|
const walletReport = await initializeResolvedWalletReport(actors, configuration2);
|
|
@@ -336,6 +476,10 @@ async function getLocatorsFromConfig(actors, configuration2) {
|
|
|
336
476
|
}
|
|
337
477
|
const onInsecureGenesisConfirm = skipInsecureConfirm ? void 0 : async () => await promptForInsecureGenesisConfirmation(logger);
|
|
338
478
|
const locators = await locatorsFromConfig(context, config2, onInsecureGenesisConfirm);
|
|
479
|
+
if (dumpProviders) {
|
|
480
|
+
console.log(formatProviderTree(locators));
|
|
481
|
+
process.exit(0);
|
|
482
|
+
}
|
|
339
483
|
const healthCheckPort = configuration2.healthCheckPort ?? DEFAULT_HEALTH_CHECK_PORT;
|
|
340
484
|
const healthServer = healthCheckPort > 0 && context.statusReporter !== void 0 ? await initHealthEndpoints({
|
|
341
485
|
logger,
|
|
@@ -357,12 +501,8 @@ async function getLocatorsFromConfig(actors, configuration2) {
|
|
|
357
501
|
}
|
|
358
502
|
})();
|
|
359
503
|
});
|
|
360
|
-
return {
|
|
361
|
-
locators,
|
|
362
|
-
orchestrator
|
|
363
|
-
};
|
|
504
|
+
return { locators, orchestrator };
|
|
364
505
|
}
|
|
365
|
-
__name(getLocatorsFromConfig, "getLocatorsFromConfig");
|
|
366
506
|
async function runCLI() {
|
|
367
507
|
const y = yargs(hideBin(process.argv));
|
|
368
508
|
const argv = y.usage(`
|
|
@@ -373,13 +513,17 @@ Run various components of the XL1 ecosystem.
|
|
|
373
513
|
Usage:
|
|
374
514
|
$0 <command> [options]`).parserConfiguration({
|
|
375
515
|
"dot-notation": true,
|
|
516
|
+
// foo.bar → { foo: { bar } }
|
|
376
517
|
"parse-numbers": false,
|
|
518
|
+
// Don't auto-parse numbers to allow strings like "0x1"
|
|
377
519
|
"populate--": true
|
|
520
|
+
// Populate -- with all options so we can detected user-supplied vs defaults
|
|
378
521
|
}).env("XL1").scriptName("xl1").middleware(async (argv2) => {
|
|
379
522
|
await configMiddleware(argv2, (config2) => {
|
|
380
523
|
configuration = config2;
|
|
381
524
|
});
|
|
382
525
|
skipInsecureConfirm = Boolean(argv2["skip-insecure-confirm"]);
|
|
526
|
+
dumpProviders = Boolean(argv2["dump-providers"]);
|
|
383
527
|
}).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({
|
|
384
528
|
"config": {
|
|
385
529
|
type: "string",
|
|
@@ -392,7 +536,17 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
392
536
|
},
|
|
393
537
|
"dump-config": {
|
|
394
538
|
type: "boolean",
|
|
395
|
-
description: "Just process the configuration and print the resolved config to stdout, then exit.",
|
|
539
|
+
description: "Just process the configuration and print the resolved config to stdout, then exit. Secrets are redacted unless --with-secrets is also passed.",
|
|
540
|
+
default: false
|
|
541
|
+
},
|
|
542
|
+
"with-secrets": {
|
|
543
|
+
type: "boolean",
|
|
544
|
+
description: 'When used with --dump-config, print raw secret values (mnemonic, private keys, passwords) instead of "[REDACTED]". Use only on a developer machine.',
|
|
545
|
+
default: false
|
|
546
|
+
},
|
|
547
|
+
"dump-providers": {
|
|
548
|
+
type: "boolean",
|
|
549
|
+
description: "Run the normal command flow up to provider locator construction, print the per-actor provider tree (with duplicate detection), then exit.",
|
|
396
550
|
default: false
|
|
397
551
|
},
|
|
398
552
|
"skip-insecure-confirm": {
|
|
@@ -403,20 +557,18 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
403
557
|
}).help().alias("help", "h").version(version).argv;
|
|
404
558
|
await argv;
|
|
405
559
|
}
|
|
406
|
-
__name(runCLI, "runCLI");
|
|
407
560
|
|
|
408
561
|
// src/start.ts
|
|
409
562
|
import { config } from "dotenv";
|
|
410
|
-
var start =
|
|
411
|
-
config({
|
|
412
|
-
quiet: true
|
|
413
|
-
});
|
|
563
|
+
var start = async () => {
|
|
564
|
+
config({ quiet: true });
|
|
414
565
|
await runCLI();
|
|
415
|
-
}
|
|
566
|
+
};
|
|
416
567
|
export {
|
|
417
568
|
configMiddleware,
|
|
418
569
|
initLogger,
|
|
570
|
+
redactConfig,
|
|
419
571
|
runCLI,
|
|
420
572
|
start
|
|
421
573
|
};
|
|
422
|
-
//# sourceMappingURL=index.mjs.map
|
|
574
|
+
//# sourceMappingURL=index.mjs.map
|