@xyo-network/xl1-cli-lib 1.19.7 → 1.19.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/commands/bridge/runBridge.d.ts +3 -8
- package/dist/node/commands/bridge/runBridge.d.ts.map +1 -1
- package/dist/node/commands/index.d.ts +0 -1
- package/dist/node/commands/index.d.ts.map +1 -1
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts +3 -8
- package/dist/node/commands/rewardRedemption/runRewardRedemptionApi.d.ts.map +1 -1
- package/dist/node/commands/validator/runValidator.d.ts +3 -11
- package/dist/node/commands/validator/runValidator.d.ts.map +1 -1
- package/dist/node/index.mjs +394 -71
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/locatorFromConfig.d.ts +14 -0
- package/dist/node/locatorFromConfig.d.ts.map +1 -0
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/tryParseConfig.d.ts +373 -68
- package/dist/node/tryParseConfig.d.ts.map +1 -1
- package/dist/node/xl1.mjs +394 -71
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +18 -15
- package/src/commands/bridge/runBridge.ts +24 -9
- package/src/commands/index.ts +0 -1
- package/src/commands/rewardRedemption/runRewardRedemptionApi.ts +22 -9
- package/src/commands/validator/runValidator.ts +15 -28
- package/src/initLogger.ts +3 -3
- package/src/locatorFromConfig.ts +335 -0
- package/src/runCLI.ts +78 -34
- package/dist/node/commands/mempool/index.d.ts +0 -2
- package/dist/node/commands/mempool/index.d.ts.map +0 -1
- package/dist/node/commands/mempool/runMempool.d.ts +0 -9
- package/dist/node/commands/mempool/runMempool.d.ts.map +0 -1
- package/src/commands/mempool/index.ts +0 -1
- package/src/commands/mempool/runMempool.ts +0 -12
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-sdk';
|
|
3
|
-
|
|
4
|
-
config: Config;
|
|
5
|
-
logger?: Logger;
|
|
6
|
-
}
|
|
7
|
-
export declare function runBridge(context: RunBridgeContext): void;
|
|
8
|
-
export {};
|
|
1
|
+
import { type OrchestratorInstance } from '@xyo-network/chain-orchestration';
|
|
2
|
+
import type { Config, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
|
|
3
|
+
export declare const runBridge: (config: Config, orchestrator: OrchestratorInstance, locator: ProviderFactoryLocatorInstance) => Promise<void>;
|
|
9
4
|
//# sourceMappingURL=runBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runBridge.d.ts","sourceRoot":"","sources":["../../../../src/commands/bridge/runBridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runBridge.d.ts","sourceRoot":"","sources":["../../../../src/commands/bridge/runBridge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAC9F,OAAO,KAAK,EACV,MAAM,EACN,8BAA8B,EAC/B,MAAM,sBAAsB,CAAA;AAE7B,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EACd,cAAc,oBAAoB,EAClC,SAAS,8BAA8B,kBAexC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Config } from '@xyo-network/xl1-sdk';
|
|
3
|
-
|
|
4
|
-
config: Config;
|
|
5
|
-
logger?: Logger;
|
|
6
|
-
}
|
|
7
|
-
export declare function runRewardRedemptionApi(context: RunRewardRedemptionApiContext): void;
|
|
8
|
-
export {};
|
|
1
|
+
import type { OrchestratorInstance } from '@xyo-network/chain-orchestration';
|
|
2
|
+
import type { Config, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
|
|
3
|
+
export declare function runRewardRedemptionApi(config: Config, orchestrator: OrchestratorInstance, locator: ProviderFactoryLocatorInstance): Promise<void>;
|
|
9
4
|
//# sourceMappingURL=runRewardRedemptionApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runRewardRedemptionApi.d.ts","sourceRoot":"","sources":["../../../../src/commands/rewardRedemption/runRewardRedemptionApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runRewardRedemptionApi.d.ts","sourceRoot":"","sources":["../../../../src/commands/rewardRedemption/runRewardRedemptionApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAG5E,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAA;AAElF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,8BAA8B,iBAexC"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
interface RunValidatorContext extends CachingContext {
|
|
5
|
-
account: AccountInstance;
|
|
6
|
-
config: Config;
|
|
7
|
-
locator: ProviderFactoryLocatorInstance;
|
|
8
|
-
orchestrator: OrchestratorInstance;
|
|
9
|
-
}
|
|
10
|
-
export declare const runValidator: (context: RunValidatorContext) => Promise<void>;
|
|
11
|
-
export {};
|
|
1
|
+
import { type OrchestratorInstance } from '@xyo-network/chain-orchestration';
|
|
2
|
+
import type { Config, ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
|
|
3
|
+
export declare const runValidator: (config: Config, orchestrator: OrchestratorInstance, locator: ProviderFactoryLocatorInstance) => Promise<void>;
|
|
12
4
|
//# sourceMappingURL=runValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runValidator.d.ts","sourceRoot":"","sources":["../../../../src/commands/validator/runValidator.ts"],"names":[],"mappings":"AACA,OAAO,EACgB,KAAK,oBAAoB,EAC/C,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EACV,MAAM,EACN,8BAA8B,EAC/B,MAAM,sBAAsB,CAAA;AAE7B,eAAO,MAAM,YAAY,GACvB,QAAQ,MAAM,EACd,cAAc,oBAAoB,EAClC,SAAS,8BAA8B,kBAexC,CAAA"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -2,33 +2,59 @@ 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 { isDefined as
|
|
5
|
+
import { deepMerge, isDefined as isDefined4, toAddress } from "@xylabs/sdk-js";
|
|
6
6
|
import { runApi } from "@xyo-network/chain-api";
|
|
7
|
+
import { runMempool } from "@xyo-network/chain-mempool";
|
|
7
8
|
import { Orchestrator } from "@xyo-network/chain-orchestration";
|
|
8
9
|
import { runProducer } from "@xyo-network/chain-producer";
|
|
9
10
|
import { ConfigZod as ConfigZod2, isZodError } from "@xyo-network/xl1-sdk";
|
|
10
|
-
import { merge as deepMerge } from "ts-deepmerge";
|
|
11
11
|
import yargs from "yargs";
|
|
12
12
|
import { hideBin } from "yargs/helpers";
|
|
13
13
|
|
|
14
14
|
// src/commands/bridge/runBridge.ts
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
import { exists } from "@xylabs/sdk-js";
|
|
16
|
+
import { BridgeActor } from "@xyo-network/chain-bridge";
|
|
17
|
+
import { initBridgeWallet } from "@xyo-network/chain-orchestration";
|
|
18
|
+
var runBridge = /* @__PURE__ */ __name(async (config2, orchestrator, locator) => {
|
|
19
|
+
const account = await initBridgeWallet({
|
|
20
|
+
config: config2,
|
|
21
|
+
logger: locator.context.logger
|
|
22
|
+
});
|
|
23
|
+
const api = await BridgeActor.create({
|
|
24
|
+
account,
|
|
25
|
+
config: config2,
|
|
26
|
+
locator
|
|
27
|
+
});
|
|
28
|
+
const actors = [
|
|
29
|
+
api
|
|
30
|
+
].filter(exists);
|
|
31
|
+
for (const actor of actors) {
|
|
32
|
+
await orchestrator.registerActor(actor);
|
|
33
|
+
}
|
|
34
|
+
await orchestrator.start();
|
|
35
|
+
}, "runBridge");
|
|
27
36
|
|
|
28
37
|
// src/commands/rewardRedemption/runRewardRedemptionApi.ts
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
import { exists as exists2 } from "@xylabs/sdk-js";
|
|
39
|
+
import { initRewardsRedemptionApiWallet } from "@xyo-network/chain-orchestration";
|
|
40
|
+
import { RewardRedemptionActor } from "@xyo-network/chain-reward-redemption";
|
|
41
|
+
async function runRewardRedemptionApi(config2, orchestrator, locator) {
|
|
42
|
+
const account = await initRewardsRedemptionApiWallet({
|
|
43
|
+
config: config2,
|
|
44
|
+
logger: locator.context.logger
|
|
45
|
+
});
|
|
46
|
+
const rewardRedemption = await RewardRedemptionActor.create({
|
|
47
|
+
account,
|
|
48
|
+
config: config2,
|
|
49
|
+
locator
|
|
50
|
+
});
|
|
51
|
+
const actors = [
|
|
52
|
+
rewardRedemption
|
|
53
|
+
].filter(exists2);
|
|
54
|
+
for (const actor of actors) {
|
|
55
|
+
await orchestrator.registerActor(actor);
|
|
56
|
+
}
|
|
57
|
+
await orchestrator.start();
|
|
32
58
|
}
|
|
33
59
|
__name(runRewardRedemptionApi, "runRewardRedemptionApi");
|
|
34
60
|
|
|
@@ -56,12 +82,12 @@ var XL1LogoColorizedAscii = `\x1B[38;2;128;128;128m\xA0\xA0\xA0\xA0\xA0\xA0\xA0\
|
|
|
56
82
|
import { Base, ConsoleLogger, isDefined, LogLevel, SilentLogger } from "@xylabs/sdk-js";
|
|
57
83
|
var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
58
84
|
let logger;
|
|
59
|
-
if (config2.silent) {
|
|
85
|
+
if (config2.log.silent) {
|
|
60
86
|
logger = new SilentLogger();
|
|
61
87
|
} else {
|
|
62
88
|
let level;
|
|
63
|
-
if (isDefined(config2.logLevel)) {
|
|
64
|
-
const parsed = LogLevel[config2.logLevel.toLowerCase()];
|
|
89
|
+
if (isDefined(config2.log.logLevel)) {
|
|
90
|
+
const parsed = LogLevel[config2.log.logLevel.toLowerCase()];
|
|
65
91
|
if (isDefined(parsed)) level = parsed;
|
|
66
92
|
}
|
|
67
93
|
logger = new ConsoleLogger(level);
|
|
@@ -70,6 +96,294 @@ var initLogger = /* @__PURE__ */ __name((config2) => {
|
|
|
70
96
|
return logger;
|
|
71
97
|
}, "initLogger");
|
|
72
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, SimpleFinalizationViewer, SimpleMempoolRunner, SimpleMempoolViewer, SimpleNetworkStakeViewer, SimpleStepRewardsByPositionViewer, SimpleStepRewardsByStakerViewer, SimpleStepRewardsByStepViewer, SimpleStepRewardsTotalViewer, SimpleStepRewardsViewer, SimpleStepViewer, SimpleTimeSyncViewer, SimpleWindowedBlockViewer, SimpleXyoConnectionRunner, SimpleXyoConnectionViewer, 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
|
+
]);
|
|
208
|
+
locator.freeze();
|
|
209
|
+
return locator;
|
|
210
|
+
}
|
|
211
|
+
__name(localLocatorFromConfig, "localLocatorFromConfig");
|
|
212
|
+
async function remoteLocatorFromConfig(config2, context) {
|
|
213
|
+
const balancesSummaryMap = assertEx(await initBalanceSummaryMap(context), () => "Balance Summary Map not initialized");
|
|
214
|
+
const transfersSummaryMap = assertEx(await initTransferSummaryMap(context), () => "Transfer Summary Map not initialized");
|
|
215
|
+
const wallet = await initApiWallet(context);
|
|
216
|
+
const { readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist } = await initServerNode({
|
|
217
|
+
...context,
|
|
218
|
+
wallet,
|
|
219
|
+
transfersSummaryMap,
|
|
220
|
+
balancesSummaryMap
|
|
221
|
+
});
|
|
222
|
+
const locator = new ProviderFactoryLocator(context);
|
|
223
|
+
locator.registerMany([
|
|
224
|
+
SimpleMempoolViewer.factory(SimpleMempoolViewer.dependencies, {
|
|
225
|
+
pendingTransactionsArchivist,
|
|
226
|
+
pendingBlocksArchivist
|
|
227
|
+
}),
|
|
228
|
+
SimpleMempoolRunner.factory(SimpleMempoolRunner.dependencies, {
|
|
229
|
+
pendingTransactionsArchivist,
|
|
230
|
+
pendingBlocksArchivist
|
|
231
|
+
}),
|
|
232
|
+
SimpleAccountBalanceViewer.factory(SimpleAccountBalanceViewer.dependencies, {
|
|
233
|
+
balancesSummaryMap,
|
|
234
|
+
transfersSummaryMap
|
|
235
|
+
}),
|
|
236
|
+
SimpleFinalizationViewer.factory(SimpleFinalizationViewer.dependencies, {
|
|
237
|
+
finalizedArchivist: readonlyChainArchivist
|
|
238
|
+
}),
|
|
239
|
+
SimpleBlockViewer.factory(SimpleBlockViewer.dependencies, {
|
|
240
|
+
finalizedArchivist: readonlyChainArchivist
|
|
241
|
+
}),
|
|
242
|
+
SimpleWindowedBlockViewer.factory(SimpleWindowedBlockViewer.dependencies, {
|
|
243
|
+
maxWindowSize: 1e4,
|
|
244
|
+
syncInterval: 1e4
|
|
245
|
+
}),
|
|
246
|
+
SimpleXyoViewer.factory(SimpleXyoViewer.dependencies, {
|
|
247
|
+
finalizedArchivist: readonlyChainArchivist
|
|
248
|
+
})
|
|
249
|
+
]);
|
|
250
|
+
locator.freeze();
|
|
251
|
+
return locator;
|
|
252
|
+
}
|
|
253
|
+
__name(remoteLocatorFromConfig, "remoteLocatorFromConfig");
|
|
254
|
+
async function producerLocatorFromConfig(config2, context) {
|
|
255
|
+
const { logger } = context;
|
|
256
|
+
const account = await initProducerAccount({
|
|
257
|
+
config: config2
|
|
258
|
+
});
|
|
259
|
+
const locator = new ProviderFactoryLocator(context);
|
|
260
|
+
const rewardAddress = asAddress(config2.actors.producer.rewardAddress ?? account.address, true);
|
|
261
|
+
logger?.info(`Using reward address ${rewardAddress}`);
|
|
262
|
+
if (rewardAddress === account.address) {
|
|
263
|
+
logger?.warn(`Using producer account address as reward address: ${account.address}`);
|
|
264
|
+
}
|
|
265
|
+
const remoteUrl = config2.remote.rpc?.url;
|
|
266
|
+
if (isString(remoteUrl)) {
|
|
267
|
+
const transportFactory = /* @__PURE__ */ __name((schemas) => new HttpRpcTransport(remoteUrl, schemas), "transportFactory");
|
|
268
|
+
locator.registerMany([
|
|
269
|
+
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {
|
|
270
|
+
transport: await transportFactory(MempoolViewerRpcSchemas)
|
|
271
|
+
}),
|
|
272
|
+
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {
|
|
273
|
+
transport: await transportFactory(MempoolRunnerRpcSchemas)
|
|
274
|
+
}),
|
|
275
|
+
JsonRpcAccountBalanceViewer.factory(JsonRpcAccountBalanceViewer.dependencies, {
|
|
276
|
+
transport: await transportFactory(AccountBalanceViewerRpcSchemas)
|
|
277
|
+
}),
|
|
278
|
+
JsonRpcFinalizationViewer.factory(JsonRpcFinalizationViewer.dependencies, {
|
|
279
|
+
transport: await transportFactory(FinalizationViewerRpcSchemas)
|
|
280
|
+
}),
|
|
281
|
+
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {
|
|
282
|
+
transport: await transportFactory(BlockViewerRpcSchemas)
|
|
283
|
+
})
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
locator.registerMany([
|
|
287
|
+
SimpleBlockRewardViewer.factory(SimpleBlockRewardViewer.dependencies, {}),
|
|
288
|
+
SimpleBlockRunner.factory(SimpleBlockRunner.dependencies, {
|
|
289
|
+
account,
|
|
290
|
+
rewardAddress
|
|
291
|
+
})
|
|
292
|
+
]);
|
|
293
|
+
locator.freeze();
|
|
294
|
+
return locator;
|
|
295
|
+
}
|
|
296
|
+
__name(producerLocatorFromConfig, "producerLocatorFromConfig");
|
|
297
|
+
function apiLocatorFromConfig(config2, context) {
|
|
298
|
+
const locator = new ProviderFactoryLocator(context);
|
|
299
|
+
locator.registerMany([]);
|
|
300
|
+
locator.freeze();
|
|
301
|
+
return locator;
|
|
302
|
+
}
|
|
303
|
+
__name(apiLocatorFromConfig, "apiLocatorFromConfig");
|
|
304
|
+
function mempoolLocatorFromConfig(config2, context) {
|
|
305
|
+
const locator = new ProviderFactoryLocator(context);
|
|
306
|
+
locator.registerMany([]);
|
|
307
|
+
locator.freeze();
|
|
308
|
+
return locator;
|
|
309
|
+
}
|
|
310
|
+
__name(mempoolLocatorFromConfig, "mempoolLocatorFromConfig");
|
|
311
|
+
async function bridgeLocatorFromConfig(config2, context) {
|
|
312
|
+
const locator = new ProviderFactoryLocator(context);
|
|
313
|
+
const { mnemonic } = config2.actors.bridge;
|
|
314
|
+
const walletPhrase = isDefined2(mnemonic) ? mnemonic : HDWallet.generateMnemonic();
|
|
315
|
+
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase);
|
|
316
|
+
const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO);
|
|
317
|
+
const remoteUrl = config2.actors.bridge.remote.rpc?.url;
|
|
318
|
+
if (isString(remoteUrl)) {
|
|
319
|
+
const transportFactory = /* @__PURE__ */ __name((schemas) => new HttpRpcTransport(remoteUrl, schemas), "transportFactory");
|
|
320
|
+
locator.registerMany([
|
|
321
|
+
JsonRpcMempoolViewer.factory(JsonRpcMempoolViewer.dependencies, {
|
|
322
|
+
transport: await transportFactory(MempoolViewerRpcSchemas)
|
|
323
|
+
}),
|
|
324
|
+
JsonRpcMempoolRunner.factory(JsonRpcMempoolRunner.dependencies, {
|
|
325
|
+
transport: await transportFactory(MempoolRunnerRpcSchemas)
|
|
326
|
+
}),
|
|
327
|
+
JsonRpcAccountBalanceViewer.factory(JsonRpcAccountBalanceViewer.dependencies, {
|
|
328
|
+
transport: await transportFactory(AccountBalanceViewerRpcSchemas)
|
|
329
|
+
}),
|
|
330
|
+
JsonRpcFinalizationViewer.factory(JsonRpcFinalizationViewer.dependencies, {
|
|
331
|
+
transport: await transportFactory(FinalizationViewerRpcSchemas)
|
|
332
|
+
}),
|
|
333
|
+
JsonRpcBlockViewer.factory(JsonRpcBlockViewer.dependencies, {
|
|
334
|
+
transport: await transportFactory(BlockViewerRpcSchemas)
|
|
335
|
+
})
|
|
336
|
+
]);
|
|
337
|
+
}
|
|
338
|
+
locator.registerMany([
|
|
339
|
+
SimpleXyoSigner.factory(SimpleXyoSigner.dependencies, {
|
|
340
|
+
account: signerAccount
|
|
341
|
+
}),
|
|
342
|
+
SimpleXyoRunner.factory(SimpleXyoRunner.dependencies, {}),
|
|
343
|
+
SimpleXyoConnectionRunner.factory(SimpleXyoConnectionRunner.dependencies, {}),
|
|
344
|
+
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
345
|
+
]);
|
|
346
|
+
locator.freeze();
|
|
347
|
+
return locator;
|
|
348
|
+
}
|
|
349
|
+
__name(bridgeLocatorFromConfig, "bridgeLocatorFromConfig");
|
|
350
|
+
function rewardRedemptionLocatorFromConfig(config2, context) {
|
|
351
|
+
const locator = new ProviderFactoryLocator(context);
|
|
352
|
+
locator.registerMany([
|
|
353
|
+
SimpleXyoGatewayRunner.factory(SimpleXyoGatewayRunner.dependencies, {})
|
|
354
|
+
]);
|
|
355
|
+
locator.freeze();
|
|
356
|
+
return locator;
|
|
357
|
+
}
|
|
358
|
+
__name(rewardRedemptionLocatorFromConfig, "rewardRedemptionLocatorFromConfig");
|
|
359
|
+
async function locatorsFromConfig(actors, config2, context) {
|
|
360
|
+
const result = {
|
|
361
|
+
_root: await rootLocatorFromConfig(config2, context)
|
|
362
|
+
};
|
|
363
|
+
const producer = actors.includes("producer") ? await producerLocatorFromConfig(config2, result._root.context) : void 0;
|
|
364
|
+
if (producer) {
|
|
365
|
+
result.producer = producer;
|
|
366
|
+
}
|
|
367
|
+
const api = actors.includes("api") ? await apiLocatorFromConfig(config2, result._root.context) : void 0;
|
|
368
|
+
if (api) {
|
|
369
|
+
result.api = api;
|
|
370
|
+
}
|
|
371
|
+
const mempool = actors.includes("mempool") ? await mempoolLocatorFromConfig(config2, result._root.context) : void 0;
|
|
372
|
+
if (mempool) {
|
|
373
|
+
result.mempool = mempool;
|
|
374
|
+
}
|
|
375
|
+
const bridge = actors.includes("bridge") ? await bridgeLocatorFromConfig(config2, result._root.context) : void 0;
|
|
376
|
+
if (bridge) {
|
|
377
|
+
result.bridge = bridge;
|
|
378
|
+
}
|
|
379
|
+
const rewardRedemption = actors.includes("rewardRedemption") ? await rewardRedemptionLocatorFromConfig(config2, result._root.context) : void 0;
|
|
380
|
+
if (rewardRedemption) {
|
|
381
|
+
result.rewardRedemption = rewardRedemption;
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
__name(locatorsFromConfig, "locatorsFromConfig");
|
|
386
|
+
|
|
73
387
|
// src/optionsFromGlobalZodRegistry.ts
|
|
74
388
|
import { isUsageMeta } from "@xyo-network/xl1-sdk";
|
|
75
389
|
import { globalRegistry } from "zod";
|
|
@@ -88,7 +402,7 @@ var optionsFromGlobalZodRegistry = /* @__PURE__ */ __name(() => {
|
|
|
88
402
|
}, "optionsFromGlobalZodRegistry");
|
|
89
403
|
|
|
90
404
|
// src/tryParseConfig.ts
|
|
91
|
-
import { isDefined as
|
|
405
|
+
import { isDefined as isDefined3, isNull } from "@xylabs/sdk-js";
|
|
92
406
|
import { ConfigZod } from "@xyo-network/xl1-sdk";
|
|
93
407
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
94
408
|
var configName = "xyo";
|
|
@@ -98,7 +412,7 @@ var tryParseConfig = /* @__PURE__ */ __name(() => {
|
|
|
98
412
|
const result = explorer.search();
|
|
99
413
|
if (!isNull(result)) {
|
|
100
414
|
const section = result?.config?.[configSection];
|
|
101
|
-
if (
|
|
415
|
+
if (isDefined3(section) && typeof section === "object") {
|
|
102
416
|
return ConfigZod.parse(section);
|
|
103
417
|
}
|
|
104
418
|
}
|
|
@@ -128,7 +442,7 @@ var waitForHostPort = /* @__PURE__ */ __name((host, port) => {
|
|
|
128
442
|
|
|
129
443
|
// src/runCLI.ts
|
|
130
444
|
var configuration;
|
|
131
|
-
var version =
|
|
445
|
+
var version = isDefined4("1.19.8") ? "1.19.8" : "unknown";
|
|
132
446
|
function resolveConfig(config2) {
|
|
133
447
|
const logger = console;
|
|
134
448
|
const defaultChainId = toAddress("1");
|
|
@@ -140,11 +454,13 @@ function resolveConfig(config2) {
|
|
|
140
454
|
return resolved;
|
|
141
455
|
}
|
|
142
456
|
__name(resolveConfig, "resolveConfig");
|
|
143
|
-
var
|
|
457
|
+
var getLocatorsFromConfig = /* @__PURE__ */ __name(async (actors, configuration2) => {
|
|
144
458
|
const logger = initLogger(configuration2);
|
|
145
459
|
const orchestrator = await Orchestrator.create({
|
|
146
460
|
logger
|
|
147
461
|
});
|
|
462
|
+
const context = await contextFromConfigWithoutLocator(configuration2, logger, "xl1-cli", version);
|
|
463
|
+
const locators = await locatorsFromConfig(actors, configuration2, context);
|
|
148
464
|
process.on("SIGINT", () => {
|
|
149
465
|
void (async () => {
|
|
150
466
|
try {
|
|
@@ -159,10 +475,10 @@ var getContextFromConfig = /* @__PURE__ */ __name(async (configuration2) => {
|
|
|
159
475
|
})();
|
|
160
476
|
});
|
|
161
477
|
return {
|
|
162
|
-
|
|
478
|
+
locators,
|
|
163
479
|
orchestrator
|
|
164
480
|
};
|
|
165
|
-
}, "
|
|
481
|
+
}, "getLocatorsFromConfig");
|
|
166
482
|
async function runCLI() {
|
|
167
483
|
const y = yargs(hideBin(process.argv));
|
|
168
484
|
const argv = y.usage(`
|
|
@@ -194,6 +510,15 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
194
510
|
throw validatedConfigResult.error;
|
|
195
511
|
}
|
|
196
512
|
configuration = validatedConfigResult.data;
|
|
513
|
+
const { actors, ...rootConfig } = configuration;
|
|
514
|
+
const actorNames = Object.keys(actors);
|
|
515
|
+
for (const actorName of actorNames) {
|
|
516
|
+
configuration.actors[actorName] = deepMerge(rootConfig ?? {}, configuration.actors[actorName] ?? {});
|
|
517
|
+
}
|
|
518
|
+
if (argv2["dump-config"]) {
|
|
519
|
+
console.log(JSON.stringify(configuration, null, 2));
|
|
520
|
+
process.exit(0);
|
|
521
|
+
}
|
|
197
522
|
} catch (err) {
|
|
198
523
|
if (isZodError(err)) {
|
|
199
524
|
console.error(`Zod error: ${err.message}`);
|
|
@@ -206,71 +531,69 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
206
531
|
}).options(optionsFromGlobalZodRegistry()).wrap(y.terminalWidth()).command("api", "Run a XL1 API Node", (yargs2) => {
|
|
207
532
|
return yargs2.command("$0", "Run a XL1 API Node", () => {
|
|
208
533
|
}, async () => {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
singletons: {}
|
|
214
|
-
});
|
|
534
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
535
|
+
"api"
|
|
536
|
+
], configuration);
|
|
537
|
+
await runApi(configuration, orchestrator, locators["api"]);
|
|
215
538
|
});
|
|
216
539
|
}).command("bridge", "Run a XL1 Bridge Node", (yargs2) => {
|
|
217
540
|
return yargs2.command("$0", "Run a XL1 Bridge Node", () => {
|
|
218
541
|
}, async () => {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
542
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
543
|
+
"bridge"
|
|
544
|
+
], configuration);
|
|
545
|
+
await runBridge(configuration, orchestrator, locators["bridge"]);
|
|
224
546
|
});
|
|
225
547
|
}).command("mempool", "Run a XL1 Mempool Node", (yargs2) => {
|
|
226
548
|
return yargs2.command("$0", "Run a XL1 Mempool Node", () => {
|
|
227
549
|
}, async () => {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
});
|
|
550
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
551
|
+
"mempool"
|
|
552
|
+
], configuration);
|
|
553
|
+
await runMempool(configuration, orchestrator, locators["mempool"]);
|
|
233
554
|
});
|
|
234
555
|
}).command("producer", "Run a XL1 Producer Node", (yargs2) => {
|
|
235
556
|
return yargs2.command("$0", "Run a XL1 Producer Node", () => {
|
|
236
557
|
}, async () => {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
singletons: {}
|
|
242
|
-
});
|
|
558
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
559
|
+
"producer"
|
|
560
|
+
], configuration);
|
|
561
|
+
await runProducer(configuration, orchestrator, locators["producer"]);
|
|
243
562
|
});
|
|
244
563
|
}).command("reward-redemption-api", "Run a XL1 Rewards Redemption API Node", (yargs2) => {
|
|
245
564
|
return yargs2.command("$0", "Run a XL1 Rewards Redemption API Node", () => {
|
|
246
565
|
}, async () => {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
});
|
|
566
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
567
|
+
"rewardRedemption"
|
|
568
|
+
], configuration);
|
|
569
|
+
await runRewardRedemptionApi(configuration, orchestrator, locators["rewardRedemption"]);
|
|
252
570
|
});
|
|
253
571
|
}).command("$0", "Run a full XL1 Node", () => {
|
|
254
572
|
}, async () => {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
573
|
+
const actors = [
|
|
574
|
+
"producer",
|
|
575
|
+
"api"
|
|
576
|
+
];
|
|
577
|
+
if (configuration.actors.mempool.enabled) {
|
|
578
|
+
actors.push("mempool");
|
|
579
|
+
}
|
|
580
|
+
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
581
|
+
"api",
|
|
582
|
+
"producer"
|
|
583
|
+
], configuration);
|
|
584
|
+
if (configuration.actors.mempool.enabled) {
|
|
585
|
+
await runMempool(configuration, orchestrator, locators["mempool"]);
|
|
586
|
+
await waitForHostPort(configuration.actors.mempool.host, configuration.actors.mempool.port);
|
|
587
|
+
}
|
|
588
|
+
await runApi(configuration, orchestrator, locators["api"]);
|
|
589
|
+
await waitForHostPort(configuration.actors.api.host, configuration.actors.api.port);
|
|
590
|
+
await runProducer(configuration, orchestrator, locators["producer"]);
|
|
591
|
+
}).options({
|
|
592
|
+
"dump-config": {
|
|
593
|
+
type: "boolean",
|
|
594
|
+
description: "Just process the configuration and print the resolved config to stdout, then exit.",
|
|
595
|
+
default: false
|
|
262
596
|
}
|
|
263
|
-
await runApi({
|
|
264
|
-
...context,
|
|
265
|
-
config: configuration,
|
|
266
|
-
singletons: {}
|
|
267
|
-
});
|
|
268
|
-
await waitForHostPort(configuration.api.host, configuration.api.port);
|
|
269
|
-
await runProducer({
|
|
270
|
-
...context,
|
|
271
|
-
config: configuration,
|
|
272
|
-
singletons: {}
|
|
273
|
-
});
|
|
274
597
|
}).help().alias("help", "h").version(version).argv;
|
|
275
598
|
await argv;
|
|
276
599
|
}
|