@xyo-network/chain-api 1.15.28 → 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.
Files changed (37) hide show
  1. package/dist/node/index.mjs +238 -72
  2. package/dist/node/index.mjs.map +1 -1
  3. package/dist/node/manifest/getLocator.d.ts +3 -1
  4. package/dist/node/manifest/getLocator.d.ts.map +1 -1
  5. package/dist/node/manifest/getNode.d.ts.map +1 -1
  6. package/dist/node/manifest/public/WithMempool/index.d.ts +6 -0
  7. package/dist/node/manifest/public/WithMempool/index.d.ts.map +1 -0
  8. package/dist/node/manifest/public/WithoutMempool/index.d.ts +6 -0
  9. package/dist/node/manifest/public/WithoutMempool/index.d.ts.map +1 -0
  10. package/dist/node/manifest/public/index.d.ts +2 -13
  11. package/dist/node/manifest/public/index.d.ts.map +1 -1
  12. package/dist/node/server/app.d.ts +3 -2
  13. package/dist/node/server/app.d.ts.map +1 -1
  14. package/dist/node/server/routes/addRoutes.d.ts +3 -2
  15. package/dist/node/server/routes/addRoutes.d.ts.map +1 -1
  16. package/dist/node/server/routes/address/get/get.d.ts.map +1 -1
  17. package/dist/node/server/routes/rpc/routes/addRpcRoutes.d.ts +3 -2
  18. package/dist/node/server/routes/rpc/routes/addRpcRoutes.d.ts.map +1 -1
  19. package/dist/node/server/server.d.ts.map +1 -1
  20. package/package.json +48 -48
  21. package/src/manifest/getLocator.ts +20 -7
  22. package/src/manifest/getNode.ts +4 -2
  23. package/src/manifest/public/{Chain.json → WithMempool/Chain.json} +1 -1
  24. package/src/manifest/public/{Pending.json → WithMempool/Pending.json} +1 -1
  25. package/src/manifest/public/WithMempool/index.ts +20 -0
  26. package/src/manifest/public/WithoutMempool/Chain.json +97 -0
  27. package/src/manifest/public/WithoutMempool/Pending.json +35 -0
  28. package/src/manifest/public/WithoutMempool/index.ts +20 -0
  29. package/src/manifest/public/index.ts +2 -20
  30. package/src/server/app.ts +6 -3
  31. package/src/server/routes/addRoutes.ts +11 -3
  32. package/src/server/routes/address/get/get.ts +8 -10
  33. package/src/server/routes/rpc/routes/addRpcRoutes.ts +20 -3
  34. package/src/server/server.ts +7 -4
  35. package/dist/node/manifest/public/spec/Node.spec.d.ts +0 -2
  36. package/dist/node/manifest/public/spec/Node.spec.d.ts.map +0 -1
  37. package/src/manifest/public/spec/Node.spec.ts +0 -32
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/app.ts","../../src/server/instrumentation.ts","../../src/server/routes/address/addNodeRoutes.ts","../../src/server/routes/address/get/get.ts","../../src/server/routes/address/post/post.ts","../../src/server/routes/address/post/getQueryConfig.ts","../../src/server/routes/dataLake/archivistMiddleware.ts","../../src/server/routes/dataLake/addDataLakeRoutes.ts","../../src/server/routes/rpc/routes/addRpcRoutes.ts","../../src/server/routes/addRoutes.ts","../../src/server/server.ts","../../src/helpers/initChainId.ts","../../src/helpers/initInfuraProvider.ts","../../src/manifest/getLocator.ts","../../src/driver/mongo/MongoMap.ts","../../src/manifest/getNode.ts","../../src/manifest/node.json","../../src/manifest/nodeManifest.ts","../../src/manifest/private/index.ts","../../src/manifest/public/Chain.json","../../src/manifest/public/Pending.json","../../src/manifest/public/index.ts"],"sourcesContent":["import {\n customPoweredByHeader,\n disableCaseSensitiveRouting,\n disableExpressDefaultPoweredByHeader,\n getJsonBodyParser,\n getJsonBodyParserOptions,\n responseProfiler,\n standardErrors,\n standardResponses,\n} from '@xylabs/express'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport type { StakedChainContextRead, StakeEventsRead } from '@xyo-network/xl1-protocol-sdk'\nimport compression from 'compression'\nimport cors from 'cors'\nimport type { Express } from 'express'\nimport express from 'express'\n\nimport { addInstrumentation } from './instrumentation.ts'\nimport { addRoutes } from './routes/index.ts'\n\nexport const getApp = async (\n node: NodeInstance,\n eventsReader: StakeEventsRead,\n stakedChainContext: StakedChainContextRead,\n initRewardsCache?: boolean,\n): Promise<Express> => {\n addInstrumentation()\n const app = express()\n app.set('etag', false)\n\n app.use(cors())\n app.use(compression())\n app.use(responseProfiler)\n app.use(getJsonBodyParser(getJsonBodyParserOptions({ limit: '1mb' })))\n app.use(standardResponses)\n disableExpressDefaultPoweredByHeader(app)\n app.use(customPoweredByHeader)\n disableCaseSensitiveRouting(app)\n app.node = node\n await addRoutes(app, stakedChainContext, initRewardsCache)\n app.use(standardErrors)\n return app\n}\n","import { registerInstrumentations } from '@opentelemetry/instrumentation'\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\n\n/**\n * Registers OpenTelemetry instrumentations for HTTP and Express.\n * This function is used to set up the necessary instrumentations for monitoring\n * HTTP requests and Express applications. Since it monkey patches the Express\n * router & middleware system, it should be called before any Express applications\n * are defined.\n */\nexport const addInstrumentation = () => {\n const instrumentations = [new HttpInstrumentation(), new ExpressInstrumentation()]\n registerInstrumentations({ instrumentations })\n}\n","import type { Express } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport { getAddress } from './get/index.ts'\nimport { postAddress } from './post/index.ts'\n\nexport const addNodeRoutes = (app: Express) => {\n const defaultModule = app.node\n const address = defaultModule.address\n const defaultModuleEndpoint = `/${address}`\n app.get('/', (_req, res) => res.redirect(StatusCodes.MOVED_TEMPORARILY, defaultModuleEndpoint))\n app.post('/', (_req, res) => res.redirect(StatusCodes.TEMPORARY_REDIRECT, defaultModuleEndpoint))\n app.get('/:address', getAddress)\n app.post('/:address', postAddress)\n app.get('/:hash', (_req, res) => {\n res.sendStatus(StatusCodes.NOT_FOUND)\n })\n app.post('/:hash', (_req, res) => {\n res.sendStatus(StatusCodes.NOT_FOUND)\n })\n}\n","import { assertEx } from '@xylabs/assert'\nimport { asyncHandler } from '@xylabs/express'\nimport { asAddress, toAddress } from '@xylabs/hex'\nimport { isModuleIdentifierPart } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { RequestHandler } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport type { AddressPathParams } from '../AddressPathParams.ts'\n\nconst handler: RequestHandler<AddressPathParams, Payload[]> = async (req, res, next) => {\n const { address: rawAddress } = req.params\n const { node } = req.app\n const address = asAddress(rawAddress)\n if (address !== undefined) {\n let mod = node.address === address ? node : (await node.resolve(address, { direction: 'down' }))\n if (mod) {\n res.json(await mod.state())\n return\n }\n }\n if (isModuleIdentifierPart(rawAddress)) {\n const moduleIdentifier = toAddress(rawAddress)\n const mod = await node.resolve(moduleIdentifier, { direction: 'down' })\n if (mod) {\n const moduleAddress = assertEx(mod?.address, () => 'Error redirecting to module by address')\n res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${moduleAddress}`)\n return\n }\n }\n next('route')\n}\nexport const getAddress = asyncHandler(handler)\n","import { assertEx } from '@xylabs/assert'\nimport { asyncHandler } from '@xylabs/express'\nimport {\n asAddress, isAddress,\n toAddress,\n} from '@xylabs/hex'\nimport type { JsonObject } from '@xylabs/object'\nimport { isQueryBoundWitness, type QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleErrorBuilder } from '@xyo-network/module-abstract'\nimport type { ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'\nimport type { ModuleError, Payload } from '@xyo-network/payload-model'\nimport type { RequestHandler } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport type { AddressPathParams } from '../AddressPathParams.ts'\nimport { getQueryConfig } from './getQueryConfig.ts'\n\ntype PostAddressRequestBody = [QueryBoundWitness, undefined | Payload[]]\n\nconst handler: RequestHandler<AddressPathParams, ModuleQueryResult | ModuleError, PostAddressRequestBody> = async (req, res, next) => {\n const returnError = (code: number, message = 'An error occurred', details?: JsonObject) => {\n const error = new ModuleErrorBuilder().message(message).details(details).build()\n res.locals.rawResponse = false\n res.status(code).json(error)\n next()\n }\n\n const { address } = req.params\n const { node } = req.app\n const [bw, payloads] = Array.isArray(req.body) ? req.body : []\n if (!isAddress(address)) {\n return returnError(StatusCodes.BAD_REQUEST, 'Missing address')\n }\n\n if (!bw) {\n return returnError(StatusCodes.BAD_REQUEST, 'Missing boundwitness')\n }\n\n if (!isQueryBoundWitness(bw)) {\n return returnError(StatusCodes.BAD_REQUEST, 'Invalid query boundwitness')\n }\n\n let modules: ModuleInstance[] = []\n const normalizedAddress = toAddress(address)\n if (node.address === normalizedAddress) modules = [node]\n else {\n const typedAddress = asAddress(address)\n const byAddress = (typedAddress === undefined) ? undefined : await node.resolve(typedAddress, { maxDepth: 10 })\n\n if (byAddress) modules = [byAddress]\n else {\n const byName = await node.resolve(address, { direction: 'down' })\n if (byName) {\n const moduleAddress = assertEx(byName?.address, () => 'Error redirecting to module by address')\n res.redirect(StatusCodes.TEMPORARY_REDIRECT, `/${moduleAddress}`)\n return\n } else {\n return returnError(StatusCodes.NOT_FOUND, 'Module not found', { address })\n }\n }\n }\n\n if (modules.length > 0) {\n const mod = modules[0]\n const queryConfig = getQueryConfig(mod, req, bw, payloads)\n try {\n const queryResult = await mod.query(bw, payloads, queryConfig)\n res.json(queryResult)\n } catch (ex) {\n return returnError(StatusCodes.INTERNAL_SERVER_ERROR, 'Query Failed', { message: (ex as Error)?.message ?? 'Unknown Error' })\n }\n } else {\n return returnError(StatusCodes.NOT_FOUND, 'Module not found', { address })\n }\n}\n\nexport const postAddress = asyncHandler(handler)\n","import type { BoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { ModuleConfig, ModuleInstance } from '@xyo-network/module-model'\nimport { ModuleConfigSchema } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { Request } from 'express'\n\nconst DEFAULT_DEPTH = 5 as const\n\nexport const getQueryConfig = (mod: ModuleInstance, req: Request, bw: QueryBoundWitness, payloads?: Payload[]): ModuleConfig | undefined => {\n // TODO: Filter based on query addresses?\n // Recurse through payloads for nested BWs\n const nestedBwAddresses\n = payloads\n ?.flat(DEFAULT_DEPTH)\n .filter<BoundWitness>((payload): payload is BoundWitness => payload?.schema === BoundWitnessSchema)\n .map(bw => bw.addresses) ?? []\n // TODO: Do we want to end up with a list of addresses or a list of address lists?\n const addresses = [bw.addresses, ...nestedBwAddresses].filter(address => address.length > 0)\n const allowed = addresses.length > 0 ? Object.fromEntries(mod.queries.map(schema => [schema, addresses])) : {}\n const security = { allowed }\n return { schema: ModuleConfigSchema, security }\n}\n","import { setRawResponseFormat } from '@xylabs/express'\nimport { asHash } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport type {\n ArchivistInstance,\n ArchivistNextOptions, NextOptions,\n} from '@xyo-network/archivist-model'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isAnyPayload, isSequence } from '@xyo-network/payload-model'\nimport type { Router } from 'express'\nimport express from 'express'\nimport type { Request } from 'express-serve-static-core'\n\nconst resolveArchivist = async (node: NodeInstance, archivistModuleIdentifier: ModuleIdentifier): Promise<ArchivistInstance> => {\n const mod = await node.resolve(archivistModuleIdentifier)\n return asArchivistInstance(mod, { required: true })\n}\n\nlet archivistInstance: ArchivistInstance | undefined\n\nconst getArchivist = async (node: NodeInstance, archivistModuleIdentifier: ModuleIdentifier): Promise<ArchivistInstance> => {\n if (isDefined(archivistInstance)) return archivistInstance\n archivistInstance = await resolveArchivist(node, archivistModuleIdentifier)\n return archivistInstance\n}\n\ntype ArchivistMiddlewareOptions = {\n archivistModuleIdentifier: ModuleIdentifier\n node: NodeInstance\n}\n\nexport const archivistMiddleware = (options: ArchivistMiddlewareOptions): Router => {\n const { node, archivistModuleIdentifier } = options\n const router = express.Router({ mergeParams: true })\n\n router.post('/insert', async (req, res) => {\n setRawResponseFormat(res)\n const body = Array.isArray(req.body) ? req.body : [req.body]\n const payloads = (await PayloadBuilder.hashPairs<Payload>(body)).map(p => p[0])\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await archivist.insert(payloads)\n res.status(200).json(result)\n })\n\n router.get('/next', async (req: Request<Partial<NextOptions>>, res) => {\n setRawResponseFormat(res)\n const cursor = isSequence(req.query.cursor) ? req.query.cursor : undefined\n const limit = isDefined(req.query.limit) ? Number(req.query.limit) : undefined\n const open = isDefined(req.query.open) ? Boolean(req.query.open) : undefined\n const order = req.query.order === 'asc' ? 'asc' : 'desc'\n const options: ArchivistNextOptions = {\n limit, open, order, cursor,\n }\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await archivist.next(options)\n res.status(200).json(result)\n })\n router.post('/next', async (req: Request<{}, {}, ArchivistNextOptions | undefined>, res) => {\n setRawResponseFormat(res)\n const options = req.body\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await (isDefined(options) ? archivist.next(options) : archivist.next())\n res.status(200).json(result)\n })\n\n router.get('/get/:hash', async (req, res) => {\n setRawResponseFormat(res)\n const { hash: rawHash } = req.params\n const hash = asHash(rawHash)\n if (isDefined(hash)) {\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const [payload] = await archivist.get([hash])\n if (isAnyPayload(payload)) {\n res.json(payload)\n return\n }\n }\n res.status(400).send()\n })\n\n return router\n}\n","import type { Express } from 'express'\n\nimport { archivistMiddleware } from './archivistMiddleware.ts'\n\nexport const addDataLakeRoutes = (app: Express) => {\n const { node } = app\n const archivistModuleIdentifier = 'Chain:Finalized'\n app.use('/chain', archivistMiddleware({ node, archivistModuleIdentifier }))\n}\n","import { setRawResponseFormat } from '@xylabs/express'\nimport {\n NodeNetworkStakeViewer, NodeStepRewardsByPositionViewer, NodeXyoViewer,\n} from '@xyo-network/chain-rpc'\nimport { RewardMultipliers, type StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'\nimport {\n NodeXyoRunner, rpcEngineFromConnection,\n XyoBaseConnection,\n} from '@xyo-network/xl1-rpc'\nimport type { Express } from 'express'\n\nexport const addRpcRoutes = async (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => {\n const { node } = app\n const runner = new NodeXyoRunner(node)\n const networkStakeViewer = await NodeNetworkStakeViewer.create({ context: stakedChainContext })\n\n console.log('Initializing NodeNetworkStakeViewer...')\n await networkStakeViewer.start()\n console.log('Initialized NodeNetworkStakeViewer.')\n\n const viewer = await NodeXyoViewer.create({\n node, rewardMultipliers: RewardMultipliers, initRewardsCache, networkStakeViewer,\n })\n\n console.log('Initializing NodeXyoViewer...')\n await viewer.start()\n console.log('Initialized NodeXyoViewer.')\n\n const stepRewardsByPositionViewer = await NodeStepRewardsByPositionViewer.create({\n context: stakedChainContext,\n rewardMultipliers: RewardMultipliers,\n })\n\n console.log('Initializing NodeStepRewardsByPositionViewer...')\n await stepRewardsByPositionViewer.start()\n console.log('Initialized NodeStepRewardsByPositionViewer.')\n\n const connection = new XyoBaseConnection({ runner, viewer })\n const engine = rpcEngineFromConnection(connection, networkStakeViewer)\n\n app.post('/rpc', (req, res) => {\n setRawResponseFormat(res)\n engine.handle(req.body, (_, rpcResponse) => {\n res.json(rpcResponse)\n })\n })\n}\n","import type { StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'\nimport type { Express } from 'express'\n\nimport { addNodeRoutes } from './address/index.ts'\nimport { addDataLakeRoutes } from './dataLake/index.ts'\nimport { addRpcRoutes } from './rpc/index.ts'\n\nexport const addRoutes = async (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => {\n await addRpcRoutes(app, stakedChainContext, initRewardsCache)\n addDataLakeRoutes(app)\n addNodeRoutes(app)\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toEthAddress } from '@xylabs/hex'\nimport type { Logger } from '@xylabs/logger'\nimport { isDefined, isString } from '@xylabs/typeof'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { boot } from '@xyo-network/bios'\nimport type { BiosExternalInterface } from '@xyo-network/bios-model'\nimport { EthereumChainStake, EthereumChainStakeEvents } from '@xyo-network/chain-ethereum'\nimport { findMostRecentBlock } from '@xyo-network/chain-protocol'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { StakedXyoChainV2__factory } from '@xyo-network/typechain'\nimport { HDWallet } from '@xyo-network/wallet'\nimport type { ChainId } from '@xyo-network/xl1-protocol'\nimport type { Config, StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'\nimport { readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'\n\nimport { initInfuraProvider } from '../helpers/index.ts'\nimport { getNode } from '../manifest/index.ts'\nimport { getApp } from './app.ts'\n\nconst hostname = '::'\n// const hostname = '0.0.0.0'\n\n// TODO: Make nodejs version of bios support round tripping mnemonic between boots\nconst getSeedPhrase = async (bios: BiosExternalInterface, config: Config, logger?: Logger): Promise<string> => {\n const storedSeedPhrase = await bios.seedPhraseStore.get('os')\n logger?.debug(`[API] Stored mnemonic: ${storedSeedPhrase}`)\n const { mnemonic } = config.api\n if (isString(storedSeedPhrase) && isString(mnemonic)) {\n logger?.warn('[API] Stored mnemonic does not match supplied. Updating stored mnemonic to supplied.')\n await bios.seedPhraseStore.set('os', mnemonic)\n } else {\n let seedPhrase: string\n if (isString(mnemonic)) {\n seedPhrase = mnemonic\n } else {\n seedPhrase = HDWallet.generateMnemonic()\n logger?.log('[API] No mnemonic provided, using random mnemonic. This is not recommended for production use.')\n logger?.log(`[API] Mnemonic: ${seedPhrase}`)\n }\n await bios.seedPhraseStore.set('os', seedPhrase)\n }\n return assertEx(await bios.seedPhraseStore.get('os'), () => 'Unable to acquire mnemonic from bios')\n}\n\ninterface GetServerContext {\n config: Config\n logger?: Logger\n node?: NodeInstance\n}\n\nexport const getServer = async (context: GetServerContext) => {\n const {\n config, logger, node,\n } = context\n const { mnemonic, port } = context.config.api\n const bios = await boot()\n const seedPhrase = isDefined(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger)\n const wallet = await HDWallet.fromPhrase(seedPhrase)\n const provider = await initInfuraProvider(config)\n const contractAddress = assertEx(config.chain.id, () => 'Missing config.evm.chainId') as ChainId\n const contract = StakedXyoChainV2__factory.connect(toEthAddress(contractAddress), provider)\n const nodeContext = {\n wallet, logger, config,\n }\n const eventsReader = await EthereumChainStakeEvents.create({ contract, logger })\n assertEx(await eventsReader.start(), () => 'Failed to start EthereumChainStakeEvents reader')\n const stakeChainReader = await EthereumChainStake.create({\n contract, eventsReader, logger,\n })\n assertEx(await stakeChainReader.start(), () => 'Failed to start EthereumChainStake reader')\n const rootNode = await getNode(nodeContext)\n const chainArchivist = assertEx(asArchivistInstance(\n await rootNode.resolve('Chain:Validated'),\n { required: true },\n ), () => 'FinalizedArchivist not found in node')\n const chainMap = readPayloadMapFromStore<WithStorageMeta<Payload>>(chainArchivist)\n const resolvedNode: NodeInstance = node ?? await getNode(nodeContext)\n\n const stakedChainContext: StakedChainContextRead = {\n chainId: contractAddress,\n events: eventsReader,\n stake: stakeChainReader,\n store: { chainMap },\n head: async (): Promise<[Hash, number]> => {\n const head = await findMostRecentBlock(chainArchivist)\n return [assertEx(head?._hash, () => 'No head found in chainArchivist'), assertEx(head?.block, () => 'No head found in chainArchivist')]\n },\n }\n const mods = await resolvedNode.resolve('*')\n await Promise.all(mods.map((mod) => {\n return mod.start?.() ?? (() => true)\n }))\n const app = await getApp(resolvedNode, eventsReader, stakedChainContext, config.api.initRewardsCache)\n const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`))\n server.setTimeout(20_000)\n return server\n}\n","import { assertEx } from '@xylabs/assert'\nimport { hexFrom, isHex } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\n\nexport const canUseChainId = (config: Config): boolean => {\n return isDefined(config.evm.chainId)\n}\n\nexport const getChainId = (config: Config) => {\n const chainId = assertEx(config.evm.chainId, () => 'Missing config.evm.chainId')\n if (isHex(chainId, { prefix: true })) {\n const hex = hexFrom(chainId)\n const parsed = Number.parseInt(hex, 16)\n return parsed\n } else {\n const parsed = Number.parseInt(chainId, 10)\n return parsed\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\nimport type { Provider } from 'ethers'\nimport { InfuraWebSocketProvider } from 'ethers/providers'\n\nimport { canUseChainId, getChainId } from './initChainId.ts'\n\nlet instance: Promise<InfuraWebSocketProvider> | undefined\n\nexport const initInfuraProvider = (config: Config): Promise<Provider> => {\n if (instance) return instance\n const providerConfig = getInfuraProviderConfig(config)\n instance = Promise.resolve(new InfuraWebSocketProvider(providerConfig[0], providerConfig[1]))\n return instance\n}\n\nexport const canUseInfuraProvider = (config: Config): boolean => {\n return canUseChainId(config)\n && isDefined(config.evm?.infura?.projectId)\n && isDefined(config.evm?.infura?.projectSecret)\n}\n\nexport const getInfuraProviderConfig = (config: Config) => {\n const projectId = assertEx(config.evm?.infura?.projectId, () => 'Missing config.evm.infura.projectId')\n const projectSecret = assertEx(config.evm?.infura?.projectSecret, () => 'Missing config.evm.infura.projectSecret')\n return [getChainId(config), projectId, projectSecret] as const\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { asAddress, ZERO_ADDRESS } from '@xylabs/hex'\nimport type { Logger } from '@xylabs/logger'\nimport { BaseMongoSdk, type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'\nimport { isDefined } from '@xylabs/typeof'\nimport { MemoryArchivist } from '@xyo-network/archivist-memory'\nimport { MongoDBArchivistV2 } from '@xyo-network/archivist-mongodb'\nimport { ViewArchivist } from '@xyo-network/archivist-view'\nimport {\n AddressBalanceDivinerV2, AddressTransferDiviner, ArchivistSyncDiviner, HeadValidationDiviner,\n} from '@xyo-network/chain-modules'\nimport { initTelemetry } from '@xyo-network/chain-telemetry'\nimport { AbstractModule, LoggerModuleStatusReporter } from '@xyo-network/module-abstract'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { MongoDBModuleParamsV2 } from '@xyo-network/module-model-mongodb'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { StepSizes } from '@xyo-network/xl1-protocol'\nimport type {\n BalancesStepSummary, Config, MapType, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport { hasMongoConfig } from '@xyo-network/xl1-protocol-sdk'\nimport { Semaphore } from 'async-mutex'\n\nimport { MongoMap } from '../driver/index.ts'\n\nexport interface GetLocatorContext {\n config: Config\n logger?: Logger\n}\n\n/**\n * Used for retrieving a locator with the necessary modules registered for testing\n * operation of the node (entirely in memory)\n * @returns A locator with the necessary modules registered\n */\nexport const getLocator = async (context: GetLocatorContext) => {\n const { config, logger } = context\n const { otlpEndpoint } = config.telemetry?.otel ?? {}\n const { traceProvider, meterProvider } = await initTelemetry({\n attributes: {\n serviceName: 'xl1-api',\n serviceVersion: '1.0.0',\n },\n otlpEndpoint,\n metricsConfig: {\n endpoint: '/metrics',\n port: 9465,\n },\n })\n\n if (isDefined(logger)) AbstractModule.defaultLogger = logger\n const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : undefined\n\n const locator = new ModuleFactoryLocator()\n let balanceSummaryMap: MapType<string, WithStorageMeta<BalancesStepSummary>> | undefined\n let transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined\n // If there's a MongoDB configuration\n const mongoConfig = config.storage?.mongo\n if (hasMongoConfig(mongoConfig)) {\n // Create the MongoDB SDK from the configuration\n const {\n connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,\n } = mongoConfig\n const payloadSdkConfig: BaseMongoSdkPrivateConfig = {\n dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,\n }\n const params: Partial<MongoDBModuleParamsV2> = {\n meterProvider, payloadSdkConfig, statusReporter, traceProvider,\n }\n // Register the MongoDB Archivist as the default\n locator.register(MongoDBArchivistV2.factory(params), undefined, true)\n\n // Use a persistent MongoMap for the summary repository if MongoDB is configured\n const sdkBalanceSummaryMap = new BaseMongoSdk<WithStorageMeta<BalancesStepSummary>>({ ...payloadSdkConfig, collection: 'balance_summary_map' })\n balanceSummaryMap = await MongoMap.create<MongoMap<Hash, WithStorageMeta<BalancesStepSummary>>>({\n sdk: sdkBalanceSummaryMap,\n getCache: { enabled: true, maxEntries: 5000 },\n })\n\n const sdkTransferSummaryMap = new BaseMongoSdk<WithStorageMeta<TransfersStepSummary>>({ ...payloadSdkConfig, collection: 'transfer_summary_map' })\n transferSummaryMap = await MongoMap.create<MongoMap<Hash, WithStorageMeta<TransfersStepSummary>>>({\n sdk: sdkTransferSummaryMap,\n getCache: { enabled: true, maxEntries: 5000 },\n })\n }\n\n locator.register(AddressBalanceDivinerV2.factory<AddressBalanceDivinerV2>({\n traceProvider, meterProvider, statusReporter, summaryMap: balanceSummaryMap, stepSemaphores: StepSizes.map(() => new Semaphore(20)),\n }))\n\n locator.register(AddressTransferDiviner.factory<AddressTransferDiviner>({\n traceProvider, meterProvider, statusReporter, summaryMap: transferSummaryMap, stepSemaphores: StepSizes.map(() => new Semaphore(20)),\n }))\n\n const chainId = isDefined(config.chain.id)\n ? assertEx(asAddress(config.chain.id), () => 'chain.id must be an Address')\n : ZERO_ADDRESS\n locator.register(HeadValidationDiviner.factory<HeadValidationDiviner>({\n traceProvider,\n meterProvider,\n statusReporter,\n chainId,\n allowedProducers: config.producer.allowlist,\n }))\n locator.register(MemoryArchivist.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(MemorySentinel.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(ViewArchivist.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(ArchivistSyncDiviner.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n return locator\n}\n","import { assertEx } from '@xylabs/assert'\nimport {\n AbstractCreatable, creatable, CreatableParams,\n} from '@xylabs/creatable'\nimport { BaseMongoSdk } from '@xylabs/mongo'\nimport { isNull } from '@xylabs/typeof'\nimport { AsynchronousMap } from '@xyo-network/xl1-protocol-sdk'\nimport { LRUCache } from 'lru-cache'\nimport {\n Document, Filter, OptionalUnlessRequiredId, WithId,\n} from 'mongodb'\n\nexport interface MongoMapParams<TData extends Document = Document> extends CreatableParams {\n getCache?: {\n enabled: boolean\n maxEntries?: number\n }\n sdk: BaseMongoSdk<TData>\n}\n\nfunction stripMongoId<V extends Document>(doc: WithId<V>): V {\n const { _id, ...rest } = doc\n return rest as unknown as V\n}\n\n@creatable()\nexport class MongoMap<K extends {} = string, V extends Document = Document>\n extends AbstractCreatable<MongoMapParams<V>>\n implements AsynchronousMap<K, V> {\n private _getCache: LRUCache<K, V> | undefined\n\n get sdk(): BaseMongoSdk<V> {\n return assertEx(this.params.sdk, () => 'No sdk specified')\n }\n\n async clear(): Promise<void> {\n this._getCache?.clear()\n await this.sdk.deleteMany({})\n }\n\n async delete(id: K): Promise<boolean> {\n this._getCache?.delete(id)\n\n const filter = { _id: id } as Filter<V>\n const result = await this.sdk.deleteOne(filter)\n return result.deletedCount > 0\n }\n\n async get(id: K): Promise<V | undefined> {\n if (this._getCache) {\n const getCacheResult = this._getCache.get(id)\n if (getCacheResult) {\n return getCacheResult\n }\n }\n const filter = { _id: id } as Filter<V>\n const doc = await this.sdk.findOne(filter)\n return isNull(doc) ? undefined : stripMongoId(doc)\n }\n\n async getMany(ids: K[]): Promise<V[]> {\n /* const results = await Promise.all(ids.map(async (id) => {\n return await this.get(id)\n }))\n return results.filter(exists) */\n const cache = this._getCache\n const idSet = new Set(ids)\n const results: V[] = []\n if (cache) {\n const getCacheResult = ids.map(id => ([id, cache.get(id)])).filter(([, item]) => item !== undefined) as [K, V][]\n for (const [id] of getCacheResult) {\n idSet.delete(id)\n }\n results.push(...getCacheResult.map(([, item]) => item))\n }\n const filter = { _id: { $in: [...idSet] } } as Filter<V>\n const items = await (await this.sdk.find(filter)).toArray()\n for (const item of items) {\n const id = item._id\n const stripped = stripMongoId(item)\n if (cache) {\n cache.set(id as unknown as K, stripped)\n }\n results.push(stripped)\n }\n return results\n }\n\n async has(id: K): Promise<boolean> {\n if (this._getCache) {\n const getCacheResult = this._getCache.has(id)\n if (getCacheResult) {\n return getCacheResult\n }\n }\n const filter = { _id: id } as Filter<V>\n const exists = await this.sdk.findOne(filter)\n return isNull(exists) ? false : true\n }\n\n async set(id: K, data: V): Promise<void> {\n const filter = { _id: id } as Filter<V>\n const value = { ...data, _id: id } as OptionalUnlessRequiredId<V>\n await this.sdk.replaceOne(filter, value, { upsert: true })\n this._getCache?.set(id, data)\n }\n\n override async startHandler(): Promise<void> {\n await super.startHandler()\n // TODO: Ensure index\n\n if (this.params.getCache?.enabled === true) {\n const maxEntries = this.params.getCache?.maxEntries ?? 5000\n this._getCache = new LRUCache<K, V>({ max: maxEntries })\n }\n }\n}\n","import type { Logger } from '@xylabs/logger'\nimport { ManifestWrapper } from '@xyo-network/manifest-wrapper'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\n\nimport { getLocator } from './getLocator.ts'\nimport { NodeManifest } from './nodeManifest.ts'\nimport { PrivateChildManifests } from './private/index.ts'\nimport { PublicChildManifests } from './public/index.ts'\n\nexport interface GetNodeContext {\n config: Config\n logger?: Logger\n wallet: WalletInstance\n}\n\n/**\n * Creates a node with the xyo-chain modules registered\n * @param context The context to use for the node\n * @returns A node with the xyo-chain modules registered\n */\nexport const getNode = async (context: GetNodeContext) => {\n const { wallet } = context\n const locator = await getLocator(context)\n const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests)\n const [node, ...childNodes] = await wrapper.loadNodes()\n if (childNodes?.length > 0) {\n await Promise.all(childNodes.map(childNode => node.register(childNode)))\n await Promise.all(childNodes.map(childNode => node.attach(childNode.address, true)))\n }\n return node\n}\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"44'/60'/1\",\n \"name\": \"XYOChain\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": []\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","import type { PackageManifestPayload } from '@xyo-network/manifest-model'\n\nimport node from './node.json' with { type: 'json' }\n\n/**\n * Root Node Manifest\n */\nexport const NodeManifest = node as PackageManifestPayload\n","/**\n * Private Child Manifests\n */\nexport const PrivateChildManifests = []\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"1\",\n \"name\": \"Chain\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [\n {\n \"config\": {\n \"accountPath\": \"1/1'/1'\",\n \"name\": \"Validated\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_validated\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/2'\",\n \"schema\": \"network.xyo.diviner.chain.head.validation.config\",\n \"eventSubscriptions\": [\n {\n \"sourceEvent\": \"inserted\",\n \"sourceModule\": \"Submissions\",\n \"targetModuleFunction\": \"divine\"\n }\n ],\n \"inArchivist\": \"Submissions\",\n \"outArchivist\": \"Validated\",\n \"name\": \"HeadValidationDiviner\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/3'\",\n \"automations\": [\n {\n \"frequency\": 1000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"ChainValidationSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"HeadValidationDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/4'\",\n \"automations\": [\n {\n \"frequency\": 10000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"AddressBalancePollingSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"AddressBalanceDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/5'\",\n \"automations\": [\n {\n \"frequency\": 10000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"AddressTransferPollingSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"AddressTransferDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n }\n ],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1/1/1\",\n \"name\": \"Submissions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_submissions\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/2\",\n \"name\": \"Finalized\",\n \"allowedQueries\": [\n \"network.xyo.query.archivist.get\",\n \"network.xyo.query.archivist.next\"\n ],\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 50000\n },\n \"originArchivist\": \"Validated\",\n \"schema\": \"network.xyo.archivist.view.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/3'\",\n \"name\": \"AddressBalanceDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.balance.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_balance\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/4'\",\n \"name\": \"AddressTransferDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.transfer.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_transfer\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"2\",\n \"name\": \"Pending\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"2/1/2\",\n \"name\": \"PendingTransactions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"labels\": {\n \"network.xyo.storage.class\": \"mongodb\"\n },\n \"payloadSdkConfig\": {\n \"collection\": \"pending_bundles\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'\n\nimport Chain from './Chain.json' with { type: 'json' }\nimport Pending from './Pending.json' with { type: 'json' }\n\n/**\n * Chain Node Manifest\n */\nexport const ChainNodeManifest = Chain as PackageManifestPayload\n/**\n * Pending Node Manifest\n */\nexport const PendingNodeManifest = Pending as PackageManifestPayload\n/**\n * Public Child Manifests\n */\nexport const PublicChildManifests: ModuleManifest[] = [\n ...ChainNodeManifest.nodes,\n ...PendingNodeManifest.nodes,\n]\n"],"mappings":";;;;AAAA,SACEA,uBACAC,6BACAC,sCACAC,mBACAC,0BACAC,kBACAC,gBACAC,yBACK;AAGP,OAAOC,iBAAiB;AACxB,OAAOC,UAAU;AAEjB,OA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AAA;AAEzD,QAAMgB,qBAA6C;IACjDC,SAASxB;IACTyB,QAAQjB;IACRkB,OAAOd;IACPe,OAAO;MAAEP;IAAS;IAClBQ,MAAM,mCAAA;AACJ,YAAMA,OAAO,MAAMC,oBAAoBb,cAAAA;AACvC,aAAO;QAAC3B,UAASuC,MAAME,OAAO,MAAM,iCAAA;QAAoCzC,UAASuC,MAAMG,OAAO,MAAM,iCAAA;;IACtG,GAHM;EAIR;AACA,QAAMC,OAAO,MAAMV,aAAaJ,QAAQ,GAAA;AACxC,QAAMe,QAAQC,IAAIF,KAAKG,IAAI,CAACC,QAAAA;AAC1B,WAAOA,IAAIzB,QAAK,MAAS,MAAM;EACjC,CAAA,CAAA;AACA,QAAM0B,MAAM,MAAMC,OAAOhB,cAAcd,cAAce,oBAAoBjD,OAAOO,IAAI0D,gBAAgB;AACpG,QAAMC,SAASH,IAAII,OAAOhD,MAAMtB,UAAU,MAAMI,QAAQa,IAAI,oCAAoCjB,QAAAA,IAAYsB,IAAAA,EAAM,CAAA;AAClH+C,SAAOE,WAAW,GAAA;AAClB,SAAOF;AACT,GA9CyB;","names":["customPoweredByHeader","disableCaseSensitiveRouting","disableExpressDefaultPoweredByHeader","getJsonBodyParser","getJsonBodyParserOptions","responseProfiler","standardErrors","standardResponses","compression","cors","express","registerInstrumentations","ExpressInstrumentation","HttpInstrumentation","addInstrumentation","instrumentations","HttpInstrumentation","ExpressInstrumentation","registerInstrumentations","StatusCodes","assertEx","asyncHandler","asAddress","toAddress","isModuleIdentifierPart","StatusCodes","handler","req","res","next","address","rawAddress","params","node","app","asAddress","undefined","mod","resolve","direction","json","state","isModuleIdentifierPart","moduleIdentifier","toAddress","moduleAddress","assertEx","redirect","StatusCodes","MOVED_TEMPORARILY","getAddress","asyncHandler","assertEx","asyncHandler","asAddress","isAddress","toAddress","isQueryBoundWitness","ModuleErrorBuilder","StatusCodes","BoundWitnessSchema","ModuleConfigSchema","DEFAULT_DEPTH","getQueryConfig","mod","req","bw","payloads","nestedBwAddresses","flat","filter","payload","schema","BoundWitnessSchema","map","addresses","address","length","allowed","Object","fromEntries","queries","security","ModuleConfigSchema","handler","req","res","next","returnError","code","message","details","error","ModuleErrorBuilder","build","locals","rawResponse","status","json","address","params","node","app","bw","payloads","Array","isArray","body","isAddress","StatusCodes","BAD_REQUEST","isQueryBoundWitness","modules","normalizedAddress","toAddress","typedAddress","asAddress","byAddress","undefined","resolve","maxDepth","byName","direction","moduleAddress","assertEx","redirect","TEMPORARY_REDIRECT","NOT_FOUND","length","mod","queryConfig","getQueryConfig","queryResult","query","ex","INTERNAL_SERVER_ERROR","postAddress","asyncHandler","addNodeRoutes","app","defaultModule","node","address","defaultModuleEndpoint","get","_req","res","redirect","StatusCodes","MOVED_TEMPORARILY","post","TEMPORARY_REDIRECT","getAddress","postAddress","sendStatus","NOT_FOUND","setRawResponseFormat","asHash","isDefined","asArchivistInstance","PayloadBuilder","isAnyPayload","isSequence","express","resolveArchivist","node","archivistModuleIdentifier","mod","resolve","asArchivistInstance","required","archivistInstance","getArchivist","isDefined","archivistMiddleware","options","router","express","Router","mergeParams","post","req","res","setRawResponseFormat","body","Array","isArray","payloads","PayloadBuilder","hashPairs","map","p","archivist","result","insert","status","json","get","cursor","isSequence","query","undefined","limit","Number","open","Boolean","order","next","hash","rawHash","params","asHash","payload","isAnyPayload","send","addDataLakeRoutes","app","node","archivistModuleIdentifier","use","archivistMiddleware","setRawResponseFormat","NodeNetworkStakeViewer","NodeStepRewardsByPositionViewer","NodeXyoViewer","RewardMultipliers","NodeXyoRunner","rpcEngineFromConnection","XyoBaseConnection","addRpcRoutes","app","stakedChainContext","initRewardsCache","node","runner","NodeXyoRunner","networkStakeViewer","NodeNetworkStakeViewer","create","context","console","log","start","viewer","NodeXyoViewer","rewardMultipliers","RewardMultipliers","stepRewardsByPositionViewer","NodeStepRewardsByPositionViewer","connection","XyoBaseConnection","engine","rpcEngineFromConnection","post","req","res","setRawResponseFormat","handle","body","_","rpcResponse","json","addRoutes","app","stakedChainContext","initRewardsCache","addRpcRoutes","addDataLakeRoutes","addNodeRoutes","getApp","node","eventsReader","stakedChainContext","initRewardsCache","addInstrumentation","app","express","set","use","cors","compression","responseProfiler","getJsonBodyParser","getJsonBodyParserOptions","limit","standardResponses","disableExpressDefaultPoweredByHeader","customPoweredByHeader","disableCaseSensitiveRouting","addRoutes","standardErrors","assertEx","toEthAddress","isDefined","isString","asArchivistInstance","boot","EthereumChainStake","EthereumChainStakeEvents","findMostRecentBlock","StakedXyoChainV2__factory","HDWallet","readPayloadMapFromStore","assertEx","hexFrom","isHex","isDefined","getChainId","config","chainId","assertEx","evm","isHex","prefix","hex","hexFrom","parsed","Number","parseInt","assertEx","isDefined","InfuraWebSocketProvider","instance","initInfuraProvider","config","providerConfig","getInfuraProviderConfig","Promise","resolve","InfuraWebSocketProvider","getInfuraProviderConfig","config","projectId","assertEx","evm","infura","projectSecret","getChainId","assertEx","asAddress","ZERO_ADDRESS","BaseMongoSdk","isDefined","MemoryArchivist","MongoDBArchivistV2","ViewArchivist","AddressBalanceDivinerV2","AddressTransferDiviner","ArchivistSyncDiviner","HeadValidationDiviner","initTelemetry","AbstractModule","LoggerModuleStatusReporter","ModuleFactoryLocator","MemorySentinel","StepSizes","hasMongoConfig","Semaphore","assertEx","AbstractCreatable","creatable","isNull","LRUCache","stripMongoId","doc","_id","rest","MongoMap","AbstractCreatable","_getCache","sdk","assertEx","params","clear","deleteMany","delete","id","filter","result","deleteOne","deletedCount","get","getCacheResult","findOne","isNull","undefined","getMany","ids","cache","idSet","Set","results","map","item","push","$in","items","find","toArray","stripped","set","has","exists","data","value","replaceOne","upsert","startHandler","getCache","enabled","maxEntries","LRUCache","max","getLocator","context","config","logger","otlpEndpoint","telemetry","otel","traceProvider","meterProvider","initTelemetry","attributes","serviceName","serviceVersion","metricsConfig","endpoint","port","isDefined","AbstractModule","defaultLogger","statusReporter","LoggerModuleStatusReporter","undefined","locator","ModuleFactoryLocator","balanceSummaryMap","transferSummaryMap","mongoConfig","storage","mongo","hasMongoConfig","connectionString","dbConnectionString","database","dbName","domain","dbDomain","password","dbPassword","username","dbUserName","payloadSdkConfig","params","register","MongoDBArchivistV2","factory","sdkBalanceSummaryMap","BaseMongoSdk","collection","MongoMap","create","sdk","getCache","enabled","maxEntries","sdkTransferSummaryMap","AddressBalanceDivinerV2","summaryMap","stepSemaphores","StepSizes","map","Semaphore","AddressTransferDiviner","chainId","chain","id","assertEx","asAddress","ZERO_ADDRESS","HeadValidationDiviner","allowedProducers","producer","allowlist","MemoryArchivist","MemorySentinel","ViewArchivist","ArchivistSyncDiviner","ManifestWrapper","NodeManifest","node","PrivateChildManifests","ChainNodeManifest","Chain","PendingNodeManifest","Pending","PublicChildManifests","nodes","getNode","context","wallet","locator","getLocator","wrapper","ManifestWrapper","NodeManifest","PublicChildManifests","PrivateChildManifests","node","childNodes","loadNodes","length","Promise","all","map","childNode","register","attach","address","hostname","getSeedPhrase","bios","config","logger","storedSeedPhrase","seedPhraseStore","get","debug","mnemonic","api","isString","warn","set","seedPhrase","HDWallet","generateMnemonic","log","assertEx","getServer","context","node","port","boot","isDefined","wallet","fromPhrase","provider","initInfuraProvider","contractAddress","chain","id","contract","StakedXyoChainV2__factory","connect","toEthAddress","nodeContext","eventsReader","EthereumChainStakeEvents","create","start","stakeChainReader","EthereumChainStake","rootNode","getNode","chainArchivist","asArchivistInstance","resolve","required","chainMap","readPayloadMapFromStore","resolvedNode","stakedChainContext","chainId","events","stake","store","head","findMostRecentBlock","_hash","block","mods","Promise","all","map","mod","app","getApp","initRewardsCache","server","listen","setTimeout"]}
1
+ {"version":3,"sources":["../../src/server/app.ts","../../src/server/instrumentation.ts","../../src/server/routes/address/addNodeRoutes.ts","../../src/server/routes/address/get/get.ts","../../src/server/routes/address/post/post.ts","../../src/server/routes/address/post/getQueryConfig.ts","../../src/server/routes/dataLake/archivistMiddleware.ts","../../src/server/routes/dataLake/addDataLakeRoutes.ts","../../src/server/routes/rpc/routes/addRpcRoutes.ts","../../src/server/routes/addRoutes.ts","../../src/server/server.ts","../../src/helpers/initChainId.ts","../../src/helpers/initInfuraProvider.ts","../../src/manifest/getLocator.ts","../../src/driver/mongo/MongoMap.ts","../../src/manifest/getNode.ts","../../src/manifest/node.json","../../src/manifest/nodeManifest.ts","../../src/manifest/private/index.ts","../../src/manifest/public/WithMempool/Chain.json","../../src/manifest/public/WithMempool/Pending.json","../../src/manifest/public/WithMempool/index.ts","../../src/manifest/public/WithoutMempool/Chain.json","../../src/manifest/public/WithoutMempool/Pending.json","../../src/manifest/public/WithoutMempool/index.ts"],"sourcesContent":["import {\n customPoweredByHeader,\n disableCaseSensitiveRouting,\n disableExpressDefaultPoweredByHeader,\n getJsonBodyParser,\n getJsonBodyParserOptions,\n responseProfiler,\n standardErrors,\n standardResponses,\n} from '@xylabs/express'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type {\n MapType, StakedChainContextRead, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport compression from 'compression'\nimport cors from 'cors'\nimport type { Express } from 'express'\nimport express from 'express'\n\nimport { addInstrumentation } from './instrumentation.ts'\nimport { addRoutes } from './routes/index.ts'\n\nexport const getApp = async (\n node: NodeInstance,\n transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,\n stakedChainContext: StakedChainContextRead,\n initRewardsCache?: boolean,\n): Promise<Express> => {\n addInstrumentation()\n const app = express()\n app.set('etag', false)\n\n app.use(cors())\n app.use(compression())\n app.use(responseProfiler)\n app.use(getJsonBodyParser(getJsonBodyParserOptions({ limit: '1mb' })))\n app.use(standardResponses)\n disableExpressDefaultPoweredByHeader(app)\n app.use(customPoweredByHeader)\n disableCaseSensitiveRouting(app)\n app.node = node\n await addRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache)\n app.use(standardErrors)\n return app\n}\n","import { registerInstrumentations } from '@opentelemetry/instrumentation'\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\n\n/**\n * Registers OpenTelemetry instrumentations for HTTP and Express.\n * This function is used to set up the necessary instrumentations for monitoring\n * HTTP requests and Express applications. Since it monkey patches the Express\n * router & middleware system, it should be called before any Express applications\n * are defined.\n */\nexport const addInstrumentation = () => {\n const instrumentations = [new HttpInstrumentation(), new ExpressInstrumentation()]\n registerInstrumentations({ instrumentations })\n}\n","import type { Express } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport { getAddress } from './get/index.ts'\nimport { postAddress } from './post/index.ts'\n\nexport const addNodeRoutes = (app: Express) => {\n const defaultModule = app.node\n const address = defaultModule.address\n const defaultModuleEndpoint = `/${address}`\n app.get('/', (_req, res) => res.redirect(StatusCodes.MOVED_TEMPORARILY, defaultModuleEndpoint))\n app.post('/', (_req, res) => res.redirect(StatusCodes.TEMPORARY_REDIRECT, defaultModuleEndpoint))\n app.get('/:address', getAddress)\n app.post('/:address', postAddress)\n app.get('/:hash', (_req, res) => {\n res.sendStatus(StatusCodes.NOT_FOUND)\n })\n app.post('/:hash', (_req, res) => {\n res.sendStatus(StatusCodes.NOT_FOUND)\n })\n}\n","import { asyncHandler } from '@xylabs/express'\nimport { asAddress } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport { isModuleName } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { RequestHandler } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport type { AddressPathParams } from '../AddressPathParams.ts'\n\nconst handler: RequestHandler<AddressPathParams, Payload[]> = async (req, res, next) => {\n const { address: moduleIdentifier } = req.params\n const { node } = req.app\n const address = asAddress(moduleIdentifier)\n if (isDefined(address)) {\n let mod = node.address === address ? node : (await node.resolve(address, { direction: 'down' }))\n if (mod) {\n res.json(await mod.state())\n return\n }\n }\n if (isModuleName(moduleIdentifier)) {\n const mod = await node.resolve(moduleIdentifier, { direction: 'down' })\n if (mod) {\n res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${mod.address}`)\n return\n }\n }\n next('route')\n}\nexport const getAddress = asyncHandler(handler)\n","import { assertEx } from '@xylabs/assert'\nimport { asyncHandler } from '@xylabs/express'\nimport {\n asAddress, isAddress,\n toAddress,\n} from '@xylabs/hex'\nimport type { JsonObject } from '@xylabs/object'\nimport { isQueryBoundWitness, type QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleErrorBuilder } from '@xyo-network/module-abstract'\nimport type { ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'\nimport type { ModuleError, Payload } from '@xyo-network/payload-model'\nimport type { RequestHandler } from 'express'\nimport { StatusCodes } from 'http-status-codes'\n\nimport type { AddressPathParams } from '../AddressPathParams.ts'\nimport { getQueryConfig } from './getQueryConfig.ts'\n\ntype PostAddressRequestBody = [QueryBoundWitness, undefined | Payload[]]\n\nconst handler: RequestHandler<AddressPathParams, ModuleQueryResult | ModuleError, PostAddressRequestBody> = async (req, res, next) => {\n const returnError = (code: number, message = 'An error occurred', details?: JsonObject) => {\n const error = new ModuleErrorBuilder().message(message).details(details).build()\n res.locals.rawResponse = false\n res.status(code).json(error)\n next()\n }\n\n const { address } = req.params\n const { node } = req.app\n const [bw, payloads] = Array.isArray(req.body) ? req.body : []\n if (!isAddress(address)) {\n return returnError(StatusCodes.BAD_REQUEST, 'Missing address')\n }\n\n if (!bw) {\n return returnError(StatusCodes.BAD_REQUEST, 'Missing boundwitness')\n }\n\n if (!isQueryBoundWitness(bw)) {\n return returnError(StatusCodes.BAD_REQUEST, 'Invalid query boundwitness')\n }\n\n let modules: ModuleInstance[] = []\n const normalizedAddress = toAddress(address)\n if (node.address === normalizedAddress) modules = [node]\n else {\n const typedAddress = asAddress(address)\n const byAddress = (typedAddress === undefined) ? undefined : await node.resolve(typedAddress, { maxDepth: 10 })\n\n if (byAddress) modules = [byAddress]\n else {\n const byName = await node.resolve(address, { direction: 'down' })\n if (byName) {\n const moduleAddress = assertEx(byName?.address, () => 'Error redirecting to module by address')\n res.redirect(StatusCodes.TEMPORARY_REDIRECT, `/${moduleAddress}`)\n return\n } else {\n return returnError(StatusCodes.NOT_FOUND, 'Module not found', { address })\n }\n }\n }\n\n if (modules.length > 0) {\n const mod = modules[0]\n const queryConfig = getQueryConfig(mod, req, bw, payloads)\n try {\n const queryResult = await mod.query(bw, payloads, queryConfig)\n res.json(queryResult)\n } catch (ex) {\n return returnError(StatusCodes.INTERNAL_SERVER_ERROR, 'Query Failed', { message: (ex as Error)?.message ?? 'Unknown Error' })\n }\n } else {\n return returnError(StatusCodes.NOT_FOUND, 'Module not found', { address })\n }\n}\n\nexport const postAddress = asyncHandler(handler)\n","import type { BoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport type { ModuleConfig, ModuleInstance } from '@xyo-network/module-model'\nimport { ModuleConfigSchema } from '@xyo-network/module-model'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { Request } from 'express'\n\nconst DEFAULT_DEPTH = 5 as const\n\nexport const getQueryConfig = (mod: ModuleInstance, req: Request, bw: QueryBoundWitness, payloads?: Payload[]): ModuleConfig | undefined => {\n // TODO: Filter based on query addresses?\n // Recurse through payloads for nested BWs\n const nestedBwAddresses\n = payloads\n ?.flat(DEFAULT_DEPTH)\n .filter<BoundWitness>((payload): payload is BoundWitness => payload?.schema === BoundWitnessSchema)\n .map(bw => bw.addresses) ?? []\n // TODO: Do we want to end up with a list of addresses or a list of address lists?\n const addresses = [bw.addresses, ...nestedBwAddresses].filter(address => address.length > 0)\n const allowed = addresses.length > 0 ? Object.fromEntries(mod.queries.map(schema => [schema, addresses])) : {}\n const security = { allowed }\n return { schema: ModuleConfigSchema, security }\n}\n","import { setRawResponseFormat } from '@xylabs/express'\nimport { asHash } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport type {\n ArchivistInstance,\n ArchivistNextOptions, NextOptions,\n} from '@xyo-network/archivist-model'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isAnyPayload, isSequence } from '@xyo-network/payload-model'\nimport type { Router } from 'express'\nimport express from 'express'\nimport type { Request } from 'express-serve-static-core'\n\nconst resolveArchivist = async (node: NodeInstance, archivistModuleIdentifier: ModuleIdentifier): Promise<ArchivistInstance> => {\n const mod = await node.resolve(archivistModuleIdentifier)\n return asArchivistInstance(mod, { required: true })\n}\n\nlet archivistInstance: ArchivistInstance | undefined\n\nconst getArchivist = async (node: NodeInstance, archivistModuleIdentifier: ModuleIdentifier): Promise<ArchivistInstance> => {\n if (isDefined(archivistInstance)) return archivistInstance\n archivistInstance = await resolveArchivist(node, archivistModuleIdentifier)\n return archivistInstance\n}\n\ntype ArchivistMiddlewareOptions = {\n archivistModuleIdentifier: ModuleIdentifier\n node: NodeInstance\n}\n\nexport const archivistMiddleware = (options: ArchivistMiddlewareOptions): Router => {\n const { node, archivistModuleIdentifier } = options\n const router = express.Router({ mergeParams: true })\n\n router.post('/insert', async (req, res) => {\n setRawResponseFormat(res)\n const body = Array.isArray(req.body) ? req.body : [req.body]\n const payloads = (await PayloadBuilder.hashPairs<Payload>(body)).map(p => p[0])\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await archivist.insert(payloads)\n res.status(200).json(result)\n })\n\n router.get('/next', async (req: Request<Partial<NextOptions>>, res) => {\n setRawResponseFormat(res)\n const cursor = isSequence(req.query.cursor) ? req.query.cursor : undefined\n const limit = isDefined(req.query.limit) ? Number(req.query.limit) : undefined\n const open = isDefined(req.query.open) ? Boolean(req.query.open) : undefined\n const order = req.query.order === 'asc' ? 'asc' : 'desc'\n const options: ArchivistNextOptions = {\n limit, open, order, cursor,\n }\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await archivist.next(options)\n res.status(200).json(result)\n })\n router.post('/next', async (req: Request<{}, {}, ArchivistNextOptions | undefined>, res) => {\n setRawResponseFormat(res)\n const options = req.body\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const result = await (isDefined(options) ? archivist.next(options) : archivist.next())\n res.status(200).json(result)\n })\n\n router.get('/get/:hash', async (req, res) => {\n setRawResponseFormat(res)\n const { hash: rawHash } = req.params\n const hash = asHash(rawHash)\n if (isDefined(hash)) {\n const archivist = await getArchivist(node, archivistModuleIdentifier)\n const [payload] = await archivist.get([hash])\n if (isAnyPayload(payload)) {\n res.json(payload)\n return\n }\n }\n res.status(400).send()\n })\n\n return router\n}\n","import type { Express } from 'express'\n\nimport { archivistMiddleware } from './archivistMiddleware.ts'\n\nexport const addDataLakeRoutes = (app: Express) => {\n const { node } = app\n const archivistModuleIdentifier = 'Chain:Finalized'\n app.use('/chain', archivistMiddleware({ node, archivistModuleIdentifier }))\n}\n","import { setRawResponseFormat } from '@xylabs/express'\nimport {\n NodeNetworkStakeViewer, NodeStepRewardsByPositionViewer, NodeXyoViewer,\n} from '@xyo-network/chain-rpc'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { StepSizes } from '@xyo-network/xl1-protocol'\nimport type {\n MapType, StakedChainContextRead, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport { RewardMultipliers } from '@xyo-network/xl1-protocol-sdk'\nimport {\n NodeXyoRunner, rpcEngineFromConnection,\n XyoBaseConnection,\n} from '@xyo-network/xl1-rpc'\nimport { Semaphore } from 'async-mutex'\nimport type { Express } from 'express'\n\nexport const addRpcRoutes = async (\n app: Express,\n transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,\n stakedChainContext: StakedChainContextRead,\n initRewardsCache?: boolean,\n) => {\n const { node } = app\n const runner = new NodeXyoRunner(node)\n const networkStakeViewer = await NodeNetworkStakeViewer.create({ context: stakedChainContext })\n\n console.log('Initializing NodeNetworkStakeViewer...')\n await networkStakeViewer.start()\n console.log('Initialized NodeNetworkStakeViewer.')\n\n const viewer = await NodeXyoViewer.create({\n node,\n rewardMultipliers: RewardMultipliers,\n initRewardsCache,\n context: stakedChainContext,\n transfersSummaryContext: {\n ...stakedChainContext, stepSemaphores: StepSizes.map(() => new Semaphore(20)), summaryMap: transferSummaryMap,\n },\n })\n\n console.log('Initializing NodeXyoViewer...')\n await viewer.start()\n console.log('Initialized NodeXyoViewer.')\n\n const stepRewardsByPositionViewer = await NodeStepRewardsByPositionViewer.create({\n context: stakedChainContext,\n rewardMultipliers: RewardMultipliers,\n })\n\n console.log('Initializing NodeStepRewardsByPositionViewer...')\n await stepRewardsByPositionViewer.start()\n console.log('Initialized NodeStepRewardsByPositionViewer.')\n\n const connection = new XyoBaseConnection({ runner, viewer })\n const engine = rpcEngineFromConnection(connection, networkStakeViewer)\n\n app.post('/rpc', (req, res) => {\n setRawResponseFormat(res)\n engine.handle(req.body, (_, rpcResponse) => {\n res.json(rpcResponse)\n })\n })\n}\n","import type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type {\n MapType, StakedChainContextRead, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport type { Express } from 'express'\n\nimport { addNodeRoutes } from './address/index.ts'\nimport { addDataLakeRoutes } from './dataLake/index.ts'\nimport { addRpcRoutes } from './rpc/index.ts'\n\nexport const addRoutes = async (\n app: Express,\n transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,\n stakedChainContext: StakedChainContextRead,\n initRewardsCache?: boolean,\n) => {\n await addRpcRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache)\n addDataLakeRoutes(app)\n addNodeRoutes(app)\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toEthAddress } from '@xylabs/hex'\nimport type { Logger } from '@xylabs/logger'\nimport { isDefined, isString } from '@xylabs/typeof'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { boot } from '@xyo-network/bios'\nimport type { BiosExternalInterface } from '@xyo-network/bios-model'\nimport { EthereumChainStake, EthereumChainStakeEvents } from '@xyo-network/chain-ethereum'\nimport { findMostRecentBlock, getLocalPersistentMap } from '@xyo-network/chain-protocol'\nimport type { NodeInstance } from '@xyo-network/node-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport { StakedXyoChainV2__factory } from '@xyo-network/typechain'\nimport { HDWallet } from '@xyo-network/wallet'\nimport type { ChainId } from '@xyo-network/xl1-protocol'\nimport type {\n Config, StakedChainContextRead, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport { readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'\n\nimport { initInfuraProvider } from '../helpers/index.ts'\nimport { getNode, getTransferSummaryMap } from '../manifest/index.ts'\nimport { getApp } from './app.ts'\n\nconst hostname = '::'\n// const hostname = '0.0.0.0'\n\n// TODO: Make nodejs version of bios support round tripping mnemonic between boots\nconst getSeedPhrase = async (bios: BiosExternalInterface, config: Config, logger?: Logger): Promise<string> => {\n const storedSeedPhrase = await bios.seedPhraseStore.get('os')\n logger?.debug(`[API] Stored mnemonic: ${storedSeedPhrase}`)\n const { mnemonic } = config.api\n if (isString(storedSeedPhrase) && isString(mnemonic)) {\n logger?.warn('[API] Stored mnemonic does not match supplied. Updating stored mnemonic to supplied.')\n await bios.seedPhraseStore.set('os', mnemonic)\n } else {\n let seedPhrase: string\n if (isString(mnemonic)) {\n seedPhrase = mnemonic\n } else {\n seedPhrase = HDWallet.generateMnemonic()\n logger?.log('[API] No mnemonic provided, using random mnemonic. This is not recommended for production use.')\n logger?.log(`[API] Mnemonic: ${seedPhrase}`)\n }\n await bios.seedPhraseStore.set('os', seedPhrase)\n }\n return assertEx(await bios.seedPhraseStore.get('os'), () => 'Unable to acquire mnemonic from bios')\n}\n\ninterface GetServerContext {\n config: Config\n logger?: Logger\n node?: NodeInstance\n}\n\nexport const getServer = async (context: GetServerContext) => {\n const {\n config, logger, node,\n } = context\n const { mnemonic, port } = context.config.api\n const bios = await boot()\n const seedPhrase = isDefined(mnemonic) ? mnemonic : await getSeedPhrase(bios, config, logger)\n const wallet = await HDWallet.fromPhrase(seedPhrase)\n const provider = await initInfuraProvider(config)\n const contractAddress = assertEx(config.chain.id, () => 'Missing config.evm.chainId') as ChainId\n const contract = StakedXyoChainV2__factory.connect(toEthAddress(contractAddress), provider)\n const nodeContext = {\n wallet, logger, config,\n }\n const eventsReader = await EthereumChainStakeEvents.create({ contract, logger })\n assertEx(await eventsReader.start(), () => 'Failed to start EthereumChainStakeEvents reader')\n const stakeChainReader = await EthereumChainStake.create({\n contract, eventsReader, logger,\n })\n assertEx(await stakeChainReader.start(), () => 'Failed to start EthereumChainStake reader')\n const rootNode = await getNode(nodeContext)\n const chainArchivist = assertEx(asArchivistInstance(\n await rootNode.resolve('Chain:Validated'),\n { required: true },\n ), () => 'FinalizedArchivist not found in node')\n const chainMap = readPayloadMapFromStore<WithStorageMeta<Payload>>(chainArchivist)\n const resolvedNode: NodeInstance = node ?? await getNode(nodeContext)\n\n const stakedChainContext: StakedChainContextRead = {\n chainId: contractAddress,\n events: eventsReader,\n stake: stakeChainReader,\n store: { chainMap },\n head: async (): Promise<[Hash, number]> => {\n const head = await findMostRecentBlock(chainArchivist)\n return [assertEx(head?._hash, () => 'No head found in chainArchivist'), assertEx(head?.block, () => 'No head found in chainArchivist')]\n },\n }\n const mods = await resolvedNode.resolve('*')\n await Promise.all(mods.map((mod) => {\n return mod.start?.() ?? (() => true)\n }))\n const transferSummaryMap = assertEx(await getTransferSummaryMap(config), () => 'Transfer Summary Map not initialized')\n const app = await getApp(resolvedNode, transferSummaryMap, stakedChainContext, config.api.initRewardsCache)\n const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`))\n server.setTimeout(20_000)\n return server\n}\n","import { assertEx } from '@xylabs/assert'\nimport { hexFrom, isHex } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\n\nexport const canUseChainId = (config: Config): boolean => {\n return isDefined(config.evm.chainId)\n}\n\nexport const getChainId = (config: Config) => {\n const chainId = assertEx(config.evm.chainId, () => 'Missing config.evm.chainId')\n if (isHex(chainId, { prefix: true })) {\n const hex = hexFrom(chainId)\n const parsed = Number.parseInt(hex, 16)\n return parsed\n } else {\n const parsed = Number.parseInt(chainId, 10)\n return parsed\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\nimport type { Provider } from 'ethers'\nimport { InfuraWebSocketProvider } from 'ethers/providers'\n\nimport { canUseChainId, getChainId } from './initChainId.ts'\n\nlet instance: Promise<InfuraWebSocketProvider> | undefined\n\nexport const initInfuraProvider = (config: Config): Promise<Provider> => {\n if (instance) return instance\n const providerConfig = getInfuraProviderConfig(config)\n instance = Promise.resolve(new InfuraWebSocketProvider(providerConfig[0], providerConfig[1]))\n return instance\n}\n\nexport const canUseInfuraProvider = (config: Config): boolean => {\n return canUseChainId(config)\n && isDefined(config.evm?.infura?.projectId)\n && isDefined(config.evm?.infura?.projectSecret)\n}\n\nexport const getInfuraProviderConfig = (config: Config) => {\n const projectId = assertEx(config.evm?.infura?.projectId, () => 'Missing config.evm.infura.projectId')\n const projectSecret = assertEx(config.evm?.infura?.projectSecret, () => 'Missing config.evm.infura.projectSecret')\n return [getChainId(config), projectId, projectSecret] as const\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { asAddress, ZERO_ADDRESS } from '@xylabs/hex'\nimport type { Logger } from '@xylabs/logger'\nimport { BaseMongoSdk, type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'\nimport { isDefined } from '@xylabs/typeof'\nimport { MemoryArchivist } from '@xyo-network/archivist-memory'\nimport { MongoDBArchivistV2 } from '@xyo-network/archivist-mongodb'\nimport { ViewArchivist } from '@xyo-network/archivist-view'\nimport {\n AddressBalanceDivinerV2, AddressTransferDiviner, ArchivistSyncDiviner, HeadValidationDiviner,\n} from '@xyo-network/chain-modules'\nimport { initTelemetry } from '@xyo-network/chain-telemetry'\nimport { AbstractModule, LoggerModuleStatusReporter } from '@xyo-network/module-abstract'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { MongoDBModuleParamsV2 } from '@xyo-network/module-model-mongodb'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { StepSizes } from '@xyo-network/xl1-protocol'\nimport type {\n BalancesStepSummary, Config, MapType, TransfersStepSummary,\n} from '@xyo-network/xl1-protocol-sdk'\nimport { hasMongoConfig } from '@xyo-network/xl1-protocol-sdk'\nimport { Semaphore } from 'async-mutex'\n\nimport { MongoMap } from '../driver/index.ts'\n\nexport interface GetLocatorContext {\n config: Config\n logger?: Logger\n}\n\nexport async function getTransferSummaryMap(config: Config): Promise<Promise<MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined>> {\n const mongoConfig = config.storage?.mongo\n if (hasMongoConfig(mongoConfig)) {\n // Create the MongoDB SDK from the configuration\n const {\n connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,\n } = mongoConfig\n const payloadSdkConfig: BaseMongoSdkPrivateConfig = {\n dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,\n }\n\n const sdkTransferSummaryMap = new BaseMongoSdk<WithStorageMeta<TransfersStepSummary>>({ ...payloadSdkConfig, collection: 'transfer_summary_map' })\n return await MongoMap.create<MongoMap<Hash, WithStorageMeta<TransfersStepSummary>>>({\n sdk: sdkTransferSummaryMap,\n getCache: { enabled: true, maxEntries: 5000 },\n })\n }\n}\n\n/**\n * Used for retrieving a locator with the necessary modules registered for testing\n * operation of the node (entirely in memory)\n * @returns A locator with the necessary modules registered\n */\nexport const getLocator = async (context: GetLocatorContext) => {\n const { config, logger } = context\n const { otlpEndpoint } = config.telemetry?.otel ?? {}\n const { traceProvider, meterProvider } = await initTelemetry({\n attributes: {\n serviceName: 'xl1-api',\n serviceVersion: '1.0.0',\n },\n otlpEndpoint,\n metricsConfig: {\n endpoint: '/metrics',\n port: 9465,\n },\n })\n\n if (isDefined(logger)) AbstractModule.defaultLogger = logger\n const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : undefined\n\n const locator = new ModuleFactoryLocator()\n let balanceSummaryMap: MapType<string, WithStorageMeta<BalancesStepSummary>> | undefined\n let transferSummaryMap = await getTransferSummaryMap(config)\n // If there's a MongoDB configuration\n const mongoConfig = config.storage?.mongo\n if (hasMongoConfig(mongoConfig)) {\n // Create the MongoDB SDK from the configuration\n const {\n connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,\n } = mongoConfig\n const payloadSdkConfig: BaseMongoSdkPrivateConfig = {\n dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,\n }\n const params: Partial<MongoDBModuleParamsV2> = {\n meterProvider, payloadSdkConfig, statusReporter, traceProvider,\n }\n // Register the MongoDB Archivist as the default\n locator.register(MongoDBArchivistV2.factory(params), undefined, true)\n\n // Use a persistent MongoMap for the summary repository if MongoDB is configured\n const sdkBalanceSummaryMap = new BaseMongoSdk<WithStorageMeta<BalancesStepSummary>>({ ...payloadSdkConfig, collection: 'balance_summary_map' })\n balanceSummaryMap = await MongoMap.create<MongoMap<Hash, WithStorageMeta<BalancesStepSummary>>>({\n sdk: sdkBalanceSummaryMap,\n getCache: { enabled: true, maxEntries: 5000 },\n })\n }\n\n locator.register(AddressBalanceDivinerV2.factory<AddressBalanceDivinerV2>({\n traceProvider, meterProvider, statusReporter, summaryMap: balanceSummaryMap, stepSemaphores: StepSizes.map(() => new Semaphore(20)),\n }))\n\n locator.register(AddressTransferDiviner.factory<AddressTransferDiviner>({\n traceProvider, meterProvider, statusReporter, summaryMap: transferSummaryMap, stepSemaphores: StepSizes.map(() => new Semaphore(20)),\n }))\n\n const chainId = isDefined(config.chain.id)\n ? assertEx(asAddress(config.chain.id), () => 'chain.id must be an Address')\n : ZERO_ADDRESS\n locator.register(HeadValidationDiviner.factory<HeadValidationDiviner>({\n traceProvider,\n meterProvider,\n statusReporter,\n chainId,\n allowedProducers: config.producer.allowlist,\n }))\n locator.register(MemoryArchivist.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(MemorySentinel.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(ViewArchivist.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n locator.register(ArchivistSyncDiviner.factory({\n traceProvider, meterProvider, statusReporter,\n }))\n return locator\n}\n","import { assertEx } from '@xylabs/assert'\nimport {\n AbstractCreatable, creatable, CreatableParams,\n} from '@xylabs/creatable'\nimport { BaseMongoSdk } from '@xylabs/mongo'\nimport { isNull } from '@xylabs/typeof'\nimport { AsynchronousMap } from '@xyo-network/xl1-protocol-sdk'\nimport { LRUCache } from 'lru-cache'\nimport {\n Document, Filter, OptionalUnlessRequiredId, WithId,\n} from 'mongodb'\n\nexport interface MongoMapParams<TData extends Document = Document> extends CreatableParams {\n getCache?: {\n enabled: boolean\n maxEntries?: number\n }\n sdk: BaseMongoSdk<TData>\n}\n\nfunction stripMongoId<V extends Document>(doc: WithId<V>): V {\n const { _id, ...rest } = doc\n return rest as unknown as V\n}\n\n@creatable()\nexport class MongoMap<K extends {} = string, V extends Document = Document>\n extends AbstractCreatable<MongoMapParams<V>>\n implements AsynchronousMap<K, V> {\n private _getCache: LRUCache<K, V> | undefined\n\n get sdk(): BaseMongoSdk<V> {\n return assertEx(this.params.sdk, () => 'No sdk specified')\n }\n\n async clear(): Promise<void> {\n this._getCache?.clear()\n await this.sdk.deleteMany({})\n }\n\n async delete(id: K): Promise<boolean> {\n this._getCache?.delete(id)\n\n const filter = { _id: id } as Filter<V>\n const result = await this.sdk.deleteOne(filter)\n return result.deletedCount > 0\n }\n\n async get(id: K): Promise<V | undefined> {\n if (this._getCache) {\n const getCacheResult = this._getCache.get(id)\n if (getCacheResult) {\n return getCacheResult\n }\n }\n const filter = { _id: id } as Filter<V>\n const doc = await this.sdk.findOne(filter)\n return isNull(doc) ? undefined : stripMongoId(doc)\n }\n\n async getMany(ids: K[]): Promise<V[]> {\n /* const results = await Promise.all(ids.map(async (id) => {\n return await this.get(id)\n }))\n return results.filter(exists) */\n const cache = this._getCache\n const idSet = new Set(ids)\n const results: V[] = []\n if (cache) {\n const getCacheResult = ids.map(id => ([id, cache.get(id)])).filter(([, item]) => item !== undefined) as [K, V][]\n for (const [id] of getCacheResult) {\n idSet.delete(id)\n }\n results.push(...getCacheResult.map(([, item]) => item))\n }\n const filter = { _id: { $in: [...idSet] } } as Filter<V>\n const items = await (await this.sdk.find(filter)).toArray()\n for (const item of items) {\n const id = item._id\n const stripped = stripMongoId(item)\n if (cache) {\n cache.set(id as unknown as K, stripped)\n }\n results.push(stripped)\n }\n return results\n }\n\n async has(id: K): Promise<boolean> {\n if (this._getCache) {\n const getCacheResult = this._getCache.has(id)\n if (getCacheResult) {\n return getCacheResult\n }\n }\n const filter = { _id: id } as Filter<V>\n const exists = await this.sdk.findOne(filter)\n return isNull(exists) ? false : true\n }\n\n async set(id: K, data: V): Promise<void> {\n const filter = { _id: id } as Filter<V>\n const value = { ...data, _id: id } as OptionalUnlessRequiredId<V>\n await this.sdk.replaceOne(filter, value, { upsert: true })\n this._getCache?.set(id, data)\n }\n\n override async startHandler(): Promise<void> {\n await super.startHandler()\n // TODO: Ensure index\n\n if (this.params.getCache?.enabled === true) {\n const maxEntries = this.params.getCache?.maxEntries ?? 5000\n this._getCache = new LRUCache<K, V>({ max: maxEntries })\n }\n }\n}\n","import type { Logger } from '@xylabs/logger'\nimport { ManifestWrapper } from '@xyo-network/manifest-wrapper'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { Config } from '@xyo-network/xl1-protocol-sdk'\n\nimport { getLocator } from './getLocator.ts'\nimport { NodeManifest } from './nodeManifest.ts'\nimport { PrivateChildManifests } from './private/index.ts'\nimport { PublicChildManifestsWithMempool, PublicChildManifestsWithoutMempool } from './public/index.ts'\n\nexport interface GetNodeContext {\n config: Config\n logger?: Logger\n wallet: WalletInstance\n}\n\n/**\n * Creates a node with the xyo-chain modules registered\n * @param context The context to use for the node\n * @returns A node with the xyo-chain modules registered\n */\nexport const getNode = async (context: GetNodeContext) => {\n const { wallet, config } = context\n const { enabled: mempoolEnabled } = config.mempool\n const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool\n const locator = await getLocator(context)\n const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests)\n const [node, ...childNodes] = await wrapper.loadNodes()\n if (childNodes?.length > 0) {\n await Promise.all(childNodes.map(childNode => node.register(childNode)))\n await Promise.all(childNodes.map(childNode => node.attach(childNode.address, true)))\n }\n return node\n}\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"44'/60'/1\",\n \"name\": \"XYOChain\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": []\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","import type { PackageManifestPayload } from '@xyo-network/manifest-model'\n\nimport node from './node.json' with { type: 'json' }\n\n/**\n * Root Node Manifest\n */\nexport const NodeManifest = node as PackageManifestPayload\n","/**\n * Private Child Manifests\n */\nexport const PrivateChildManifests = []\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"1\",\n \"name\": \"Chain\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [\n {\n \"config\": {\n \"accountPath\": \"1/1'/1'\",\n \"name\": \"Validated\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_validated\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/2'\",\n \"schema\": \"network.xyo.diviner.chain.head.validation.config\",\n \"eventSubscriptions\": [\n {\n \"sourceEvent\": \"inserted\",\n \"sourceModule\": \"Submissions\",\n \"targetModuleFunction\": \"divine\"\n }\n ],\n \"inArchivist\": \"Submissions\",\n \"outArchivist\": \"Validated\",\n \"name\": \"HeadValidationDiviner\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/3'\",\n \"automations\": [\n {\n \"frequency\": 1000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"ChainValidationSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"HeadValidationDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/4'\",\n \"automations\": [\n {\n \"frequency\": 10000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"AddressBalancePollingSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"AddressBalanceDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1'/5'\",\n \"automations\": [\n {\n \"frequency\": 10000,\n \"frequencyUnits\": \"millis\",\n \"schema\": \"network.xyo.automation.interval\",\n \"type\": \"interval\"\n }\n ],\n \"name\": \"AddressTransferPollingSentinel\",\n \"schema\": \"network.xyo.sentinel.config\",\n \"synchronous\": true,\n \"tasks\": [\n {\n \"mod\": \"AddressTransferDiviner\",\n \"endPoint\": \"divine\"\n }\n ]\n }\n }\n ],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1/1/1\",\n \"name\": \"Submissions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_submissions\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/2\",\n \"name\": \"Finalized\",\n \"allowedQueries\": [\n \"network.xyo.query.archivist.get\",\n \"network.xyo.query.archivist.next\"\n ],\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 50000\n },\n \"originArchivist\": \"Validated\",\n \"schema\": \"network.xyo.archivist.view.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/3'\",\n \"name\": \"AddressBalanceDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.balance.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_balance\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/4'\",\n \"name\": \"AddressTransferDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.transfer.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_transfer\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"2\",\n \"name\": \"Pending\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"2/1/1\",\n \"name\": \"PendingTransactions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"labels\": {\n \"network.xyo.storage.class\": \"mongodb\"\n },\n \"payloadSdkConfig\": {\n \"collection\": \"pending_bundles\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'\n\nimport Chain from './Chain.json' with { type: 'json' }\nimport Pending from './Pending.json' with { type: 'json' }\n\n/**\n * Chain Node Manifest\n */\nconst ChainNodeManifest = Chain as PackageManifestPayload\n/**\n * Pending Node Manifest\n */\nconst PendingNodeManifest = Pending as PackageManifestPayload\n/**\n * Public Child Manifests\n */\nexport const PublicChildManifestsWithMempool: ModuleManifest[] = [\n ...ChainNodeManifest.nodes,\n ...PendingNodeManifest.nodes,\n]\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"1\",\n \"name\": \"Chain\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [\n {\n \"config\": {\n \"accountPath\": \"1/1'/1'\",\n \"name\": \"Validated\",\n \"allowedQueries\": [\n \"network.xyo.query.archivist.get\",\n \"network.xyo.query.archivist.next\"\n ],\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_validated\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n }\n ],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1/1/1\",\n \"name\": \"Submissions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"payloadSdkConfig\": {\n \"collection\": \"chain_submissions\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/2\",\n \"name\": \"Finalized\",\n \"allowedQueries\": [\n \"network.xyo.query.archivist.get\",\n \"network.xyo.query.archivist.next\"\n ],\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 50000\n },\n \"originArchivist\": \"Validated\",\n \"schema\": \"network.xyo.archivist.view.config\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/3'\",\n \"name\": \"AddressBalanceDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.balance.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_balance\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n },\n {\n \"config\": {\n \"accountPath\": \"1/1/4'\",\n \"name\": \"AddressTransferDiviner\",\n \"schema\": \"network.xyo.diviner.chain.address.transfer.config\",\n \"map\": {\n \"lmdb\": {\n \"dbName\": \"summaries\",\n \"storeName\": \"address_transfer\",\n \"location\": \".store\"\n }\n },\n \"archivist\": \"Validated\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"2\",\n \"name\": \"Pending\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"2/1/1\",\n \"name\": \"PendingTransactions\",\n \"getCache\": {\n \"enabled\": true,\n \"maxEntries\": 5000\n },\n \"labels\": {\n \"network.xyo.storage.class\": \"mongodb\"\n },\n \"payloadSdkConfig\": {\n \"collection\": \"pending_bundles\"\n },\n \"schema\": \"network.xyo.archivist.config\"\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest\"\n}\n","import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'\n\nimport Chain from './Chain.json' with { type: 'json' }\nimport Pending from './Pending.json' with { type: 'json' }\n\n/**\n * Chain Node Manifest\n */\n const ChainNodeManifest = Chain as PackageManifestPayload\n/**\n * Pending Node Manifest\n */\n const PendingNodeManifest = Pending as PackageManifestPayload\n/**\n * Public Child Manifests\n */\nexport const PublicChildManifestsWithoutMempool: ModuleManifest[] = [\n ...ChainNodeManifest.nodes,\n ...PendingNodeManifest.nodes,\n]\n"],"mappings":";;;;AAAA,SACEA,uBACAC,6BACAC,sCACAC,mBACAC,0BACAC,kBACAC,gBACAC,yBACK;AAMP,OAAOC,iBAAiB;AACxB,OAAOC,UAAU;AAEjB,OAAOC,cAAa;;;AClBpB,SAASC,gCAAgC;AACzC,SAASC,8BAA8B;AACvC,SAASC,2BAA2B;AAS7B,IAAMC,qBAAqB,6BAAA;AAChC,QAAMC,mBAAmB;IAAC,IAAIC,oBAAAA;IAAuB,IAAIC,uBAAAA;;AACzDC,2BAAyB;IAAEH;EAAiB,CAAA;AAC9C,GAHkC;;;ACVlC,SAASI,eAAAA,oBAAmB;;;ACD5B,SAASC,oBAAoB;AAC7B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAG7B,SAASC,mBAAmB;AAI5B,IAAMC,UAAwD,8BAAOC,KAAKC,KAAKC,SAAAA;AAC7E,QAAM,EAAEC,SAASC,iBAAgB,IAAKJ,IAAIK;AAC1C,QAAM,EAAEC,KAAI,IAAKN,IAAIO;AACrB,QAAMJ,UAAUK,UAAUJ,gBAAAA;AAC1B,MAAIK,UAAUN,OAAAA,GAAU;AACtB,QAAIO,MAAMJ,KAAKH,YAAYA,UAAUG,OAAQ,MAAMA,KAAKK,QAAQR,SAAS;MAAES,WAAW;IAAO,CAAA;AAC7F,QAAIF,KAAK;AACPT,UAAIY,KAAK,MAAMH,IAAII,MAAK,CAAA;AACxB;IACF;EACF;AACA,MAAIC,aAAaX,gBAAAA,GAAmB;AAClC,UAAMM,MAAM,MAAMJ,KAAKK,QAAQP,kBAAkB;MAAEQ,WAAW;IAAO,CAAA;AACrE,QAAIF,KAAK;AACPT,UAAIe,SAASC,YAAYC,mBAAmB,IAAIR,IAAIP,OAAO,EAAE;AAC7D;IACF;EACF;AACAD,OAAK,OAAA;AACP,GAnB8D;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onBodyParser","getJsonBodyParserOptions","responseProfiler","standardErrors","standardResponses","compression","cors","express","registerInstrumentations","ExpressInstrumentation","HttpInstrumentation","addInstrumentation","instrumentations","HttpInstrumentation","ExpressInstrumentation","registerInstrumentations","StatusCodes","asyncHandler","asAddress","isDefined","isModuleName","StatusCodes","handler","req","res","next","address","moduleIdentifier","params","node","app","asAddress","isDefined","mod","resolve","direction","json","state","isModuleName","redirect","StatusCodes","MOVED_TEMPORARILY","getAddress","asyncHandler","assertEx","asyncHandler","asAddress","isAddress","toAddress","isQueryBoundWitness","ModuleErrorBuilder","StatusCodes","BoundWitnessSchema","ModuleConfigSchema","DEFAULT_DEPTH","getQueryConfig","mod","req","bw","payloads","nestedBwAddresses","flat","filter","payload","schema","BoundWitnessSchema","map","addresses","address","length","allowed","Object","fromEntries","queries","security","ModuleConfigSchema","handler","req","res","next","returnError","code","message","details","error","ModuleErrorBuilder","build","locals","rawResponse","status","json","address","params","node","app","bw","payloads","Array","isArray","body","isAddress","StatusCodes","BAD_REQUEST","isQueryBoundWitness","modules","normalizedAddress","toAddress","typedAddress","asAddress","byAddress","undefined","resolve","maxDepth","byName","direction","moduleAddress","assertEx","redirect","TEMPORARY_REDIRECT","NOT_FOUND","length","mod","queryConfig","getQueryConfig","queryResult","query","ex","INTERNAL_SERVER_ERROR","postAddress","asyncHandler","addNodeRoutes","app","defaultModule","node","address","defaultModuleEndpoint","get","_req","res","redirect","StatusCodes","MOVED_TEMPORARILY","post","TEMPORARY_REDIRECT","getAddress","postAddress","sendStatus","NOT_FOUND","setRawResponseFormat","asHash","isDefined","asArchivistInstance","PayloadBuilder","isAnyPayload","isSequence","express","resolveArchivist","node","archivistModuleIdentifier","mod","resolve","asArchivistInstance","required","archivistInstance","getArchivist","isDefined","archivistMiddleware","options","router","express","Router","mergeParams","post","req","res","setRawResponseFormat","body","Array","isArray","payloads","PayloadBuilder","hashPairs","map","p","archivist","result","insert","status","json","get","cursor","isSequence","query","undefined","limit","Number","open","Boolean","order","next","hash","rawHash","params","asHash","payload","isAnyPayload","send","addDataLakeRoutes","app","node","archivistModuleIdentifier","use","archivistMiddleware","setRawResponseFormat","NodeNetworkStakeViewer","NodeStepRewardsByPositionViewer","NodeXyoViewer","StepSizes","RewardMultipliers","NodeXyoRunner","rpcEngineFromConnection","XyoBaseConnection","Semaphore","addRpcRoutes","app","transferSummaryMap","stakedChainContext","initRewardsCache","node","runner","NodeXyoRunner","networkStakeViewer","NodeNetworkStakeViewer","create","context","console","log","start","viewer","NodeXyoViewer","rewardMultipliers","RewardMultipliers","transfersSummaryContext","stepSemaphores","StepSizes","map","Semaphore","summaryMap","stepRewardsByPositionViewer","NodeStepRewardsByPositionViewer","connection","XyoBaseConnection","engine","rpcEngineFromConnection","post","req","res","setRawResponseFormat","handle","body","_","rpcResponse","json","addRoutes","app","transferSummaryMap","stakedChainContext","initRewardsCache","addRpcRoutes","addDataLakeRoutes","addNodeRoutes","getApp","node","transferSummaryMap","stakedChainContext","initRewardsCache","addInstrumentation","app","express","set","use","cors","compression","responseProfiler","getJsonBodyParser","getJsonBodyParserOptions","limit","standardResponses","disableExpressDefaultPoweredByHeader","customPoweredByHeader","disableCaseSensitiveRouting","addRoutes","standardErrors","assertEx","toEthAddress","isDefined","isString","asArchivistInstance","boot","EthereumChainStake","EthereumChainStakeEvents","findMostRecentBlock","StakedXyoChainV2__factory","HDWallet","readPayloadMapFromStore","assertEx","hexFrom","isHex","isDefined","getChainId","config","chainId","assertEx","evm","isHex","prefix","hex","hexFrom","parsed","Number","parseInt","assertEx","isDefined","InfuraWebSocketProvider","instance","initInfuraProvider","config","providerConfig","getInfuraProviderConfig","Promise","resolve","InfuraWebSocketProvider","getInfuraProviderConfig","config","projectId","assertEx","evm","infura","projectSecret","getChainId","assertEx","asAddress","ZERO_ADDRESS","BaseMongoSdk","isDefined","MemoryArchivist","MongoDBArchivistV2","ViewArchivist","AddressBalanceDivinerV2","AddressTransferDiviner","ArchivistSyncDiviner","HeadValidationDiviner","initTelemetry","AbstractModule","LoggerModuleStatusReporter","ModuleFactoryLocator","MemorySentinel","StepSizes","hasMongoConfig","Semaphore","assertEx","AbstractCreatable","creatable","isNull","LRUCache","stripMongoId","doc","_id","rest","MongoMap","AbstractCreatable","_getCache","sdk","assertEx","params","clear","deleteMany","delete","id","filter","result","deleteOne","deletedCount","get","getCacheResult","findOne","isNull","undefined","getMany","ids","cache","idSet","Set","results","map","item","push","$in","items","find","toArray","stripped","set","has","exists","data","value","replaceOne","upsert","startHandler","getCache","enabled","maxEntries","LRUCache","max","getTransferSummaryMap","config","mongoConfig","storage","mongo","hasMongoConfig","connectionString","dbConnectionString","database","dbName","domain","dbDomain","password","dbPassword","username","dbUserName","payloadSdkConfig","sdkTransferSummaryMap","BaseMongoSdk","collection","MongoMap","create","sdk","getCache","enabled","maxEntries","getLocator","context","logger","otlpEndpoint","telemetry","otel","traceProvider","meterProvider","initTelemetry","attributes","serviceName","serviceVersion","metricsConfig","endpoint","port","isDefined","AbstractModule","defaultLogger","statusReporter","LoggerModuleStatusReporter","undefined","locator","ModuleFactoryLocator","balanceSummaryMap","transferSummaryMap","params","register","MongoDBArchivistV2","factory","sdkBalanceSummaryMap","AddressBalanceDivinerV2","summaryMap","stepSemaphores","StepSizes","map","Semaphore","AddressTransferDiviner","chainId","chain","id","assertEx","asAddress","ZERO_ADDRESS","HeadValidationDiviner","allowedProducers","producer","allowlist","MemoryArchivist","MemorySentinel","ViewArchivist","ArchivistSyncDiviner","ManifestWrapper","NodeManifest","node","PrivateChildManifests","ChainNodeManifest","Chain","PendingNodeManifest","Pending","PublicChildManifestsWithMempool","nodes","Chain_default","Pending_default","ChainNodeManifest","Chain","PendingNodeManifest","Pending","PublicChildManifestsWithoutMempool","nodes","getNode","context","wallet","config","enabled","mempoolEnabled","mempool","PublicChildManifests","PublicChildManifestsWithoutMempool","PublicChildManifestsWithMempool","locator","getLocator","wrapper","ManifestWrapper","NodeManifest","PrivateChildManifests","node","childNodes","loadNodes","length","Promise","all","map","childNode","register","attach","address","hostname","getSeedPhrase","bios","config","logger","storedSeedPhrase","seedPhraseStore","get","debug","mnemonic","api","isString","warn","set","seedPhrase","HDWallet","generateMnemonic","log","assertEx","getServer","context","node","port","boot","isDefined","wallet","fromPhrase","provider","initInfuraProvider","contractAddress","chain","id","contract","StakedXyoChainV2__factory","connect","toEthAddress","nodeContext","eventsReader","EthereumChainStakeEvents","create","start","stakeChainReader","EthereumChainStake","rootNode","getNode","chainArchivist","asArchivistInstance","resolve","required","chainMap","readPayloadMapFromStore","resolvedNode","stakedChainContext","chainId","events","stake","store","head","findMostRecentBlock","_hash","block","mods","Promise","all","map","mod","transferSummaryMap","getTransferSummaryMap","app","getApp","initRewardsCache","server","listen","setTimeout"]}
@@ -1,10 +1,12 @@
1
1
  import type { Logger } from '@xylabs/logger';
2
2
  import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator';
3
- import type { Config } from '@xyo-network/xl1-protocol-sdk';
3
+ import type { WithStorageMeta } from '@xyo-network/payload-model';
4
+ import type { Config, MapType, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk';
4
5
  export interface GetLocatorContext {
5
6
  config: Config;
6
7
  logger?: Logger;
7
8
  }
9
+ export declare function getTransferSummaryMap(config: Config): Promise<Promise<MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined>>;
8
10
  /**
9
11
  * Used for retrieving a locator with the necessary modules registered for testing
10
12
  * operation of the node (entirely in memory)
@@ -1 +1 @@
1
- {"version":3,"file":"getLocator.d.ts","sourceRoot":"","sources":["../../../src/manifest/getLocator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAW5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAK1E,OAAO,KAAK,EACW,MAAM,EAC5B,MAAM,+BAA+B,CAAA;AAMtC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,SAAS,iBAAiB,kCAkF1D,CAAA"}
1
+ {"version":3,"file":"getLocator.d.ts","sourceRoot":"","sources":["../../../src/manifest/getLocator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAW5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAGjE,OAAO,KAAK,EACW,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAC3D,MAAM,+BAA+B,CAAA;AAMtC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAiBhJ;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,SAAS,iBAAiB,kCA4E1D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getNode.d.ts","sourceRoot":"","sources":["../../../src/manifest/getNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAO3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,cAAc,CAAA;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,uKAUpD,CAAA"}
1
+ {"version":3,"file":"getNode.d.ts","sourceRoot":"","sources":["../../../src/manifest/getNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAO3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,cAAc,CAAA;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,uKAYpD,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ModuleManifest } from '@xyo-network/manifest-model';
2
+ /**
3
+ * Public Child Manifests
4
+ */
5
+ export declare const PublicChildManifestsWithMempool: ModuleManifest[];
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/manifest/public/WithMempool/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,6BAA6B,CAAA;AAazF;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,cAAc,EAG3D,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { ModuleManifest } from '@xyo-network/manifest-model';
2
+ /**
3
+ * Public Child Manifests
4
+ */
5
+ export declare const PublicChildManifestsWithoutMempool: ModuleManifest[];
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/manifest/public/WithoutMempool/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,6BAA6B,CAAA;AAazF;;GAEG;AACH,eAAO,MAAM,kCAAkC,EAAE,cAAc,EAG9D,CAAA"}
@@ -1,14 +1,3 @@
1
- import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model';
2
- /**
3
- * Chain Node Manifest
4
- */
5
- export declare const ChainNodeManifest: PackageManifestPayload;
6
- /**
7
- * Pending Node Manifest
8
- */
9
- export declare const PendingNodeManifest: PackageManifestPayload;
10
- /**
11
- * Public Child Manifests
12
- */
13
- export declare const PublicChildManifests: ModuleManifest[];
1
+ export * from './WithMempool/index.ts';
2
+ export * from './WithoutMempool/index.ts';
14
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manifest/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAKzF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAY,sBAAsB,CAAA;AAChE;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAc,sBAAsB,CAAA;AACpE;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,cAAc,EAGhD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manifest/public/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import type { NodeInstance } from '@xyo-network/node-model';
2
- import type { StakedChainContextRead, StakeEventsRead } from '@xyo-network/xl1-protocol-sdk';
2
+ import type { WithStorageMeta } from '@xyo-network/payload-model';
3
+ import type { MapType, StakedChainContextRead, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk';
3
4
  import type { Express } from 'express';
4
- export declare const getApp: (node: NodeInstance, eventsReader: StakeEventsRead, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<Express>;
5
+ export declare const getApp: (node: NodeInstance, transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<Express>;
5
6
  //# sourceMappingURL=app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAG5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,MAAM,GACjB,MAAM,YAAY,EAClB,cAAc,eAAe,EAC7B,oBAAoB,sBAAsB,EAC1C,mBAAmB,OAAO,KACzB,OAAO,CAAC,OAAO,CAiBjB,CAAA"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EACV,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EACtD,MAAM,+BAA+B,CAAA;AAGtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,MAAM,GACjB,MAAM,YAAY,EAClB,oBAAoB,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC,EAC1E,oBAAoB,sBAAsB,EAC1C,mBAAmB,OAAO,KACzB,OAAO,CAAC,OAAO,CAiBjB,CAAA"}
@@ -1,4 +1,5 @@
1
- import type { StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk';
1
+ import type { WithStorageMeta } from '@xyo-network/payload-model';
2
+ import type { MapType, StakedChainContextRead, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk';
2
3
  import type { Express } from 'express';
3
- export declare const addRoutes: (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<void>;
4
+ export declare const addRoutes: (app: Express, transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<void>;
4
5
  //# sourceMappingURL=addRoutes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addRoutes.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/addRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,SAAS,GAAU,KAAK,OAAO,EAAE,oBAAoB,sBAAsB,EAAE,mBAAmB,OAAO,kBAInH,CAAA"}
1
+ {"version":3,"file":"addRoutes.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/addRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EACV,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EACtD,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,SAAS,GACpB,KAAK,OAAO,EACZ,oBAAoB,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC,EAC1E,oBAAoB,sBAAsB,EAC1C,mBAAmB,OAAO,kBAK3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/get/get.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAwBhE,eAAO,MAAM,UAAU,4OAAwB,CAAA"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/get/get.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAsBhE,eAAO,MAAM,UAAU,4OAAwB,CAAA"}
@@ -1,4 +1,5 @@
1
- import { type StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk';
1
+ import type { WithStorageMeta } from '@xyo-network/payload-model';
2
+ import type { MapType, StakedChainContextRead, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk';
2
3
  import type { Express } from 'express';
3
- export declare const addRpcRoutes: (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<void>;
4
+ export declare const addRpcRoutes: (app: Express, transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => Promise<void>;
4
5
  //# sourceMappingURL=addRpcRoutes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addRpcRoutes.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/rpc/routes/addRpcRoutes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAK9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,eAAO,MAAM,YAAY,GAAU,KAAK,OAAO,EAAE,oBAAoB,sBAAsB,EAAE,mBAAmB,OAAO,kBAmCtH,CAAA"}
1
+ {"version":3,"file":"addRpcRoutes.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/rpc/routes/addRpcRoutes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EACV,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EACtD,MAAM,+BAA+B,CAAA;AAOtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,eAAO,MAAM,YAAY,GACvB,KAAK,OAAO,EACZ,oBAAoB,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC,EAC1E,oBAAoB,sBAAsB,EAC1C,mBAAmB,OAAO,kBA0C3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAO5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAK3D,OAAO,KAAK,EAAE,MAAM,EAA0B,MAAM,+BAA+B,CAAA;AAgCnF,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,eAAO,MAAM,SAAS,GAAU,SAAS,gBAAgB,gHA8CxD,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAO5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAK3D,OAAO,KAAK,EACV,MAAM,EACP,MAAM,+BAA+B,CAAA;AAgCtC,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,eAAO,MAAM,SAAS,GAAU,SAAS,gBAAgB,gHA+CxD,CAAA"}