@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/chain-api",
3
- "version": "1.15.28",
3
+ "version": "1.16.0",
4
4
  "description": "XYO Layer One API",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -46,42 +46,42 @@
46
46
  "types": "tsc --noEmit -p tsconfig.test.json"
47
47
  },
48
48
  "dependencies": {
49
- "@opentelemetry/instrumentation": "~0.207.0",
50
- "@opentelemetry/instrumentation-express": "~0.56.0",
51
- "@opentelemetry/instrumentation-http": "~0.207.0",
52
- "@xylabs/assert": "~5.0.18",
53
- "@xylabs/creatable": "~5.0.18",
54
- "@xylabs/express": "~5.0.18",
55
- "@xylabs/hex": "~5.0.18",
56
- "@xylabs/logger": "~5.0.18",
57
- "@xylabs/mongo": "~5.0.18",
58
- "@xylabs/typeof": "~5.0.18",
59
- "@xyo-network/archivist-memory": "~5.1.17",
60
- "@xyo-network/archivist-model": "~5.1.17",
61
- "@xyo-network/archivist-mongodb": "~5.1.17",
62
- "@xyo-network/archivist-view": "~5.1.17",
49
+ "@opentelemetry/instrumentation": "~0.208.0",
50
+ "@opentelemetry/instrumentation-express": "~0.57.0",
51
+ "@opentelemetry/instrumentation-http": "~0.208.0",
52
+ "@xylabs/assert": "~5.0.19",
53
+ "@xylabs/creatable": "~5.0.19",
54
+ "@xylabs/express": "~5.0.19",
55
+ "@xylabs/hex": "~5.0.19",
56
+ "@xylabs/logger": "~5.0.19",
57
+ "@xylabs/mongo": "~5.0.19",
58
+ "@xylabs/typeof": "~5.0.19",
59
+ "@xyo-network/archivist-memory": "~5.1.18",
60
+ "@xyo-network/archivist-model": "~5.1.18",
61
+ "@xyo-network/archivist-mongodb": "~5.1.18",
62
+ "@xyo-network/archivist-view": "~5.1.18",
63
63
  "@xyo-network/bios": "~7.1.1",
64
- "@xyo-network/boundwitness-model": "~5.1.17",
65
- "@xyo-network/chain-ethereum": "~1.15.28",
66
- "@xyo-network/chain-modules": "~1.15.28",
67
- "@xyo-network/chain-protocol": "~1.15.28",
68
- "@xyo-network/chain-rpc": "~1.15.28",
69
- "@xyo-network/chain-telemetry": "~1.15.28",
70
- "@xyo-network/manifest-model": "~5.1.17",
71
- "@xyo-network/manifest-wrapper": "~5.1.17",
72
- "@xyo-network/module-abstract": "~5.1.17",
73
- "@xyo-network/module-factory-locator": "~5.1.17",
74
- "@xyo-network/module-model": "~5.1.17",
75
- "@xyo-network/node-model": "~5.1.17",
76
- "@xyo-network/payload-builder": "~5.1.17",
77
- "@xyo-network/payload-model": "~5.1.17",
78
- "@xyo-network/sentinel-memory": "~5.1.17",
64
+ "@xyo-network/boundwitness-model": "~5.1.18",
65
+ "@xyo-network/chain-ethereum": "~1.16.0",
66
+ "@xyo-network/chain-modules": "~1.16.0",
67
+ "@xyo-network/chain-protocol": "~1.16.0",
68
+ "@xyo-network/chain-rpc": "~1.16.0",
69
+ "@xyo-network/chain-telemetry": "~1.16.0",
70
+ "@xyo-network/manifest-model": "~5.1.18",
71
+ "@xyo-network/manifest-wrapper": "~5.1.18",
72
+ "@xyo-network/module-abstract": "~5.1.18",
73
+ "@xyo-network/module-factory-locator": "~5.1.18",
74
+ "@xyo-network/module-model": "~5.1.18",
75
+ "@xyo-network/node-model": "~5.1.18",
76
+ "@xyo-network/payload-builder": "~5.1.18",
77
+ "@xyo-network/payload-model": "~5.1.18",
78
+ "@xyo-network/sentinel-memory": "~5.1.18",
79
79
  "@xyo-network/typechain": "~4.0.10",
80
- "@xyo-network/wallet": "~5.1.17",
81
- "@xyo-network/wallet-model": "~5.1.17",
82
- "@xyo-network/xl1-protocol": "~1.12.102",
83
- "@xyo-network/xl1-protocol-sdk": "~1.15.28",
84
- "@xyo-network/xl1-rpc": "~1.15.28",
80
+ "@xyo-network/wallet": "~5.1.18",
81
+ "@xyo-network/wallet-model": "~5.1.18",
82
+ "@xyo-network/xl1-protocol": "~1.13.0",
83
+ "@xyo-network/xl1-protocol-sdk": "~1.16.0",
84
+ "@xyo-network/xl1-rpc": "~1.16.0",
85
85
  "async-mutex": "~0.5.0",
86
86
  "compression": "~1.8.1",
87
87
  "cors": "~2.8.5",
@@ -89,7 +89,7 @@
89
89
  "express": "~5.1.0",
90
90
  "http-status-codes": "~2.3.0",
91
91
  "lru-cache": "~11.2.2",
92
- "mongodb": "~6.20.0"
92
+ "mongodb": "~7.0.0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/compression": "~1.8.1",
@@ -97,26 +97,26 @@
97
97
  "@types/express": "5.0.5",
98
98
  "@types/express-serve-static-core": "~5.1.0",
99
99
  "@types/node": "~24.10.0",
100
- "@xylabs/base": "~5.0.18",
101
- "@xylabs/object": "~5.0.18",
102
- "@xylabs/promise": "~5.0.18",
100
+ "@xylabs/base": "~5.0.19",
101
+ "@xylabs/object": "~5.0.19",
102
+ "@xylabs/promise": "~5.0.19",
103
103
  "@xylabs/ts-scripts-yarn3": "~7.2.4",
104
104
  "@xylabs/tsconfig": "~7.2.4",
105
- "@xyo-network/account": "~5.1.17",
106
- "@xyo-network/account-model": "~5.1.17",
107
- "@xyo-network/archivist-abstract": "~5.1.17",
105
+ "@xyo-network/account": "~5.1.18",
106
+ "@xyo-network/account-model": "~5.1.18",
107
+ "@xyo-network/archivist-abstract": "~5.1.18",
108
108
  "@xyo-network/bios-model": "~7.1.1",
109
- "@xyo-network/boundwitness-builder": "~5.1.17",
110
- "@xyo-network/module-abstract-mongodb": "~5.1.17",
111
- "@xyo-network/module-model-mongodb": "~5.1.17",
112
- "@xyo-network/node-memory": "~5.1.17",
113
- "@xyo-network/xl1-protocol": "~1.12.102",
109
+ "@xyo-network/boundwitness-builder": "~5.1.18",
110
+ "@xyo-network/module-abstract-mongodb": "~5.1.18",
111
+ "@xyo-network/module-model-mongodb": "~5.1.18",
112
+ "@xyo-network/node-memory": "~5.1.18",
113
+ "@xyo-network/xl1-protocol": "~1.13.0",
114
114
  "dotenv": "~17.2.3",
115
115
  "eslint": "^9.39.1",
116
116
  "nodemon": "~3.1.10",
117
117
  "tslib": "~2.8.1",
118
118
  "typescript": "~5.9.3",
119
- "vitest": "~4.0.7",
119
+ "vitest": "~4.0.8",
120
120
  "vitest-mock-extended": "~3.1.0"
121
121
  },
