@xyo-network/chain-api 1.16.22 → 1.16.24
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 +32 -595
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/server/server.d.ts +1 -1
- package/dist/node/server/server.d.ts.map +1 -1
- package/package.json +12 -25
- package/src/helpers/initInfuraProvider.ts +3 -3
- package/src/server/server.ts +30 -51
- package/dist/node/manifest/getLocator.d.ts +0 -16
- package/dist/node/manifest/getLocator.d.ts.map +0 -1
- package/dist/node/manifest/getNode.d.ts +0 -15
- package/dist/node/manifest/getNode.d.ts.map +0 -1
- package/dist/node/manifest/index.d.ts +0 -6
- package/dist/node/manifest/index.d.ts.map +0 -1
- package/dist/node/manifest/nodeManifest.d.ts +0 -6
- package/dist/node/manifest/nodeManifest.d.ts.map +0 -1
- package/dist/node/manifest/private/index.d.ts +0 -5
- package/dist/node/manifest/private/index.d.ts.map +0 -1
- package/dist/node/manifest/public/WithMempool/index.d.ts +0 -6
- package/dist/node/manifest/public/WithMempool/index.d.ts.map +0 -1
- package/dist/node/manifest/public/WithoutMempool/index.d.ts +0 -6
- package/dist/node/manifest/public/WithoutMempool/index.d.ts.map +0 -1
- package/dist/node/manifest/public/index.d.ts +0 -3
- package/dist/node/manifest/public/index.d.ts.map +0 -1
- package/src/manifest/getLocator.ts +0 -137
- package/src/manifest/getNode.ts +0 -34
- package/src/manifest/index.ts +0 -5
- package/src/manifest/node.json +0 -17
- package/src/manifest/nodeManifest.ts +0 -8
- package/src/manifest/private/index.ts +0 -4
- package/src/manifest/public/WithMempool/Chain.json +0 -175
- package/src/manifest/public/WithMempool/Pending.json +0 -35
- package/src/manifest/public/WithMempool/index.ts +0 -20
- package/src/manifest/public/WithoutMempool/Chain.json +0 -97
- package/src/manifest/public/WithoutMempool/Pending.json +0 -35
- package/src/manifest/public/WithoutMempool/index.ts +0 -20
- package/src/manifest/public/index.ts +0 -2
package/dist/node/index.mjs
CHANGED
|
@@ -336,600 +336,36 @@ var getApp = /* @__PURE__ */ __name(async (node, transferSummaryMap, stakedChain
|
|
|
336
336
|
}, "getApp");
|
|
337
337
|
|
|
338
338
|
// src/server/server.ts
|
|
339
|
-
import { assertEx as
|
|
340
|
-
import {
|
|
341
|
-
import { boot } from "@xyo-network/bios";
|
|
342
|
-
import { createProducerChainStakeIntentBlock, initChainStakeViewer, initProducerAccount } from "@xyo-network/chain-orchestration";
|
|
339
|
+
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
340
|
+
import { createProducerChainStakeIntentBlock, initBalanceSummaryMap, initChainStakeViewer, initProducerAccount, initServerNode, initServerWallet, initTransferSummaryMap } from "@xyo-network/chain-orchestration";
|
|
343
341
|
import { createGenesisBlock, findMostRecentBlock } from "@xyo-network/chain-protocol";
|
|
344
|
-
import {
|
|
345
|
-
import { asXL1BlockRange } from "@xyo-network/xl1-protocol";
|
|
342
|
+
import { asXL1, asXL1BlockRange, XL1Amount } from "@xyo-network/xl1-protocol";
|
|
346
343
|
import { readPayloadMapFromStore } from "@xyo-network/xl1-protocol-sdk";
|
|
347
|
-
|
|
348
|
-
// src/manifest/getLocator.ts
|
|
349
|
-
import { BaseMongoSdk } from "@xylabs/mongo";
|
|
350
|
-
import { asAddress as asAddress3, assertEx as assertEx3, isDefined as isDefined3, ZERO_ADDRESS } from "@xylabs/sdk-js";
|
|
351
|
-
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
352
|
-
import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
|
|
353
|
-
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
354
|
-
import { AddressBalanceDivinerV2, AddressTransferDiviner, ArchivistSyncDiviner, HeadValidationDiviner } from "@xyo-network/chain-modules";
|
|
355
|
-
import { MongoMap } from "@xyo-network/chain-protocol";
|
|
356
|
-
import { initTelemetry } from "@xyo-network/chain-telemetry";
|
|
357
|
-
import { AbstractModule, LoggerModuleStatusReporter } from "@xyo-network/module-abstract";
|
|
358
|
-
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
359
|
-
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
360
|
-
import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol";
|
|
361
|
-
import { hasMongoConfig, MemoryMap } from "@xyo-network/xl1-protocol-sdk";
|
|
362
|
-
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
363
|
-
async function getTransferSummaryMap(config) {
|
|
364
|
-
const mongoConfig = config.storage?.mongo;
|
|
365
|
-
if (hasMongoConfig(mongoConfig)) {
|
|
366
|
-
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
367
|
-
const payloadSdkConfig = {
|
|
368
|
-
dbConnectionString,
|
|
369
|
-
dbDomain,
|
|
370
|
-
dbName,
|
|
371
|
-
dbPassword,
|
|
372
|
-
dbUserName
|
|
373
|
-
};
|
|
374
|
-
const sdkTransferSummaryMap = new BaseMongoSdk({
|
|
375
|
-
...payloadSdkConfig,
|
|
376
|
-
collection: "transfer_summary_map"
|
|
377
|
-
});
|
|
378
|
-
const result = await MongoMap.create({
|
|
379
|
-
sdk: sdkTransferSummaryMap,
|
|
380
|
-
getCache: {
|
|
381
|
-
enabled: true,
|
|
382
|
-
maxEntries: 5e3
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
assertEx3(await result.start(), () => "Failed to start transfer summary map");
|
|
386
|
-
return result;
|
|
387
|
-
} else {
|
|
388
|
-
console.warn("[API] Mongo configuration not found. Using MemoryMap for TransferSummaryMap.");
|
|
389
|
-
return new MemoryMap();
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
__name(getTransferSummaryMap, "getTransferSummaryMap");
|
|
393
|
-
var getLocator = /* @__PURE__ */ __name(async (context) => {
|
|
394
|
-
const { config, logger } = context;
|
|
395
|
-
const { otlpEndpoint } = config.telemetry?.otel ?? {};
|
|
396
|
-
const { traceProvider, meterProvider } = await initTelemetry({
|
|
397
|
-
attributes: {
|
|
398
|
-
serviceName: "xl1-api",
|
|
399
|
-
serviceVersion: "1.0.0"
|
|
400
|
-
},
|
|
401
|
-
otlpEndpoint,
|
|
402
|
-
metricsConfig: {
|
|
403
|
-
endpoint: "/metrics",
|
|
404
|
-
port: 9465
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
if (isDefined3(logger)) AbstractModule.defaultLogger = logger;
|
|
408
|
-
const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
|
|
409
|
-
const locator = new ModuleFactoryLocator();
|
|
410
|
-
let balanceSummaryMap;
|
|
411
|
-
let transferSummaryMap = await getTransferSummaryMap(config);
|
|
412
|
-
const mongoConfig = config.storage?.mongo;
|
|
413
|
-
if (hasMongoConfig(mongoConfig)) {
|
|
414
|
-
const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
|
|
415
|
-
const payloadSdkConfig = {
|
|
416
|
-
dbConnectionString,
|
|
417
|
-
dbDomain,
|
|
418
|
-
dbName,
|
|
419
|
-
dbPassword,
|
|
420
|
-
dbUserName
|
|
421
|
-
};
|
|
422
|
-
const params = {
|
|
423
|
-
meterProvider,
|
|
424
|
-
payloadSdkConfig,
|
|
425
|
-
statusReporter,
|
|
426
|
-
traceProvider
|
|
427
|
-
};
|
|
428
|
-
locator.register(MongoDBArchivistV2.factory(params), void 0, true);
|
|
429
|
-
const sdkBalanceSummaryMap = new BaseMongoSdk({
|
|
430
|
-
...payloadSdkConfig,
|
|
431
|
-
collection: "balance_summary_map"
|
|
432
|
-
});
|
|
433
|
-
balanceSummaryMap = await MongoMap.create({
|
|
434
|
-
sdk: sdkBalanceSummaryMap,
|
|
435
|
-
getCache: {
|
|
436
|
-
enabled: true,
|
|
437
|
-
maxEntries: 5e3
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
locator.register(AddressBalanceDivinerV2.factory({
|
|
442
|
-
traceProvider,
|
|
443
|
-
meterProvider,
|
|
444
|
-
statusReporter,
|
|
445
|
-
summaryMap: balanceSummaryMap,
|
|
446
|
-
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
447
|
-
}));
|
|
448
|
-
locator.register(AddressTransferDiviner.factory({
|
|
449
|
-
traceProvider,
|
|
450
|
-
meterProvider,
|
|
451
|
-
statusReporter,
|
|
452
|
-
summaryMap: transferSummaryMap,
|
|
453
|
-
stepSemaphores: StepSizes2.map(() => new Semaphore2(20))
|
|
454
|
-
}));
|
|
455
|
-
const chainId = isDefined3(config.chain.id) ? assertEx3(asAddress3(config.chain.id), () => "chain.id must be an Address") : ZERO_ADDRESS;
|
|
456
|
-
locator.register(HeadValidationDiviner.factory({
|
|
457
|
-
traceProvider,
|
|
458
|
-
meterProvider,
|
|
459
|
-
statusReporter,
|
|
460
|
-
chainId,
|
|
461
|
-
allowedProducers: config.producer.allowlist
|
|
462
|
-
}));
|
|
463
|
-
locator.register(MemoryArchivist.factory({
|
|
464
|
-
traceProvider,
|
|
465
|
-
meterProvider,
|
|
466
|
-
statusReporter
|
|
467
|
-
}));
|
|
468
|
-
locator.register(MemorySentinel.factory({
|
|
469
|
-
traceProvider,
|
|
470
|
-
meterProvider,
|
|
471
|
-
statusReporter
|
|
472
|
-
}));
|
|
473
|
-
locator.register(ViewArchivist.factory({
|
|
474
|
-
traceProvider,
|
|
475
|
-
meterProvider,
|
|
476
|
-
statusReporter
|
|
477
|
-
}));
|
|
478
|
-
locator.register(ArchivistSyncDiviner.factory({
|
|
479
|
-
traceProvider,
|
|
480
|
-
meterProvider,
|
|
481
|
-
statusReporter
|
|
482
|
-
}));
|
|
483
|
-
return locator;
|
|
484
|
-
}, "getLocator");
|
|
485
|
-
|
|
486
|
-
// src/manifest/getNode.ts
|
|
487
|
-
import { ManifestWrapper } from "@xyo-network/manifest-wrapper";
|
|
488
|
-
|
|
489
|
-
// src/manifest/node.json
|
|
490
|
-
var node_default = {
|
|
491
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
492
|
-
nodes: [
|
|
493
|
-
{
|
|
494
|
-
config: {
|
|
495
|
-
accountPath: "44'/60'/1",
|
|
496
|
-
name: "XYOChain",
|
|
497
|
-
schema: "network.xyo.node.config"
|
|
498
|
-
},
|
|
499
|
-
modules: {
|
|
500
|
-
private: [],
|
|
501
|
-
public: []
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
],
|
|
505
|
-
schema: "network.xyo.manifest"
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
// src/manifest/nodeManifest.ts
|
|
509
|
-
var NodeManifest = node_default;
|
|
510
|
-
|
|
511
|
-
// src/manifest/private/index.ts
|
|
512
|
-
var PrivateChildManifests = [];
|
|
513
|
-
|
|
514
|
-
// src/manifest/public/WithMempool/Chain.json
|
|
515
|
-
var Chain_default = {
|
|
516
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
517
|
-
nodes: [
|
|
518
|
-
{
|
|
519
|
-
config: {
|
|
520
|
-
accountPath: "1",
|
|
521
|
-
name: "Chain",
|
|
522
|
-
schema: "network.xyo.node.config"
|
|
523
|
-
},
|
|
524
|
-
modules: {
|
|
525
|
-
private: [
|
|
526
|
-
{
|
|
527
|
-
config: {
|
|
528
|
-
accountPath: "1/1'/1'",
|
|
529
|
-
name: "Validated",
|
|
530
|
-
getCache: {
|
|
531
|
-
enabled: true,
|
|
532
|
-
maxEntries: 5e3
|
|
533
|
-
},
|
|
534
|
-
payloadSdkConfig: {
|
|
535
|
-
collection: "chain_validated"
|
|
536
|
-
},
|
|
537
|
-
schema: "network.xyo.archivist.config"
|
|
538
|
-
}
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
config: {
|
|
542
|
-
accountPath: "1/1'/2'",
|
|
543
|
-
schema: "network.xyo.diviner.chain.head.validation.config",
|
|
544
|
-
eventSubscriptions: [
|
|
545
|
-
{
|
|
546
|
-
sourceEvent: "inserted",
|
|
547
|
-
sourceModule: "Submissions",
|
|
548
|
-
targetModuleFunction: "divine"
|
|
549
|
-
}
|
|
550
|
-
],
|
|
551
|
-
inArchivist: "Submissions",
|
|
552
|
-
outArchivist: "Validated",
|
|
553
|
-
name: "HeadValidationDiviner"
|
|
554
|
-
}
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
config: {
|
|
558
|
-
accountPath: "1/1'/3'",
|
|
559
|
-
automations: [
|
|
560
|
-
{
|
|
561
|
-
frequency: 1e3,
|
|
562
|
-
frequencyUnits: "millis",
|
|
563
|
-
schema: "network.xyo.automation.interval",
|
|
564
|
-
type: "interval"
|
|
565
|
-
}
|
|
566
|
-
],
|
|
567
|
-
name: "ChainValidationSentinel",
|
|
568
|
-
schema: "network.xyo.sentinel.config",
|
|
569
|
-
synchronous: true,
|
|
570
|
-
tasks: [
|
|
571
|
-
{
|
|
572
|
-
mod: "HeadValidationDiviner",
|
|
573
|
-
endPoint: "divine"
|
|
574
|
-
}
|
|
575
|
-
]
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
config: {
|
|
580
|
-
accountPath: "1/1'/4'",
|
|
581
|
-
automations: [
|
|
582
|
-
{
|
|
583
|
-
frequency: 1e4,
|
|
584
|
-
frequencyUnits: "millis",
|
|
585
|
-
schema: "network.xyo.automation.interval",
|
|
586
|
-
type: "interval"
|
|
587
|
-
}
|
|
588
|
-
],
|
|
589
|
-
name: "AddressBalancePollingSentinel",
|
|
590
|
-
schema: "network.xyo.sentinel.config",
|
|
591
|
-
synchronous: true,
|
|
592
|
-
tasks: [
|
|
593
|
-
{
|
|
594
|
-
mod: "AddressBalanceDiviner",
|
|
595
|
-
endPoint: "divine"
|
|
596
|
-
}
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
config: {
|
|
602
|
-
accountPath: "1/1'/5'",
|
|
603
|
-
automations: [
|
|
604
|
-
{
|
|
605
|
-
frequency: 1e4,
|
|
606
|
-
frequencyUnits: "millis",
|
|
607
|
-
schema: "network.xyo.automation.interval",
|
|
608
|
-
type: "interval"
|
|
609
|
-
}
|
|
610
|
-
],
|
|
611
|
-
name: "AddressTransferPollingSentinel",
|
|
612
|
-
schema: "network.xyo.sentinel.config",
|
|
613
|
-
synchronous: true,
|
|
614
|
-
tasks: [
|
|
615
|
-
{
|
|
616
|
-
mod: "AddressTransferDiviner",
|
|
617
|
-
endPoint: "divine"
|
|
618
|
-
}
|
|
619
|
-
]
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
],
|
|
623
|
-
public: [
|
|
624
|
-
{
|
|
625
|
-
config: {
|
|
626
|
-
accountPath: "1/1/1",
|
|
627
|
-
name: "Submissions",
|
|
628
|
-
getCache: {
|
|
629
|
-
enabled: true,
|
|
630
|
-
maxEntries: 5e3
|
|
631
|
-
},
|
|
632
|
-
payloadSdkConfig: {
|
|
633
|
-
collection: "chain_submissions"
|
|
634
|
-
},
|
|
635
|
-
schema: "network.xyo.archivist.config"
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
{
|
|
639
|
-
config: {
|
|
640
|
-
accountPath: "1/1/2",
|
|
641
|
-
name: "Finalized",
|
|
642
|
-
allowedQueries: [
|
|
643
|
-
"network.xyo.query.archivist.get",
|
|
644
|
-
"network.xyo.query.archivist.next"
|
|
645
|
-
],
|
|
646
|
-
getCache: {
|
|
647
|
-
enabled: true,
|
|
648
|
-
maxEntries: 5e4
|
|
649
|
-
},
|
|
650
|
-
originArchivist: "Validated",
|
|
651
|
-
schema: "network.xyo.archivist.view.config"
|
|
652
|
-
}
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
config: {
|
|
656
|
-
accountPath: "1/1/3'",
|
|
657
|
-
name: "AddressBalanceDiviner",
|
|
658
|
-
schema: "network.xyo.diviner.chain.address.balance.config",
|
|
659
|
-
map: {
|
|
660
|
-
lmdb: {
|
|
661
|
-
dbName: "summaries",
|
|
662
|
-
storeName: "address_balance",
|
|
663
|
-
location: ".store"
|
|
664
|
-
}
|
|
665
|
-
},
|
|
666
|
-
archivist: "Validated"
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
config: {
|
|
671
|
-
accountPath: "1/1/4'",
|
|
672
|
-
name: "AddressTransferDiviner",
|
|
673
|
-
schema: "network.xyo.diviner.chain.address.transfer.config",
|
|
674
|
-
map: {
|
|
675
|
-
lmdb: {
|
|
676
|
-
dbName: "summaries",
|
|
677
|
-
storeName: "address_transfer",
|
|
678
|
-
location: ".store"
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
archivist: "Validated"
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
]
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
],
|
|
688
|
-
schema: "network.xyo.manifest"
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
// src/manifest/public/WithMempool/Pending.json
|
|
692
|
-
var Pending_default = {
|
|
693
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
694
|
-
nodes: [
|
|
695
|
-
{
|
|
696
|
-
config: {
|
|
697
|
-
accountPath: "2",
|
|
698
|
-
name: "Pending",
|
|
699
|
-
schema: "network.xyo.node.config"
|
|
700
|
-
},
|
|
701
|
-
modules: {
|
|
702
|
-
private: [],
|
|
703
|
-
public: [
|
|
704
|
-
{
|
|
705
|
-
config: {
|
|
706
|
-
accountPath: "2/1/1",
|
|
707
|
-
name: "PendingTransactions",
|
|
708
|
-
getCache: {
|
|
709
|
-
enabled: true,
|
|
710
|
-
maxEntries: 5e3
|
|
711
|
-
},
|
|
712
|
-
labels: {
|
|
713
|
-
"network.xyo.storage.class": "mongodb"
|
|
714
|
-
},
|
|
715
|
-
payloadSdkConfig: {
|
|
716
|
-
collection: "pending_bundles"
|
|
717
|
-
},
|
|
718
|
-
schema: "network.xyo.archivist.config"
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
]
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
],
|
|
725
|
-
schema: "network.xyo.manifest"
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
// src/manifest/public/WithMempool/index.ts
|
|
729
|
-
var ChainNodeManifest = Chain_default;
|
|
730
|
-
var PendingNodeManifest = Pending_default;
|
|
731
|
-
var PublicChildManifestsWithMempool = [
|
|
732
|
-
...ChainNodeManifest.nodes,
|
|
733
|
-
...PendingNodeManifest.nodes
|
|
734
|
-
];
|
|
735
|
-
|
|
736
|
-
// src/manifest/public/WithoutMempool/Chain.json
|
|
737
|
-
var Chain_default2 = {
|
|
738
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
739
|
-
nodes: [
|
|
740
|
-
{
|
|
741
|
-
config: {
|
|
742
|
-
accountPath: "1",
|
|
743
|
-
name: "Chain",
|
|
744
|
-
schema: "network.xyo.node.config"
|
|
745
|
-
},
|
|
746
|
-
modules: {
|
|
747
|
-
private: [
|
|
748
|
-
{
|
|
749
|
-
config: {
|
|
750
|
-
accountPath: "1/1'/1'",
|
|
751
|
-
name: "Validated",
|
|
752
|
-
allowedQueries: [
|
|
753
|
-
"network.xyo.query.archivist.get",
|
|
754
|
-
"network.xyo.query.archivist.next"
|
|
755
|
-
],
|
|
756
|
-
getCache: {
|
|
757
|
-
enabled: true,
|
|
758
|
-
maxEntries: 5e3
|
|
759
|
-
},
|
|
760
|
-
payloadSdkConfig: {
|
|
761
|
-
collection: "chain_validated"
|
|
762
|
-
},
|
|
763
|
-
schema: "network.xyo.archivist.config"
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
],
|
|
767
|
-
public: [
|
|
768
|
-
{
|
|
769
|
-
config: {
|
|
770
|
-
accountPath: "1/1/1",
|
|
771
|
-
name: "Submissions",
|
|
772
|
-
getCache: {
|
|
773
|
-
enabled: true,
|
|
774
|
-
maxEntries: 5e3
|
|
775
|
-
},
|
|
776
|
-
payloadSdkConfig: {
|
|
777
|
-
collection: "chain_submissions"
|
|
778
|
-
},
|
|
779
|
-
schema: "network.xyo.archivist.config"
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
config: {
|
|
784
|
-
accountPath: "1/1/2",
|
|
785
|
-
name: "Finalized",
|
|
786
|
-
allowedQueries: [
|
|
787
|
-
"network.xyo.query.archivist.get",
|
|
788
|
-
"network.xyo.query.archivist.next"
|
|
789
|
-
],
|
|
790
|
-
getCache: {
|
|
791
|
-
enabled: true,
|
|
792
|
-
maxEntries: 5e4
|
|
793
|
-
},
|
|
794
|
-
originArchivist: "Validated",
|
|
795
|
-
schema: "network.xyo.archivist.view.config"
|
|
796
|
-
}
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
config: {
|
|
800
|
-
accountPath: "1/1/3'",
|
|
801
|
-
name: "AddressBalanceDiviner",
|
|
802
|
-
schema: "network.xyo.diviner.chain.address.balance.config",
|
|
803
|
-
map: {
|
|
804
|
-
lmdb: {
|
|
805
|
-
dbName: "summaries",
|
|
806
|
-
storeName: "address_balance",
|
|
807
|
-
location: ".store"
|
|
808
|
-
}
|
|
809
|
-
},
|
|
810
|
-
archivist: "Validated"
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
config: {
|
|
815
|
-
accountPath: "1/1/4'",
|
|
816
|
-
name: "AddressTransferDiviner",
|
|
817
|
-
schema: "network.xyo.diviner.chain.address.transfer.config",
|
|
818
|
-
map: {
|
|
819
|
-
lmdb: {
|
|
820
|
-
dbName: "summaries",
|
|
821
|
-
storeName: "address_transfer",
|
|
822
|
-
location: ".store"
|
|
823
|
-
}
|
|
824
|
-
},
|
|
825
|
-
archivist: "Validated"
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
]
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
],
|
|
832
|
-
schema: "network.xyo.manifest"
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
// src/manifest/public/WithoutMempool/Pending.json
|
|
836
|
-
var Pending_default2 = {
|
|
837
|
-
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
|
|
838
|
-
nodes: [
|
|
839
|
-
{
|
|
840
|
-
config: {
|
|
841
|
-
accountPath: "2",
|
|
842
|
-
name: "Pending",
|
|
843
|
-
schema: "network.xyo.node.config"
|
|
844
|
-
},
|
|
845
|
-
modules: {
|
|
846
|
-
private: [],
|
|
847
|
-
public: [
|
|
848
|
-
{
|
|
849
|
-
config: {
|
|
850
|
-
accountPath: "2/1/1",
|
|
851
|
-
name: "PendingTransactions",
|
|
852
|
-
getCache: {
|
|
853
|
-
enabled: true,
|
|
854
|
-
maxEntries: 5e3
|
|
855
|
-
},
|
|
856
|
-
labels: {
|
|
857
|
-
"network.xyo.storage.class": "mongodb"
|
|
858
|
-
},
|
|
859
|
-
payloadSdkConfig: {
|
|
860
|
-
collection: "pending_bundles"
|
|
861
|
-
},
|
|
862
|
-
schema: "network.xyo.archivist.config"
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
]
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
],
|
|
869
|
-
schema: "network.xyo.manifest"
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
// src/manifest/public/WithoutMempool/index.ts
|
|
873
|
-
var ChainNodeManifest2 = Chain_default2;
|
|
874
|
-
var PendingNodeManifest2 = Pending_default2;
|
|
875
|
-
var PublicChildManifestsWithoutMempool = [
|
|
876
|
-
...ChainNodeManifest2.nodes,
|
|
877
|
-
...PendingNodeManifest2.nodes
|
|
878
|
-
];
|
|
879
|
-
|
|
880
|
-
// src/manifest/getNode.ts
|
|
881
|
-
var getNode = /* @__PURE__ */ __name(async (context) => {
|
|
882
|
-
const { wallet, config } = context;
|
|
883
|
-
const { enabled: mempoolEnabled } = config.mempool;
|
|
884
|
-
const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool;
|
|
885
|
-
const locator = await getLocator(context);
|
|
886
|
-
const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests);
|
|
887
|
-
const [node, ...childNodes] = await wrapper.loadNodes();
|
|
888
|
-
if (childNodes?.length > 0) {
|
|
889
|
-
await Promise.all(childNodes.map((childNode) => node.register(childNode)));
|
|
890
|
-
await Promise.all(childNodes.map((childNode) => node.attach(childNode.address, true)));
|
|
891
|
-
}
|
|
892
|
-
return node;
|
|
893
|
-
}, "getNode");
|
|
894
|
-
|
|
895
|
-
// src/server/server.ts
|
|
896
344
|
var hostname = "::";
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
logger
|
|
903
|
-
|
|
904
|
-
} else {
|
|
905
|
-
let seedPhrase;
|
|
906
|
-
if (isString(mnemonic)) {
|
|
907
|
-
seedPhrase = mnemonic;
|
|
908
|
-
} else {
|
|
909
|
-
seedPhrase = HDWallet.generateMnemonic();
|
|
910
|
-
logger?.log("[API] No mnemonic provided, using random mnemonic. This is not recommended for production use.");
|
|
911
|
-
logger?.log(`[API] Mnemonic: ${seedPhrase}`);
|
|
912
|
-
}
|
|
913
|
-
await bios.seedPhraseStore.set("os", seedPhrase);
|
|
914
|
-
}
|
|
915
|
-
return assertEx4(await bios.seedPhraseStore.get("os"), () => "Unable to acquire mnemonic from bios");
|
|
916
|
-
}, "getSeedPhrase");
|
|
917
|
-
var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
918
|
-
const { config, logger, node } = context;
|
|
919
|
-
const { mnemonic, port } = context.config.api;
|
|
920
|
-
const bios = await boot();
|
|
921
|
-
const seedPhrase = isDefined4(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger);
|
|
922
|
-
const wallet = await HDWallet.fromPhrase(seedPhrase);
|
|
345
|
+
async function getServer(context) {
|
|
346
|
+
const { config, logger, node: providedNode } = context;
|
|
347
|
+
const { port } = context.config.api;
|
|
348
|
+
const wallet = await initServerWallet({
|
|
349
|
+
config,
|
|
350
|
+
logger
|
|
351
|
+
});
|
|
923
352
|
const stakeChainViewer = await initChainStakeViewer(config, logger);
|
|
924
|
-
const
|
|
925
|
-
|
|
353
|
+
const balanceSummaryMap = assertEx3(await initBalanceSummaryMap({
|
|
354
|
+
config,
|
|
355
|
+
logger
|
|
356
|
+
}), () => "Balance Summary Map not initialized");
|
|
357
|
+
const transferSummaryMap = assertEx3(await initTransferSummaryMap({
|
|
358
|
+
config,
|
|
359
|
+
logger
|
|
360
|
+
}), () => "Transfer Summary Map not initialized");
|
|
361
|
+
const { node, chainArchivist } = await initServerNode({
|
|
362
|
+
config,
|
|
926
363
|
logger,
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}), () => "FinalizedArchivist not found in node");
|
|
364
|
+
wallet,
|
|
365
|
+
node: providedNode,
|
|
366
|
+
transferSummaryMap,
|
|
367
|
+
balanceSummaryMap
|
|
368
|
+
});
|
|
933
369
|
const chainMap = readPayloadMapFromStore(chainArchivist);
|
|
934
370
|
const payloads = await chainArchivist.next();
|
|
935
371
|
if (payloads.length === 0) {
|
|
@@ -939,7 +375,8 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
939
375
|
logger
|
|
940
376
|
});
|
|
941
377
|
const chainId = stakeChainViewer.chainId;
|
|
942
|
-
const
|
|
378
|
+
const genesisRewardAddress = config.chain.genesisRewardAddress ?? producerAccount.address;
|
|
379
|
+
const block0 = await createGenesisBlock(producerAccount, chainId, XL1Amount.fromXL1(asXL1(1000000n)).atto, genesisRewardAddress);
|
|
943
380
|
await chainArchivist.insert([
|
|
944
381
|
...block0[1].flat(),
|
|
945
382
|
block0[0]
|
|
@@ -964,21 +401,21 @@ var getServer = /* @__PURE__ */ __name(async (context) => {
|
|
|
964
401
|
head: /* @__PURE__ */ __name(async () => {
|
|
965
402
|
const head = await findMostRecentBlock(chainArchivist);
|
|
966
403
|
return [
|
|
967
|
-
|
|
404
|
+
assertEx3(head?._hash, () => "No head found in chainArchivist"),
|
|
968
405
|
head?.block ?? 0
|
|
969
406
|
];
|
|
970
407
|
}, "head")
|
|
971
408
|
};
|
|
972
|
-
const mods = await
|
|
409
|
+
const mods = await node.resolve("*");
|
|
973
410
|
await Promise.all(mods.map((mod) => {
|
|
974
411
|
return mod.start?.() ?? (() => true);
|
|
975
412
|
}));
|
|
976
|
-
const
|
|
977
|
-
const app = await getApp(resolvedNode, transferSummaryMap, stakedChainContext, config.api.initRewardsCache);
|
|
413
|
+
const app = await getApp(node, transferSummaryMap, stakedChainContext, config.api.initRewardsCache);
|
|
978
414
|
const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`));
|
|
979
415
|
server.setTimeout(2e4);
|
|
980
416
|
return server;
|
|
981
|
-
}
|
|
417
|
+
}
|
|
418
|
+
__name(getServer, "getServer");
|
|
982
419
|
export {
|
|
983
420
|
getApp,
|
|
984
421
|
getServer
|