@xyo-network/chain-api 1.15.28 → 1.16.1
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 +238 -72
- 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 +50 -50
- 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 +20 -3
- package/src/server/server.ts +7 -4
- 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
|
|
@@ -263,9 +261,11 @@ var addDataLakeRoutes = /* @__PURE__ */ __name((app) => {
|
|
|
263
261
|
// src/server/routes/rpc/routes/addRpcRoutes.ts
|
|
264
262
|
import { setRawResponseFormat as setRawResponseFormat2 } from "@xylabs/express";
|
|
265
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
271
|
const networkStakeViewer = await NodeNetworkStakeViewer.create({
|
|
@@ -278,7 +278,12 @@ var addRpcRoutes = /* @__PURE__ */ __name(async (app, stakedChainContext, initRe
|
|
|
278
278
|
node,
|
|
279
279
|
rewardMultipliers: RewardMultipliers,
|
|
280
280
|
initRewardsCache,
|
|
281
|
-
|
|
281
|
+
context: stakedChainContext,
|
|
282
|
+
transfersSummaryContext: {
|
|
283
|
+
...stakedChainContext,
|
|
284
|
+
stepSemaphores: StepSizes.map(() => new Semaphore(20)),
|
|
285
|
+
summaryMap: transferSummaryMap
|
|
286
|
+
}
|
|
282
287
|
});
|
|
283
288
|
console.log("Initializing NodeXyoViewer...");
|
|
284
289
|
await viewer.start();
|
|
@@ -304,14 +309,14 @@ var addRpcRoutes = /* @__PURE__ */ __name(async (app, stakedChainContext, initRe
|
|
|
304
309
|
}, "addRpcRoutes");
|
|
305
310
|
|
|
306
311
|
// src/server/routes/addRoutes.ts
|
|
307
|
-
var addRoutes = /* @__PURE__ */ __name(async (app, stakedChainContext, initRewardsCache) => {
|
|
308
|
-
await addRpcRoutes(app, stakedChainContext, initRewardsCache);
|
|
312
|
+
var addRoutes = /* @__PURE__ */ __name(async (app, transferSummaryMap, stakedChainContext, initRewardsCache) => {
|
|
313
|
+
await addRpcRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache);
|
|
309
314
|
addDataLakeRoutes(app);
|
|
310
315
|
addNodeRoutes(app);
|
|
311
316
|
}, "addRoutes");
|
|
312
317
|
|
|
313
318
|
// src/server/app.ts
|
|
314
|
-
var getApp = /* @__PURE__ */ __name(async (node,
|
|
319
|
+
var getApp = /* @__PURE__ */ __name(async (node, transferSummaryMap, stakedChainContext, initRewardsCache) => {
|
|
315
320
|
addInstrumentation();
|
|
316
321
|
const app = express2();
|
|
317
322
|
app.set("etag", false);
|
|
@@ -326,15 +331,15 @@ var getApp = /* @__PURE__ */ __name(async (node, eventsReader, stakedChainContex
|
|
|
326
331
|
app.use(customPoweredByHeader);
|
|
327
332
|
disableCaseSensitiveRouting(app);
|
|
328
333
|
app.node = node;
|
|
329
|
-
await addRoutes(app, stakedChainContext, initRewardsCache);
|
|
334
|
+
await addRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache);
|
|
330
335
|
app.use(standardErrors);
|
|
331
336
|
return app;
|
|
332
337
|
}, "getApp");
|
|
333
338
|
|
|
334
339
|
// src/server/server.ts
|
|
335
|
-
import { assertEx as
|
|
340
|
+
import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
336
341
|
import { toEthAddress } from "@xylabs/hex";
|
|
337
|
-
import { isDefined as
|
|
342
|
+
import { isDefined as isDefined6, isString } from "@xylabs/typeof";
|
|
338
343
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/archivist-model";
|
|
339
344
|
import { boot } from "@xyo-network/bios";
|
|
340
345
|
import { EthereumChainStake, EthereumChainStakeEvents } from "@xyo-network/chain-ethereum";
|
|
@@ -344,11 +349,11 @@ import { HDWallet } from "@xyo-network/wallet";
|
|
|
344
349
|
import { readPayloadMapFromStore } from "@xyo-network/xl1-protocol-sdk";
|
|
345
350
|
|
|
346
351
|
// src/helpers/initChainId.ts
|
|
347
|
-
import { assertEx as
|
|
352
|
+
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
348
353
|
import { hexFrom, isHex } from "@xylabs/hex";
|
|
349
|
-
import { isDefined as
|
|
354
|
+
import { isDefined as isDefined3 } from "@xylabs/typeof";
|
|
350
355
|
var getChainId = /* @__PURE__ */ __name((config) => {
|
|
351
|
-
const chainId =
|
|
356
|
+
const chainId = assertEx2(config.evm.chainId, () => "Missing config.evm.chainId");
|
|
352
357
|
if (isHex(chainId, {
|
|
353
358
|
prefix: true
|
|
354
359
|
})) {
|
|
@@ -362,8 +367,8 @@ var getChainId = /* @__PURE__ */ __name((config) => {
|
|
|
362
367
|
}, "getChainId");
|
|
363
368
|
|
|
364
369
|
// src/helpers/initInfuraProvider.ts
|
|
365
|
-
import { assertEx as
|
|
366
|
-
import { isDefined as
|
|
370
|
+
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
371
|
+
import { isDefined as isDefined4 } from "@xylabs/typeof";
|
|
367
372
|
import { InfuraWebSocketProvider } from "ethers/providers";
|
|
368
373
|
var instance;
|
|
369
374
|
var initInfuraProvider = /* @__PURE__ */ __name((config) => {
|
|
@@ -373,8 +378,8 @@ var initInfuraProvider = /* @__PURE__ */ __name((config) => {
|
|
|
373
378
|
return instance;
|
|
374
379
|
}, "initInfuraProvider");
|
|
375
380
|
var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
376
|
-
const projectId =
|
|
377
|
-
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");
|
|
378
383
|
return [
|
|
379
384
|
getChainId(config),
|
|
380
385
|
projectId,
|
|
@@ -383,10 +388,10 @@ var getInfuraProviderConfig = /* @__PURE__ */ __name((config) => {
|
|
|
383
388
|
}, "getInfuraProviderConfig");
|
|
384
389
|
|
|
385
390
|
// src/manifest/getLocator.ts
|
|
386
|
-
import { assertEx as
|
|
391
|
+
import { assertEx as assertEx5 } from "@xylabs/assert";
|
|
387
392
|
import { asAddress as asAddress3, ZERO_ADDRESS } from "@xylabs/hex";
|
|
388
393
|
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
389
|
-
import { isDefined as
|
|
394
|
+
import { isDefined as isDefined5 } from "@xylabs/typeof";
|
|
390
395
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
391
396
|
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
392
397
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
@@ -395,12 +400,12 @@ import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
|
395
400
|
import { AbstractModule, LoggerModuleStatusReporter } from "@xyo-network/module-abstract";
|
|
396
401
|
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
397
402
|
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
398
|
-
import { StepSizes } from "@xyo-network/xl1-protocol";
|
|
403
|
+
import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol";
|
|
399
404
|
import { hasMongoConfig } from "@xyo-network/xl1-protocol-sdk";
|
|
400
|
-
import { Semaphore } from "async-mutex";
|
|
405
|
+
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
401
406
|
|
|
402
407
|
// src/driver/mongo/MongoMap.ts
|
|
403
|
-
import { assertEx as
|
|
408
|
+
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
404
409
|
import { AbstractCreatable, creatable } from "@xylabs/creatable";
|
|
405
410
|
import { isNull } from "@xylabs/typeof";
|
|
406
411
|
import { LRUCache } from "lru-cache";
|
|
@@ -422,7 +427,7 @@ var MongoMap = class extends AbstractCreatable {
|
|
|
422
427
|
}
|
|
423
428
|
_getCache;
|
|
424
429
|
get sdk() {
|
|
425
|
-
return
|
|
430
|
+
return assertEx4(this.params.sdk, () => "No sdk specified");
|
|
426
431
|
}
|
|
427
432
|
async clear() {
|
|
428
433
|
this._getCache?.clear();
|
|
@@ -522,6 +527,31 @@ MongoMap = _ts_decorate([
|
|
|
522
527
|
], MongoMap);
|
|
523
528
|
|
|
524
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");
|
|
525
555
|
var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
526
556
|
const { config, logger } = context;
|
|
527
557
|
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
@@ -536,11 +566,11 @@ var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
|
536
566
|
port: 9465
|
|
537
567
|
}
|
|
538
568
|
});
|
|
539
|
-
if (
|
|
569
|
+
if (isDefined5(logger)) AbstractModule.defaultLogger = logger;
|
|
540
570
|
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
541
571
|
const locator = new ModuleFactoryLocator();
|
|
542
572
|
let balanceSummaryMap;
|
|
543
|
-
let transferSummaryMap;
|
|
573
|
+
let transferSummaryMap = await getTransferSummaryMap(config);
|
|
544
574
|
const mongoConfig = config.storage?.mongo;
|
|
545
575
|
if (hasMongoConfig(mongoConfig)) {
|
|
546
576
|
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
@@ -569,33 +599,22 @@ var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
|
569
599
|
maxEntries: 5e3
|
|
570
600
|
}
|
|
571
601
|
});
|
|
572
|
-
const sdkTransferSummaryMap = new BaseMongoSdk({
|
|
573
|
-
...payloadSdkConfig,
|
|
574
|
-
collection: "transfer_summary_map"
|
|
575
|
-
});
|
|
576
|
-
transferSummaryMap = await MongoMap.create({
|
|
577
|
-
sdk: sdkTransferSummaryMap,
|
|
578
|
-
getCache: {
|
|
579
|
-
enabled: true,
|
|
580
|
-
maxEntries: 5e3
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
602
|
}
|
|
584
603
|
locator.register(AddressBalanceDivinerV2.factory({
|
|
585
604
|
traceProvider,
|
|
586
605
|
meterProvider,
|
|
587
606
|
statusReporter,
|
|
588
607
|
summaryMap: balanceSummaryMap,
|
|
589
|
-
stepSemaphores:
|
|
608
|
+
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
590
609
|
}));
|
|
591
610
|
locator.register(AddressTransferDiviner.factory({
|
|
592
611
|
traceProvider,
|
|
593
612
|
meterProvider,
|
|
594
613
|
statusReporter,
|
|
595
614
|
summaryMap: transferSummaryMap,
|
|
596
|
-
stepSemaphores:
|
|
615
|
+
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
597
616
|
}));
|
|
598
|
-
const chainId =
|
|
617
|
+
const chainId = isDefined5(config.chain.id) ? assertEx5(asAddress3(config.chain.id), () => "chain.id must be an Address") : ZERO_ADDRESS;
|
|
599
618
|
locator.register(HeadValidationDiviner.factory({
|
|
600
619
|
traceProvider,
|
|
601
620
|
meterProvider,
|
|
@@ -654,7 +673,7 @@ var NodeManifest = node_default;
|
|
|
654
673
|
// src/manifest/private/index.ts
|
|
655
674
|
var PrivateChildManifests = [];
|
|
656
675
|
|
|
657
|
-
// src/manifest/public/Chain.json
|
|
676
|
+
// src/manifest/public/WithMempool/Chain.json
|
|
658
677
|
var Chain_default = {
|
|
659
678
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
660
679
|
nodes: [
|
|
@@ -831,7 +850,7 @@ var Chain_default = {
|
|
|
831
850
|
schema: "network.xyo.manifest"
|
|
832
851
|
};
|
|
833
852
|
|
|
834
|
-
// src/manifest/public/Pending.json
|
|
853
|
+
// src/manifest/public/WithMempool/Pending.json
|
|
835
854
|
var Pending_default = {
|
|
836
855
|
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
837
856
|
nodes: [
|
|
@@ -846,7 +865,7 @@ var Pending_default = {
|
|
|
846
865
|
public: [
|
|
847
866
|
{
|
|
848
867
|
config: {
|
|
849
|
-
accountPath: "2/1/
|
|
868
|
+
accountPath: "2/1/1",
|
|
850
869
|
name: "PendingTransactions",
|
|
851
870
|
getCache: {
|
|
852
871
|
enabled: true,
|
|
@@ -868,17 +887,163 @@ var Pending_default = {
|
|
|
868
887
|
schema: "network.xyo.manifest"
|
|
869
888
|
};
|
|
870
889
|
|
|
871
|
-
// src/manifest/public/index.ts
|
|
890
|
+
// src/manifest/public/WithMempool/index.ts
|
|
872
891
|
var ChainNodeManifest = Chain_default;
|
|
873
892
|
var PendingNodeManifest = Pending_default;
|
|
874
|
-
var
|
|
893
|
+
var PublicChildManifestsWithMempool = [
|
|
875
894
|
...ChainNodeManifest.nodes,
|
|
876
895
|
...PendingNodeManifest.nodes
|
|
877
896
|
];
|
|
878
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
|
+
|
|
879
1042
|
// src/manifest/getNode.ts
|
|
880
1043
|
var getNode = /* @__PURE__ */ __name(async (context) => {
|
|
881
|
-
const { wallet } = context;
|
|
1044
|
+
const { wallet, config } = context;
|
|
1045
|
+
const { enabled: mempoolEnabled } = config.mempool;
|
|
1046
|
+
const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool;
|
|
882
1047
|
const locator = await getLocator(context);
|
|
883
1048
|
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
884
1049
|
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
@@ -909,16 +1074,16 @@ var getSeedPhrase = /* @__PURE__ */ __name(async (bios, config, logger) => {
|
|
|
909
1074
|
}
|
|
910
1075
|
await bios.seedPhraseStore.set("os", seedPhrase);
|
|
911
1076
|
}
|
|
912
|
-
return
|
|
1077
|
+
return assertEx6(await bios.seedPhraseStore.get("os"), () => "Unable to acquire mnemonic from bios");
|
|
913
1078
|
}, "getSeedPhrase");
|
|
914
1079
|
var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
915
1080
|
const { config, logger, node } = context;
|
|
916
1081
|
const { mnemonic, port } = context.config.api;
|
|
917
1082
|
const bios = await boot();
|
|
918
|
-
const seedPhrase =
|
|
1083
|
+
const seedPhrase = isDefined6(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger);
|
|
919
1084
|
const wallet = await HDWallet.fromPhrase(seedPhrase);
|
|
920
1085
|
const provider = await initInfuraProvider(config);
|
|
921
|
-
const contractAddress =
|
|
1086
|
+
const contractAddress = assertEx6(config.chain.id, () => "Missing config.evm.chainId");
|
|
922
1087
|
const contract = StakedXyoChainV2__factory.connect(toEthAddress(contractAddress), provider);
|
|
923
1088
|
const nodeContext = {
|
|
924
1089
|
wallet,
|
|
@@ -929,15 +1094,15 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
929
1094
|
contract,
|
|
930
1095
|
logger
|
|
931
1096
|
});
|
|
932
|
-
|
|
1097
|
+
assertEx6(await eventsReader.start(), () => "Failed to start EthereumChainStakeEvents reader");
|
|
933
1098
|
const stakeChainReader = await EthereumChainStake.create({
|
|
934
1099
|
contract,
|
|
935
1100
|
eventsReader,
|
|
936
1101
|
logger
|
|
937
1102
|
});
|
|
938
|
-
|
|
1103
|
+
assertEx6(await stakeChainReader.start(), () => "Failed to start EthereumChainStake reader");
|
|
939
1104
|
const rootNode = await getNode(nodeContext);
|
|
940
|
-
const chainArchivist =
|
|
1105
|
+
const chainArchivist = assertEx6(asArchivistInstance2(await rootNode.resolve("Chain:Validated"), {
|
|
941
1106
|
required: true
|
|
942
1107
|
}), () => "FinalizedArchivist not found in node");
|
|
943
1108
|
const chainMap = readPayloadMapFromStore(chainArchivist);
|
|
@@ -952,8 +1117,8 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
952
1117
|
head: /* @__PURE__ */ __name(async () => {
|
|
953
1118
|
const head = await findMostRecentBlock(chainArchivist);
|
|
954
1119
|
return [
|
|
955
|
-
|
|
956
|
-
|
|
1120
|
+
assertEx6(head?._hash, () => "No head found in chainArchivist"),
|
|
1121
|
+
assertEx6(head?.block, () => "No head found in chainArchivist")
|
|
957
1122
|
];
|
|
958
1123
|
}, "head")
|
|
959
1124
|
};
|
|
@@ -961,7 +1126,8 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
961
1126
|
await Promise.all(mods.map((mod) => {
|
|
962
1127
|
return mod.start?.() ?? (() => true);
|
|
963
1128
|
}));
|
|
964
|
-
const
|
|
1129
|
+
const transferSummaryMap = assertEx6(await getTransferSummaryMap(config), () => "Transfer Summary Map not initialized");
|
|
1130
|
+
const app = await getApp(resolvedNode, transferSummaryMap, stakedChainContext, config.api.initRewardsCache);
|
|
965
1131
|
const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`));
|
|
966
1132
|
server.setTimeout(2e4);
|
|
967
1133
|
return server;
|