@xyo-network/xl1-cli-lib 1.19.6 → 1.19.7
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/validator/runValidator.d.ts +2 -2
- package/dist/node/commands/validator/runValidator.d.ts.map +1 -1
- package/dist/node/index.mjs +38 -10
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/tryParseConfig.d.ts +123 -1
- package/dist/node/tryParseConfig.d.ts.map +1 -1
- package/dist/node/xl1.mjs +38 -10
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +14 -13
- package/src/commands/validator/runValidator.ts +2 -2
- package/src/runCLI.ts +36 -7
- package/src/tryParseConfig.ts +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AccountInstance } from '@xyo-network/account-model';
|
|
2
2
|
import type { OrchestratorInstance } from '@xyo-network/chain-orchestration';
|
|
3
|
-
import type {
|
|
4
|
-
interface RunValidatorContext extends
|
|
3
|
+
import type { CachingContext, Config, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
|
|
4
|
+
interface RunValidatorContext extends CachingContext {
|
|
5
5
|
account: AccountInstance;
|
|
6
6
|
config: Config;
|
|
7
7
|
locator: ProviderFactoryLocatorInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EACV,cAAc,EAAE,MAAM,EAAE,8BAA8B,EACvD,MAAM,sBAAsB,CAAA;AAE7B,UAAU,mBAAoB,SAAQ,cAAc;IAClD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,8BAA8B,CAAA;IACvC,YAAY,EAAE,oBAAoB,CAAA;CACnC;AAED,eAAO,MAAM,YAAY,GAAU,SAAS,mBAAmB,kBAuB9D,CAAA"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/runCLI.ts
|
|
5
|
-
import {
|
|
5
|
+
import { isDefined as isDefined3, toAddress } from "@xylabs/sdk-js";
|
|
6
6
|
import { runApi } from "@xyo-network/chain-api";
|
|
7
7
|
import { Orchestrator } from "@xyo-network/chain-orchestration";
|
|
8
8
|
import { runProducer } from "@xyo-network/chain-producer";
|
|
9
|
-
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
9
|
+
import { ConfigZod as ConfigZod2, isZodError } from "@xyo-network/xl1-sdk";
|
|
10
|
+
import { merge as deepMerge } from "ts-deepmerge";
|
|
10
11
|
import yargs from "yargs";
|
|
11
12
|
import { hideBin } from "yargs/helpers";
|
|
12
|
-
import { ZodError } from "zod";
|
|
13
13
|
|
|
14
14
|
// src/commands/bridge/runBridge.ts
|
|
15
15
|
import { getServer } from "@xyo-network/chain-bridge";
|
|
@@ -89,6 +89,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
89
89
|
|
|
90
90
|
// src/tryParseConfig.ts
|
|
91
91
|
import { isDefined as isDefined2, isNull } from "@xylabs/sdk-js";
|
|
92
|
+
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
92
93
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
93
94
|
var configName = "xyo";
|
|
94
95
|
var configSection = "xl1";
|
|
@@ -98,10 +99,10 @@ var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
|
98
99
|
if (!isNull(result)) {
|
|
99
100
|
const section = result?.config?.[configSection];
|
|
100
101
|
if (isDefined2(section) && typeof section === "object") {
|
|
101
|
-
return section;
|
|
102
|
+
return ConfigZod.parse(section);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
return {};
|
|
105
|
+
return ConfigZod.parse({});
|
|
105
106
|
}, "tryParseConfig");
|
|
106
107
|
|
|
107
108
|
// src/waitForHostPort.ts
|
|
@@ -127,7 +128,18 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
127
128
|
|
|
128
129
|
// src/runCLI.ts
|
|
129
130
|
var configuration;
|
|
130
|
-
var version = isDefined3("1.19.
|
|
131
|
+
var version = isDefined3("1.19.6") ? "1.19.6" : "unknown";
|
|
132
|
+
function resolveConfig(config2) {
|
|
133
|
+
const logger = console;
|
|
134
|
+
const defaultChainId = toAddress("1");
|
|
135
|
+
const resolved = structuredClone(config2);
|
|
136
|
+
if (!resolved.chain.id) {
|
|
137
|
+
logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`);
|
|
138
|
+
resolved.chain.id = defaultChainId;
|
|
139
|
+
}
|
|
140
|
+
return resolved;
|
|
141
|
+
}
|
|
142
|
+
__name(resolveConfig, "resolveConfig");
|
|
131
143
|
var getContextFromConfig = /* @__PURE__ */ __name(async (configuration2) => {
|
|
132
144
|
const logger = initLogger(configuration2);
|
|
133
145
|
const orchestrator = await Orchestrator.create({
|
|
@@ -167,12 +179,28 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
167
179
|
try {
|
|
168
180
|
const parsedConfigFile = tryParseConfig();
|
|
169
181
|
const parsedConfigArgs = argv2;
|
|
170
|
-
const
|
|
171
|
-
|
|
182
|
+
const parseResult = ConfigZod2.safeParse(parsedConfigFile);
|
|
183
|
+
if (!parseResult.success) {
|
|
184
|
+
throw parseResult.error;
|
|
185
|
+
}
|
|
186
|
+
const mergedConfig = deepMerge(parsedConfigArgs);
|
|
187
|
+
const validatedMergedConfigResult = ConfigZod2.safeParse(mergedConfig);
|
|
188
|
+
if (!validatedMergedConfigResult.success) {
|
|
189
|
+
throw validatedMergedConfigResult.error;
|
|
190
|
+
}
|
|
191
|
+
const resolvedConfig = resolveConfig(validatedMergedConfigResult.data);
|
|
192
|
+
const validatedConfigResult = ConfigZod2.safeParse(resolvedConfig);
|
|
193
|
+
if (!validatedConfigResult.success) {
|
|
194
|
+
throw validatedConfigResult.error;
|
|
195
|
+
}
|
|
196
|
+
configuration = validatedConfigResult.data;
|
|
172
197
|
} catch (err) {
|
|
173
|
-
if (err
|
|
174
|
-
console.error(
|
|
198
|
+
if (isZodError(err)) {
|
|
199
|
+
console.error(`Zod error: ${err.message}`);
|
|
200
|
+
} else {
|
|
201
|
+
console.error(`Error parsing configuration: ${err}`);
|
|
175
202
|
}
|
|
203
|
+
console.error(`Stack: ${err instanceof Error ? err.stack : "N/A"}`);
|
|
176
204
|
throw new Error("Invalid configuration");
|
|
177
205
|
}
|
|
178
206
|
}).options(optionsFromGlobalZodRegistry()).wrap(y.terminalWidth()).command("api", "Run a XL1 API Node", (yargs2) => {
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runCLI.ts","../../src/commands/bridge/runBridge.ts","../../src/commands/mempool/runMempool.ts","../../src/commands/rewardRedemption/runRewardRedemptionApi.ts","../../src/images.ts","../../src/initLogger.ts","../../src/optionsFromGlobalZodRegistry.ts","../../src/tryParseConfig.ts","../../src/waitForHostPort.ts","../../src/start.ts"],"sourcesContent":["import type { Logger } from '@xylabs/sdk-js'\nimport { deepMerge, isDefined } from '@xylabs/sdk-js'\nimport { runApi } from '@xyo-network/chain-api'\nimport { Orchestrator } from '@xyo-network/chain-orchestration'\nimport { runProducer } from '@xyo-network/chain-producer'\nimport { type Config, ConfigZod } from '@xyo-network/xl1-sdk'\nimport type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\nimport { ZodError } from 'zod'\n\nimport {\n runBridge, runMempool, runRewardRedemptionApi,\n} from './commands/index.ts'\nimport { XL1LogoColorizedAscii } from './images.ts'\nimport { initLogger } from './initLogger.ts'\nimport { optionsFromGlobalZodRegistry } from './optionsFromGlobalZodRegistry.ts'\nimport { tryParseConfig } from './tryParseConfig.ts'\nimport { waitForHostPort } from './waitForHostPort.ts'\n\n/** Version string injected by Rollup at build time. */\ndeclare const __VERSION__: string\n\ninterface RunCliContext {\n logger: Logger\n orchestrator: Orchestrator\n}\n\n/**\n * The configuration that will be used throughout the CLI.\n * This is materialized after parsing the command-line arguments,\n * environment variables, and defaults.\n */\nlet configuration: Config\n\nconst version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'\n\nconst getContextFromConfig = async (configuration: Config): Promise<RunCliContext> => {\n const logger = initLogger(configuration)\n const orchestrator = await Orchestrator.create({ logger })\n // Handle cancellation (Ctrl+C)\n process.on('SIGINT', () => {\n void (async () => {\n try {\n logger.log('\\nSIGINT received. Attempting graceful shutdown...')\n await orchestrator?.stop()\n logger.log('Orchestrator stopped, exiting now.')\n process.exit(0)\n } catch (err) {\n logger.error('Error stopping orchestrator:', err)\n process.exit(1)\n }\n })()\n })\n return { logger, orchestrator }\n}\n\n// Main entry point\nexport async function runCLI() {\n // Parse command-line arguments using Yargs\n const y = yargs(hideBin(process.argv)) as Argv<Config>\n const argv = y\n .usage(`\n🚀 XL1 Node CLI (${version})\n${XL1LogoColorizedAscii}\nRun various components of the XL1 ecosystem.\n\nUsage:\n$0 <command> [options]`)\n .parserConfiguration({\n 'dot-notation': true, // foo.bar → { foo: { bar } }\n 'parse-numbers': false, // Don't auto-parse numbers to allow strings like \"0x1\"\n 'populate--': true, // Populate -- with all options so we can detected user-supplied vs defaults\n })\n .env('XL1')\n .scriptName('xl1')\n .middleware((argv) => {\n try {\n // Parse the various config sources\n const parsedConfigFile = tryParseConfig() // Config file\n const parsedConfigArgs = argv // Command-line arguments & ENV VARs\n // Deep merge with precedence\n // TODO: Would like precedence to be defaults < file < ENV < CLI Args\n // but there is currently no way to determine which are defaults vs\n // user-supplied CLI Args since we set the CLI args to the defaults\n // and receive a flattened object. We might need to manually invoke\n // the parser without the defaults to achieve this.\n const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)\n // Validate the merged configuration\n configuration = ConfigZod.parse(mergedConfig)\n } catch (err) {\n if (err instanceof ZodError) {\n console.error(`${err.message}`)\n }\n throw new Error('Invalid configuration')\n }\n })\n .options(optionsFromGlobalZodRegistry())\n // .commandDir('./command/commands', opts) // Not yet supported for ESM\n .wrap(y.terminalWidth())\n .command('api', 'Run a XL1 API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('bridge', 'Run a XL1 Bridge Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Bridge Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runBridge({ ...context, config: configuration })\n })\n })\n .command('mempool', 'Run a XL1 Mempool Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Mempool Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runMempool({ ...context, config: configuration })\n })\n })\n .command('producer', 'Run a XL1 Producer Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Producer Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('reward-redemption-api', 'Run a XL1 Rewards Redemption API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Rewards Redemption API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runRewardRedemptionApi({ ...context, config: configuration })\n })\n })\n .command('$0', 'Run a full XL1 Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n if (configuration.mempool.enabled) {\n // Start Mempool but do not block\n runMempool({ ...context, config: configuration })\n // Wait for Mempool to be ready\n await waitForHostPort(configuration.mempool.host, configuration.mempool.port)\n }\n // Start API but do not block\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n // Wait for API to be ready\n await waitForHostPort(configuration.api.host, configuration.api.port)\n // Start Producer and block on it\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n .help()\n .alias('help', 'h')\n .version(version)\n .argv\n\n await argv\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-bridge'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunBridgeContext {\n config: Config\n logger?: Logger\n}\n\nexport function runBridge(context: RunBridgeContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-mempool'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunMempoolContext {\n config: Config\n logger: Logger\n}\n\nexport function runMempool(context: RunMempoolContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-reward-redemption'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunRewardRedemptionApiContext {\n config: Config\n logger?: Logger\n}\n\nexport function runRewardRedemptionApi(context: RunRewardRedemptionApiContext) {\n void getServer(context)\n}\n","/* eslint-disable @stylistic/max-len */\nexport const XL1LogoColorizedAscii = `\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;118;111;144m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;72;32;223m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m ╠╠\u001b[0m\u001b[38;2;103;85;170m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;79;121;152m╦\u001b[0m\u001b[38;2;82;121;151m╦\u001b[0m\u001b[38;2;112;125;136m_ \u001b[0m\u001b[38;2;88;59;196m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;73;34;221m▒ \u001b[0m\u001b[38;2;121;121;127m_\u001b[0m\u001b[38;2;100;101;128m╔\u001b[0m\u001b[38;2;93;94;127m╦\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;82;121;151m²\u001b[0m\u001b[38;2;44;116;170m╠\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;51;117;167mD\u001b[0m\u001b[38;2;80;121;152m╦\u001b[0m\u001b[38;2;111;125;136m_ \u001b[0m\u001b[38;2;67;23;232m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;120;121;128m_\u001b[0m\u001b[38;2;100;101;127m╔\u001b[0m\u001b[38;2;79;81;127mR\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;88;90;127m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;55;117;165m╚\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;44;116;171m▒▒\u001b[0m\u001b[38;2;50;116;167mD\u001b[0m\u001b[38;2;80;121;152m╦ \u001b[0m\u001b[38;2;106;90;165mj\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;89;61;194mH \u001b[0m\u001b[38;2;99;100;127m╔\u001b[0m\u001b[38;2;79;80;127mD\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒▒╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;83;121;150m²\u001b[0m\u001b[38;2;44;116;170m▒\u001b[0m\u001b[38;2;44;116;171m▒▒▒ \u001b[0m\u001b[38;2;76;38;217m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;74;76;128m╠\u001b[0m\u001b[38;2;71;73;128m▒▒▒\u001b[0m\u001b[38;2;89;90;128m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;90;118;148m\\`\u001b[0m\u001b[38;2;89;107;153m_\u001b[0m\u001b[38;2;93;97;154m,\u001b[0m\u001b[38;2;105;89;166m╓\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;95;72;183m╓\u001b[0m\u001b[38;2;106;96;152m_\u001b[0m\u001b[38;2;100;94;143m\\`\u001b[0m\u001b[38;2;101;100;133m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;122;118;137m_\u001b[0m\u001b[38;2;113;102;153m,\u001b[0m\u001b[38;2;108;94;161m╓\u001b[0m\u001b[38;2;104;86;169m╓\u001b[0m\u001b[38;2;98;77;178m╔\u001b[0m\u001b[38;2;93;67;188m╗\u001b[0m\u001b[38;2;88;59;196mφ\u001b[0m\u001b[38;2;83;51;204m@\u001b[0m\u001b[38;2;78;42;213mD\u001b[0m\u001b[38;2;72;32;223m▒\u001b[0m\u001b[38;2;68;24;231m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;71;30;225m▒\u001b[0m\u001b[38;2;77;40;215m▒\u001b[0m\u001b[38;2;82;49;206mK\u001b[0m\u001b[38;2;87;57;198mφ\u001b[0m\u001b[38;2;91;65;190m╗\u001b[0m\u001b[38;2;97;75;180m╦\u001b[0m\u001b[38;2;103;84;171m╖\u001b[0m\u001b[38;2;107;92;163m²\u001b[0m\u001b[38;2;112;101;154m_\u001b[0m\u001b[38;2;119;112;143m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;106;91;164m\\`\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;89;62;193m╙\u001b[0m\u001b[38;2;85;54;201m╙\u001b[0m\u001b[38;2;80;45;210m╚\u001b[0m\u001b[38;2;74;35;220m╝\u001b[0m\u001b[38;2;69;26;229m╠\u001b[0m\u001b[38;2;66;22;233m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;73;33;222m╝\u001b[0m\u001b[38;2;79;43;212m╩\u001b[0m\u001b[38;2;84;52;203m╜\u001b[0m\u001b[38;2;88;60;195m╙\u001b[0m\u001b[38;2;93;68;187m^\u001b[0m\u001b[38;2;100;80;175m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;113;84;152m\\`\u001b[0m\u001b[38;2;103;79;169m'\u001b[0m\u001b[38;2;95;72;183m\"\u001b[0m\u001b[38;2;87;57;198m╙\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;80;46;209m╜\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;102;77;175m^\u001b[0m\u001b[38;2;112;81;162m\\`\u001b[0m\u001b[38;2;115;92;155m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;145;116;107m,\u001b[0m\u001b[38;2;199;82;45m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒╠ \u001b[0m\u001b[38;2;70;28;227m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;189;49;97må\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;155;92;114m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;175;98;73m╔\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒▒▒\u001b[0m\u001b[38;2;197;83;47m╩ \u001b[0m\u001b[38;2;98;76;179m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;81;48;207mH \u001b[0m\u001b[38;2;188;51;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠╠\u001b[0m\u001b[38;2;183;57;100mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;146;116;106m,\u001b[0m\u001b[38;2;199;82;44m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;196;84;48m╩\u001b[0m\u001b[38;2;168;102;81m^ \u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;160;87;111m'\u001b[0m\u001b[38;2;187;52;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;156;91;113m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;198;83;46m╩\u001b[0m\u001b[38;2;194;85;50m╩\u001b[0m\u001b[38;2;167;102;82m^ \u001b[0m\u001b[38;2;81;46;209m╚\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠ \u001b[0m\u001b[38;2;159;88;112m'\u001b[0m\u001b[38;2;186;53;98m╚\u001b[0m\u001b[38;2;197;40;93m╩\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;110;97;158m'\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;94;69;186mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;68;25;230m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;108;93;162m²\u001b[0m\u001b[38;2;99;79;176m^\u001b[0m`\n","import type { Logger, LogLevelValue } from '@xylabs/sdk-js'\nimport {\n Base,\n ConsoleLogger, isDefined,\n LogLevel, SilentLogger,\n} from '@xylabs/sdk-js'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\nexport const initLogger = (config: Config): Logger => {\n let logger: Logger\n if (config.silent) {\n logger = new SilentLogger()\n } else {\n let level: LogLevelValue | undefined\n if (isDefined(config.logLevel)) {\n const parsed = LogLevel[config.logLevel.toLowerCase() as keyof typeof LogLevel]\n if (isDefined(parsed)) level = parsed\n }\n logger = new ConsoleLogger(level)\n }\n Base.defaultLogger = logger\n return logger\n}\n","import type { UsageMeta } from '@xyo-network/xl1-sdk'\nimport { isUsageMeta } from '@xyo-network/xl1-sdk'\nimport type { Options } from 'yargs'\nimport { globalRegistry } from 'zod'\n\nconst usageMetaToOptions = (meta: UsageMeta): Options => {\n return meta\n}\n\nexport const optionsFromGlobalZodRegistry = (): Record<string, Options> => {\n const opts: Record<string, Options> = {}\n for (const schema of Object.values(globalRegistry._map)) {\n if (isUsageMeta(schema)) {\n if (schema.hidden) continue // skip hidden options\n opts[schema.title] = usageMetaToOptions(schema)\n }\n }\n return opts\n}\n","import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { cosmiconfigSync } from 'cosmiconfig'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport const tryParseConfig = (): Record<string, unknown> => {\n const explorer = cosmiconfigSync(\n configName,\n /* {\n searchPlaces: [\n 'package.json', // Looks under `xyo` key in package.json\n '.xyorc.json', // Supports common dotfile format\n 'xyo.config.json', // Supports custom-named config file\n ],\n loaders: {\n '.json': defaultLoaders['.json'],\n 'noExt': defaultLoaders['.json'],\n },\n }, */\n )\n const result = explorer.search()\n if (!isNull(result)) {\n const section = result?.config?.[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return section\n }\n }\n return {}\n}\n","import net from 'node:net'\n\nexport const waitForHostPort = (host: string, port: number): Promise<void> => {\n return new Promise((resolve) => {\n const tryConnect = () => {\n const socket = new net.Socket()\n\n socket\n .setTimeout(1000)\n .once('error', () => {\n socket.destroy()\n setTimeout(tryConnect, 500) // retry after 500ms\n })\n .once('timeout', () => {\n socket.destroy()\n setTimeout(tryConnect, 500)\n })\n .connect(port, host, () => {\n socket.end()\n resolve()\n })\n }\n\n tryConnect()\n })\n}\n","import { config } from 'dotenv'\n\nimport { runCLI } from './runCLI.ts'\n\nexport const start = async () => {\n config({ quiet: true })\n await runCLI()\n}\n"],"mappings":";;;;AACA,SAASA,WAAWC,aAAAA,kBAAiB;AACrC,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAC5B,SAAsBC,iBAAiB;AAEvC,OAAOC,WAAW;AAClB,SAASC,eAAe;AACxB,SAASC,gBAAgB;;;ACRzB,SAASC,iBAAiB;AAQnB,SAASC,UAAUC,SAAyB;AACjD,OAAKC,UAAUD,OAAAA;AACjB;AAFgBD;;;ACRhB,SAASG,aAAAA,kBAAiB;AAQnB,SAASC,WAAWC,SAA0B;AACnD,OAAKC,WAAUD,OAAAA;AACjB;AAFgBD;;;ACRhB,SAASG,aAAAA,kBAAiB;AAQnB,SAASC,uBAAuBC,SAAsC;AAC3E,OAAKC,WAAUD,OAAAA;AACjB;AAFgBD;;;ACRT,IAAMG,wBAAwB;;;;;;;;;;;;;;;;;;;;ACArC,SACEC,MACAC,eAAeC,WACfC,UAAUC,oBACL;AAGA,IAAMC,aAAa,wBAACC,YAAAA;AACzB,MAAIC;AACJ,MAAID,QAAOE,QAAQ;AACjBD,aAAS,IAAIE,aAAAA;EACf,OAAO;AAC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yB,yCAAyC,CAACxB,WAAAA;AAC1E,WAAOA,OACJwB,QAAQ,MAAM,yCAAyC,MAAA;IAAO,GAAG,YAAA;AAChE,YAAMC,UAAU,MAAMxC,qBAAqBJ,aAAAA;AAC3CmD,6BAAuB;QAAE,GAAGP;QAASE,QAAQ9C;MAAc,CAAA;IAC7D,CAAA;EACJ,CAAA,EACC2C,QAAQ,MAAM,uBAAuB,MAAA;EAAO,GAAG,YAAA;AAC9C,UAAMC,UAAU,MAAMxC,qBAAqBJ,aAAAA;AAC3C,QAAIA,cAAcoD,QAAQC,SAAS;AAEjCJ,iBAAW;QAAE,GAAGL;QAASE,QAAQ9C;MAAc,CAAA;AAE/C,YAAMsD,gBAAgBtD,cAAcoD,QAAQG,MAAMvD,cAAcoD,QAAQI,IAAI;IAC9E;AAEA,UAAMX,OAAO;MACX,GAAGD;MAASE,QAAQ9C;MAAe+C,YAAY,CAAC;IAClD,CAAA;AAEA,UAAMO,gBAAgBtD,cAAcyD,IAAIF,MAAMvD,cAAcyD,IAAID,IAAI;AAEpE,UAAMN,YAAY;MAChB,GAAGN;MAASE,QAAQ9C;MAAe+C,YAAY,CAAC;IAClD,CAAA;EACF,CAAA,EACCW,KAAI,EACJC,MAAM,QAAQ,GAAA,EACd1D,QAAQA,OAAAA,EACRoB;AAEH,QAAMA;AACR;AA1GsBJ;;;AS1DtB,SAAS2C,cAAc;AAIhB,IAAMC,QAAQ,mCAAA;AACnBC,SAAO;IAAEC,OAAO;EAAK,CAAA;AACrB,QAAMC,OAAAA;AACR,GAHqB;","names":["deepMerge","isDefined","runApi","Orchestrator","runProducer","ConfigZod","yargs","hideBin","ZodError","getServer","runBridge","context","getServer","getServer","runMempool","context","getServer","getServer","runRewardRedemptionApi","context","getServer","XL1LogoColorizedAscii","Base","ConsoleLogger","isDefined","LogLevel","SilentLogger","initLogger","config","logger","silent","SilentLogger","level","isDefined","logLevel","parsed","LogLevel","toLowerCase","ConsoleLogger","Base","defaultLogger","isUsageMeta","globalRegistry","usageMetaToOptions","meta","optionsFromGlobalZodRegistry","opts","schema","Object","values","globalRegistry","_map","isUsageMeta","hidden","title","isDefined","isNull","cosmiconfigSync","configName","configSection","tryParseConfig","explorer","cosmiconfigSync","result","search","isNull","section","config","isDefined","net","waitForHostPort","host","port","Promise","resolve","tryConnect","socket","net","Socket","setTimeout","once","destroy","connect","end","configuration","version","isDefined","__VERSION__","getContextFromConfig","logger","initLogger","orchestrator","Orchestrator","create","process","on","log","stop","exit","err","error","runCLI","y","yargs","hideBin","argv","usage","XL1LogoColorizedAscii","parserConfiguration","env","scriptName","middleware","parsedConfigFile","tryParseConfig","parsedConfigArgs","mergedConfig","deepMerge","ConfigZod","parse","ZodError","console","message","Error","options","optionsFromGlobalZodRegistry","wrap","terminalWidth","command","context","runApi","config","singletons","runBridge","runMempool","runProducer","runRewardRedemptionApi","mempool","enabled","waitForHostPort","host","port","api","help","alias","config","start","config","quiet","runCLI"]}
|
|
1
|
+
{"version":3,"sources":["../../src/runCLI.ts","../../src/commands/bridge/runBridge.ts","../../src/commands/mempool/runMempool.ts","../../src/commands/rewardRedemption/runRewardRedemptionApi.ts","../../src/images.ts","../../src/initLogger.ts","../../src/optionsFromGlobalZodRegistry.ts","../../src/tryParseConfig.ts","../../src/waitForHostPort.ts","../../src/start.ts"],"sourcesContent":["import type { Logger } from '@xylabs/sdk-js'\nimport { isDefined, toAddress } from '@xylabs/sdk-js'\nimport { runApi } from '@xyo-network/chain-api'\nimport { Orchestrator } from '@xyo-network/chain-orchestration'\nimport { runProducer } from '@xyo-network/chain-producer'\nimport type { Config } from '@xyo-network/xl1-sdk'\nimport { ConfigZod, isZodError } from '@xyo-network/xl1-sdk'\nimport { merge as deepMerge } from 'ts-deepmerge'\nimport type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\nimport {\n runBridge, runMempool, runRewardRedemptionApi,\n} from './commands/index.ts'\nimport { XL1LogoColorizedAscii } from './images.ts'\nimport { initLogger } from './initLogger.ts'\nimport { optionsFromGlobalZodRegistry } from './optionsFromGlobalZodRegistry.ts'\nimport { tryParseConfig } from './tryParseConfig.ts'\nimport { waitForHostPort } from './waitForHostPort.ts'\n\n/** Version string injected by Rollup at build time. */\ndeclare const __VERSION__: string\n\ninterface RunCliContext {\n logger: Logger\n orchestrator: Orchestrator\n}\n\n/**\n * The configuration that will be used throughout the CLI.\n * This is materialized after parsing the command-line arguments,\n * environment variables, and defaults.\n */\nlet configuration: Config\n\nconst version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'\n\nfunction resolveConfig(config: Config): Config {\n const logger = console\n const defaultChainId = toAddress('1')\n const resolved = structuredClone(config)\n if (!resolved.chain.id) {\n logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`)\n resolved.chain.id = defaultChainId\n }\n return resolved\n}\n\nconst getContextFromConfig = async (configuration: Config): Promise<RunCliContext> => {\n const logger = initLogger(configuration)\n const orchestrator = await Orchestrator.create({ logger })\n // Handle cancellation (Ctrl+C)\n process.on('SIGINT', () => {\n void (async () => {\n try {\n logger.log('\\nSIGINT received. Attempting graceful shutdown...')\n await orchestrator?.stop()\n logger.log('Orchestrator stopped, exiting now.')\n process.exit(0)\n } catch (err) {\n logger.error('Error stopping orchestrator:', err)\n process.exit(1)\n }\n })()\n })\n return { logger, orchestrator }\n}\n\n// Main entry point\nexport async function runCLI() {\n // Parse command-line arguments using Yargs\n const y = yargs(hideBin(process.argv)) as Argv<Config>\n const argv = y\n .usage(`\n🚀 XL1 Node CLI (${version})\n${XL1LogoColorizedAscii}\nRun various components of the XL1 ecosystem.\n\nUsage:\n$0 <command> [options]`)\n .parserConfiguration({\n 'dot-notation': true, // foo.bar → { foo: { bar } }\n 'parse-numbers': false, // Don't auto-parse numbers to allow strings like \"0x1\"\n 'populate--': true, // Populate -- with all options so we can detected user-supplied vs defaults\n })\n .env('XL1')\n .scriptName('xl1')\n .middleware((argv) => {\n try {\n // Parse the various config sources\n const parsedConfigFile = tryParseConfig() // Config file\n const parsedConfigArgs = argv // Command-line arguments & ENV VARs\n const parseResult = ConfigZod.safeParse(parsedConfigFile)\n if (!parseResult.success) {\n throw parseResult.error\n }\n // Deep merge with precedence\n // TODO: Would like precedence to be defaults < file < ENV < CLI Args\n // but there is currently no way to determine which are defaults vs\n // user-supplied CLI Args since we set the CLI args to the defaults\n // and receive a flattened object. We might need to manually invoke\n // the parser without the defaults to achieve this.\n // const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)\n const mergedConfig = deepMerge(parsedConfigArgs)\n const validatedMergedConfigResult = ConfigZod.safeParse(mergedConfig)\n if (!validatedMergedConfigResult.success) {\n throw validatedMergedConfigResult.error\n }\n const resolvedConfig = resolveConfig(validatedMergedConfigResult.data)\n // Validate the merged configuration\n const validatedConfigResult = ConfigZod.safeParse(resolvedConfig)\n if (!validatedConfigResult.success) {\n throw validatedConfigResult.error\n }\n configuration = validatedConfigResult.data\n } catch (err) {\n if (isZodError(err)) {\n console.error(`Zod error: ${err.message}`)\n } else {\n console.error(`Error parsing configuration: ${err}`)\n }\n console.error(`Stack: ${err instanceof Error ? err.stack : 'N/A'}`)\n throw new Error('Invalid configuration')\n }\n })\n .options(optionsFromGlobalZodRegistry())\n // .commandDir('./command/commands', opts) // Not yet supported for ESM\n .wrap(y.terminalWidth())\n .command('api', 'Run a XL1 API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('bridge', 'Run a XL1 Bridge Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Bridge Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runBridge({ ...context, config: configuration })\n })\n })\n .command('mempool', 'Run a XL1 Mempool Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Mempool Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runMempool({ ...context, config: configuration })\n })\n })\n .command('producer', 'Run a XL1 Producer Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Producer Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('reward-redemption-api', 'Run a XL1 Rewards Redemption API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Rewards Redemption API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runRewardRedemptionApi({ ...context, config: configuration })\n })\n })\n .command('$0', 'Run a full XL1 Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n if (configuration.mempool.enabled) {\n // Start Mempool but do not block\n runMempool({ ...context, config: configuration })\n // Wait for Mempool to be ready\n await waitForHostPort(configuration.mempool.host, configuration.mempool.port)\n }\n // Start API but do not block\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n // Wait for API to be ready\n await waitForHostPort(configuration.api.host, configuration.api.port)\n // Start Producer and block on it\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n .help()\n .alias('help', 'h')\n .version(version)\n .argv\n\n await argv\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-bridge'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunBridgeContext {\n config: Config\n logger?: Logger\n}\n\nexport function runBridge(context: RunBridgeContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-mempool'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunMempoolContext {\n config: Config\n logger: Logger\n}\n\nexport function runMempool(context: RunMempoolContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-reward-redemption'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunRewardRedemptionApiContext {\n config: Config\n logger?: Logger\n}\n\nexport function runRewardRedemptionApi(context: RunRewardRedemptionApiContext) {\n void getServer(context)\n}\n","/* eslint-disable @stylistic/max-len */\nexport const XL1LogoColorizedAscii = `\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;118;111;144m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;72;32;223m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m ╠╠\u001b[0m\u001b[38;2;103;85;170m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;79;121;152m╦\u001b[0m\u001b[38;2;82;121;151m╦\u001b[0m\u001b[38;2;112;125;136m_ \u001b[0m\u001b[38;2;88;59;196m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;73;34;221m▒ \u001b[0m\u001b[38;2;121;121;127m_\u001b[0m\u001b[38;2;100;101;128m╔\u001b[0m\u001b[38;2;93;94;127m╦\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;82;121;151m²\u001b[0m\u001b[38;2;44;116;170m╠\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;51;117;167mD\u001b[0m\u001b[38;2;80;121;152m╦\u001b[0m\u001b[38;2;111;125;136m_ \u001b[0m\u001b[38;2;67;23;232m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;120;121;128m_\u001b[0m\u001b[38;2;100;101;127m╔\u001b[0m\u001b[38;2;79;81;127mR\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;88;90;127m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;55;117;165m╚\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;44;116;171m▒▒\u001b[0m\u001b[38;2;50;116;167mD\u001b[0m\u001b[38;2;80;121;152m╦ \u001b[0m\u001b[38;2;106;90;165mj\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;89;61;194mH \u001b[0m\u001b[38;2;99;100;127m╔\u001b[0m\u001b[38;2;79;80;127mD\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒▒╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;83;121;150m²\u001b[0m\u001b[38;2;44;116;170m▒\u001b[0m\u001b[38;2;44;116;171m▒▒▒ \u001b[0m\u001b[38;2;76;38;217m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;74;76;128m╠\u001b[0m\u001b[38;2;71;73;128m▒▒▒\u001b[0m\u001b[38;2;89;90;128m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;90;118;148m\\`\u001b[0m\u001b[38;2;89;107;153m_\u001b[0m\u001b[38;2;93;97;154m,\u001b[0m\u001b[38;2;105;89;166m╓\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;95;72;183m╓\u001b[0m\u001b[38;2;106;96;152m_\u001b[0m\u001b[38;2;100;94;143m\\`\u001b[0m\u001b[38;2;101;100;133m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;122;118;137m_\u001b[0m\u001b[38;2;113;102;153m,\u001b[0m\u001b[38;2;108;94;161m╓\u001b[0m\u001b[38;2;104;86;169m╓\u001b[0m\u001b[38;2;98;77;178m╔\u001b[0m\u001b[38;2;93;67;188m╗\u001b[0m\u001b[38;2;88;59;196mφ\u001b[0m\u001b[38;2;83;51;204m@\u001b[0m\u001b[38;2;78;42;213mD\u001b[0m\u001b[38;2;72;32;223m▒\u001b[0m\u001b[38;2;68;24;231m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;71;30;225m▒\u001b[0m\u001b[38;2;77;40;215m▒\u001b[0m\u001b[38;2;82;49;206mK\u001b[0m\u001b[38;2;87;57;198mφ\u001b[0m\u001b[38;2;91;65;190m╗\u001b[0m\u001b[38;2;97;75;180m╦\u001b[0m\u001b[38;2;103;84;171m╖\u001b[0m\u001b[38;2;107;92;163m²\u001b[0m\u001b[38;2;112;101;154m_\u001b[0m\u001b[38;2;119;112;143m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;106;91;164m\\`\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;89;62;193m╙\u001b[0m\u001b[38;2;85;54;201m╙\u001b[0m\u001b[38;2;80;45;210m╚\u001b[0m\u001b[38;2;74;35;220m╝\u001b[0m\u001b[38;2;69;26;229m╠\u001b[0m\u001b[38;2;66;22;233m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;73;33;222m╝\u001b[0m\u001b[38;2;79;43;212m╩\u001b[0m\u001b[38;2;84;52;203m╜\u001b[0m\u001b[38;2;88;60;195m╙\u001b[0m\u001b[38;2;93;68;187m^\u001b[0m\u001b[38;2;100;80;175m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;113;84;152m\\`\u001b[0m\u001b[38;2;103;79;169m'\u001b[0m\u001b[38;2;95;72;183m\"\u001b[0m\u001b[38;2;87;57;198m╙\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;80;46;209m╜\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;102;77;175m^\u001b[0m\u001b[38;2;112;81;162m\\`\u001b[0m\u001b[38;2;115;92;155m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;145;116;107m,\u001b[0m\u001b[38;2;199;82;45m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒╠ \u001b[0m\u001b[38;2;70;28;227m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;189;49;97må\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;155;92;114m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;175;98;73m╔\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒▒▒\u001b[0m\u001b[38;2;197;83;47m╩ \u001b[0m\u001b[38;2;98;76;179m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;81;48;207mH \u001b[0m\u001b[38;2;188;51;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠╠\u001b[0m\u001b[38;2;183;57;100mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;146;116;106m,\u001b[0m\u001b[38;2;199;82;44m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;196;84;48m╩\u001b[0m\u001b[38;2;168;102;81m^ \u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;160;87;111m'\u001b[0m\u001b[38;2;187;52;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;156;91;113m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;198;83;46m╩\u001b[0m\u001b[38;2;194;85;50m╩\u001b[0m\u001b[38;2;167;102;82m^ \u001b[0m\u001b[38;2;81;46;209m╚\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠ \u001b[0m\u001b[38;2;159;88;112m'\u001b[0m\u001b[38;2;186;53;98m╚\u001b[0m\u001b[38;2;197;40;93m╩\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;110;97;158m'\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;94;69;186mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;68;25;230m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;108;93;162m²\u001b[0m\u001b[38;2;99;79;176m^\u001b[0m`\n","import type { Logger, LogLevelValue } from '@xylabs/sdk-js'\nimport {\n Base,\n ConsoleLogger, isDefined,\n LogLevel, SilentLogger,\n} from '@xylabs/sdk-js'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\nexport const initLogger = (config: Config): Logger => {\n let logger: Logger\n if (config.silent) {\n logger = new SilentLogger()\n } else {\n let level: LogLevelValue | undefined\n if (isDefined(config.logLevel)) {\n const parsed = LogLevel[config.logLevel.toLowerCase() as keyof typeof LogLevel]\n if (isDefined(parsed)) level = parsed\n }\n logger = new ConsoleLogger(level)\n }\n Base.defaultLogger = logger\n return logger\n}\n","import type { UsageMeta } from '@xyo-network/xl1-sdk'\nimport { isUsageMeta } from '@xyo-network/xl1-sdk'\nimport type { Options } from 'yargs'\nimport { globalRegistry } from 'zod'\n\nconst usageMetaToOptions = (meta: UsageMeta): Options => {\n return meta\n}\n\nexport const optionsFromGlobalZodRegistry = (): Record<string, Options> => {\n const opts: Record<string, Options> = {}\n for (const schema of Object.values(globalRegistry._map)) {\n if (isUsageMeta(schema)) {\n if (schema.hidden) continue // skip hidden options\n opts[schema.title] = usageMetaToOptions(schema)\n }\n }\n return opts\n}\n","import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { ConfigZod } from '@xyo-network/xl1-sdk'\nimport { cosmiconfigSync } from 'cosmiconfig'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport const tryParseConfig = () => {\n const explorer = cosmiconfigSync(\n configName,\n /* {\n searchPlaces: [\n 'package.json', // Looks under `xyo` key in package.json\n '.xyorc.json', // Supports common dotfile format\n 'xyo.config.json', // Supports custom-named config file\n ],\n loaders: {\n '.json': defaultLoaders['.json'],\n 'noExt': defaultLoaders['.json'],\n },\n }, */\n )\n const result = explorer.search()\n if (!isNull(result)) {\n const section = result?.config?.[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return ConfigZod.parse(section)\n }\n }\n return ConfigZod.parse({})\n}\n","import net from 'node:net'\n\nexport const waitForHostPort = (host: string, port: number): Promise<void> => {\n return new Promise((resolve) => {\n const tryConnect = () => {\n const socket = new net.Socket()\n\n socket\n .setTimeout(1000)\n .once('error', () => {\n socket.destroy()\n setTimeout(tryConnect, 500) // retry after 500ms\n })\n .once('timeout', () => {\n socket.destroy()\n setTimeout(tryConnect, 500)\n })\n .connect(port, host, () => {\n socket.end()\n resolve()\n })\n }\n\n tryConnect()\n })\n}\n","import { config } from 'dotenv'\n\nimport { runCLI } from './runCLI.ts'\n\nexport const start = async () => {\n config({ quiet: true })\n await runCLI()\n}\n"],"mappings":";;;;AACA,SAASA,aAAAA,YAAWC,iBAAiB;AACrC,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAE5B,SAASC,aAAAA,YAAWC,kBAAkB;AACtC,SAASC,SAASC,iBAAiB;AAEnC,OAAOC,WAAW;AAClB,SAASC,eAAe;;;ACTxB,SAASC,iBAAiB;AAQnB,SAASC,UAAUC,SAAyB;AACjD,OAAKC,UAAUD,OAAAA;AACjB;AAFgBD;;;ACRhB,SAASG,aAAAA,kBAAiB;AAQnB,SAASC,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QAAQ,MAAM,yCAAyC,MAAA;IAAO,GAAG,YAAA;AAChE,YAAMC,UAAU,MAAM7C,qBAAqBf,aAAAA;AAC3CkE,6BAAuB;QAAE,GAAGN;QAASvD,QAAQL;MAAc,CAAA;IAC7D,CAAA;EACJ,CAAA,EACC2D,QAAQ,MAAM,uBAAuB,MAAA;EAAO,GAAG,YAAA;AAC9C,UAAMC,UAAU,MAAM7C,qBAAqBf,aAAAA;AAC3C,QAAIA,cAAcmE,QAAQC,SAAS;AAEjCJ,iBAAW;QAAE,GAAGJ;QAASvD,QAAQL;MAAc,CAAA;AAE/C,YAAMqE,gBAAgBrE,cAAcmE,QAAQG,MAAMtE,cAAcmE,QAAQI,IAAI;IAC9E;AAEA,UAAMV,OAAO;MACX,GAAGD;MAASvD,QAAQL;MAAe8D,YAAY,CAAC;IAClD,CAAA;AAEA,UAAMO,gBAAgBrE,cAAcwE,IAAIF,MAAMtE,cAAcwE,IAAID,IAAI;AAEpE,UAAMN,YAAY;MAChB,GAAGL;MAASvD,QAAQL;MAAe8D,YAAY,CAAC;IAClD,CAAA;EACF,CAAA,EACCW,KAAI,EACJC,MAAM,QAAQ,GAAA,EACdzE,QAAQA,OAAAA,EACR8B;AAEH,QAAMA;AACR;AA3HsBJ;;;AStEtB,SAASgD,cAAc;AAIhB,IAAMC,QAAQ,mCAAA;AACnBC,SAAO;IAAEC,OAAO;EAAK,CAAA;AACrB,QAAMC,OAAAA;AACR,GAHqB;","names":["isDefined","toAddress","runApi","Orchestrator","runProducer","ConfigZod","isZodError","merge","deepMerge","yargs","hideBin","getServer","runBridge","context","getServer","getServer","runMempool","context","getServer","getServer","runRewardRedemptionApi","context","getServer","XL1LogoColorizedAscii","Base","ConsoleLogger","isDefined","LogLevel","SilentLogger","initLogger","config","logger","silent","SilentLogger","level","isDefined","logLevel","parsed","LogLevel","toLowerCase","ConsoleLogger","Base","defaultLogger","isUsageMeta","globalRegistry","usageMetaToOptions","meta","optionsFromGlobalZodRegistry","opts","schema","Object","values","globalRegistry","_map","isUsageMeta","hidden","title","isDefined","isNull","ConfigZod","cosmiconfigSync","configName","configSection","tryParseConfig","explorer","cosmiconfigSync","result","search","isNull","section","config","isDefined","ConfigZod","parse","net","waitForHostPort","host","port","Promise","resolve","tryConnect","socket","net","Socket","setTimeout","once","destroy","connect","end","configuration","version","isDefined","__VERSION__","resolveConfig","config","logger","console","defaultChainId","toAddress","resolved","structuredClone","chain","id","warn","getContextFromConfig","initLogger","orchestrator","Orchestrator","create","process","on","log","stop","exit","err","error","runCLI","y","yargs","hideBin","argv","usage","XL1LogoColorizedAscii","parserConfiguration","env","scriptName","middleware","parsedConfigFile","tryParseConfig","parsedConfigArgs","parseResult","ConfigZod","safeParse","success","mergedConfig","deepMerge","validatedMergedConfigResult","resolvedConfig","data","validatedConfigResult","isZodError","message","Error","stack","options","optionsFromGlobalZodRegistry","wrap","terminalWidth","command","context","runApi","singletons","runBridge","runMempool","runProducer","runRewardRedemptionApi","mempool","enabled","waitForHostPort","host","port","api","help","alias","config","start","config","quiet","runCLI"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCLI.d.ts","sourceRoot":"","sources":["../../src/runCLI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runCLI.d.ts","sourceRoot":"","sources":["../../src/runCLI.ts"],"names":[],"mappings":"AAsEA,wBAAsB,MAAM,kBA2H3B"}
|
|
@@ -2,5 +2,127 @@
|
|
|
2
2
|
* Attempts to parse the configuration from a file using cosmiconfig.
|
|
3
3
|
* @returns The parsed configuration object if found and valid, otherwise undefined.
|
|
4
4
|
*/
|
|
5
|
-
export declare const tryParseConfig: () =>
|
|
5
|
+
export declare const tryParseConfig: () => {
|
|
6
|
+
api: {
|
|
7
|
+
host: string;
|
|
8
|
+
initRewardsCache: boolean;
|
|
9
|
+
port: number;
|
|
10
|
+
mnemonic?: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
bridge: {
|
|
13
|
+
chainRpcApiUrl: string;
|
|
14
|
+
feeFixed: import("@xylabs/sdk-js").BrandedHex;
|
|
15
|
+
feeRateBasisPoints: number;
|
|
16
|
+
host: string;
|
|
17
|
+
maxBridgeAmount: import("@xylabs/sdk-js").BrandedHex;
|
|
18
|
+
minBridgeAmount: import("@xylabs/sdk-js").BrandedHex;
|
|
19
|
+
port: number;
|
|
20
|
+
redisHost: string;
|
|
21
|
+
redisPort: number;
|
|
22
|
+
remoteBridgeContractAddress: Lowercase<string> & {
|
|
23
|
+
readonly __hex: true;
|
|
24
|
+
} & {
|
|
25
|
+
readonly __address: true;
|
|
26
|
+
};
|
|
27
|
+
remoteChainId: import("@xylabs/sdk-js").BrandedHex;
|
|
28
|
+
remoteTokenAddress: import("@xylabs/sdk-js").BrandedHex;
|
|
29
|
+
remoteChainWalletPrivateKey: import("@xylabs/sdk-js").BrandedHex;
|
|
30
|
+
escrowAddress?: (Lowercase<string> & {
|
|
31
|
+
readonly __hex: true;
|
|
32
|
+
} & {
|
|
33
|
+
readonly __address: true;
|
|
34
|
+
}) | undefined;
|
|
35
|
+
feesAddress?: (Lowercase<string> & {
|
|
36
|
+
readonly __hex: true;
|
|
37
|
+
} & {
|
|
38
|
+
readonly __address: true;
|
|
39
|
+
}) | undefined;
|
|
40
|
+
mnemonic?: string | undefined;
|
|
41
|
+
xl1ChainId?: import("@xylabs/sdk-js").BrandedHex | undefined;
|
|
42
|
+
xl1TokenAddress?: import("@xylabs/sdk-js").BrandedHex | undefined;
|
|
43
|
+
};
|
|
44
|
+
chain: {
|
|
45
|
+
id?: import("@xylabs/sdk-js").BrandedHex | undefined;
|
|
46
|
+
genesisRewardAddress?: (Lowercase<string> & {
|
|
47
|
+
readonly __hex: true;
|
|
48
|
+
} & {
|
|
49
|
+
readonly __address: true;
|
|
50
|
+
}) | undefined;
|
|
51
|
+
};
|
|
52
|
+
evm: {
|
|
53
|
+
chainId?: string | undefined;
|
|
54
|
+
infura?: {
|
|
55
|
+
projectId?: string | undefined;
|
|
56
|
+
projectSecret?: string | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
jsonRpc?: {
|
|
59
|
+
url?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
};
|
|
62
|
+
mempool: {
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
host: string;
|
|
65
|
+
port: number;
|
|
66
|
+
mnemonic?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
producer: {
|
|
69
|
+
heartbeatInterval: number;
|
|
70
|
+
minStake: number;
|
|
71
|
+
port: number;
|
|
72
|
+
allowlist?: (Lowercase<string> & {
|
|
73
|
+
readonly __hex: true;
|
|
74
|
+
} & {
|
|
75
|
+
readonly __address: true;
|
|
76
|
+
})[] | undefined;
|
|
77
|
+
disableIntentRedeclaration?: boolean | undefined;
|
|
78
|
+
healthCheckPort?: number | undefined;
|
|
79
|
+
mnemonic?: string | undefined;
|
|
80
|
+
rewardAddress?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
rewardRedemptionApi: {
|
|
83
|
+
chainRpcApiUrl: string;
|
|
84
|
+
host: string;
|
|
85
|
+
port: number;
|
|
86
|
+
mnemonic?: string | undefined;
|
|
87
|
+
};
|
|
88
|
+
services: {
|
|
89
|
+
accountBalanceViewerEndpoint: string;
|
|
90
|
+
apiEndpoint: string;
|
|
91
|
+
};
|
|
92
|
+
storage: {
|
|
93
|
+
mongo?: {
|
|
94
|
+
connectionString?: string | undefined;
|
|
95
|
+
database?: string | undefined;
|
|
96
|
+
domain?: string | undefined;
|
|
97
|
+
password?: string | undefined;
|
|
98
|
+
username?: string | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
root?: string | undefined;
|
|
101
|
+
};
|
|
102
|
+
telemetry: {
|
|
103
|
+
metrics?: {
|
|
104
|
+
scrape: {
|
|
105
|
+
path: string;
|
|
106
|
+
port?: number | undefined;
|
|
107
|
+
};
|
|
108
|
+
} | undefined;
|
|
109
|
+
otel?: {
|
|
110
|
+
otlpEndpoint?: string | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
};
|
|
113
|
+
validation: {
|
|
114
|
+
allowedRewardRedeemers?: (Lowercase<string> & {
|
|
115
|
+
readonly __hex: true;
|
|
116
|
+
} & {
|
|
117
|
+
readonly __address: true;
|
|
118
|
+
})[] | undefined;
|
|
119
|
+
allowedRewardEscrowAccountSigners?: (Lowercase<string> & {
|
|
120
|
+
readonly __hex: true;
|
|
121
|
+
} & {
|
|
122
|
+
readonly __address: true;
|
|
123
|
+
})[] | undefined;
|
|
124
|
+
};
|
|
125
|
+
logLevel: "error" | "warn" | "info" | "log" | "debug" | "trace";
|
|
126
|
+
silent: boolean;
|
|
127
|
+
};
|
|
6
128
|
//# sourceMappingURL=tryParseConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryParseConfig.d.ts","sourceRoot":"","sources":["../../src/tryParseConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tryParseConfig.d.ts","sourceRoot":"","sources":["../../src/tryParseConfig.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuB1B,CAAA"}
|
package/dist/node/xl1.mjs
CHANGED
|
@@ -5,14 +5,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5
5
|
import { config } from "dotenv";
|
|
6
6
|
|
|
7
7
|
// src/runCLI.ts
|
|
8
|
-
import {
|
|
8
|
+
import { isDefined as isDefined3, toAddress } from "@xylabs/sdk-js";
|
|
9
9
|
import { runApi } from "@xyo-network/chain-api";
|
|
10
10
|
import { Orchestrator } from "@xyo-network/chain-orchestration";
|
|
11
11
|
import { runProducer } from "@xyo-network/chain-producer";
|
|
12
|
-
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
12
|
+
import { ConfigZod as ConfigZod2, isZodError } from "@xyo-network/xl1-sdk";
|
|
13
|
+
import { merge as deepMerge } from "ts-deepmerge";
|
|
13
14
|
import yargs from "yargs";
|
|
14
15
|
import { hideBin } from "yargs/helpers";
|
|
15
|
-
import { ZodError } from "zod";
|
|
16
16
|
|
|
17
17
|
// src/commands/bridge/runBridge.ts
|
|
18
18
|
import { getServer } from "@xyo-network/chain-bridge";
|
|
@@ -92,6 +92,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
92
92
|
|
|
93
93
|
// src/tryParseConfig.ts
|
|
94
94
|
import { isDefined as isDefined2, isNull } from "@xylabs/sdk-js";
|
|
95
|
+
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
95
96
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
96
97
|
var configName = "xyo";
|
|
97
98
|
var configSection = "xl1";
|
|
@@ -101,10 +102,10 @@ var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
|
101
102
|
if (!isNull(result)) {
|
|
102
103
|
const section = result?.config?.[configSection];
|
|
103
104
|
if (isDefined2(section) && typeof section === "object") {
|
|
104
|
-
return section;
|
|
105
|
+
return ConfigZod.parse(section);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
return {};
|
|
108
|
+
return ConfigZod.parse({});
|
|
108
109
|
}, "tryParseConfig");
|
|
109
110
|
|
|
110
111
|
// src/waitForHostPort.ts
|
|
@@ -130,7 +131,18 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
130
131
|
|
|
131
132
|
// src/runCLI.ts
|
|
132
133
|
var configuration;
|
|
133
|
-
var version = isDefined3("1.19.
|
|
134
|
+
var version = isDefined3("1.19.6") ? "1.19.6" : "unknown";
|
|
135
|
+
function resolveConfig(config2) {
|
|
136
|
+
const logger = console;
|
|
137
|
+
const defaultChainId = toAddress("1");
|
|
138
|
+
const resolved = structuredClone(config2);
|
|
139
|
+
if (!resolved.chain.id) {
|
|
140
|
+
logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`);
|
|
141
|
+
resolved.chain.id = defaultChainId;
|
|
142
|
+
}
|
|
143
|
+
return resolved;
|
|
144
|
+
}
|
|
145
|
+
__name(resolveConfig, "resolveConfig");
|
|
134
146
|
var getContextFromConfig = /* @__PURE__ */ __name(async (configuration2) => {
|
|
135
147
|
const logger = initLogger(configuration2);
|
|
136
148
|
const orchestrator = await Orchestrator.create({
|
|
@@ -170,12 +182,28 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
170
182
|
try {
|
|
171
183
|
const parsedConfigFile = tryParseConfig();
|
|
172
184
|
const parsedConfigArgs = argv2;
|
|
173
|
-
const
|
|
174
|
-
|
|
185
|
+
const parseResult = ConfigZod2.safeParse(parsedConfigFile);
|
|
186
|
+
if (!parseResult.success) {
|
|
187
|
+
throw parseResult.error;
|
|
188
|
+
}
|
|
189
|
+
const mergedConfig = deepMerge(parsedConfigArgs);
|
|
190
|
+
const validatedMergedConfigResult = ConfigZod2.safeParse(mergedConfig);
|
|
191
|
+
if (!validatedMergedConfigResult.success) {
|
|
192
|
+
throw validatedMergedConfigResult.error;
|
|
193
|
+
}
|
|
194
|
+
const resolvedConfig = resolveConfig(validatedMergedConfigResult.data);
|
|
195
|
+
const validatedConfigResult = ConfigZod2.safeParse(resolvedConfig);
|
|
196
|
+
if (!validatedConfigResult.success) {
|
|
197
|
+
throw validatedConfigResult.error;
|
|
198
|
+
}
|
|
199
|
+
configuration = validatedConfigResult.data;
|
|
175
200
|
} catch (err) {
|
|
176
|
-
if (err
|
|
177
|
-
console.error(
|
|
201
|
+
if (isZodError(err)) {
|
|
202
|
+
console.error(`Zod error: ${err.message}`);
|
|
203
|
+
} else {
|
|
204
|
+
console.error(`Error parsing configuration: ${err}`);
|
|
178
205
|
}
|
|
206
|
+
console.error(`Stack: ${err instanceof Error ? err.stack : "N/A"}`);
|
|
179
207
|
throw new Error("Invalid configuration");
|
|
180
208
|
}
|
|
181
209
|
}).options(optionsFromGlobalZodRegistry()).wrap(y.terminalWidth()).command("api", "Run a XL1 API Node", (yargs2) => {
|
package/dist/node/xl1.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/start.ts","../../src/runCLI.ts","../../src/commands/bridge/runBridge.ts","../../src/commands/mempool/runMempool.ts","../../src/commands/rewardRedemption/runRewardRedemptionApi.ts","../../src/images.ts","../../src/initLogger.ts","../../src/optionsFromGlobalZodRegistry.ts","../../src/tryParseConfig.ts","../../src/waitForHostPort.ts","../../src/xl1.ts"],"sourcesContent":["import { config } from 'dotenv'\n\nimport { runCLI } from './runCLI.ts'\n\nexport const start = async () => {\n config({ quiet: true })\n await runCLI()\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { deepMerge, isDefined } from '@xylabs/sdk-js'\nimport { runApi } from '@xyo-network/chain-api'\nimport { Orchestrator } from '@xyo-network/chain-orchestration'\nimport { runProducer } from '@xyo-network/chain-producer'\nimport { type Config, ConfigZod } from '@xyo-network/xl1-sdk'\nimport type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\nimport { ZodError } from 'zod'\n\nimport {\n runBridge, runMempool, runRewardRedemptionApi,\n} from './commands/index.ts'\nimport { XL1LogoColorizedAscii } from './images.ts'\nimport { initLogger } from './initLogger.ts'\nimport { optionsFromGlobalZodRegistry } from './optionsFromGlobalZodRegistry.ts'\nimport { tryParseConfig } from './tryParseConfig.ts'\nimport { waitForHostPort } from './waitForHostPort.ts'\n\n/** Version string injected by Rollup at build time. */\ndeclare const __VERSION__: string\n\ninterface RunCliContext {\n logger: Logger\n orchestrator: Orchestrator\n}\n\n/**\n * The configuration that will be used throughout the CLI.\n * This is materialized after parsing the command-line arguments,\n * environment variables, and defaults.\n */\nlet configuration: Config\n\nconst version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'\n\nconst getContextFromConfig = async (configuration: Config): Promise<RunCliContext> => {\n const logger = initLogger(configuration)\n const orchestrator = await Orchestrator.create({ logger })\n // Handle cancellation (Ctrl+C)\n process.on('SIGINT', () => {\n void (async () => {\n try {\n logger.log('\\nSIGINT received. Attempting graceful shutdown...')\n await orchestrator?.stop()\n logger.log('Orchestrator stopped, exiting now.')\n process.exit(0)\n } catch (err) {\n logger.error('Error stopping orchestrator:', err)\n process.exit(1)\n }\n })()\n })\n return { logger, orchestrator }\n}\n\n// Main entry point\nexport async function runCLI() {\n // Parse command-line arguments using Yargs\n const y = yargs(hideBin(process.argv)) as Argv<Config>\n const argv = y\n .usage(`\n🚀 XL1 Node CLI (${version})\n${XL1LogoColorizedAscii}\nRun various components of the XL1 ecosystem.\n\nUsage:\n$0 <command> [options]`)\n .parserConfiguration({\n 'dot-notation': true, // foo.bar → { foo: { bar } }\n 'parse-numbers': false, // Don't auto-parse numbers to allow strings like \"0x1\"\n 'populate--': true, // Populate -- with all options so we can detected user-supplied vs defaults\n })\n .env('XL1')\n .scriptName('xl1')\n .middleware((argv) => {\n try {\n // Parse the various config sources\n const parsedConfigFile = tryParseConfig() // Config file\n const parsedConfigArgs = argv // Command-line arguments & ENV VARs\n // Deep merge with precedence\n // TODO: Would like precedence to be defaults < file < ENV < CLI Args\n // but there is currently no way to determine which are defaults vs\n // user-supplied CLI Args since we set the CLI args to the defaults\n // and receive a flattened object. We might need to manually invoke\n // the parser without the defaults to achieve this.\n const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)\n // Validate the merged configuration\n configuration = ConfigZod.parse(mergedConfig)\n } catch (err) {\n if (err instanceof ZodError) {\n console.error(`${err.message}`)\n }\n throw new Error('Invalid configuration')\n }\n })\n .options(optionsFromGlobalZodRegistry())\n // .commandDir('./command/commands', opts) // Not yet supported for ESM\n .wrap(y.terminalWidth())\n .command('api', 'Run a XL1 API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('bridge', 'Run a XL1 Bridge Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Bridge Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runBridge({ ...context, config: configuration })\n })\n })\n .command('mempool', 'Run a XL1 Mempool Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Mempool Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runMempool({ ...context, config: configuration })\n })\n })\n .command('producer', 'Run a XL1 Producer Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Producer Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('reward-redemption-api', 'Run a XL1 Rewards Redemption API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Rewards Redemption API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runRewardRedemptionApi({ ...context, config: configuration })\n })\n })\n .command('$0', 'Run a full XL1 Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n if (configuration.mempool.enabled) {\n // Start Mempool but do not block\n runMempool({ ...context, config: configuration })\n // Wait for Mempool to be ready\n await waitForHostPort(configuration.mempool.host, configuration.mempool.port)\n }\n // Start API but do not block\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n // Wait for API to be ready\n await waitForHostPort(configuration.api.host, configuration.api.port)\n // Start Producer and block on it\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n .help()\n .alias('help', 'h')\n .version(version)\n .argv\n\n await argv\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-bridge'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunBridgeContext {\n config: Config\n logger?: Logger\n}\n\nexport function runBridge(context: RunBridgeContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-mempool'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunMempoolContext {\n config: Config\n logger: Logger\n}\n\nexport function runMempool(context: RunMempoolContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-reward-redemption'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunRewardRedemptionApiContext {\n config: Config\n logger?: Logger\n}\n\nexport function runRewardRedemptionApi(context: RunRewardRedemptionApiContext) {\n void getServer(context)\n}\n","/* eslint-disable @stylistic/max-len */\nexport const XL1LogoColorizedAscii = `\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;118;111;144m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;72;32;223m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m ╠╠\u001b[0m\u001b[38;2;103;85;170m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;79;121;152m╦\u001b[0m\u001b[38;2;82;121;151m╦\u001b[0m\u001b[38;2;112;125;136m_ \u001b[0m\u001b[38;2;88;59;196m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;73;34;221m▒ \u001b[0m\u001b[38;2;121;121;127m_\u001b[0m\u001b[38;2;100;101;128m╔\u001b[0m\u001b[38;2;93;94;127m╦\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;82;121;151m²\u001b[0m\u001b[38;2;44;116;170m╠\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;51;117;167mD\u001b[0m\u001b[38;2;80;121;152m╦\u001b[0m\u001b[38;2;111;125;136m_ \u001b[0m\u001b[38;2;67;23;232m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;120;121;128m_\u001b[0m\u001b[38;2;100;101;127m╔\u001b[0m\u001b[38;2;79;81;127mR\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;88;90;127m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;55;117;165m╚\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;44;116;171m▒▒\u001b[0m\u001b[38;2;50;116;167mD\u001b[0m\u001b[38;2;80;121;152m╦ \u001b[0m\u001b[38;2;106;90;165mj\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;89;61;194mH \u001b[0m\u001b[38;2;99;100;127m╔\u001b[0m\u001b[38;2;79;80;127mD\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒▒╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;83;121;150m²\u001b[0m\u001b[38;2;44;116;170m▒\u001b[0m\u001b[38;2;44;116;171m▒▒▒ \u001b[0m\u001b[38;2;76;38;217m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;74;76;128m╠\u001b[0m\u001b[38;2;71;73;128m▒▒▒\u001b[0m\u001b[38;2;89;90;128m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;90;118;148m\\`\u001b[0m\u001b[38;2;89;107;153m_\u001b[0m\u001b[38;2;93;97;154m,\u001b[0m\u001b[38;2;105;89;166m╓\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;95;72;183m╓\u001b[0m\u001b[38;2;106;96;152m_\u001b[0m\u001b[38;2;100;94;143m\\`\u001b[0m\u001b[38;2;101;100;133m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;122;118;137m_\u001b[0m\u001b[38;2;113;102;153m,\u001b[0m\u001b[38;2;108;94;161m╓\u001b[0m\u001b[38;2;104;86;169m╓\u001b[0m\u001b[38;2;98;77;178m╔\u001b[0m\u001b[38;2;93;67;188m╗\u001b[0m\u001b[38;2;88;59;196mφ\u001b[0m\u001b[38;2;83;51;204m@\u001b[0m\u001b[38;2;78;42;213mD\u001b[0m\u001b[38;2;72;32;223m▒\u001b[0m\u001b[38;2;68;24;231m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;71;30;225m▒\u001b[0m\u001b[38;2;77;40;215m▒\u001b[0m\u001b[38;2;82;49;206mK\u001b[0m\u001b[38;2;87;57;198mφ\u001b[0m\u001b[38;2;91;65;190m╗\u001b[0m\u001b[38;2;97;75;180m╦\u001b[0m\u001b[38;2;103;84;171m╖\u001b[0m\u001b[38;2;107;92;163m²\u001b[0m\u001b[38;2;112;101;154m_\u001b[0m\u001b[38;2;119;112;143m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;106;91;164m\\`\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;89;62;193m╙\u001b[0m\u001b[38;2;85;54;201m╙\u001b[0m\u001b[38;2;80;45;210m╚\u001b[0m\u001b[38;2;74;35;220m╝\u001b[0m\u001b[38;2;69;26;229m╠\u001b[0m\u001b[38;2;66;22;233m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;73;33;222m╝\u001b[0m\u001b[38;2;79;43;212m╩\u001b[0m\u001b[38;2;84;52;203m╜\u001b[0m\u001b[38;2;88;60;195m╙\u001b[0m\u001b[38;2;93;68;187m^\u001b[0m\u001b[38;2;100;80;175m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;113;84;152m\\`\u001b[0m\u001b[38;2;103;79;169m'\u001b[0m\u001b[38;2;95;72;183m\"\u001b[0m\u001b[38;2;87;57;198m╙\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;80;46;209m╜\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;102;77;175m^\u001b[0m\u001b[38;2;112;81;162m\\`\u001b[0m\u001b[38;2;115;92;155m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;145;116;107m,\u001b[0m\u001b[38;2;199;82;45m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒╠ \u001b[0m\u001b[38;2;70;28;227m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;189;49;97må\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;155;92;114m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;175;98;73m╔\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒▒▒\u001b[0m\u001b[38;2;197;83;47m╩ \u001b[0m\u001b[38;2;98;76;179m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;81;48;207mH \u001b[0m\u001b[38;2;188;51;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠╠\u001b[0m\u001b[38;2;183;57;100mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;146;116;106m,\u001b[0m\u001b[38;2;199;82;44m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;196;84;48m╩\u001b[0m\u001b[38;2;168;102;81m^ \u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;160;87;111m'\u001b[0m\u001b[38;2;187;52;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;156;91;113m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;198;83;46m╩\u001b[0m\u001b[38;2;194;85;50m╩\u001b[0m\u001b[38;2;167;102;82m^ \u001b[0m\u001b[38;2;81;46;209m╚\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠ \u001b[0m\u001b[38;2;159;88;112m'\u001b[0m\u001b[38;2;186;53;98m╚\u001b[0m\u001b[38;2;197;40;93m╩\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;110;97;158m'\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;94;69;186mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;68;25;230m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;108;93;162m²\u001b[0m\u001b[38;2;99;79;176m^\u001b[0m`\n","import type { Logger, LogLevelValue } from '@xylabs/sdk-js'\nimport {\n Base,\n ConsoleLogger, isDefined,\n LogLevel, SilentLogger,\n} from '@xylabs/sdk-js'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\nexport const initLogger = (config: Config): Logger => {\n let logger: Logger\n if (config.silent) {\n logger = new SilentLogger()\n } else {\n let level: LogLevelValue | undefined\n if (isDefined(config.logLevel)) {\n const parsed = LogLevel[config.logLevel.toLowerCase() as keyof typeof LogLevel]\n if (isDefined(parsed)) level = parsed\n }\n logger = new ConsoleLogger(level)\n }\n Base.defaultLogger = logger\n return logger\n}\n","import type { UsageMeta } from '@xyo-network/xl1-sdk'\nimport { isUsageMeta } from '@xyo-network/xl1-sdk'\nimport type { Options } from 'yargs'\nimport { globalRegistry } from 'zod'\n\nconst usageMetaToOptions = (meta: UsageMeta): Options => {\n return meta\n}\n\nexport const optionsFromGlobalZodRegistry = (): Record<string, Options> => {\n const opts: Record<string, Options> = {}\n for (const schema of Object.values(globalRegistry._map)) {\n if (isUsageMeta(schema)) {\n if (schema.hidden) continue // skip hidden options\n opts[schema.title] = usageMetaToOptions(schema)\n }\n }\n return opts\n}\n","import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { cosmiconfigSync } from 'cosmiconfig'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport const tryParseConfig = (): Record<string, unknown> => {\n const explorer = cosmiconfigSync(\n configName,\n /* {\n searchPlaces: [\n 'package.json', // Looks under `xyo` key in package.json\n '.xyorc.json', // Supports common dotfile format\n 'xyo.config.json', // Supports custom-named config file\n ],\n loaders: {\n '.json': defaultLoaders['.json'],\n 'noExt': defaultLoaders['.json'],\n },\n }, */\n )\n const result = explorer.search()\n if (!isNull(result)) {\n const section = result?.config?.[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return section\n }\n }\n return {}\n}\n","import net from 'node:net'\n\nexport const waitForHostPort = (host: string, port: number): Promise<void> => {\n return new Promise((resolve) => {\n const tryConnect = () => {\n const socket = new net.Socket()\n\n socket\n .setTimeout(1000)\n .once('error', () => {\n socket.destroy()\n setTimeout(tryConnect, 500) // retry after 500ms\n })\n .once('timeout', () => {\n socket.destroy()\n setTimeout(tryConnect, 500)\n })\n .connect(port, host, () => {\n socket.end()\n resolve()\n })\n }\n\n tryConnect()\n })\n}\n","import { start } from './start.ts'\n\nstart().catch((err) => {\n // If we're in development mode, log the stack trace to the console\n if (process.env.NODE_ENV === 'development') console.error('An error occurred during startup:', err)\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1)\n})\n"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACCvB,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AY,CAAC;IAClD,CAAA;AAEA,UAAMO,gBAAgBtD,cAAcyD,IAAIF,MAAMvD,cAAcyD,IAAID,IAAI;AAEpE,UAAMN,YAAY;MAChB,GAAGN;MAASE,QAAQ9C;MAAe+C,YAAY,CAAC;IAClD,CAAA;EACF,CAAA,EACCW,KAAI,EACJC,MAAM,QAAQ,GAAA,EACd1D,QAAQA,OAAAA,EACRoB;AAEH,QAAMA;AACR;AA1GsBJ;;;ADtDf,IAAM2C,QAAQ,mCAAA;AACnBC,SAAO;IAAEC,OAAO;EAAK,CAAA;AACrB,QAAMC,OAAAA;AACR,GAHqB;;;AUFrBC,MAAAA,EAAQC,MAAM,CAACC,QAAAA;AAEb,MAAIC,QAAQC,IAAIC,aAAa,cAAeC,SAAQC,MAAM,qCAAqCL,GAAAA;AAE/FC,UAAQK,KAAK,CAAA;AACf,CAAA;","names":["config","deepMerge","isDefined","runApi","Orchestrator","runProducer","ConfigZod","yargs","hideBin","ZodError","getServer","runBridge","context","getServer","getServer","runMempool","context","getServer","getServer","runRewardRedemptionApi","context","getServer","XL1LogoColorizedAscii","Base","ConsoleLogger","isDefined","LogLevel","SilentLogger","initLogger","config","logger","silent","SilentLogger","level","isDefined","logLevel","parsed","LogLevel","toLowerCase","ConsoleLogger","Base","defaultLogger","isUsageMeta","globalRegistry","usageMetaToOptions","meta","optionsFromGlobalZodRegistry","opts","schema","Object","values","globalRegistry","_map","isUsageMeta","hidden","title","isDefined","isNull","cosmiconfigSync","configName","configSection","tryParseConfig","explorer","cosmiconfigSync","result","search","isNull","section","config","isDefined","net","waitForHostPort","host","port","Promise","resolve","tryConnect","socket","net","Socket","setTimeout","once","destroy","connect","end","configuration","version","isDefined","__VERSION__","getContextFromConfig","logger","initLogger","orchestrator","Orchestrator","create","process","on","log","stop","exit","err","error","runCLI","y","yargs","hideBin","argv","usage","XL1LogoColorizedAscii","parserConfiguration","env","scriptName","middleware","parsedConfigFile","tryParseConfig","parsedConfigArgs","mergedConfig","deepMerge","ConfigZod","parse","ZodError","console","message","Error","options","optionsFromGlobalZodRegistry","wrap","terminalWidth","command","context","runApi","config","singletons","runBridge","runMempool","runProducer","runRewardRedemptionApi","mempool","enabled","waitForHostPort","host","port","api","help","alias","start","config","quiet","runCLI","start","catch","err","process","env","NODE_ENV","console","error","exit"]}
|
|
1
|
+
{"version":3,"sources":["../../src/start.ts","../../src/runCLI.ts","../../src/commands/bridge/runBridge.ts","../../src/commands/mempool/runMempool.ts","../../src/commands/rewardRedemption/runRewardRedemptionApi.ts","../../src/images.ts","../../src/initLogger.ts","../../src/optionsFromGlobalZodRegistry.ts","../../src/tryParseConfig.ts","../../src/waitForHostPort.ts","../../src/xl1.ts"],"sourcesContent":["import { config } from 'dotenv'\n\nimport { runCLI } from './runCLI.ts'\n\nexport const start = async () => {\n config({ quiet: true })\n await runCLI()\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { isDefined, toAddress } from '@xylabs/sdk-js'\nimport { runApi } from '@xyo-network/chain-api'\nimport { Orchestrator } from '@xyo-network/chain-orchestration'\nimport { runProducer } from '@xyo-network/chain-producer'\nimport type { Config } from '@xyo-network/xl1-sdk'\nimport { ConfigZod, isZodError } from '@xyo-network/xl1-sdk'\nimport { merge as deepMerge } from 'ts-deepmerge'\nimport type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\nimport {\n runBridge, runMempool, runRewardRedemptionApi,\n} from './commands/index.ts'\nimport { XL1LogoColorizedAscii } from './images.ts'\nimport { initLogger } from './initLogger.ts'\nimport { optionsFromGlobalZodRegistry } from './optionsFromGlobalZodRegistry.ts'\nimport { tryParseConfig } from './tryParseConfig.ts'\nimport { waitForHostPort } from './waitForHostPort.ts'\n\n/** Version string injected by Rollup at build time. */\ndeclare const __VERSION__: string\n\ninterface RunCliContext {\n logger: Logger\n orchestrator: Orchestrator\n}\n\n/**\n * The configuration that will be used throughout the CLI.\n * This is materialized after parsing the command-line arguments,\n * environment variables, and defaults.\n */\nlet configuration: Config\n\nconst version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'\n\nfunction resolveConfig(config: Config): Config {\n const logger = console\n const defaultChainId = toAddress('1')\n const resolved = structuredClone(config)\n if (!resolved.chain.id) {\n logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`)\n resolved.chain.id = defaultChainId\n }\n return resolved\n}\n\nconst getContextFromConfig = async (configuration: Config): Promise<RunCliContext> => {\n const logger = initLogger(configuration)\n const orchestrator = await Orchestrator.create({ logger })\n // Handle cancellation (Ctrl+C)\n process.on('SIGINT', () => {\n void (async () => {\n try {\n logger.log('\\nSIGINT received. Attempting graceful shutdown...')\n await orchestrator?.stop()\n logger.log('Orchestrator stopped, exiting now.')\n process.exit(0)\n } catch (err) {\n logger.error('Error stopping orchestrator:', err)\n process.exit(1)\n }\n })()\n })\n return { logger, orchestrator }\n}\n\n// Main entry point\nexport async function runCLI() {\n // Parse command-line arguments using Yargs\n const y = yargs(hideBin(process.argv)) as Argv<Config>\n const argv = y\n .usage(`\n🚀 XL1 Node CLI (${version})\n${XL1LogoColorizedAscii}\nRun various components of the XL1 ecosystem.\n\nUsage:\n$0 <command> [options]`)\n .parserConfiguration({\n 'dot-notation': true, // foo.bar → { foo: { bar } }\n 'parse-numbers': false, // Don't auto-parse numbers to allow strings like \"0x1\"\n 'populate--': true, // Populate -- with all options so we can detected user-supplied vs defaults\n })\n .env('XL1')\n .scriptName('xl1')\n .middleware((argv) => {\n try {\n // Parse the various config sources\n const parsedConfigFile = tryParseConfig() // Config file\n const parsedConfigArgs = argv // Command-line arguments & ENV VARs\n const parseResult = ConfigZod.safeParse(parsedConfigFile)\n if (!parseResult.success) {\n throw parseResult.error\n }\n // Deep merge with precedence\n // TODO: Would like precedence to be defaults < file < ENV < CLI Args\n // but there is currently no way to determine which are defaults vs\n // user-supplied CLI Args since we set the CLI args to the defaults\n // and receive a flattened object. We might need to manually invoke\n // the parser without the defaults to achieve this.\n // const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)\n const mergedConfig = deepMerge(parsedConfigArgs)\n const validatedMergedConfigResult = ConfigZod.safeParse(mergedConfig)\n if (!validatedMergedConfigResult.success) {\n throw validatedMergedConfigResult.error\n }\n const resolvedConfig = resolveConfig(validatedMergedConfigResult.data)\n // Validate the merged configuration\n const validatedConfigResult = ConfigZod.safeParse(resolvedConfig)\n if (!validatedConfigResult.success) {\n throw validatedConfigResult.error\n }\n configuration = validatedConfigResult.data\n } catch (err) {\n if (isZodError(err)) {\n console.error(`Zod error: ${err.message}`)\n } else {\n console.error(`Error parsing configuration: ${err}`)\n }\n console.error(`Stack: ${err instanceof Error ? err.stack : 'N/A'}`)\n throw new Error('Invalid configuration')\n }\n })\n .options(optionsFromGlobalZodRegistry())\n // .commandDir('./command/commands', opts) // Not yet supported for ESM\n .wrap(y.terminalWidth())\n .command('api', 'Run a XL1 API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('bridge', 'Run a XL1 Bridge Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Bridge Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runBridge({ ...context, config: configuration })\n })\n })\n .command('mempool', 'Run a XL1 Mempool Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Mempool Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runMempool({ ...context, config: configuration })\n })\n })\n .command('producer', 'Run a XL1 Producer Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Producer Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n })\n .command('reward-redemption-api', 'Run a XL1 Rewards Redemption API Node', (yargs) => {\n return yargs\n .command('$0', 'Run a XL1 Rewards Redemption API Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n runRewardRedemptionApi({ ...context, config: configuration })\n })\n })\n .command('$0', 'Run a full XL1 Node', () => {}, async () => {\n const context = await getContextFromConfig(configuration)\n if (configuration.mempool.enabled) {\n // Start Mempool but do not block\n runMempool({ ...context, config: configuration })\n // Wait for Mempool to be ready\n await waitForHostPort(configuration.mempool.host, configuration.mempool.port)\n }\n // Start API but do not block\n await runApi({\n ...context, config: configuration, singletons: {},\n })\n // Wait for API to be ready\n await waitForHostPort(configuration.api.host, configuration.api.port)\n // Start Producer and block on it\n await runProducer({\n ...context, config: configuration, singletons: {},\n })\n })\n .help()\n .alias('help', 'h')\n .version(version)\n .argv\n\n await argv\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-bridge'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunBridgeContext {\n config: Config\n logger?: Logger\n}\n\nexport function runBridge(context: RunBridgeContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-mempool'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunMempoolContext {\n config: Config\n logger: Logger\n}\n\nexport function runMempool(context: RunMempoolContext) {\n void getServer(context)\n}\n","import type { Logger } from '@xylabs/sdk-js'\nimport { getServer } from '@xyo-network/chain-reward-redemption'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\ninterface RunRewardRedemptionApiContext {\n config: Config\n logger?: Logger\n}\n\nexport function runRewardRedemptionApi(context: RunRewardRedemptionApiContext) {\n void getServer(context)\n}\n","/* eslint-disable @stylistic/max-len */\nexport const XL1LogoColorizedAscii = `\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;118;111;144m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;72;32;223m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m ╠╠\u001b[0m\u001b[38;2;103;85;170m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;79;121;152m╦\u001b[0m\u001b[38;2;82;121;151m╦\u001b[0m\u001b[38;2;112;125;136m_ \u001b[0m\u001b[38;2;88;59;196m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;73;34;221m▒ \u001b[0m\u001b[38;2;121;121;127m_\u001b[0m\u001b[38;2;100;101;128m╔\u001b[0m\u001b[38;2;93;94;127m╦\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;82;121;151m²\u001b[0m\u001b[38;2;44;116;170m╠\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;51;117;167mD\u001b[0m\u001b[38;2;80;121;152m╦\u001b[0m\u001b[38;2;111;125;136m_ \u001b[0m\u001b[38;2;67;23;232m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;120;121;128m_\u001b[0m\u001b[38;2;100;101;127m╔\u001b[0m\u001b[38;2;79;81;127mR\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;88;90;127m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;55;117;165m╚\u001b[0m\u001b[38;2;44;116;171m▒\u001b[0m\u001b[38;2;44;116;171m▒▒\u001b[0m\u001b[38;2;50;116;167mD\u001b[0m\u001b[38;2;80;121;152m╦ \u001b[0m\u001b[38;2;106;90;165mj\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;89;61;194mH \u001b[0m\u001b[38;2;99;100;127m╔\u001b[0m\u001b[38;2;79;80;127mD\u001b[0m\u001b[38;2;71;73;128m▒\u001b[0m\u001b[38;2;71;73;128m▒▒╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;83;121;150m²\u001b[0m\u001b[38;2;44;116;170m▒\u001b[0m\u001b[38;2;44;116;171m▒▒▒ \u001b[0m\u001b[38;2;76;38;217m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;74;76;128m╠\u001b[0m\u001b[38;2;71;73;128m▒▒▒\u001b[0m\u001b[38;2;89;90;128m╙\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;90;118;148m\\`\u001b[0m\u001b[38;2;89;107;153m_\u001b[0m\u001b[38;2;93;97;154m,\u001b[0m\u001b[38;2;105;89;166m╓\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;95;72;183m╓\u001b[0m\u001b[38;2;106;96;152m_\u001b[0m\u001b[38;2;100;94;143m\\`\u001b[0m\u001b[38;2;101;100;133m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;122;118;137m_\u001b[0m\u001b[38;2;113;102;153m,\u001b[0m\u001b[38;2;108;94;161m╓\u001b[0m\u001b[38;2;104;86;169m╓\u001b[0m\u001b[38;2;98;77;178m╔\u001b[0m\u001b[38;2;93;67;188m╗\u001b[0m\u001b[38;2;88;59;196mφ\u001b[0m\u001b[38;2;83;51;204m@\u001b[0m\u001b[38;2;78;42;213mD\u001b[0m\u001b[38;2;72;32;223m▒\u001b[0m\u001b[38;2;68;24;231m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;71;30;225m▒\u001b[0m\u001b[38;2;77;40;215m▒\u001b[0m\u001b[38;2;82;49;206mK\u001b[0m\u001b[38;2;87;57;198mφ\u001b[0m\u001b[38;2;91;65;190m╗\u001b[0m\u001b[38;2;97;75;180m╦\u001b[0m\u001b[38;2;103;84;171m╖\u001b[0m\u001b[38;2;107;92;163m²\u001b[0m\u001b[38;2;112;101;154m_\u001b[0m\u001b[38;2;119;112;143m_\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;106;91;164m\\`\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;89;62;193m╙\u001b[0m\u001b[38;2;85;54;201m╙\u001b[0m\u001b[38;2;80;45;210m╚\u001b[0m\u001b[38;2;74;35;220m╝\u001b[0m\u001b[38;2;69;26;229m╠\u001b[0m\u001b[38;2;66;22;233m╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠\u001b[0m\u001b[38;2;73;33;222m╝\u001b[0m\u001b[38;2;79;43;212m╩\u001b[0m\u001b[38;2;84;52;203m╜\u001b[0m\u001b[38;2;88;60;195m╙\u001b[0m\u001b[38;2;93;68;187m^\u001b[0m\u001b[38;2;100;80;175m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;113;84;152m\\`\u001b[0m\u001b[38;2;103;79;169m'\u001b[0m\u001b[38;2;95;72;183m\"\u001b[0m\u001b[38;2;87;57;198m╙\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠╠\u001b[0m\u001b[38;2;80;46;209m╜\u001b[0m\u001b[38;2;94;70;185m^\u001b[0m\u001b[38;2;102;77;175m^\u001b[0m\u001b[38;2;112;81;162m\\`\u001b[0m\u001b[38;2;115;92;155m\\`\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;145;116;107m,\u001b[0m\u001b[38;2;199;82;45m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒╠ \u001b[0m\u001b[38;2;70;28;227m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠╠ \u001b[0m\u001b[38;2;189;49;97må\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;155;92;114m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;175;98;73m╔\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒▒▒\u001b[0m\u001b[38;2;197;83;47m╩ \u001b[0m\u001b[38;2;98;76;179m[\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠\u001b[0m\u001b[38;2;81;48;207mH \u001b[0m\u001b[38;2;188;51;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠╠\u001b[0m\u001b[38;2;183;57;100mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;146;116;106m,\u001b[0m\u001b[38;2;199;82;44m╠\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;207;77;35m▒\u001b[0m\u001b[38;2;196;84;48m╩\u001b[0m\u001b[38;2;168;102;81m^ \u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠╠ \u001b[0m\u001b[38;2;160;87;111m'\u001b[0m\u001b[38;2;187;52;98m╚\u001b[0m\u001b[38;2;203;32;90m╠\u001b[0m\u001b[38;2;203;32;90m╠╠\u001b[0m\u001b[38;2;156;91;113m,\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;198;83;46m╩\u001b[0m\u001b[38;2;194;85;50m╩\u001b[0m\u001b[38;2;167;102;82m^ \u001b[0m\u001b[38;2;81;46;209m╚\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠╠ \u001b[0m\u001b[38;2;159;88;112m'\u001b[0m\u001b[38;2;186;53;98m╚\u001b[0m\u001b[38;2;197;40;93m╩\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;110;97;158m'\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\u001b[38;2;94;69;186mH\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;68;25;230m╠\u001b[0m\u001b[38;2;66;21;234m╠\u001b[0m\n\u001b[38;2;128;128;128m \u001b[0m\u001b[38;2;108;93;162m²\u001b[0m\u001b[38;2;99;79;176m^\u001b[0m`\n","import type { Logger, LogLevelValue } from '@xylabs/sdk-js'\nimport {\n Base,\n ConsoleLogger, isDefined,\n LogLevel, SilentLogger,\n} from '@xylabs/sdk-js'\nimport type { Config } from '@xyo-network/xl1-sdk'\n\nexport const initLogger = (config: Config): Logger => {\n let logger: Logger\n if (config.silent) {\n logger = new SilentLogger()\n } else {\n let level: LogLevelValue | undefined\n if (isDefined(config.logLevel)) {\n const parsed = LogLevel[config.logLevel.toLowerCase() as keyof typeof LogLevel]\n if (isDefined(parsed)) level = parsed\n }\n logger = new ConsoleLogger(level)\n }\n Base.defaultLogger = logger\n return logger\n}\n","import type { UsageMeta } from '@xyo-network/xl1-sdk'\nimport { isUsageMeta } from '@xyo-network/xl1-sdk'\nimport type { Options } from 'yargs'\nimport { globalRegistry } from 'zod'\n\nconst usageMetaToOptions = (meta: UsageMeta): Options => {\n return meta\n}\n\nexport const optionsFromGlobalZodRegistry = (): Record<string, Options> => {\n const opts: Record<string, Options> = {}\n for (const schema of Object.values(globalRegistry._map)) {\n if (isUsageMeta(schema)) {\n if (schema.hidden) continue // skip hidden options\n opts[schema.title] = usageMetaToOptions(schema)\n }\n }\n return opts\n}\n","import { isDefined, isNull } from '@xylabs/sdk-js'\nimport { ConfigZod } from '@xyo-network/xl1-sdk'\nimport { cosmiconfigSync } from 'cosmiconfig'\n\n/**\n * The name of the configuration file to search for.\n */\nconst configName = 'xyo'\n\n/**\n * The name of the section within the configuration file to parse.\n */\nconst configSection = 'xl1' // Default section in the config file\n\n/**\n * Attempts to parse the configuration from a file using cosmiconfig.\n * @returns The parsed configuration object if found and valid, otherwise undefined.\n */\nexport const tryParseConfig = () => {\n const explorer = cosmiconfigSync(\n configName,\n /* {\n searchPlaces: [\n 'package.json', // Looks under `xyo` key in package.json\n '.xyorc.json', // Supports common dotfile format\n 'xyo.config.json', // Supports custom-named config file\n ],\n loaders: {\n '.json': defaultLoaders['.json'],\n 'noExt': defaultLoaders['.json'],\n },\n }, */\n )\n const result = explorer.search()\n if (!isNull(result)) {\n const section = result?.config?.[configSection]\n if (isDefined(section) && typeof section === 'object') {\n return ConfigZod.parse(section)\n }\n }\n return ConfigZod.parse({})\n}\n","import net from 'node:net'\n\nexport const waitForHostPort = (host: string, port: number): Promise<void> => {\n return new Promise((resolve) => {\n const tryConnect = () => {\n const socket = new net.Socket()\n\n socket\n .setTimeout(1000)\n .once('error', () => {\n socket.destroy()\n setTimeout(tryConnect, 500) // retry after 500ms\n })\n .once('timeout', () => {\n socket.destroy()\n setTimeout(tryConnect, 500)\n })\n .connect(port, host, () => {\n socket.end()\n resolve()\n })\n }\n\n tryConnect()\n })\n}\n","import { start } from './start.ts'\n\nstart().catch((err) => {\n // If we're in development mode, log the stack trace to the console\n if (process.env.NODE_ENV === 'development') console.error('An error occurred during startup:', err)\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1)\n})\n"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACCvB,SAASC,aAAAA,YAAWC,iBAAiB;AACrC,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAE5B,SAASC,aAAAA,YAAWC,kBAAkB;AACtC,SAASC,SAASC,iBAAiB;AAEnC,OAAOC,WAAW;AAClB,SAASC,eAAe;;;ACTxB,SAASC,iBAAiB;AAQnB,SAASC,UAAUC,SAAyB;AACjD,OAAKC,UAAUD,OAAAA;AACjB;AAFgBD;;;ACRhB,SAASG,aAAAA,kBAAiB;AAQnB,SAASC,WAAWC,SAA0B;AACnD,OAAKC,WAAUD,OAAAA;AACjB;AAFgBD;;;ACRhB,SAASG,aAAAA,kBAAiB;AAQnB,SAASC,uBAAuBC,SAAsC;AAC3E,OAAKC,WAAUD,OAAAA;AACjB;AAFgBD;;;ACRT,IAAMG,wBAAwB;;;;;;;;;;;;;;;;;;;;AC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AO,GAAG,YAAA;AAC9C,UAAMC,UAAU,MAAM7C,qBAAqBf,aAAAA;AAC3C,QAAIA,cAAcmE,QAAQC,SAAS;AAEjCJ,iBAAW;QAAE,GAAGJ;QAASvD,QAAQL;MAAc,CAAA;AAE/C,YAAMqE,gBAAgBrE,cAAcmE,QAAQG,MAAMtE,cAAcmE,QAAQI,IAAI;IAC9E;AAEA,UAAMV,OAAO;MACX,GAAGD;MAASvD,QAAQL;MAAe8D,YAAY,CAAC;IAClD,CAAA;AAEA,UAAMO,gBAAgBrE,cAAcwE,IAAIF,MAAMtE,cAAcwE,IAAID,IAAI;AAEpE,UAAMN,YAAY;MAChB,GAAGL;MAASvD,QAAQL;MAAe8D,YAAY,CAAC;IAClD,CAAA;EACF,CAAA,EACCW,KAAI,EACJC,MAAM,QAAQ,GAAA,EACdzE,QAAQA,OAAAA,EACR8B;AAEH,QAAMA;AACR;AA3HsBJ;;;ADlEf,IAAMgD,QAAQ,mCAAA;AACnBC,SAAO;IAAEC,OAAO;EAAK,CAAA;AACrB,QAAMC,OAAAA;AACR,GAHqB;;;AUFrBC,MAAAA,EAAQC,MAAM,CAACC,QAAAA;AAEb,MAAIC,QAAQC,IAAIC,aAAa,cAAeC,SAAQC,MAAM,qCAAqCL,GAAAA;AAE/FC,UAAQK,KAAK,CAAA;AACf,CAAA;","names":["config","isDefined","toAddress","runApi","Orchestrator","runProducer","ConfigZod","isZodError","merge","deepMerge","yargs","hideBin","getServer","runBridge","context","getServer","getServer","runMempool","context","getServer","getServer","runRewardRedemptionApi","context","getServer","XL1LogoColorizedAscii","Base","ConsoleLogger","isDefined","LogLevel","SilentLogger","initLogger","config","logger","silent","SilentLogger","level","isDefined","logLevel","parsed","LogLevel","toLowerCase","ConsoleLogger","Base","defaultLogger","isUsageMeta","globalRegistry","usageMetaToOptions","meta","optionsFromGlobalZodRegistry","opts","schema","Object","values","globalRegistry","_map","isUsageMeta","hidden","title","isDefined","isNull","ConfigZod","cosmiconfigSync","configName","configSection","tryParseConfig","explorer","cosmiconfigSync","result","search","isNull","section","config","isDefined","ConfigZod","parse","net","waitForHostPort","host","port","Promise","resolve","tryConnect","socket","net","Socket","setTimeout","once","destroy","connect","end","configuration","version","isDefined","__VERSION__","resolveConfig","config","logger","console","defaultChainId","toAddress","resolved","structuredClone","chain","id","warn","getContextFromConfig","initLogger","orchestrator","Orchestrator","create","process","on","log","stop","exit","err","error","runCLI","y","yargs","hideBin","argv","usage","XL1LogoColorizedAscii","parserConfiguration","env","scriptName","middleware","parsedConfigFile","tryParseConfig","parsedConfigArgs","parseResult","ConfigZod","safeParse","success","mergedConfig","deepMerge","validatedMergedConfigResult","resolvedConfig","data","validatedConfigResult","isZodError","message","Error","stack","options","optionsFromGlobalZodRegistry","wrap","terminalWidth","command","context","runApi","singletons","runBridge","runMempool","runProducer","runRewardRedemptionApi","mempool","enabled","waitForHostPort","host","port","api","help","alias","start","config","quiet","runCLI","start","catch","err","process","env","NODE_ENV","console","error","exit"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xl1-cli-lib",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.7",
|
|
4
4
|
"description": "XYO Layer One CLI Library",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -44,15 +44,16 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@xylabs/sdk-js": "~5.0.65",
|
|
47
|
-
"@xyo-network/chain-api": "~1.19.
|
|
48
|
-
"@xyo-network/chain-bridge": "~1.19.
|
|
49
|
-
"@xyo-network/chain-mempool": "~1.19.
|
|
50
|
-
"@xyo-network/chain-orchestration": "~1.19.
|
|
51
|
-
"@xyo-network/chain-producer": "~1.19.
|
|
52
|
-
"@xyo-network/chain-reward-redemption": "~1.19.
|
|
53
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
47
|
+
"@xyo-network/chain-api": "~1.19.7",
|
|
48
|
+
"@xyo-network/chain-bridge": "~1.19.7",
|
|
49
|
+
"@xyo-network/chain-mempool": "~1.19.7",
|
|
50
|
+
"@xyo-network/chain-orchestration": "~1.19.7",
|
|
51
|
+
"@xyo-network/chain-producer": "~1.19.7",
|
|
52
|
+
"@xyo-network/chain-reward-redemption": "~1.19.7",
|
|
53
|
+
"@xyo-network/xl1-sdk": "~1.22.30",
|
|
54
54
|
"cosmiconfig": "~9.0.0",
|
|
55
|
-
"dotenv": "~17.2.
|
|
55
|
+
"dotenv": "~17.2.4",
|
|
56
|
+
"ts-deepmerge": "^7.0.3",
|
|
56
57
|
"yargs": "~18.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
@@ -62,13 +63,13 @@
|
|
|
62
63
|
"@xyo-network/account-model": "~5.3.2",
|
|
63
64
|
"@xyo-network/archivist-lmdb": "~5.3.2",
|
|
64
65
|
"@xyo-network/archivist-mongodb": "~5.3.2",
|
|
65
|
-
"@xyo-network/chain-ethereum": "~1.19.
|
|
66
|
-
"@xyo-network/chain-services": "~1.19.
|
|
67
|
-
"@xyo-network/chain-test": "~1.19.
|
|
66
|
+
"@xyo-network/chain-ethereum": "~1.19.7",
|
|
67
|
+
"@xyo-network/chain-services": "~1.19.7",
|
|
68
|
+
"@xyo-network/chain-test": "~1.19.7",
|
|
68
69
|
"@xyo-network/typechain": "~4.1.1",
|
|
69
70
|
"@xyo-network/wallet": "~5.3.2",
|
|
70
71
|
"@xyo-network/wallet-model": "~5.3.2",
|
|
71
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
72
|
+
"@xyo-network/xl1-sdk": "~1.22.30",
|
|
72
73
|
"eslint": "^9.39.2",
|
|
73
74
|
"ethers": "^6.16.0",
|
|
74
75
|
"lmdb": "~3.5.1",
|
|
@@ -5,10 +5,10 @@ import type {
|
|
|
5
5
|
} from '@xyo-network/chain-orchestration'
|
|
6
6
|
import { ValidatorActor } from '@xyo-network/chain-orchestration'
|
|
7
7
|
import type {
|
|
8
|
-
|
|
8
|
+
CachingContext, Config, ProviderFactoryLocatorInstance,
|
|
9
9
|
} from '@xyo-network/xl1-sdk'
|
|
10
10
|
|
|
11
|
-
interface RunValidatorContext extends
|
|
11
|
+
interface RunValidatorContext extends CachingContext {
|
|
12
12
|
account: AccountInstance
|
|
13
13
|
config: Config
|
|
14
14
|
locator: ProviderFactoryLocatorInstance
|
package/src/runCLI.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Logger } from '@xylabs/sdk-js'
|
|
2
|
-
import {
|
|
2
|
+
import { isDefined, toAddress } from '@xylabs/sdk-js'
|
|
3
3
|
import { runApi } from '@xyo-network/chain-api'
|
|
4
4
|
import { Orchestrator } from '@xyo-network/chain-orchestration'
|
|
5
5
|
import { runProducer } from '@xyo-network/chain-producer'
|
|
6
|
-
import {
|
|
6
|
+
import type { Config } from '@xyo-network/xl1-sdk'
|
|
7
|
+
import { ConfigZod, isZodError } from '@xyo-network/xl1-sdk'
|
|
8
|
+
import { merge as deepMerge } from 'ts-deepmerge'
|
|
7
9
|
import type { Argv } from 'yargs'
|
|
8
10
|
import yargs from 'yargs'
|
|
9
11
|
import { hideBin } from 'yargs/helpers'
|
|
10
|
-
import { ZodError } from 'zod'
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
14
|
runBridge, runMempool, runRewardRedemptionApi,
|
|
@@ -35,6 +36,17 @@ let configuration: Config
|
|
|
35
36
|
|
|
36
37
|
const version = isDefined(__VERSION__) ? __VERSION__ : 'unknown'
|
|
37
38
|
|
|
39
|
+
function resolveConfig(config: Config): Config {
|
|
40
|
+
const logger = console
|
|
41
|
+
const defaultChainId = toAddress('1')
|
|
42
|
+
const resolved = structuredClone(config)
|
|
43
|
+
if (!resolved.chain.id) {
|
|
44
|
+
logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`)
|
|
45
|
+
resolved.chain.id = defaultChainId
|
|
46
|
+
}
|
|
47
|
+
return resolved
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
const getContextFromConfig = async (configuration: Config): Promise<RunCliContext> => {
|
|
39
51
|
const logger = initLogger(configuration)
|
|
40
52
|
const orchestrator = await Orchestrator.create({ logger })
|
|
@@ -79,19 +91,36 @@ $0 <command> [options]`)
|
|
|
79
91
|
// Parse the various config sources
|
|
80
92
|
const parsedConfigFile = tryParseConfig() // Config file
|
|
81
93
|
const parsedConfigArgs = argv // Command-line arguments & ENV VARs
|
|
94
|
+
const parseResult = ConfigZod.safeParse(parsedConfigFile)
|
|
95
|
+
if (!parseResult.success) {
|
|
96
|
+
throw parseResult.error
|
|
97
|
+
}
|
|
82
98
|
// Deep merge with precedence
|
|
83
99
|
// TODO: Would like precedence to be defaults < file < ENV < CLI Args
|
|
84
100
|
// but there is currently no way to determine which are defaults vs
|
|
85
101
|
// user-supplied CLI Args since we set the CLI args to the defaults
|
|
86
102
|
// and receive a flattened object. We might need to manually invoke
|
|
87
103
|
// the parser without the defaults to achieve this.
|
|
88
|
-
const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)
|
|
104
|
+
// const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)
|
|
105
|
+
const mergedConfig = deepMerge(parsedConfigArgs)
|
|
106
|
+
const validatedMergedConfigResult = ConfigZod.safeParse(mergedConfig)
|
|
107
|
+
if (!validatedMergedConfigResult.success) {
|
|
108
|
+
throw validatedMergedConfigResult.error
|
|
109
|
+
}
|
|
110
|
+
const resolvedConfig = resolveConfig(validatedMergedConfigResult.data)
|
|
89
111
|
// Validate the merged configuration
|
|
90
|
-
|
|
112
|
+
const validatedConfigResult = ConfigZod.safeParse(resolvedConfig)
|
|
113
|
+
if (!validatedConfigResult.success) {
|
|
114
|
+
throw validatedConfigResult.error
|
|
115
|
+
}
|
|
116
|
+
configuration = validatedConfigResult.data
|
|
91
117
|
} catch (err) {
|
|
92
|
-
if (err
|
|
93
|
-
console.error(
|
|
118
|
+
if (isZodError(err)) {
|
|
119
|
+
console.error(`Zod error: ${err.message}`)
|
|
120
|
+
} else {
|
|
121
|
+
console.error(`Error parsing configuration: ${err}`)
|
|
94
122
|
}
|
|
123
|
+
console.error(`Stack: ${err instanceof Error ? err.stack : 'N/A'}`)
|
|
95
124
|
throw new Error('Invalid configuration')
|
|
96
125
|
}
|
|
97
126
|
})
|
package/src/tryParseConfig.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isDefined, isNull } from '@xylabs/sdk-js'
|
|
2
|
+
import { ConfigZod } from '@xyo-network/xl1-sdk'
|
|
2
3
|
import { cosmiconfigSync } from 'cosmiconfig'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -15,7 +16,7 @@ const configSection = 'xl1' // Default section in the config file
|
|
|
15
16
|
* Attempts to parse the configuration from a file using cosmiconfig.
|
|
16
17
|
* @returns The parsed configuration object if found and valid, otherwise undefined.
|
|
17
18
|
*/
|
|
18
|
-
export const tryParseConfig = ()
|
|
19
|
+
export const tryParseConfig = () => {
|
|
19
20
|
const explorer = cosmiconfigSync(
|
|
20
21
|
configName,
|
|
21
22
|
/* {
|
|
@@ -34,8 +35,8 @@ export const tryParseConfig = (): Record<string, unknown> => {
|
|
|
34
35
|
if (!isNull(result)) {
|
|
35
36
|
const section = result?.config?.[configSection]
|
|
36
37
|
if (isDefined(section) && typeof section === 'object') {
|
|
37
|
-
return section
|
|
38
|
+
return ConfigZod.parse(section)
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
return {}
|
|
41
|
+
return ConfigZod.parse({})
|
|
41
42
|
}
|