@xyo-network/xl1-cli-lib 1.19.14 → 1.19.16
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/bridge/runBridge.d.ts +5 -3
- package/dist/node/commands/bridge/runBridge.d.ts.map +1 -1
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts +5 -3
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts.map +1 -1
- package/dist/node/commands/validator/runValidator.d.ts +5 -3
- package/dist/node/commands/validator/runValidator.d.ts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +114 -374
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/initLogger.d.ts +2 -2
- package/dist/node/initLogger.d.ts.map +1 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/xl1.mjs +95 -356
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +26 -28
- package/src/commands/bridge/runBridge.ts +18 -11
- package/src/commands/rewardRedemption/runRewardRedemptionApi.ts +20 -9
- package/src/commands/validator/runValidator.ts +17 -12
- package/src/index.ts +1 -0
- package/src/initLogger.ts +2 -2
- package/src/runCLI.ts +61 -77
- package/dist/node/locatorFromConfig.d.ts +0 -14
- package/dist/node/locatorFromConfig.d.ts.map +0 -1
- package/dist/node/tryParseConfig.d.ts +0 -431
- package/dist/node/tryParseConfig.d.ts.map +0 -1
- package/src/locatorFromConfig.ts +0 -326
- package/src/spec/MultiProducer.ChainOutput.json +0 -864
- package/src/tryParseConfig.ts +0 -42
package/dist/node/index.mjs
CHANGED
|
@@ -1,32 +1,55 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/initLogger.ts
|
|
5
|
+
import { Base, ConsoleLogger, isDefined, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
6
|
+
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
7
|
+
let logger;
|
|
8
|
+
if (config2.log.silent) {
|
|
9
|
+
logger = new SilentLogger();
|
|
10
|
+
} else {
|
|
11
|
+
let level;
|
|
12
|
+
if (isDefined(config2.log.logLevel)) {
|
|
13
|
+
const parsed = LogLevel[config2.log.logLevel.toLowerCase()];
|
|
14
|
+
if (isDefined(parsed)) level = parsed;
|
|
15
|
+
}
|
|
16
|
+
logger = new ConsoleLogger(level);
|
|
17
|
+
}
|
|
18
|
+
Base.defaultLogger = logger;
|
|
19
|
+
return logger;
|
|
20
|
+
}, "initLogger");
|
|
21
|
+
|
|
4
22
|
// src/runCLI.ts
|
|
5
|
-
import {
|
|
6
|
-
import { runApi } from "@xyo-network/chain-api";
|
|
7
|
-
import { runMempool } from "@xyo-network/chain-mempool";
|
|
8
|
-
import { Orchestrator } from "@xyo-network/chain-orchestration";
|
|
23
|
+
import { createDeepMerge, isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
24
|
+
import { getApiActor, runApi } from "@xyo-network/chain-api";
|
|
25
|
+
import { getMempoolActor, runMempool } from "@xyo-network/chain-mempool";
|
|
26
|
+
import { ApiConfigZod, BridgeConfigZod, contextFromConfigWithoutLocator, locatorsFromConfig, MempoolConfigZod, Orchestrator, ProducerConfigZod, RewardRedemptionConfigZod, tryParseConfig } from "@xyo-network/chain-orchestration";
|
|
9
27
|
import { runProducer } from "@xyo-network/chain-producer";
|
|
10
|
-
import { ConfigZod
|
|
28
|
+
import { ActorConfigZod, ConfigZod, isZodError, resolveConfig } from "@xyo-network/xl1-sdk";
|
|
11
29
|
import yargs from "yargs";
|
|
12
30
|
import { hideBin } from "yargs/helpers";
|
|
13
31
|
|
|
14
32
|
// src/commands/bridge/runBridge.ts
|
|
15
33
|
import { exists } from "@xylabs/sdk-js";
|
|
16
34
|
import { BridgeActor } from "@xyo-network/chain-bridge";
|
|
17
|
-
import {
|
|
18
|
-
var
|
|
19
|
-
const account = await
|
|
35
|
+
import { initActorWallet } from "@xyo-network/chain-orchestration";
|
|
36
|
+
var getBridgeActor = /* @__PURE__ */ __name(async (config2, locator) => {
|
|
37
|
+
const account = await initActorWallet({
|
|
20
38
|
config: config2,
|
|
21
|
-
logger: locator.context.logger
|
|
39
|
+
logger: locator.context.logger,
|
|
40
|
+
singletons: {},
|
|
41
|
+
caches: {}
|
|
22
42
|
});
|
|
23
|
-
|
|
43
|
+
return await BridgeActor.create({
|
|
24
44
|
account,
|
|
25
45
|
config: config2,
|
|
26
46
|
locator
|
|
27
47
|
});
|
|
48
|
+
}, "getBridgeActor");
|
|
49
|
+
var runBridge = /* @__PURE__ */ __name(async (config2, orchestrator, locator) => {
|
|
50
|
+
const bridge = await getBridgeActor(config2, locator);
|
|
28
51
|
const actors = [
|
|
29
|
-
|
|
52
|
+
bridge
|
|
30
53
|
].filter(exists);
|
|
31
54
|
for (const actor of actors) {
|
|
32
55
|
await orchestrator.registerActor(actor);
|
|
@@ -36,18 +59,24 @@ var runBridge = /* @__PURE__ */ __name(async (config2, orchestrator, locator) =>
|
|
|
36
59
|
|
|
37
60
|
// src/commands/rewardRedemption/runRewardRedemptionApi.ts
|
|
38
61
|
import { exists as exists2 } from "@xylabs/sdk-js";
|
|
39
|
-
import {
|
|
62
|
+
import { initActorWallet as initActorWallet2 } from "@xyo-network/chain-orchestration";
|
|
40
63
|
import { RewardRedemptionActor } from "@xyo-network/chain-reward-redemption";
|
|
41
|
-
async function
|
|
42
|
-
const account = await
|
|
64
|
+
async function getRewardRedemptionActor(config2, locator) {
|
|
65
|
+
const account = await initActorWallet2({
|
|
43
66
|
config: config2,
|
|
44
|
-
logger: locator.context.logger
|
|
67
|
+
logger: locator.context.logger,
|
|
68
|
+
singletons: {},
|
|
69
|
+
caches: {}
|
|
45
70
|
});
|
|
46
|
-
|
|
71
|
+
return await RewardRedemptionActor.create({
|
|
47
72
|
account,
|
|
48
73
|
config: config2,
|
|
49
74
|
locator
|
|
50
75
|
});
|
|
76
|
+
}
|
|
77
|
+
__name(getRewardRedemptionActor, "getRewardRedemptionActor");
|
|
78
|
+
async function runRewardRedemptionApi(config2, orchestrator, locator) {
|
|
79
|
+
const rewardRedemption = await getRewardRedemptionActor(config2, locator);
|
|
51
80
|
const actors = [
|
|
52
81
|
rewardRedemption
|
|
53
82
|
].filter(exists2);
|
|
@@ -58,6 +87,23 @@ async function runRewardRedemptionApi(config2, orchestrator, locator) {
|
|
|
58
87
|
}
|
|
59
88
|
__name(runRewardRedemptionApi, "runRewardRedemptionApi");
|
|
60
89
|
|
|
90
|
+
// src/commands/validator/runValidator.ts
|
|
91
|
+
import { exists as exists3 } from "@xylabs/sdk-js";
|
|
92
|
+
import { initActorWallet as initActorWallet3, ValidatorActor } from "@xyo-network/chain-orchestration";
|
|
93
|
+
var getValidatorActor = /* @__PURE__ */ __name(async (config2, locator) => {
|
|
94
|
+
const account = await initActorWallet3({
|
|
95
|
+
config: config2,
|
|
96
|
+
logger: locator.context.logger,
|
|
97
|
+
singletons: {},
|
|
98
|
+
caches: {}
|
|
99
|
+
});
|
|
100
|
+
return await ValidatorActor.create({
|
|
101
|
+
account,
|
|
102
|
+
config: config2,
|
|
103
|
+
locator
|
|
104
|
+
});
|
|
105
|
+
}, "getValidatorActor");
|
|
106
|
+
|
|
61
107
|
// src/images.ts
|
|
62
108
|
var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;118;111;144m_\x1B[0m
|
|
63
109
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;72;32;223m\u2560\x1B[0m\x1B[38;2;66;21;234m\u2560\x1B[0m
|
|
@@ -78,307 +124,6 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
78
124
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;68;25;230m\u2560\x1B[0m\x1B[38;2;66;21;234m\u2560\x1B[0m
|
|
79
125
|
\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\x1B[0m\x1B[38;2;108;93;162m\xB2\x1B[0m\x1B[38;2;99;79;176m^\x1B[0m`;
|
|
80
126
|
|
|
81
|
-
// src/initLogger.ts
|
|
82
|
-
import { Base, ConsoleLogger, isDefined, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
83
|
-
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
84
|
-
let logger;
|
|
85
|
-
if (config2.log.silent) {
|
|
86
|
-
logger = new SilentLogger();
|
|
87
|
-
} else {
|
|
88
|
-
let level;
|
|
89
|
-
if (isDefined(config2.log.logLevel)) {
|
|
90
|
-
const parsed = LogLevel[config2.log.logLevel.toLowerCase()];
|
|
91
|
-
if (isDefined(parsed)) level = parsed;
|
|
92
|
-
}
|
|
93
|
-
logger = new ConsoleLogger(level);
|
|
94
|
-
}
|
|
95
|
-
Base.defaultLogger = logger;
|
|
96
|
-
return logger;
|
|
97
|
-
}, "initLogger");
|
|
98
|
-
|
|
99
|
-
// src/locatorFromConfig.ts
|
|
100
|
-
import { asAddress, assertEx, isDefined as isDefined2, isString } from "@xylabs/sdk-js";
|
|
101
|
-
import { initApiWallet, initBalanceSummaryMap, initEvmProvidersIfAvailable, initFinalizationArchivistIfNeeded, initProducerAccount, initServerNode, initStatusReporter, initTransferSummaryMap } from "@xyo-network/chain-orchestration";
|
|
102
|
-
import { SimpleBlockRunner } from "@xyo-network/chain-services";
|
|
103
|
-
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
104
|
-
import { validateHydratedBlock, validateHydratedBlockState } from "@xyo-network/chain-validation";
|
|
105
|
-
import { HDWallet } from "@xyo-network/wallet";
|
|
106
|
-
import { AccountBalanceViewerRpcSchemas, ADDRESS_INDEX, BlockViewerRpcSchemas, FinalizationViewerRpcSchemas, generateXyoBaseWalletFromPhrase, HttpRpcTransport, JsonRpcAccountBalanceViewer, JsonRpcBlockViewer, JsonRpcFinalizationViewer, JsonRpcMempoolRunner, JsonRpcMempoolViewer, MempoolRunnerRpcSchemas, MempoolViewerRpcSchemas, ProviderFactoryLocator, SimpleAccountBalanceViewer, SimpleBlockRewardViewer, SimpleBlockValidationViewer, SimpleBlockViewer, SimpleFinalizationRunner, SimpleFinalizationViewer, SimpleMempoolRunner, SimpleMempoolViewer, SimpleNetworkStakeViewer, SimpleStepRewardsByPositionViewer, SimpleStepRewardsByStakerViewer, SimpleStepRewardsByStepViewer, SimpleStepRewardsTotalViewer, SimpleStepRewardsViewer, SimpleStepViewer, SimpleTimeSyncViewer, SimpleWindowedBlockViewer, SimpleXyoConnectionRunner, SimpleXyoConnectionViewer, SimpleXyoGateway, SimpleXyoGatewayRunner, SimpleXyoRunner, SimpleXyoSigner, SimpleXyoViewer } from "@xyo-network/xl1-sdk";
|
|
107
|
-
async function telemetryContextFromConfig(config2, serviceName, serviceVersion) {
|
|
108
|
-
const { otlpEndpoint } = config2.telemetry?.otel ?? {};
|
|
109
|
-
const { path: endpoint = "/metrics", port = 9466 } = config2.telemetry?.metrics?.scrape ?? {};
|
|
110
|
-
return await initTelemetry({
|
|
111
|
-
attributes: {
|
|
112
|
-
serviceName,
|
|
113
|
-
serviceVersion
|
|
114
|
-
},
|
|
115
|
-
otlpEndpoint,
|
|
116
|
-
metricsConfig: {
|
|
117
|
-
endpoint,
|
|
118
|
-
port
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
__name(telemetryContextFromConfig, "telemetryContextFromConfig");
|
|
123
|
-
async function contextFromConfigWithoutLocator(config2, logger, serviceName, serviceVersion) {
|
|
124
|
-
const singletons = {};
|
|
125
|
-
const caches = {};
|
|
126
|
-
const telemetryConfig = await telemetryContextFromConfig(config2, serviceName, serviceVersion);
|
|
127
|
-
const statusReporter = initStatusReporter({
|
|
128
|
-
logger
|
|
129
|
-
});
|
|
130
|
-
return {
|
|
131
|
-
...telemetryConfig,
|
|
132
|
-
config: config2,
|
|
133
|
-
singletons,
|
|
134
|
-
caches,
|
|
135
|
-
logger,
|
|
136
|
-
statusReporter
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
__name(contextFromConfigWithoutLocator, "contextFromConfigWithoutLocator");
|
|
140
|
-
async function rootLocatorFromConfig(config2, context) {
|
|
141
|
-
let locator = new ProviderFactoryLocator(context);
|
|
142
|
-
locator.registerMany([
|
|
143
|
-
SimpleNetworkStakeViewer.factory(SimpleNetworkStakeViewer.dependencies, {}),
|
|
144
|
-
SimpleTimeSyncViewer.factory(SimpleTimeSyncViewer.dependencies, {}),
|
|
145
|
-
SimpleStepViewer.factory(SimpleStepViewer.dependencies, {}),
|
|
146
|
-
SimpleStepRewardsViewer.factory(SimpleStepRewardsViewer.dependencies, {}),
|
|
147
|
-
SimpleStepRewardsByPositionViewer.factory(SimpleStepRewardsByPositionViewer.dependencies, {}),
|
|
148
|
-
SimpleStepRewardsByStakerViewer.factory(SimpleStepRewardsByStakerViewer.dependencies, {}),
|
|
149
|
-
SimpleStepRewardsByStepViewer.factory(SimpleStepRewardsByStepViewer.dependencies, {}),
|
|
150
|
-
SimpleStepRewardsTotalViewer.factory(SimpleStepRewardsTotalViewer.dependencies, {}),
|
|
151
|
-
SimpleBlockValidationViewer.factory(SimpleBlockValidationViewer.dependencies, {
|
|
152
|
-
state: validateHydratedBlockState,
|
|
153
|
-
protocol: validateHydratedBlock
|
|
154
|
-
})
|
|
155
|
-
]);
|
|
156
|
-
locator = await initEvmProvidersIfAvailable(locator);
|
|
157
|
-
locator = await (isString(config2.remote.rpc?.url) ? remoteLocatorFromConfig(config2, {
|
|
158
|
-
...context,
|
|
159
|
-
locator
|
|
160
|
-
}) : localLocatorFromConfig(config2, {
|
|
161
|
-
...context,
|
|
162
|
-
locator
|
|
163
|
-
}));
|
|
164
|
-
locator.freeze();
|
|
165
|
-
return locator;
|
|
166
|
-
}
|
|
167
|
-
__name(rootLocatorFromConfig, "rootLocatorFromConfig");
|
|
168
|
-
async function localLocatorFromConfig(config2, context) {
|
|
169
|
-
const balancesSummaryMap = assertEx(await initBalanceSummaryMap(context), () => "Balance Summary Map not initialized");
|
|
170
|
-
const transfersSummaryMap = assertEx(await initTransferSummaryMap(context), () => "Transfer Summary Map not initialized");
|
|
171
|
-
const wallet = await initApiWallet(context);
|
|
172
|
-
const { writableChainArchivist, readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist } = await initServerNode({
|
|
173
|
-
...context,
|
|
174
|
-
wallet,
|
|
175
|
-
transfersSummaryMap,
|
|
176
|
-
balancesSummaryMap
|
|
177
|
-
});
|
|
178
|
-
await initFinalizationArchivistIfNeeded(writableChainArchivist, config2, wallet);
|
|
179
|
-
const locator = new ProviderFactoryLocator(context);
|
|
180
|
-
locator.registerMany([
|
|
181
|
-
SimpleMempoolViewer.factory(SimpleMempoolViewer.dependencies, {
|
|
182
|
-
pendingTransactionsArchivist,
|
|
183
|
-
pendingBlocksArchivist
|
|
184
|
-
}),
|
|
185
|
-
SimpleMempoolRunner.factory(SimpleMempoolRunner.dependencies, {
|
|
186
|
-
pendingTransactionsArchivist,
|
|
187
|
-
pendingBlocksArchivist
|
|
188
|
-
}),
|
|
189
|
-
SimpleAccountBalanceViewer.factory(SimpleAccountBalanceViewer.dependencies, {
|
|
190
|
-
balancesSummaryMap,
|
|
191
|
-
transfersSummaryMap
|
|
192
|
-
}),
|
|
193
|
-
SimpleFinalizationViewer.factory(SimpleFinalizationViewer.dependencies, {
|
|
194
|
-
finalizedArchivist: readonlyChainArchivist
|
|
195
|
-
}),
|
|
196
|
-
SimpleBlockViewer.factory(SimpleBlockViewer.dependencies, {
|
|
197
|
-
finalizedArchivist: readonlyChainArchivist
|
|
198
|
-
}),
|
|
199
|
-
SimpleWindowedBlockViewer.factory(SimpleWindowedBlockViewer.dependencies, {
|
|
200
|
-
maxWindowSize: 1e4,
|
|
201
|
-
syncInterval: 1e4
|
|
202
|
-
}),
|
|
203
|
-
SimpleXyoConnectionViewer.factory(SimpleXyoConnectionViewer.dependencies, {}),
|
|
204
|
-
SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {
|
|
205
|
-
finalizedArchivist: readonlyChainArchivist
|
|
206
|
-
}),
|
|
207
|
-
SimpleFinalizationViewer.factory(SimpleFinalizationViewer.dependencies, {
|
|
208
|
-
finalizedArchivist: readonlyChainArchivist
|
|
209
|
-
}),
|
|
210
|
-
SimpleFinalizationRunner.factory(SimpleFinalizationRunner.dependencies, {
|
|
211
|
-
finalizedArchivist: writableChainArchivist
|
|
212
|
-
})
|
|
213
|
-
]);
|
|
214
|
-
locator.freeze();
|
|
215
|
-
return locator;
|
|
216
|
-
}
|
|
217
|
-
__name(localLocatorFromConfig, "localLocatorFromConfig");
|
|
218
|
-
async function remoteLocatorFromConfig(config2, context) {
|
|
219
|
-
const balancesSummaryMap = assertEx(await initBalanceSummaryMap(context), () => "Balance Summary Map not initialized");
|
|
220
|
-
const transfersSummaryMap = assertEx(await initTransferSummaryMap(context), () => "Transfer Summary Map not initialized");
|
|
221
|
-
const wallet = await initApiWallet(context);
|
|
222
|
-
const { readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist } = await initServerNode({
|
|
223
|
-
...context,
|
|
224
|
-
wallet,
|
|
225
|
-
transfersSummaryMap,
|
|
226
|
-
balancesSummaryMap
|
|
227
|
-
});
|
|
228
|
-
const locator = new ProviderFactoryLocator(context);
|
|
229
|
-
locator.registerMany([
|
|
230
|
-
SimpleMempoolViewer.factory(SimpleMempoolViewer.dependencies, {
|
|
231
|
-
pendingTransactionsArchivist,
|
|
232
|
-
pendingBlocksArchivist
|
|
233
|
-
}),
|
|
234
|
-
SimpleMempoolRunner.factory(SimpleMempoolRunner.dependencies, {
|
|
235
|
-
pendingTransactionsArchivist,
|
|
236
|
-
pendingBlocksArchivist
|
|
237
|
-
}),
|
|
238
|
-
SimpleAccountBalanceViewer.factory(SimpleAccountBalanceViewer.dependencies, {
|
|
239
|
-
balancesSummaryMap,
|
|
240
|
-
transfersSummaryMap
|
|
241
|
-
}),
|
|
242
|
-
SimpleFinalizationViewer.factory(SimpleFinalizationViewer.dependencies, {
|
|
243
|
-
finalizedArchivist: readonlyChainArchivist
|
|
244
|
-
}),
|
|
245
|
-
SimpleBlockViewer.factory(SimpleBlockViewer.dependencies, {
|
|
246
|
-
finalizedArchivist: readonlyChainArchivist
|
|
247
|
-
}),
|
|
248
|
-
SimpleWindowedBlockViewer.factory(SimpleWindowedBlockViewer.dependencies, {
|
|
249
|
-
maxWindowSize: 1e4,
|
|
250
|
-
syncInterval: 1e4
|
|
251
|
-
}),
|
|
252
|
-
SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {
|
|
253
|
-
finalizedArchivist: readonlyChainArchivist
|
|
254
|
-
})
|
|
255
|
-
]);
|
|
256
|
-
locator.freeze();
|
|
257
|
-
return locator;
|
|
258
|
-
}
|
|
259
|
-
__name(remoteLocatorFromConfig, "remoteLocatorFromConfig");
|
|
260
|
-
async function producerLocatorFromConfig(config2, context) {
|
|
261
|
-
const { logger } = context;
|
|
262
|
-
const account = await initProducerAccount({
|
|
263
|
-
config: config2
|
|
264
|
-
});
|
|
265
|
-
const locator = new ProviderFactoryLocator(context);
|
|
266
|
-
const rewardAddress = asAddress(config2.actors.producer.rewardAddress ?? account.address, true);
|
|
267
|
-
logger?.info(`Using reward address ${rewardAddress}`);
|
|
268
|
-
if (rewardAddress === account.address) {
|
|
269
|
-
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
270
|
-
}
|
|
271
|
-
const remoteUrl = config2.actors.producer.remote.rpc?.url;
|
|
272
|
-
if (isString(remoteUrl)) {
|
|
273
|
-
const transportFactory = /* @__PURE__ */ __name((schemas) => new HttpRpcTransport(remoteUrl, schemas), "transportFactory");
|
|
274
|
-
locator.registerMany([
|
|
275
|
-
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {
|
|
276
|
-
transport: await transportFactory(MempoolViewerRpcSchemas)
|
|
277
|
-
}),
|
|
278
|
-
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {
|
|
279
|
-
transport: await transportFactory(MempoolRunnerRpcSchemas)
|
|
280
|
-
}),
|
|
281
|
-
JsonRpcAccountBalanceViewer.factory(JsonRpcAccountBalanceViewer.dependencies, {
|
|
282
|
-
transport: await transportFactory(AccountBalanceViewerRpcSchemas)
|
|
283
|
-
}),
|
|
284
|
-
JsonRpcFinalizationViewer.factory(JsonRpcFinalizationViewer.dependencies, {
|
|
285
|
-
transport: await transportFactory(FinalizationViewerRpcSchemas)
|
|
286
|
-
}),
|
|
287
|
-
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {
|
|
288
|
-
transport: await transportFactory(BlockViewerRpcSchemas)
|
|
289
|
-
})
|
|
290
|
-
]);
|
|
291
|
-
}
|
|
292
|
-
locator.registerMany([
|
|
293
|
-
SimpleBlockRewardViewer.factory(SimpleBlockRewardViewer.dependencies, {}),
|
|
294
|
-
SimpleBlockRunner.factory(SimpleBlockRunner.dependencies, {
|
|
295
|
-
account,
|
|
296
|
-
rewardAddress
|
|
297
|
-
})
|
|
298
|
-
]);
|
|
299
|
-
locator.freeze();
|
|
300
|
-
return locator;
|
|
301
|
-
}
|
|
302
|
-
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
303
|
-
function apiLocatorFromConfig(config2, context) {
|
|
304
|
-
const locator = new ProviderFactoryLocator(context);
|
|
305
|
-
locator.registerMany([
|
|
306
|
-
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
307
|
-
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
308
|
-
SimpleXyoGateway.factory(SimpleXyoGateway.dependencies, {})
|
|
309
|
-
]);
|
|
310
|
-
locator.freeze();
|
|
311
|
-
return locator;
|
|
312
|
-
}
|
|
313
|
-
__name(apiLocatorFromConfig, "apiLocatorFromConfig");
|
|
314
|
-
function mempoolLocatorFromConfig(config2, context) {
|
|
315
|
-
const locator = new ProviderFactoryLocator(context);
|
|
316
|
-
locator.registerMany([]);
|
|
317
|
-
locator.freeze();
|
|
318
|
-
return locator;
|
|
319
|
-
}
|
|
320
|
-
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
321
|
-
async function bridgeLocatorFromConfig(config2, context) {
|
|
322
|
-
const locator = new ProviderFactoryLocator(context);
|
|
323
|
-
const { mnemonic } = config2.actors.bridge;
|
|
324
|
-
const walletPhrase = isDefined2(mnemonic) ? mnemonic : HDWallet.generateMnemonic();
|
|
325
|
-
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase);
|
|
326
|
-
const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO);
|
|
327
|
-
const remoteUrl = config2.actors.bridge.remote.rpc?.url;
|
|
328
|
-
if (isString(remoteUrl)) {
|
|
329
|
-
const transportFactory = /* @__PURE__ */ __name((schemas) => new HttpRpcTransport(remoteUrl, schemas), "transportFactory");
|
|
330
|
-
locator.registerMany([
|
|
331
|
-
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {
|
|
332
|
-
transport: await transportFactory(MempoolViewerRpcSchemas)
|
|
333
|
-
}),
|
|
334
|
-
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {
|
|
335
|
-
transport: await transportFactory(MempoolRunnerRpcSchemas)
|
|
336
|
-
}),
|
|
337
|
-
JsonRpcAccountBalanceViewer.factory(JsonRpcAccountBalanceViewer.dependencies, {
|
|
338
|
-
transport: await transportFactory(AccountBalanceViewerRpcSchemas)
|
|
339
|
-
}),
|
|
340
|
-
JsonRpcFinalizationViewer.factory(JsonRpcFinalizationViewer.dependencies, {
|
|
341
|
-
transport: await transportFactory(FinalizationViewerRpcSchemas)
|
|
342
|
-
}),
|
|
343
|
-
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {
|
|
344
|
-
transport: await transportFactory(BlockViewerRpcSchemas)
|
|
345
|
-
})
|
|
346
|
-
]);
|
|
347
|
-
}
|
|
348
|
-
locator.registerMany([
|
|
349
|
-
SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, {
|
|
350
|
-
account: signerAccount
|
|
351
|
-
}),
|
|
352
|
-
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
353
|
-
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
354
|
-
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
355
|
-
]);
|
|
356
|
-
locator.freeze();
|
|
357
|
-
return locator;
|
|
358
|
-
}
|
|
359
|
-
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
360
|
-
function rewardRedemptionLocatorFromConfig(config2, context) {
|
|
361
|
-
const locator = new ProviderFactoryLocator(context);
|
|
362
|
-
locator.registerMany([
|
|
363
|
-
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
364
|
-
]);
|
|
365
|
-
locator.freeze();
|
|
366
|
-
return locator;
|
|
367
|
-
}
|
|
368
|
-
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
369
|
-
async function locatorsFromConfig(actors, config2, context) {
|
|
370
|
-
const result = {
|
|
371
|
-
_root: await rootLocatorFromConfig(config2, context)
|
|
372
|
-
};
|
|
373
|
-
if (actors.includes("producer")) result.producer = await producerLocatorFromConfig(config2, result._root.context);
|
|
374
|
-
if (actors.includes("api")) result.api = await apiLocatorFromConfig(config2, result._root.context);
|
|
375
|
-
if (actors.includes("mempool")) result.mempool = await mempoolLocatorFromConfig(config2, result._root.context);
|
|
376
|
-
if (actors.includes("bridge")) result.bridge = await bridgeLocatorFromConfig(config2, result._root.context);
|
|
377
|
-
if (actors.includes("rewardRedemption")) result.rewardRedemption = await rewardRedemptionLocatorFromConfig(config2, result._root.context);
|
|
378
|
-
return result;
|
|
379
|
-
}
|
|
380
|
-
__name(locatorsFromConfig, "locatorsFromConfig");
|
|
381
|
-
|
|
382
127
|
// src/optionsFromGlobalZodRegistry.ts
|
|
383
128
|
import { isUsageMeta } from "@xyo-network/xl1-sdk";
|
|
384
129
|
import { globalRegistry } from "zod";
|
|
@@ -396,24 +141,6 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
396
141
|
return opts;
|
|
397
142
|
}, "optionsFromGlobalZodRegistry");
|
|
398
143
|
|
|
399
|
-
// src/tryParseConfig.ts
|
|
400
|
-
import { isDefined as isDefined3, isNull } from "@xylabs/sdk-js";
|
|
401
|
-
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
402
|
-
import { cosmiconfigSync } from "cosmiconfig";
|
|
403
|
-
var configName = "xyo";
|
|
404
|
-
var configSection = "xl1";
|
|
405
|
-
var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
406
|
-
const explorer = cosmiconfigSync(configName);
|
|
407
|
-
const result = explorer.search();
|
|
408
|
-
if (!isNull(result)) {
|
|
409
|
-
const section = result?.config?.[configSection];
|
|
410
|
-
if (isDefined3(section) && typeof section === "object") {
|
|
411
|
-
return ConfigZod.parse(section);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return ConfigZod.parse({});
|
|
415
|
-
}, "tryParseConfig");
|
|
416
|
-
|
|
417
144
|
// src/waitForHostPort.ts
|
|
418
145
|
import net from "net";
|
|
419
146
|
var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
@@ -437,25 +164,28 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
437
164
|
|
|
438
165
|
// src/runCLI.ts
|
|
439
166
|
var configuration;
|
|
440
|
-
var version =
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const resolved = structuredClone(config2);
|
|
445
|
-
if (!resolved.chain.id) {
|
|
446
|
-
logger.warn(`No chain ID specified in configuration; defaulting to ${defaultChainId}`);
|
|
447
|
-
resolved.chain.id = defaultChainId;
|
|
448
|
-
}
|
|
449
|
-
return resolved;
|
|
450
|
-
}
|
|
451
|
-
__name(resolveConfig, "resolveConfig");
|
|
167
|
+
var version = isDefined2("1.19.15") ? "1.19.15" : "unknown";
|
|
168
|
+
var deepMerge = createDeepMerge({
|
|
169
|
+
arrayStrategy: "concat"
|
|
170
|
+
});
|
|
452
171
|
var getLocatorsFromConfig = /* @__PURE__ */ __name(async (actors, configuration2) => {
|
|
172
|
+
const actorConfigs = [];
|
|
173
|
+
for (const actorName of actors) {
|
|
174
|
+
const rawConfig = configuration2.actors.find((actor) => actor.name === actorName) ?? {
|
|
175
|
+
name: actorName
|
|
176
|
+
};
|
|
177
|
+
const actorConfig = ActorConfigZod.loose().parse(rawConfig);
|
|
178
|
+
actorConfigs.push(actorConfig);
|
|
179
|
+
}
|
|
180
|
+
const config2 = ConfigZod.parse(deepMerge(configuration2, {
|
|
181
|
+
actors: actorConfigs
|
|
182
|
+
}));
|
|
453
183
|
const logger = initLogger(configuration2);
|
|
454
184
|
const orchestrator = await Orchestrator.create({
|
|
455
185
|
logger
|
|
456
186
|
});
|
|
457
|
-
const context = await contextFromConfigWithoutLocator(
|
|
458
|
-
const locators = await locatorsFromConfig(
|
|
187
|
+
const context = await contextFromConfigWithoutLocator(config2, logger, "xl1-cli", version);
|
|
188
|
+
const locators = await locatorsFromConfig(context, config2);
|
|
459
189
|
process.on("SIGINT", () => {
|
|
460
190
|
void (async () => {
|
|
461
191
|
try {
|
|
@@ -486,30 +216,25 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
486
216
|
"dot-notation": true,
|
|
487
217
|
"parse-numbers": false,
|
|
488
218
|
"populate--": true
|
|
489
|
-
}).env("XL1").scriptName("xl1").middleware((argv2) => {
|
|
219
|
+
}).env("XL1").scriptName("xl1").middleware(async (argv2) => {
|
|
490
220
|
try {
|
|
491
|
-
const parsedConfigFile = tryParseConfig();
|
|
492
|
-
const parsedConfigArgs = argv2;
|
|
493
|
-
const parseResult =
|
|
221
|
+
const parsedConfigFile = await tryParseConfig();
|
|
222
|
+
const parsedConfigArgs = ConfigZod.safeParse(argv2).data ?? {};
|
|
223
|
+
const parseResult = ConfigZod.safeParse(deepMerge(parsedConfigFile, parsedConfigArgs));
|
|
494
224
|
if (!parseResult.success) {
|
|
495
225
|
throw parseResult.error;
|
|
496
226
|
}
|
|
497
|
-
const mergedConfig =
|
|
498
|
-
const validatedMergedConfigResult =
|
|
227
|
+
const mergedConfig = parseResult.data;
|
|
228
|
+
const validatedMergedConfigResult = ConfigZod.safeParse(mergedConfig);
|
|
499
229
|
if (!validatedMergedConfigResult.success) {
|
|
500
230
|
throw validatedMergedConfigResult.error;
|
|
501
231
|
}
|
|
502
232
|
const resolvedConfig = resolveConfig(validatedMergedConfigResult.data);
|
|
503
|
-
const validatedConfigResult =
|
|
233
|
+
const validatedConfigResult = ConfigZod.safeParse(resolvedConfig);
|
|
504
234
|
if (!validatedConfigResult.success) {
|
|
505
235
|
throw validatedConfigResult.error;
|
|
506
236
|
}
|
|
507
237
|
configuration = validatedConfigResult.data;
|
|
508
|
-
const { actors, ...rootConfig } = configuration;
|
|
509
|
-
const actorNames = Object.keys(actors);
|
|
510
|
-
for (const actorName of actorNames) {
|
|
511
|
-
configuration.actors[actorName] = deepMerge(rootConfig ?? {}, configuration.actors[actorName] ?? {});
|
|
512
|
-
}
|
|
513
238
|
if (argv2["dump-config"]) {
|
|
514
239
|
console.log(JSON.stringify(configuration, null, 2));
|
|
515
240
|
process.exit(0);
|
|
@@ -527,9 +252,19 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
527
252
|
return yargs2.command("$0", "Run a XL1 API Node", () => {
|
|
528
253
|
}, async () => {
|
|
529
254
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
530
|
-
"api"
|
|
255
|
+
"api",
|
|
256
|
+
"mempool",
|
|
257
|
+
"validator"
|
|
531
258
|
], configuration);
|
|
532
|
-
await
|
|
259
|
+
const actors = await Promise.all([
|
|
260
|
+
getApiActor(ApiConfigZod.parse(locators["api"].context.config), locators["api"]),
|
|
261
|
+
getMempoolActor(MempoolConfigZod.parse(locators["mempool"].context.config), locators["mempool"]),
|
|
262
|
+
getValidatorActor(ActorConfigZod.parse(locators["validator"].context.config), locators["validator"])
|
|
263
|
+
]);
|
|
264
|
+
for (const actor of actors) {
|
|
265
|
+
await orchestrator.registerActor(actor);
|
|
266
|
+
}
|
|
267
|
+
await orchestrator.start();
|
|
533
268
|
});
|
|
534
269
|
}).command("bridge", "Run a XL1 Bridge Node", (yargs2) => {
|
|
535
270
|
return yargs2.command("$0", "Run a XL1 Bridge Node", () => {
|
|
@@ -537,7 +272,7 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
537
272
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
538
273
|
"bridge"
|
|
539
274
|
], configuration);
|
|
540
|
-
await runBridge(
|
|
275
|
+
await runBridge(BridgeConfigZod.parse(locators["bridge"].context.config), orchestrator, locators["bridge"]);
|
|
541
276
|
});
|
|
542
277
|
}).command("mempool", "Run a XL1 Mempool Node", (yargs2) => {
|
|
543
278
|
return yargs2.command("$0", "Run a XL1 Mempool Node", () => {
|
|
@@ -545,7 +280,7 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
545
280
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
546
281
|
"mempool"
|
|
547
282
|
], configuration);
|
|
548
|
-
await runMempool(
|
|
283
|
+
await runMempool(MempoolConfigZod.parse(locators["mempool"].context.config), orchestrator, locators["mempool"]);
|
|
549
284
|
});
|
|
550
285
|
}).command("producer", "Run a XL1 Producer Node", (yargs2) => {
|
|
551
286
|
return yargs2.command("$0", "Run a XL1 Producer Node", () => {
|
|
@@ -553,7 +288,7 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
553
288
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
554
289
|
"producer"
|
|
555
290
|
], configuration);
|
|
556
|
-
await runProducer(
|
|
291
|
+
await runProducer(ProducerConfigZod.parse(locators["producer"].context.config), orchestrator, locators["producer"]);
|
|
557
292
|
});
|
|
558
293
|
}).command("reward-redemption-api", "Run a XL1 Rewards Redemption API Node", (yargs2) => {
|
|
559
294
|
return yargs2.command("$0", "Run a XL1 Rewards Redemption API Node", () => {
|
|
@@ -561,7 +296,7 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
561
296
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
562
297
|
"rewardRedemption"
|
|
563
298
|
], configuration);
|
|
564
|
-
await runRewardRedemptionApi(
|
|
299
|
+
await runRewardRedemptionApi(RewardRedemptionConfigZod.parse(locators["rewardRedemption"].context.config), orchestrator, locators["rewardRedemption"]);
|
|
565
300
|
});
|
|
566
301
|
}).command("$0", "Run a full XL1 Node", () => {
|
|
567
302
|
}, async () => {
|
|
@@ -569,20 +304,24 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
569
304
|
"producer",
|
|
570
305
|
"api"
|
|
571
306
|
];
|
|
572
|
-
|
|
307
|
+
const mempoolEnabled = configuration.actors.find((actor) => actor.name === "mempool")?.enabled;
|
|
308
|
+
if (mempoolEnabled) {
|
|
573
309
|
actors.push("mempool");
|
|
574
310
|
}
|
|
575
311
|
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
576
312
|
"api",
|
|
577
313
|
"producer"
|
|
578
314
|
], configuration);
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
await
|
|
315
|
+
if (mempoolEnabled) {
|
|
316
|
+
const mempoolConfig = MempoolConfigZod.parse(locators["mempool"].context.config);
|
|
317
|
+
await runMempool(mempoolConfig, orchestrator, locators["mempool"]);
|
|
318
|
+
await waitForHostPort(mempoolConfig.host, mempoolConfig.port);
|
|
582
319
|
}
|
|
583
|
-
|
|
584
|
-
await
|
|
585
|
-
await
|
|
320
|
+
const apiConfig = ApiConfigZod.parse(locators["api"].context.config);
|
|
321
|
+
await runApi(apiConfig, orchestrator, locators["api"]);
|
|
322
|
+
await waitForHostPort(apiConfig.host, apiConfig.port);
|
|
323
|
+
const producerConfig = ProducerConfigZod.parse(locators["producer"].context.config);
|
|
324
|
+
await runProducer(producerConfig, orchestrator, locators["producer"]);
|
|
586
325
|
}).options({
|
|
587
326
|
"dump-config": {
|
|
588
327
|
type: "boolean",
|
|
@@ -603,6 +342,7 @@ var start = /* @__PURE__ */ __name(async () => {
|
|
|
603
342
|
await runCLI();
|
|
604
343
|
}, "start");
|
|
605
344
|
export {
|
|
345
|
+
initLogger,
|
|
606
346
|
runCLI,
|
|
607
347
|
start
|
|
608
348
|
};
|