122
122
  "engines": {
@@ -30,6 +30,25 @@ export interface GetLocatorContext {
30
30
  logger?: Logger
31
31
  }
32
32
 
33
+ export async function getTransferSummaryMap(config: Config): Promise<Promise<MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined>> {
34
+ const mongoConfig = config.storage?.mongo
35
+ if (hasMongoConfig(mongoConfig)) {
36
+ // Create the MongoDB SDK from the configuration
37
+ const {
38
+ connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,
39
+ } = mongoConfig
40
+ const payloadSdkConfig: BaseMongoSdkPrivateConfig = {
41
+ dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,
42
+ }
43
+
44
+ const sdkTransferSummaryMap = new BaseMongoSdk<WithStorageMeta<TransfersStepSummary>>({ ...payloadSdkConfig, collection: 'transfer_summary_map' })
45
+ return await MongoMap.create<MongoMap<Hash, WithStorageMeta<TransfersStepSummary>>>({
46
+ sdk: sdkTransferSummaryMap,
47
+ getCache: { enabled: true, maxEntries: 5000 },
48
+ })
49
+ }
50
+ }
51
+
33
52
  /**
34
53
  * Used for retrieving a locator with the necessary modules registered for testing
35
54
  * operation of the node (entirely in memory)
@@ -55,7 +74,7 @@ export const getLocator = async (context: GetLocatorContext) => {
55
74
 
56
75
  const locator = new ModuleFactoryLocator()
57
76
  let balanceSummaryMap: MapType<string, WithStorageMeta<BalancesStepSummary>> | undefined
58
- let transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined
77
+ let transferSummaryMap = await getTransferSummaryMap(config)
59
78
  // If there's a MongoDB configuration
60
79
  const mongoConfig = config.storage?.mongo
61
80
  if (hasMongoConfig(mongoConfig)) {
@@ -78,12 +97,6 @@ export const getLocator = async (context: GetLocatorContext) => {
78
97
  sdk: sdkBalanceSummaryMap,
79
98
  getCache: { enabled: true, maxEntries: 5000 },
80
99
  })
81
-
82
- const sdkTransferSummaryMap = new BaseMongoSdk<WithStorageMeta<TransfersStepSummary>>({ ...payloadSdkConfig, collection: 'transfer_summary_map' })
83
- transferSummaryMap = await MongoMap.create<MongoMap<Hash, WithStorageMeta<TransfersStepSummary>>>({
84
- sdk: sdkTransferSummaryMap,
85
- getCache: { enabled: true, maxEntries: 5000 },
86
- })
87
100
  }
88
101
 
89
102
  locator.register(AddressBalanceDivinerV2.factory<AddressBalanceDivinerV2>({
@@ -6,7 +6,7 @@ import type { Config } from '@xyo-network/xl1-protocol-sdk'
6
6
  import { getLocator } from './getLocator.ts'
7
7
  import { NodeManifest } from './nodeManifest.ts'
8
8
  import { PrivateChildManifests } from './private/index.ts'
9
- import { PublicChildManifests } from './public/index.ts'
9
+ import { PublicChildManifestsWithMempool, PublicChildManifestsWithoutMempool } from './public/index.ts'
10
10
 
11
11
  export interface GetNodeContext {
12
12
  config: Config
@@ -20,7 +20,9 @@ export interface GetNodeContext {
20
20
  * @returns A node with the xyo-chain modules registered
21
21
  */
22
22
  export const getNode = async (context: GetNodeContext) => {
23
- const { wallet } = context
23
+ const { wallet, config } = context
24
+ const { enabled: mempoolEnabled } = config.mempool
25
+ const PublicChildManifests = mempoolEnabled ? PublicChildManifestsWithoutMempool : PublicChildManifestsWithMempool
24
26
  const locator = await getLocator(context)
25
27
  const wrapper = new ManifestWrapper(NodeManifest, wallet, locator, PublicChildManifests, PrivateChildManifests)
26
28
  const [node, ...childNodes] = await wrapper.loadNodes()
@@ -172,4 +172,4 @@
172
172
  }
173
173
  ],
