@xyo-network/chain-api 1.15.27 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.mjs +258 -77
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/manifest/getLocator.d.ts +3 -1
- package/dist/node/manifest/getLocator.d.ts.map +1 -1
- package/dist/node/manifest/getNode.d.ts.map +1 -1
- package/dist/node/manifest/public/WithMempool/index.d.ts +6 -0
- package/dist/node/manifest/public/WithMempool/index.d.ts.map +1 -0
- package/dist/node/manifest/public/WithoutMempool/index.d.ts +6 -0
- package/dist/node/manifest/public/WithoutMempool/index.d.ts.map +1 -0
- package/dist/node/manifest/public/index.d.ts +2 -13
- package/dist/node/manifest/public/index.d.ts.map +1 -1
- package/dist/node/server/app.d.ts +3 -2
- package/dist/node/server/app.d.ts.map +1 -1
- package/dist/node/server/routes/addRoutes.d.ts +3 -2
- package/dist/node/server/routes/addRoutes.d.ts.map +1 -1
- package/dist/node/server/routes/address/get/get.d.ts.map +1 -1
- package/dist/node/server/routes/rpc/routes/addRpcRoutes.d.ts +3 -2
- package/dist/node/server/routes/rpc/routes/addRpcRoutes.d.ts.map +1 -1
- package/dist/node/server/server.d.ts.map +1 -1
- package/package.json +52 -52
- package/src/manifest/getLocator.ts +20 -7
- package/src/manifest/getNode.ts +4 -2
- package/src/manifest/public/{Chain.json → WithMempool/Chain.json} +1 -1
- package/src/manifest/public/{Pending.json → WithMempool/Pending.json} +1 -1
- package/src/manifest/public/WithMempool/index.ts +20 -0
- package/src/manifest/public/WithoutMempool/Chain.json +97 -0
- package/src/manifest/public/WithoutMempool/Pending.json +35 -0
- package/src/manifest/public/WithoutMempool/index.ts +20 -0
- package/src/manifest/public/index.ts +2 -20
- package/src/server/app.ts +6 -3
- package/src/server/routes/addRoutes.ts +11 -3
- package/src/server/routes/address/get/get.ts +8 -10
- package/src/server/routes/rpc/routes/addRpcRoutes.ts +41 -7
- package/src/server/server.ts +10 -6
- package/dist/node/manifest/public/spec/Node.spec.d.ts +0 -2
- package/dist/node/manifest/public/spec/Node.spec.d.ts.map +0 -1
- package/src/manifest/public/spec/Node.spec.ts +0 -32
package/dist/node/index.mjs
CHANGED
|
@@ -25,16 +25,16 @@ var addInstrumentation = /* @__PURE__ */ __name(() => {
|
|
|
25
25
|
import { StatusCodes as StatusCodes3 } from "http-status-codes";
|
|
26
26
|
|
|
27
27
|
// src/server/routes/address/get/get.ts
|
|
28
|
-
import { assertEx } from "@xylabs/assert";
|
|
29
28
|
import { asyncHandler } from "@xylabs/express";
|
|
30
|
-
import { asAddress
|
|
31
|
-
import {
|
|
29
|
+
import { asAddress } from "@xylabs/hex";
|
|
30
|
+
import { isDefined } from "@xylabs/typeof";
|
|
31
|
+
import { isModuleName } from "@xyo-network/module-model";
|
|
32
32
|
import { StatusCodes } from "http-status-codes";
|
|
33
33
|
var handler = /* @__PURE__ */ __name(async (req, res, next) => {
|
|
34
|
-
const { address:
|
|
34
|
+
const { address: moduleIdentifier } = req.params;
|
|
35
35
|
const { node } = req.app;
|
|
36
|
-
const address = asAddress(
|
|
37
|
-
if (address
|
|
36
|
+
const address = asAddress(moduleIdentifier);
|
|
37
|
+
if (isDefined(address)) {
|
|
38
38
|
let mod = node.address === address ? node : await node.resolve(address, {
|
|
39
39
|
direction: "down"
|
|
40
40
|
});
|
|
@@ -43,14 +43,12 @@ var handler = /* @__PURE__ */ __name(async (req, res, next) => {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (
|
|
47
|
-
const moduleIdentifier = toAddress(rawAddress);
|
|
46
|
+
if (isModuleName(moduleIdentifier)) {
|
|
48
47
|
const mod = await node.resolve(moduleIdentifier, {
|
|
49
48
|
direction: "down"
|
|
50
49
|
});
|
|
51
50
|
if (mod) {
|
|
52
|
-
|
|
53
|
-
res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${moduleAddress}`);
|
|
51
|
+
res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${mod.address}`);
|
|
54
52
|
return;
|
|
55
53
|
}
|
|
56
54
|
}
|
|
@@ -59,9 +57,9 @@ var handler = /* @__PURE__ */ __name(async (req, res, next) => {
|
|
|
59
57
|
var getAddress = asyncHandler(handler);
|
|
60
58
|
|
|
61
59
|
// src/server/routes/address/post/post.ts
|
|
62
|
-
import { assertEx
|
|
60
|
+
import { assertEx } from "@xylabs/assert";
|
|
63
61
|
import { asyncHandler as asyncHandler2 } from "@xylabs/express";
|
|
64
|
-
import { asAddress as asAddress2, isAddress, toAddress
|
|
62
|
+
import { asAddress as asAddress2, isAddress, toAddress } from "@xylabs/hex";
|
|
65
63
|
import { isQueryBoundWitness } from "@xyo-network/boundwitness-model";
|
|
66
64
|
import { ModuleErrorBuilder } from "@xyo-network/module-abstract";
|
|
67
65
|
import { StatusCodes as StatusCodes2 } from "http-status-codes";
|
|
@@ -110,7 +108,7 @@ var handler2 = /* @__PURE__ */ __name(async (req, res, next) => {
|
|
|
110
108
|
return returnError(StatusCodes2.BAD_REQUEST, "Invalid query boundwitness");
|
|
111
109
|
}
|
|
112
110
|
let modules = [];
|
|
113
|
-
const normalizedAddress =
|
|
111
|
+
const normalizedAddress = toAddress(address);
|
|
114
112
|
if (node.address === normalizedAddress) modules = [
|
|
115
113
|
node
|
|
116
114
|
];
|
|
@@ -127,7 +125,7 @@ var handler2 = /* @__PURE__ */ __name(async (req, res, next) => {
|
|
|
127
125
|
direction: "down"
|
|
128
126
|
});
|
|
129
127
|
if (byName) {
|
|
130
|
-
const moduleAddress =
|
|
128
|
+
const moduleAddress = assertEx(byName?.address, () => "Error redirecting to module by address");
|
|
131
129
|
res.redirect(StatusCodes2.TEMPORARY_REDIRECT, `/${moduleAddress}`);
|
|
132
130
|
return;
|
|
133
131
|
} else {
|
|
@@ -176,7 +174,7 @@ var addNodeRoutes = /* @__PURE__ */ __name((app) => {
|
|
|
176
174
|
// src/server/routes/dataLake/archivistMiddleware.ts
|
|
177
175
|
import { setRawResponseFormat } from "@xylabs/express";
|
|
178
176
|
import { asHash } from "@xylabs/hex";
|
|
179
|
-
import { isDefined } from "@xylabs/typeof";
|
|
177
|
+
import { isDefined as isDefined2 } from "@xylabs/typeof";
|
|
180
178
|
import { asArchivistInstance } from "@xyo-network/archivist-model";
|
|
181
179
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
182
180
|
import { isAnyPayload, isSequence } from "@xyo-network/payload-model";
|
|
@@ -189,7 +187,7 @@ var resolveArchivist = /* @__PURE__ */ __name(async (node, archivistModuleIdenti
|
|
|
189
187
|
}, "resolveArchivist");
|
|
190
188
|
var archivistInstance;
|
|
191
189
|
var getArchivist = /* @__PURE__ */ __name(async (node, archivistModuleIdentifier) => {
|
|
192
|
-
if (
|
|
190
|
+
if (isDefined2(archivistInstance)) return archivistInstance;
|
|
193
191
|
archivistInstance = await resolveArchivist(node, archivistModuleIdentifier);
|
|
194
192
|
return archivistInstance;
|
|
195
193
|
}, "getArchivist");
|
|
@@ -211,8 +209,8 @@ var archivistMiddleware = /* @__PURE__ */ __name((options) => {
|
|
|
211
209
|
router.get("/next", async (req, res) => {
|
|
212
210
|
setRawResponseFormat(res);
|
|
213
211
|
const cursor = isSequence(req.query.cursor) ? req.query.cursor : void 0;
|
|
214
|
-
const limit =
|
|
215
|
-
const open =
|
|
212
|
+
const limit = isDefined2(req.query.limit) ? Number(req.query.limit) : void 0;
|
|
213
|
+
const open = isDefined2(req.query.open) ? Boolean(req.query.open) : void 0;
|
|
216
214
|
const order = req.query.order === "asc" ? "asc" : "desc";
|
|
217
215
|
const options2 = {
|
|
218
216
|
limit,
|
|
@@ -228,14 +226,14 @@ var archivistMiddleware = /* @__PURE__ */ __name((options) => {
|
|
|
228
226
|
setRawResponseFormat(res);
|
|
229
227
|
const options2 = req.body;
|
|
230
228
|
const archivist = await getArchivist(node, archivistModuleIdentifier);
|
|
231
|
-
const result = await (
|
|
229
|
+
const result = await (isDefined2(options2) ? archivist.next(options2) : archivist.next());
|
|
232
230
|
res.status(200).json(result);
|
|
233
231
|
});
|
|
234
232
|
router.get("/get/:hash", async (req, res) => {
|
|
235
233
|
setRawResponseFormat(res);
|
|
236
234
|
const { hash: rawHash } = req.params;
|
|
237
235
|
const hash = asHash(rawHash);
|
|
238
|
-
if (
|
|
236
|
+
if (isDefined2(hash)) {
|
|
239
237
|
const archivist = await getArchivist(node, archivistModuleIdentifier);
|
|
240
238
|
const [payload] = await archivist.get([
|
|
241
239
|
hash
|
|
@@ -262,27 +260,46 @@ var addDataLakeRoutes = /* @__PURE__ */ __name((app) => {
|
|
|
262
260
|
|
|
263
261
|
// src/server/routes/rpc/routes/addRpcRoutes.ts
|
|
264
262
|
import { setRawResponseFormat as setRawResponseFormat2 } from "@xylabs/express";
|
|
265
|
-
import { NodeXyoViewer } from "@xyo-network/chain-rpc";
|
|
263
|
+
import { NodeNetworkStakeViewer, NodeStepRewardsByPositionViewer, NodeXyoViewer } from "@xyo-network/chain-rpc";
|
|
264
|
+
import { StepSizes } from "@xyo-network/xl1-protocol";
|
|
266
265
|
import { RewardMultipliers } from "@xyo-network/xl1-protocol-sdk";
|
|
267
266
|
import { NodeXyoRunner, rpcEngineFromConnection, XyoBaseConnection } from "@xyo-network/xl1-rpc";
|
|
268
|
-
|
|
267
|
+
import { Semaphore } from "async-mutex";
|
|
268
|
+
var addRpcRoutes = /* @__PURE__ */ __name(async (app, transferSummaryMap, stakedChainContext, initRewardsCache) => {
|
|
269
269
|
const { node } = app;
|
|
270
270
|
const runner = new NodeXyoRunner(node);
|
|
271
|
+
const networkStakeViewer = await NodeNetworkStakeViewer.create({
|
|
272
|
+
context: stakedChainContext
|
|
273
|
+
});
|
|
274
|
+
console.log("Initializing NodeNetworkStakeViewer...");
|
|
275
|
+
await networkStakeViewer.start();
|
|
276
|
+
console.log("Initialized NodeNetworkStakeViewer.");
|
|
271
277
|
const viewer = await NodeXyoViewer.create({
|
|
272
278
|
node,
|
|
273
|
-
eventReader,
|
|
274
|
-
stakedChainContext,
|
|
275
279
|
rewardMultipliers: RewardMultipliers,
|
|
276
|
-
initRewardsCache
|
|
280
|
+
initRewardsCache,
|
|
281
|
+
context: stakedChainContext,
|
|
282
|
+
transfersSummaryContext: {
|
|
283
|
+
...stakedChainContext,
|
|
284
|
+
stepSemaphores: StepSizes.map(() => new Semaphore(20)),
|
|
285
|
+
summaryMap: transferSummaryMap
|
|
286
|
+
}
|
|
277
287
|
});
|
|
278
|
-
console.log("Initializing
|
|
288
|
+
console.log("Initializing NodeXyoViewer...");
|
|
279
289
|
await viewer.start();
|
|
280
|
-
console.log("Initialized
|
|
290
|
+
console.log("Initialized NodeXyoViewer.");
|
|
291
|
+
const stepRewardsByPositionViewer = await NodeStepRewardsByPositionViewer.create({
|
|
292
|
+
context: stakedChainContext,
|
|
293
|
+
rewardMultipliers: RewardMultipliers
|
|
294
|
+
});
|
|
295
|
+
console.log("Initializing NodeStepRewardsByPositionViewer...");
|
|
296
|
+
await stepRewardsByPositionViewer.start();
|
|
297
|
+
console.log("Initialized NodeStepRewardsByPositionViewer.");
|
|
281
298
|
const connection = new XyoBaseConnection({
|
|
282
299
|
runner,
|
|
283
300
|
viewer
|
|
284
301
|
});
|
|
285
|
-
const engine = rpcEngineFromConnection(connection);
|
|
302
|
+
const engine = rpcEngineFromConnection(connection, networkStakeViewer);
|
|
286
303
|
app.post("/rpc", (req, res) => {
|
|
287
304
|
setRawResponseFormat2(res);
|
|
288
305
|
engine.handle(req.body, (_, rpcResponse) => {
|
|
@@ -292,14 +309,14 @@ var addRpcRoutes = /* @__PURE__ */ __name(async (app, eventReader, stakedChainCo
|
|
|
292
309
|
}, "addRpcRoutes");
|
|
293
310
|
|
|
294
311
|
// src/server/routes/addRoutes.ts
|
|
295
|
-
var addRoutes = /* @__PURE__ */ __name(async (app,
|
|
296
|
-
await addRpcRoutes(app,
|
|
312
|
+
var addRoutes = /* @__PURE__ */ __name(async (app, transferSummaryMap, stakedChainContext, initRewardsCache) => {
|
|
313
|
+
await addRpcRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache);
|
|
297
314
|
addDataLakeRoutes(app);
|
|
298
315
|
addNodeRoutes(app);
|
|
299
316
|
}, "addRoutes");
|
|
300
317
|
|
|
301
318
|
// src/server/app.ts
|
|
302
|
-
var getApp = /* @__PURE__ */ __name(async (node,
|
|
319
|
+
var getApp = /* @__PURE__ */ __name(async (node, transferSummaryMap, stakedChainContext, initRewardsCache) => {
|
|
303
320
|
addInstrumentation();
|
|
304
321
|
const app = express2();
|
|
305
322
|
app.set("etag", false);
|
|
@@ -314,15 +331,15 @@ var getApp = /* @__PURE__ */ __name(async (node, eventsReader, stakedChainContex
|
|
|
314
331
|
app.use(customPoweredByHeader);
|
|
315
332
|
disableCaseSensitiveRouting(app);
|
|
316
333
|
app.node = node;
|
|
317
|
-
await addRoutes(app,
|
|
334
|
+
await addRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache);
|
|
318
335
|
app.use(standardErrors);
|
|
319
336
|
return app;
|
|
320
337
|
}, "getApp");
|
|
321
338
|
|
|
322
339
|
// src/server/server.ts
|
|
323
|
-
import { assertEx as
|
|
340
|
+
import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
324
341
|
import { toEthAddress } from "@xylabs/hex";
|
|
325
|
-
import { isDefined as
|
|
342
|
+
import { isDefined as isDefined6, isString } from "@xylabs/typeof";
|
|
326
343
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/archivist-model";
|
|
327
344
|
import { boot } from "@xyo-network/bios";
|
|
328
345
|
import { EthereumChainStake, EthereumChainStakeEvents } from "@xyo-network/chain-ethereum";
|
|
@@ -332,11 +349,11 @@ import { HDWallet } from "@xyo-network/wallet";
|
|
|
332
349
|
import { readPayloadMapFromStore } from "@xyo-network/xl1-protocol-sdk";
|
|
333
350
|
|
|
334
351
|
// src/helpers/initChainId.ts
|
|
335
|
-
import { assertEx as
|
|
352
|
+
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
336
353
|
import { hexFrom, isHex } from "@xylabs/hex";
|
|
337
|
-
import { isDefined as
|
|
354
|
+
import { isDefined as isDefined3 } from "@xylabs/typeof";
|
|
338
355
|
var getChainId = /* @__PURE__ */ __name((config) => {
|
|
339
|
-
const chainId =
|
|
356
|
+
const chainId = assertEx2(config.evm.chainId, () => "Missing config.evm.chainId");
|
|
340
357
|
if (isHex(chainId, {
|
|
341
358
|
prefix: true
|
|
342
359
|
})) {
|
|
@@ -350,8 +367,8 @@ var getChainId = /* @__PURE__ */ __name((config) => {
|
|
|
350
367
|
}, "getChainId");
|
|
351
368
|
|
|
352
369
|
// src/helpers/initInfuraProvider.ts
|
|
353
|
-
import { assertEx as
|
|
354
|
-
import { isDefined as
|
|
370
|
+
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
371
|
+
import { isDefined as isDefined4 } from "@xylabs/typeof";
|
|
355
372
|
import { InfuraWebSocketProvider } from "ethers/providers";
|
|
356
373
|
var instance;
|
|
357
374
|
var initInfuraProvider = /* @__PURE__ */ __name((config) => {
|
|
@@ -361,8 +378,8 @@ var initInfuraProvider = /* @__PURE__ */ __name((config) => {
|
|
|
361
378
|
return instance;
|
|
362
379
|
}, "initInfuraProvider");
|
|
363
380
|
var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
364
|
-
const projectId =
|
|
365
|
-
const projectSecret =
|
|
381
|
+
const projectId = assertEx3(config.evm?.infura?.projectId, () => "Missing config.evm.infura.projectId");
|
|
382
|
+
const projectSecret = assertEx3(config.evm?.infura?.projectSecret, () => "Missing config.evm.infura.projectSecret");
|
|
366
383
|
return [
|
|
367
384
|
getChainId(config),
|
|
368
385
|
projectId,
|
|
@@ -371,10 +388,10 @@ var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
|
371
388
|
}, "getInfuraProviderConfig");
|
|
372
389
|
|
|
373
390
|
// src/manifest/getLocator.ts
|
|
374
|
-
import { assertEx as
|
|
391
|
+
import { assertEx as assertEx5 } from "@xylabs/assert";
|
|
375
392
|
import { asAddress as asAddress3, ZERO_ADDRESS } from "@xylabs/hex";
|
|
376
393
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
377
|
-
import { isDefined as
|
|
394
|
+
import { isDefined as isDefined5 } from "@xylabs/typeof";
|
|
378
395
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
379
396
|
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
380
397
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
@@ -383,12 +400,12 @@ import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
|
383
400
|
import { AbstractModule, LoggerModuleStatusReporter } from "@xyo-network/module-abstract";
|
|
384
401
|
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
385
402
|
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
386
|
-
import { StepSizes } from "@xyo-network/xl1-protocol";
|
|
403
|
+
import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol";
|
|
387
404
|
import { hasMongoConfig } from "@xyo-network/xl1-protocol-sdk";
|
|
388
|
-
import { Semaphore } from "async-mutex";
|
|
405
|
+
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
389
406
|
|
|
390
407
|
// src/driver/mongo/MongoMap.ts
|
|
391
|
-
import { assertEx as
|
|
408
|
+
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
392
409
|
import { AbstractCreatable, creatable } from "@xylabs/creatable";
|
|
393
410
|
import { isNull } from "@xylabs/typeof";
|
|
394
411
|
import { LRUCache } from "lru-cache";
|
|
@@ -410,7 +427,7 @@ var MongoMap = class extends AbstractCreatable {
|
|
|
410
427
|
}
|
|
411
428
|
_getCache;
|
|
412
429
|
get sdk() {
|
|
413
|
-
return
|
|
430
|
+
return assertEx4(this.params.sdk, () => "No sdk specified");
|
|
414
431
|
}
|
|
415
432
|
async clear() {
|
|
416
433
|
this._getCache?.clear();
|
|
@@ -510,6 +527,31 @@ MongoMap = _ts_decorate([
|
|
|
510
527
|
], MongoMap);
|
|
511
528
|
|
|
512
529
|
// src/manifest/getLocator.ts
|
|
530
|
+
async function getTransferSummaryMap(config) {
|
|
531
|
+
const mongoConfig = config.storage?.mongo;
|
|
532
|
+
if (hasMongoConfig(mongoConfig)) {
|
|
533
|
+
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
534
|
+
const payloadSdkConfig = {
|
|
535
|
+
dbConnectionString,
|
|
536
|
+
dbDomain,
|
|
537
|
+
dbName,
|
|
538
|
+
dbPassword,
|
|
539
|
+
dbUserName
|
|
540
|
+
};
|
|
541
|
+
const sdkTransferSummaryMap = new BaseMongoSdk({
|
|
542
|
+
...payloadSdkConfig,
|
|
543
|
+
collection: "transfer_summary_map"
|
|
544
|
+
});
|
|
545
|
+
return await MongoMap.create({
|
|
546
|
+
sdk: sdkTransferSummaryMap,
|
|
547
|
+
getCache: {
|
|
548
|
+
enabled: true,
|
|
549
|
+
maxEntries: 5e3
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
__name(getTransferSummaryMap, "getTransferSummaryMap");
|
|
513
555
|
var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
514
556
|
const { config, logger } = context;
|
|
515
557
|
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
@@ -524,11 +566,11 @@ var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
|
524
566
|
port: 9465
|
|
525
567
|
}
|
|
526
568
|
});
|
|
527
|
-
if (
|
|
569
|
+
if (isDefined5(logger)) AbstractModule.defaultLogger = logger;
|
|
528
570
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
529
571
|
const locator = new ModuleFactoryLocator();
|
|
530
572
|
let balanceSummaryMap;
|
|
531
|
-
let transferSummaryMap;
|
|
573
|
+
let transferSummaryMap = await getTransferSummaryMap(config);
|
|
532
574
|
const mongoConfig = config.storage?.mongo;
|
|
533
575
|
if (hasMongoConfig(mongoConfig)) {
|
|
534
576
|
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
@@ -557,33 +599,22 @@ var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
|
557
599
|
maxEntries: 5e3
|
|
558
600
|
}
|
|
559
601
|
});
|
|
560
|
-
const sdkTransferSummaryMap = new BaseMongoSdk({
|
|
561
|
-
...payloadSdkConfig,
|
|
562
|
-
collection: "transfer_summary_map"
|
|
563
|
-
});
|
|
564
|
-
transferSummaryMap = await MongoMap.create({
|
|
565
|
-
sdk: sdkTransferSummaryMap,
|
|
566
|
-
getCache: {
|
|
567
|
-
enabled: true,
|
|
568
|
-
maxEntries: 5e3
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
602
|
}
|
|
572
603
|
locator.register(AddressBalanceDivinerV2.factory({
|
|
573
604
|
traceProvider,
|
|
574
605
|
meterProvider,
|
|
575
606
|
statusReporter,
|
|
576
607
|
summaryMap: balanceSummaryMap,
|
|
577
|
-
stepSemaphores:
|
|
608
|
+
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
578
609
|
}));
|
|
579
610
|
locator.register(AddressTransferDiviner.factory({
|
|
580
611
|
traceProvider,
|
|
581
612
|
meterProvider,
|
|
582
613
|
statusReporter,
|
|
583
614
|
summaryMap: transferSummaryMap,
|
|
584
|
-
stepSemaphores:
|
|
615
|
+
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
585
616
|
}));
|
|
586
|
-
const chainId =
|
|
617
|
+
const chainId = isDefined5(config.chain.id) ? assertEx5(asAddress3(config.chain.id), () => "chain.id must be an Address") : ZERO_ADDRESS;
|
|
587
618
|
locator.register(HeadValidationDiviner.factory({
|
|
588
619
|
traceProvider,
|
|
589
620
|
meterProvider,
|
|
@@ -642,7 +673,7 @@ var NodeManifest = node_default;
|
|
|
642
673
|
// src/manifest/private/index.ts
|
|
643
674
|
var PrivateChildManifests = [];
|
|
644
675
|
|
|
645
|
-
// src/manifest/public/Chain.json
|
|
676
|
+
// src/manifest/public/WithMempool/Chain.json
|
|
646
677
|
var Chain_default = {
|
|
647
678
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
648
679
|
nodes: [
|
|
@@ -819,7 +850,7 @@ var Chain_default = {
|
|
|
819
850
|
schema: "network.xyo.manifest"
|
|
820
851
|
};
|
|
821
852
|
|
|
822
|
-
// src/manifest/public/Pending.json
|
|
853
|
+
// src/manifest/public/WithMempool/Pending.json
|
|
823
854
|
var Pending_default = {
|
|
824
855
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
825
856
|
nodes: [
|
|
@@ -834,7 +865,7 @@ var Pending_default = {
|
|
|
834
865
|
public: [
|
|
835
866
|
{
|
|
836
867
|
config: {
|
|
837
|
-
accountPath: "2/1/
|
|
868
|
+
accountPath: "2/1/1",
|
|
838
869
|
name: "PendingTransactions",
|
|
839
870
|
getCache: {
|
|
840
871
|
enabled: true,
|
|
@@ -856,17 +887,163 @@ var Pending_default = {
|
|
|
856
887
|
schema: "network.xyo.manifest"
|
|
857
888
|
};
|
|
858
889
|
|
|
859
|
-
// src/manifest/public/index.ts
|
|
890
|
+
// src/manifest/public/WithMempool/index.ts
|
|
860
891
|
var ChainNodeManifest = Chain_default;
|
|
861
892
|
var PendingNodeManifest = Pending_default;
|
|
862
|
-
var
|
|
893
|
+
var PublicChildManifestsWithMempool = [
|
|
863
894
|
...ChainNodeManifest.nodes,
|
|
864
895
|
...PendingNodeManifest.nodes
|
|
865
896
|
];
|
|
866
897
|
|
|
898
|
+
// src/manifest/public/WithoutMempool/Chain.json
|
|
899
|
+
var Chain_default2 = {
|
|
900
|
+
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
901
|
+
nodes: [
|
|
902
|
+
{
|
|
903
|
+
config: {
|
|
904
|
+
accountPath: "1",
|
|
905
|
+
name: "Chain",
|
|
906
|
+
schema: "network.xyo.node.config"
|
|
907
|
+
},
|
|
908
|
+
modules: {
|
|
909
|
+
private: [
|
|
910
|
+
{
|
|
911
|
+
config: {
|
|
912
|
+
accountPath: "1/1'/1'",
|
|
913
|
+
name: "Validated",
|
|
914
|
+
allowedQueries: [
|
|
915
|
+
"network.xyo.query.archivist.get",
|
|
916
|
+
"network.xyo.query.archivist.next"
|
|
917
|
+
],
|
|
918
|
+
getCache: {
|
|
919
|
+
enabled: true,
|
|
920
|
+
maxEntries: 5e3
|
|
921
|
+
},
|
|
922
|
+
payloadSdkConfig: {
|
|
923
|
+
collection: "chain_validated"
|
|
924
|
+
},
|
|
925
|
+
schema: "network.xyo.archivist.config"
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
],
|
|
929
|
+
public: [
|
|
930
|
+
{
|
|
931
|
+
config: {
|
|
932
|
+
accountPath: "1/1/1",
|
|
933
|
+
name: "Submissions",
|
|
934
|
+
getCache: {
|
|
935
|
+
enabled: true,
|
|
936
|
+
maxEntries: 5e3
|
|
937
|
+
},
|
|
938
|
+
payloadSdkConfig: {
|
|
939
|
+
collection: "chain_submissions"
|
|
940
|
+
},
|
|
941
|
+
schema: "network.xyo.archivist.config"
|
|
942
|
+
}
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
config: {
|
|
946
|
+
accountPath: "1/1/2",
|
|
947
|
+
name: "Finalized",
|
|
948
|
+
allowedQueries: [
|
|
949
|
+
"network.xyo.query.archivist.get",
|
|
950
|
+
"network.xyo.query.archivist.next"
|
|
951
|
+
],
|
|
952
|
+
getCache: {
|
|
953
|
+
enabled: true,
|
|
954
|
+
maxEntries: 5e4
|
|
955
|
+
},
|
|
956
|
+
originArchivist: "Validated",
|
|
957
|
+
schema: "network.xyo.archivist.view.config"
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
config: {
|
|
962
|
+
accountPath: "1/1/3'",
|
|
963
|
+
name: "AddressBalanceDiviner",
|
|
964
|
+
schema: "network.xyo.diviner.chain.address.balance.config",
|
|
965
|
+
map: {
|
|
966
|
+
lmdb: {
|
|
967
|
+
dbName: "summaries",
|
|
968
|
+
storeName: "address_balance",
|
|
969
|
+
location: ".store"
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
archivist: "Validated"
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
config: {
|
|
977
|
+
accountPath: "1/1/4'",
|
|
978
|
+
name: "AddressTransferDiviner",
|
|
979
|
+
schema: "network.xyo.diviner.chain.address.transfer.config",
|
|
980
|
+
map: {
|
|
981
|
+
lmdb: {
|
|
982
|
+
dbName: "summaries",
|
|
983
|
+
storeName: "address_transfer",
|
|
984
|
+
location: ".store"
|
|
985
|
+
}
|
|
986
|
+
},
|
|
987
|
+
archivist: "Validated"
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
]
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
],
|
|
994
|
+
schema: "network.xyo.manifest"
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
// src/manifest/public/WithoutMempool/Pending.json
|
|
998
|
+
var Pending_default2 = {
|
|
999
|
+
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
1000
|
+
nodes: [
|
|
1001
|
+
{
|
|
1002
|
+
config: {
|
|
1003
|
+
accountPath: "2",
|
|
1004
|
+
name: "Pending",
|
|
1005
|
+
schema: "network.xyo.node.config"
|
|
1006
|
+
},
|
|
1007
|
+
modules: {
|
|
1008
|
+
private: [],
|
|
1009
|
+
public: [
|
|
1010
|
+
{
|
|
1011
|
+
config: {
|
|
1012
|
+
accountPath: "2/1/1",
|
|
1013
|
+
name: "PendingTransactions",
|
|
1014
|
+
getCache: {
|
|
1015
|
+
enabled: true,
|
|
1016
|
+
maxEntries: 5e3
|
|
1017
|
+
},
|
|
1018
|
+
labels: {
|
|
1019
|
+
"network.xyo.storage.class": "mongodb"
|
|
1020
|
+
},
|
|
1021
|
+
payloadSdkConfig: {
|
|
1022
|
+
collection: "pending_bundles"
|
|
1023
|
+
},
|
|
1024
|
+
schema: "network.xyo.archivist.config"
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
]
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
],
|
|
1031
|
+
schema: "network.xyo.manifest"
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
// src/manifest/public/WithoutMempool/index.ts
|
|
1035
|
+
var ChainNodeManifest2 = Chain_default2;
|
|
1036
|
+
var PendingNodeManifest2 = Pending_default2;
|
|
1037
|
+
var PublicChildManifestsWithoutMempool = [
|
|
1038
|
+
...ChainNodeManifest2.nodes,
|
|
1039
|
+
...PendingNodeManifest2.nodes
|
|
1040
|
+
];
|
|
1041
|
+
|
|
867
1042
|
// src/manifest/getNode.ts
|
|
868
1043
|
var getNode = /* @__PURE__ */ __name(async (context) => {
|
|
869
|
-
const { wallet } = context;
|
|
1044
|
+
const { wallet, config } = context;
|
|
1045
|
+
const { enabled: mempoolEnabled } = config.mempool;
|
|
1046
|
+
const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool;
|
|
870
1047
|
const locator = await getLocator(context);
|
|
871
1048
|
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
872
1049
|
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
@@ -897,16 +1074,16 @@ var getSeedPhrase = /* @__PURE__ */ __name(async (bios, config, logger) => {
|
|
|
897
1074
|
}
|
|
898
1075
|
await bios.seedPhraseStore.set("os", seedPhrase);
|
|
899
1076
|
}
|
|
900
|
-
return
|
|
1077
|
+
return assertEx6(await bios.seedPhraseStore.get("os"), () => "Unable to acquire mnemonic from bios");
|
|
901
1078
|
}, "getSeedPhrase");
|
|
902
1079
|
var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
903
1080
|
const { config, logger, node } = context;
|
|
904
1081
|
const { mnemonic, port } = context.config.api;
|
|
905
1082
|
const bios = await boot();
|
|
906
|
-
const seedPhrase =
|
|
1083
|
+
const seedPhrase = isDefined6(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger);
|
|
907
1084
|
const wallet = await HDWallet.fromPhrase(seedPhrase);
|
|
908
1085
|
const provider = await initInfuraProvider(config);
|
|
909
|
-
const contractAddress =
|
|
1086
|
+
const contractAddress = assertEx6(config.chain.id, () => "Missing config.evm.chainId");
|
|
910
1087
|
const contract = StakedXyoChainV2__factory.connect(toEthAddress(contractAddress), provider);
|
|
911
1088
|
const nodeContext = {
|
|
912
1089
|
wallet,
|
|
@@ -917,15 +1094,15 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
917
1094
|
contract,
|
|
918
1095
|
logger
|
|
919
1096
|
});
|
|
920
|
-
|
|
1097
|
+
assertEx6(await eventsReader.start(), () => "Failed to start EthereumChainStakeEvents reader");
|
|
921
1098
|
const stakeChainReader = await EthereumChainStake.create({
|
|
922
1099
|
contract,
|
|
923
1100
|
eventsReader,
|
|
924
1101
|
logger
|
|
925
1102
|
});
|
|
926
|
-
|
|
1103
|
+
assertEx6(await stakeChainReader.start(), () => "Failed to start EthereumChainStake reader");
|
|
927
1104
|
const rootNode = await getNode(nodeContext);
|
|
928
|
-
const chainArchivist =
|
|
1105
|
+
const chainArchivist = assertEx6(asArchivistInstance2(await rootNode.resolve("Chain:Validated"), {
|
|
929
1106
|
required: true
|
|
930
1107
|
}), () => "FinalizedArchivist not found in node");
|
|
931
1108
|
const chainMap = readPayloadMapFromStore(chainArchivist);
|
|
@@ -939,14 +1116,18 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
939
1116
|
},
|
|
940
1117
|
head: /* @__PURE__ */ __name(async () => {
|
|
941
1118
|
const head = await findMostRecentBlock(chainArchivist);
|
|
942
|
-
return
|
|
1119
|
+
return [
|
|
1120
|
+
assertEx6(head?._hash, () => "No head found in chainArchivist"),
|
|
1121
|
+
assertEx6(head?.block, () => "No head found in chainArchivist")
|
|
1122
|
+
];
|
|
943
1123
|
}, "head")
|
|
944
1124
|
};
|
|
945
1125
|
const mods = await resolvedNode.resolve("*");
|
|
946
1126
|
await Promise.all(mods.map((mod) => {
|
|
947
1127
|
return mod.start?.() ?? (() => true);
|
|
948
1128
|
}));
|
|
949
|
-
const
|
|
1129
|
+
const transferSummaryMap = assertEx6(await getTransferSummaryMap(config), () => "Transfer Summary Map not initialized");
|
|
1130
|
+
const app = await getApp(resolvedNode, transferSummaryMap, stakedChainContext, config.api.initRewardsCache);
|
|
950
1131
|
const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`));
|
|
951
1132
|
server.setTimeout(2e4);
|
|
952
1133
|
return server;
|