174
174
  "schema": "network.xyo.manifest"
175
- }
175
+ }
@@ -12,7 +12,7 @@
12
12
  "public": [
13
13
  {
14
14
  "config": {
15
- "accountPath": "2/1/2",
15
+ "accountPath": "2/1/1",
16
16
  "name": "PendingTransactions",
17
17
  "getCache": {
18
18
  "enabled": true,
@@ -0,0 +1,20 @@
1
+ import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'
2
+
3
+ import Chain from './Chain.json' with { type: 'json' }
4
+ import Pending from './Pending.json' with { type: 'json' }
5
+
6
+ /**
7
+ * Chain Node Manifest
8
+ */
9
+ const ChainNodeManifest = Chain as PackageManifestPayload
10
+ /**
11
+ * Pending Node Manifest
12
+ */
13
+ const PendingNodeManifest = Pending as PackageManifestPayload
14
+ /**
15
+ * Public Child Manifests
16
+ */
17
+ export const PublicChildManifestsWithMempool: ModuleManifest[] = [
18
+ ...ChainNodeManifest.nodes,
19
+ ...PendingNodeManifest.nodes,
20
+ ]
@@ -0,0 +1,97 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
3
+ "nodes": [
4
+ {
5
+ "config": {
6
+ "accountPath": "1",
7
+ "name": "Chain",
8
+ "schema": "network.xyo.node.config"
9
+ },
10
+ "modules": {
11
+ "private": [
12
+ {
13
+ "config": {
14
+ "accountPath": "1/1'/1'",
15
+ "name": "Validated",
16
+ "allowedQueries": [
17
+ "network.xyo.query.archivist.get",
18
+ "network.xyo.query.archivist.next"
19
+ ],
20
+ "getCache": {
21
+ "enabled": true,
22
+ "maxEntries": 5000
23
+ },
24
+ "payloadSdkConfig": {
25
+ "collection": "chain_validated"
26
+ },
27
+ "schema": "network.xyo.archivist.config"
28
+ }
29
+ }
30
+ ],
31
+ "public": [
32
+ {
33
+ "config": {
34
+ "accountPath": "1/1/1",
35
+ "name": "Submissions",
36
+ "getCache": {
37
+ "enabled": true,
38
+ "maxEntries": 5000
39
+ },
40
+ "payloadSdkConfig": {
41
+ "collection": "chain_submissions"
42
+ },
43
+ "schema": "network.xyo.archivist.config"
44
+ }
45
+ },
46
+ {
47
+ "config": {
48
+ "accountPath": "1/1/2",
49
+ "name": "Finalized",
50
+ "allowedQueries": [
51
+ "network.xyo.query.archivist.get",
52
+ "network.xyo.query.archivist.next"
53
+ ],
54
+ "getCache": {
55
+ "enabled": true,
56
+ "maxEntries": 50000
57
+ },
58
+ "originArchivist": "Validated",
59
+ "schema": "network.xyo.archivist.view.config"
60
+ }
61
+ },
62
+ {
63
+ "config": {
64
+ "accountPath": "1/1/3'",
65
+ "name": "AddressBalanceDiviner",
66
+ "schema": "network.xyo.diviner.chain.address.balance.config",
67
+ "map": {
68
+ "lmdb": {
69
+ "dbName": "summaries",
70
+ "storeName": "address_balance",
71
+ "location": ".store"
72
+ }
73
+ },
74
+ "archivist": "Validated"
75
+ }
76
+ },
77
+ {
78
+ "config": {
79
+ "accountPath": "1/1/4'",
80
+ "name": "AddressTransferDiviner",
81
+ "schema": "network.xyo.diviner.chain.address.transfer.config",
82
+ "map": {
83
+ "lmdb": {
84
+ "dbName": "summaries",
85
+ "storeName": "address_transfer",
86
+ "location": ".store"
87
+ }
88
+ },
89
+ "archivist": "Validated"
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ }
95
+ ],
96
+ "schema": "network.xyo.manifest"
97
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
3
+ "nodes": [
4
+ {
5
+ "config": {
6
+ "accountPath": "2",
7
+ "name": "Pending",
8
+ "schema": "network.xyo.node.config"
9
+ },
10
+ "modules": {
11
+ "private": [],
12
+ "public": [
13
+ {
14
+ "config": {
15
+ "accountPath": "2/1/1",
16
+ "name": "PendingTransactions",
17
+ "getCache": {
18
+ "enabled": true,
19
+ "maxEntries": 5000
20
+ },
21
+ "labels": {
22
+ "network.xyo.storage.class": "mongodb"
23
+ },
24
+ "payloadSdkConfig": {
25
+ "collection": "pending_bundles"
26
+ },
27
+ "schema": "network.xyo.archivist.config"
28
+ }
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ ],
34
+ "schema": "network.xyo.manifest"
35
+ }
@@ -0,0 +1,20 @@
1
+ import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'
2
+
3
+ import Chain from './Chain.json' with { type: 'json' }
4
+ import Pending from './Pending.json' with { type: 'json' }
5
+
6
+ /**
7
+ * Chain Node Manifest
8
+ */
9
+ const ChainNodeManifest = Chain as PackageManifestPayload
10
+ /**
11
+ * Pending Node Manifest
12
+ */
13
+ const PendingNodeManifest = Pending as PackageManifestPayload
14
+ /**
15
+ * Public Child Manifests
16
+ */
17
+ export const PublicChildManifestsWithoutMempool: ModuleManifest[] = [
18
+ ...ChainNodeManifest.nodes,
19
+ ...PendingNodeManifest.nodes,
20
+ ]
@@ -1,20 +1,2 @@
1
- import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'
2
-
3
- import Chain from './Chain.json' with { type: 'json' }
4
- import Pending from './Pending.json' with { type: 'json' }
5
-
6
- /**
7
- * Chain Node Manifest
8
- */
9
- export const ChainNodeManifest = Chain as PackageManifestPayload
10
- /**
11
- * Pending Node Manifest
12
- */
13
- export const PendingNodeManifest = Pending as PackageManifestPayload
14
- /**
15
- * Public Child Manifests
16
- */
17
- export const PublicChildManifests: ModuleManifest[] = [
18
- ...ChainNodeManifest.nodes,
19
- ...PendingNodeManifest.nodes,
20
- ]
1
+ export * from './WithMempool/index.ts'
2
+ export * from './WithoutMempool/index.ts'
package/src/server/app.ts CHANGED
@@ -9,7 +9,10 @@ import {
9
9
  standardResponses,
10
10
  } from '@xylabs/express'
11
11
  import type { NodeInstance } from '@xyo-network/node-model'
12
- import type { StakedChainContextRead, StakeEventsRead } from '@xyo-network/xl1-protocol-sdk'
12
+ import type { WithStorageMeta } from '@xyo-network/payload-model'
13
+ import type {
14
+ MapType, StakedChainContextRead, TransfersStepSummary,
15
+ } from '@xyo-network/xl1-protocol-sdk'
13
16
  import compression from 'compression'
14
17
  import cors from 'cors'
15
18
  import type { Express } from 'express'
@@ -20,7 +23,7 @@ import { addRoutes } from './routes/index.ts'
20
23
 
21
24
  export const getApp = async (
22
25
  node: NodeInstance,
23
- eventsReader: StakeEventsRead,
26
+ transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,
24
27
  stakedChainContext: StakedChainContextRead,
25
28
  initRewardsCache?: boolean,
26
29
  ): Promise<Express> => {
@@ -37,7 +40,7 @@ export const getApp = async (
37
40
  app.use(customPoweredByHeader)
38
41
  disableCaseSensitiveRouting(app)
39
42
  app.node = node
40
- await addRoutes(app, stakedChainContext, initRewardsCache)
43
+ await addRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache)
41
44
  app.use(standardErrors)
42
45
  return app
43
46
  }
@@ -1,12 +1,20 @@
1
- import type { StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'
1
+ import type { WithStorageMeta } from '@xyo-network/payload-model'
2
+ import type {
3
+ MapType, StakedChainContextRead, TransfersStepSummary,
4
+ } from '@xyo-network/xl1-protocol-sdk'
2
5
  import type { Express } from 'express'
3
6
 
4
7
  import { addNodeRoutes } from './address/index.ts'
5
8
  import { addDataLakeRoutes } from './dataLake/index.ts'
6
9
  import { addRpcRoutes } from './rpc/index.ts'
7
10
 
8
- export const addRoutes = async (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => {
9
- await addRpcRoutes(app, stakedChainContext, initRewardsCache)
11
+ export const addRoutes = async (
12
+ app: Express,
13
+ transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,
14
+ stakedChainContext: StakedChainContextRead,
15
+ initRewardsCache?: boolean,
16
+ ) => {
17
+ await addRpcRoutes(app, transferSummaryMap, stakedChainContext, initRewardsCache)
10
18
  addDataLakeRoutes(app)
11
19
  addNodeRoutes(app)
12
20
  }
@@ -1,7 +1,7 @@
1
- import { assertEx } from '@xylabs/assert'
2
1
  import { asyncHandler } from '@xylabs/express'
3
- import { asAddress, toAddress } from '@xylabs/hex'
4
- import { isModuleIdentifierPart } from '@xyo-network/module-model'
2
+ import { asAddress } from '@xylabs/hex'
3
+ import { isDefined } from '@xylabs/typeof'
4
+ import { isModuleName } from '@xyo-network/module-model'
5
5
  import type { Payload } from '@xyo-network/payload-model'
6
6
  import type { RequestHandler } from 'express'
7
7
  import { StatusCodes } from 'http-status-codes'
@@ -9,22 +9,20 @@ import { StatusCodes } from 'http-status-codes'
9
9
  import type { AddressPathParams } from '../AddressPathParams.ts'
10
10
 
11
11
  const handler: RequestHandler<AddressPathParams, Payload[]> = async (req, res, next) => {
12
- const { address: rawAddress } = req.params
12
+ const { address: moduleIdentifier } = req.params
13
13
  const { node } = req.app
14
- const address = asAddress(rawAddress)
15
- if (address !== undefined) {
14
+ const address = asAddress(moduleIdentifier)
15
+ if (isDefined(address)) {
16
16
  let mod = node.address === address ? node : (await node.resolve(address, { direction: 'down' }))
17
17
  if (mod) {
18
18
  res.json(await mod.state())
19
19
  return
20
20
  }
21
21
  }
22
- if (isModuleIdentifierPart(rawAddress)) {
23
- const moduleIdentifier = toAddress(rawAddress)
22
+ if (isModuleName(moduleIdentifier)) {
24
23
  const mod = await node.resolve(moduleIdentifier, { direction: 'down' })
25
24
  if (mod) {
26
- const moduleAddress = assertEx(mod?.address, () => 'Error redirecting to module by address')
27
- res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${moduleAddress}`)
25
+ res.redirect(StatusCodes.MOVED_TEMPORARILY, `/${mod.address}`)
28
26
  return
29
27
  }
30
28
  }
@@ -2,14 +2,25 @@ import { setRawResponseFormat } from '@xylabs/express'
2
2
  import {
3
3
  NodeNetworkStakeViewer, NodeStepRewardsByPositionViewer, NodeXyoViewer,
4
4
  } from '@xyo-network/chain-rpc'
5
- import { RewardMultipliers, type StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'
5
+ import type { WithStorageMeta } from '@xyo-network/payload-model'
6
+ import { StepSizes } from '@xyo-network/xl1-protocol'
7
+ import type {
8
+ MapType, StakedChainContextRead, TransfersStepSummary,
9
+ } from '@xyo-network/xl1-protocol-sdk'
10
+ import { RewardMultipliers } from '@xyo-network/xl1-protocol-sdk'
6
11
  import {
7
12
  NodeXyoRunner, rpcEngineFromConnection,
8
13
  XyoBaseConnection,
9
14
  } from '@xyo-network/xl1-rpc'
15
+ import { Semaphore } from 'async-mutex'
10
16
  import type { Express } from 'express'
11
17
 
12
- export const addRpcRoutes = async (app: Express, stakedChainContext: StakedChainContextRead, initRewardsCache?: boolean) => {
18
+ export const addRpcRoutes = async (
19
+ app: Express,
20
+ transferSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>,
21
+ stakedChainContext: StakedChainContextRead,
22
+ initRewardsCache?: boolean,
23
+ ) => {
13
24
  const { node } = app
14
25
  const runner = new NodeXyoRunner(node)
15
26
  const networkStakeViewer = await NodeNetworkStakeViewer.create({ context: stakedChainContext })
@@ -19,7 +30,13 @@ export const addRpcRoutes = async (app: Express, stakedChainContext: StakedChain
19
30
  console.log('Initialized NodeNetworkStakeViewer.')
20
31
 
21
32
  const viewer = await NodeXyoViewer.create({
22
- node, rewardMultipliers: RewardMultipliers, initRewardsCache, networkStakeViewer,
33
+ node,
34
+ rewardMultipliers: RewardMultipliers,
35
+ initRewardsCache,
36
+ context: stakedChainContext,
37
+ transfersSummaryContext: {
38
+ ...stakedChainContext, stepSemaphores: StepSizes.map(() => new Semaphore(20)), summaryMap: transferSummaryMap,
39
+ },
23
40
  })
24
41
 
25
42
  console.log('Initializing NodeXyoViewer...')
@@ -7,17 +7,19 @@ import { asArchivistInstance } from '@xyo-network/archivist-model'
7
7
  import { boot } from '@xyo-network/bios'
8
8
  import type { BiosExternalInterface } from '@xyo-network/bios-model'
9
9
  import { EthereumChainStake, EthereumChainStakeEvents } from '@xyo-network/chain-ethereum'
10
- import { findMostRecentBlock } from '@xyo-network/chain-protocol'
10
+ import { findMostRecentBlock, getLocalPersistentMap } from '@xyo-network/chain-protocol'
11
11
  import type { NodeInstance } from '@xyo-network/node-model'
12
12
  import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
13
13
  import { StakedXyoChainV2__factory } from '@xyo-network/typechain'
14
14
  import { HDWallet } from '@xyo-network/wallet'
15
15
  import type { ChainId } from '@xyo-network/xl1-protocol'
16
- import type { Config, StakedChainContextRead } from '@xyo-network/xl1-protocol-sdk'
16
+ import type {
17
+ Config, StakedChainContextRead, TransfersStepSummary,
18
+ } from '@xyo-network/xl1-protocol-sdk'
17
19
  import { readPayloadMapFromStore } from '@xyo-network/xl1-protocol-sdk'
18
20
 
19
21
  import { initInfuraProvider } from '../helpers/index.ts'
20
- import { getNode } from '../manifest/index.ts'
22
+ import { getNode, getTransferSummaryMap } from '../manifest/index.ts'
21
23
  import { getApp } from './app.ts'
22
24
 
23
25
  const hostname = '::'
@@ -93,7 +95,8 @@ export const getServer = async (context: GetServerContext) => {
93
95
  await Promise.all(mods.map((mod) => {
94
96
  return mod.start?.() ?? (() => true)
95
97
  }))
96
- const app = await getApp(resolvedNode, eventsReader, stakedChainContext, config.api.initRewardsCache)
98
+ const transferSummaryMap = assertEx(await getTransferSummaryMap(config), () => 'Transfer Summary Map not initialized')
99
+ const app = await getApp(resolvedNode, transferSummaryMap, stakedChainContext, config.api.initRewardsCache)
97
100
  const server = app.listen(port, hostname, () => logger?.log(`[API] Server listening at http://${hostname}:${port}`))
98
101
  server.setTimeout(20_000)
99
102
  return server
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Node.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Node.spec.d.ts","sourceRoot":"","sources":["../../../../../src/manifest/public/spec/Node.spec.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- import type { MemoryNode } from '@xyo-network/node-memory'
2
- import { HDWallet } from '@xyo-network/wallet'
3
- import { getDefaultConfig } from '@xyo-network/xl1-protocol-sdk'
4
- import {
5
- beforeAll, describe, expect,
6
- it,
7
- } from 'vitest'
8
-
9
- import { getNode, GetNodeContext } from '../../getNode.ts'
10
- import { SilentLogger } from '@xylabs/logger'
11
-
12
- /**
13
- * @group manifest
14
- */
15
- describe('Node', () => {
16
- let node: MemoryNode
17
- let context: GetNodeContext
18
-
19
- beforeAll(async () => {
20
- const config = getDefaultConfig()
21
- const logger = new SilentLogger()
22
- const wallet = await HDWallet.random()
23
- context = {
24
- config, logger, wallet,
25
- }
26
- // Create a node with the default configuration
27
- node = await getNode(context)
28
- })
29
- it('should return node', () => {
30
- expect(node).toBeDefined()
31
- })
32
- })