@xyo-network/chain-api 1.19.7 → 1.19.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/ApiActor.d.ts +4 -25
- package/dist/node/ApiActor.d.ts.map +1 -1
- package/dist/node/index.mjs +21 -323
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/runApi.d.ts +2 -6
- package/dist/node/runApi.d.ts.map +1 -1
- package/dist/node/server/app.d.ts +2 -2
- package/dist/node/server/app.d.ts.map +1 -1
- package/dist/node/server/index.d.ts +0 -1
- package/dist/node/server/index.d.ts.map +1 -1
- package/dist/node/server/routes/addRoutes.d.ts.map +1 -1
- package/dist/node/server/routes/index.d.ts +0 -1
- package/dist/node/server/routes/index.d.ts.map +1 -1
- package/dist/node/server/server.d.ts +2 -2
- package/dist/node/server/server.d.ts.map +1 -1
- package/package.json +11 -17
- package/src/ApiActor.ts +5 -40
- package/src/runApi.ts +15 -20
- package/src/server/app.ts +2 -2
- package/src/server/index.ts +0 -1
- package/src/server/routes/addRoutes.ts +0 -2
- package/src/server/routes/index.ts +0 -2
- package/src/server/server.ts +5 -4
- package/dist/node/ApiContext.d.ts +0 -6
- package/dist/node/ApiContext.d.ts.map +0 -1
- package/dist/node/server/initApiParams.d.ts +0 -12
- package/dist/node/server/initApiParams.d.ts.map +0 -1
- package/dist/node/server/routes/address/AddressPathParams.d.ts +0 -4
- package/dist/node/server/routes/address/AddressPathParams.d.ts.map +0 -1
- package/dist/node/server/routes/address/addNodeRoutes.d.ts +0 -3
- package/dist/node/server/routes/address/addNodeRoutes.d.ts.map +0 -1
- package/dist/node/server/routes/address/get/get.d.ts +0 -4
- package/dist/node/server/routes/address/get/get.d.ts.map +0 -1
- package/dist/node/server/routes/address/get/index.d.ts +0 -2
- package/dist/node/server/routes/address/get/index.d.ts.map +0 -1
- package/dist/node/server/routes/address/index.d.ts +0 -2
- package/dist/node/server/routes/address/index.d.ts.map +0 -1
- package/dist/node/server/routes/address/post/getQueryConfig.d.ts +0 -6
- package/dist/node/server/routes/address/post/getQueryConfig.d.ts.map +0 -1
- package/dist/node/server/routes/address/post/index.d.ts +0 -2
- package/dist/node/server/routes/address/post/index.d.ts.map +0 -1
- package/dist/node/server/routes/address/post/post.d.ts +0 -8
- package/dist/node/server/routes/address/post/post.d.ts.map +0 -1
- package/src/ApiContext.ts +0 -6
- package/src/server/initApiParams.ts +0 -194
- package/src/server/routes/address/AddressPathParams.ts +0 -3
- package/src/server/routes/address/addNodeRoutes.ts +0 -21
- package/src/server/routes/address/get/get.ts +0 -30
- package/src/server/routes/address/get/index.ts +0 -1
- package/src/server/routes/address/index.ts +0 -1
- package/src/server/routes/address/post/getQueryConfig.ts +0 -23
- package/src/server/routes/address/post/index.ts +0 -1
- package/src/server/routes/address/post/post.ts +0 -77
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { CreatableProviderContext } from '@xyo-network/xl1-sdk';
|
|
1
2
|
import type { Express } from 'express';
|
|
2
|
-
|
|
3
|
-
export declare const getApp: (context: ApiContext) => Promise<Express>;
|
|
3
|
+
export declare const getApp: (context: CreatableProviderContext) => Promise<Express>;
|
|
4
4
|
//# sourceMappingURL=app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAGpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,MAAM,GAAU,SAAS,wBAAwB,KAAG,OAAO,CAAC,OAAO,CAiB/E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addRoutes.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/addRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"addRoutes.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/addRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,SAAS,GACpB,KAAK,OAAO,kBAIb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function getServer(context:
|
|
1
|
+
import type { CreatableProviderContext } from '@xyo-network/xl1-sdk';
|
|
2
|
+
export declare function getServer(context: CreatableProviderContext): Promise<import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>>;
|
|
3
3
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAMpE,wBAAsB,SAAS,CAAC,OAAO,EAAE,wBAAwB,8HAQhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/chain-api",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.9",
|
|
4
4
|
"description": "XYO Layer One API",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -52,35 +52,28 @@
|
|
|
52
52
|
"@opentelemetry/instrumentation": "~0.211.0",
|
|
53
53
|
"@opentelemetry/instrumentation-express": "~0.59.0",
|
|
54
54
|
"@opentelemetry/instrumentation-http": "~0.211.0",
|
|
55
|
-
"@xylabs/express": "~5.0.
|
|
56
|
-
"@xylabs/sdk-js": "~5.0.
|
|
57
|
-
"@xyo-network/account": "~5.3.2",
|
|
55
|
+
"@xylabs/express": "~5.0.79",
|
|
56
|
+
"@xylabs/sdk-js": "~5.0.79",
|
|
58
57
|
"@xyo-network/archivist-model": "~5.3.2",
|
|
59
58
|
"@xyo-network/boundwitness-model": "~5.3.2",
|
|
60
|
-
"@xyo-network/chain-orchestration": "~1.19.
|
|
61
|
-
"@xyo-network/chain-services": "~1.19.7",
|
|
62
|
-
"@xyo-network/chain-telemetry": "~1.19.7",
|
|
63
|
-
"@xyo-network/chain-utils": "~1.19.7",
|
|
64
|
-
"@xyo-network/chain-validation": "~1.19.7",
|
|
65
|
-
"@xyo-network/module-abstract": "~5.3.2",
|
|
59
|
+
"@xyo-network/chain-orchestration": "~1.19.9",
|
|
66
60
|
"@xyo-network/module-model": "~5.3.2",
|
|
67
61
|
"@xyo-network/node-model": "~5.3.2",
|
|
68
62
|
"@xyo-network/payload-builder": "~5.3.2",
|
|
69
63
|
"@xyo-network/payload-model": "~5.3.2",
|
|
70
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
64
|
+
"@xyo-network/xl1-sdk": "~1.23.14",
|
|
71
65
|
"compression": "~1.8.1",
|
|
72
66
|
"cors": "~2.8.6",
|
|
73
67
|
"ethers": "^6.16.0",
|
|
74
|
-
"express": "~5.2.1"
|
|
75
|
-
"http-status-codes": "~2.3.0"
|
|
68
|
+
"express": "~5.2.1"
|
|
76
69
|
},
|
|
77
70
|
"devDependencies": {
|
|
78
71
|
"@types/compression": "~1.8.1",
|
|
79
72
|
"@types/cors": "~2.8.19",
|
|
80
73
|
"@types/express": "5.0.6",
|
|
81
74
|
"@types/express-serve-static-core": "~5.1.1",
|
|
82
|
-
"@types/node": "~25.2.
|
|
83
|
-
"@xylabs/sdk-js": "~5.0.
|
|
75
|
+
"@types/node": "~25.2.3",
|
|
76
|
+
"@xylabs/sdk-js": "~5.0.79",
|
|
84
77
|
"@xylabs/ts-scripts-yarn3": "~7.3.2",
|
|
85
78
|
"@xylabs/tsconfig": "~7.3.2",
|
|
86
79
|
"@xyo-network/account": "~5.3.2",
|
|
@@ -88,13 +81,14 @@
|
|
|
88
81
|
"@xyo-network/archivist-abstract": "~5.3.2",
|
|
89
82
|
"@xyo-network/bios-model": "~7.2.1",
|
|
90
83
|
"@xyo-network/boundwitness-builder": "~5.3.2",
|
|
91
|
-
"@xyo-network/chain-services": "~1.19.
|
|
84
|
+
"@xyo-network/chain-services": "~1.19.9",
|
|
92
85
|
"@xyo-network/module-abstract-mongodb": "~5.3.2",
|
|
93
86
|
"@xyo-network/module-model-mongodb": "~5.3.2",
|
|
94
87
|
"@xyo-network/node-memory": "~5.3.2",
|
|
95
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
88
|
+
"@xyo-network/xl1-sdk": "~1.23.14",
|
|
96
89
|
"dotenv": "~17.2.4",
|
|
97
90
|
"eslint": "^9.39.2",
|
|
91
|
+
"http-status-codes": "~2.3.0",
|
|
98
92
|
"nodemon": "~3.1.11",
|
|
99
93
|
"tslib": "~2.8.1",
|
|
100
94
|
"typescript": "~5.9.3",
|
package/src/ApiActor.ts
CHANGED
|
@@ -1,55 +1,20 @@
|
|
|
1
1
|
import { Server } from 'node:http'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { Account } from '@xyo-network/account'
|
|
5
|
-
import { WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
+
import { creatable } from '@xylabs/sdk-js'
|
|
6
4
|
import {
|
|
7
|
-
|
|
8
|
-
MapType,
|
|
9
|
-
TransfersStepSummary,
|
|
5
|
+
ActorParamsV3, ActorV3, Config,
|
|
10
6
|
} from '@xyo-network/xl1-sdk'
|
|
11
7
|
|
|
12
|
-
import { ApiContext } from './ApiContext.ts'
|
|
13
8
|
import { getServer } from './server/index.ts'
|
|
14
9
|
|
|
15
|
-
export type ApiActorParams =
|
|
16
|
-
|
|
17
|
-
context: ApiContext
|
|
18
|
-
transfersSummaryMap: MapType<string, WithStorageMeta<TransfersStepSummary>>
|
|
10
|
+
export type ApiActorParams = ActorParamsV3<{
|
|
11
|
+
config: Config
|
|
19
12
|
}>
|
|
20
13
|
|
|
21
14
|
@creatable()
|
|
22
|
-
export class ApiActor extends
|
|
15
|
+
export class ApiActor extends ActorV3<ApiActorParams> {
|
|
23
16
|
private server?: Server
|
|
24
17
|
|
|
25
|
-
protected override get context() {
|
|
26
|
-
return this.params.context!
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static override defaultFactories(): CreatableProviderFactory[] {
|
|
30
|
-
return [
|
|
31
|
-
...super.defaultFactories(),
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static override async paramsHandler<T extends ApiActor>(params: T['params']) {
|
|
36
|
-
const logger = params?.context?.logger
|
|
37
|
-
|
|
38
|
-
let account = params?.account
|
|
39
|
-
if (account === undefined) {
|
|
40
|
-
const newAccount = await Account.random()
|
|
41
|
-
logger?.warn(`No account provided to ApiActor, generating random account ${newAccount.address}`)
|
|
42
|
-
account = newAccount
|
|
43
|
-
}
|
|
44
|
-
logger?.info(`Running api for account ${account.address}`)
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
...await super.paramsHandler(params),
|
|
48
|
-
context: params.context,
|
|
49
|
-
account: assertEx(account, () => 'ApiActor requires an account to run'),
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
18
|
override async createHandler() {
|
|
54
19
|
await super.createHandler()
|
|
55
20
|
}
|
package/src/runApi.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { exists
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { exists } from '@xylabs/sdk-js'
|
|
2
|
+
import { initApiWallet, type OrchestratorInstance } from '@xyo-network/chain-orchestration'
|
|
3
|
+
import type {
|
|
4
|
+
Config,
|
|
5
|
+
ProviderFactoryLocatorInstance,
|
|
6
|
+
} from '@xyo-network/xl1-sdk'
|
|
5
7
|
|
|
6
8
|
import { ApiActor } from './ApiActor.ts'
|
|
7
|
-
import { initApiParams } from './server/index.ts'
|
|
8
|
-
|
|
9
|
-
export interface RunApiContext extends BaseContext {
|
|
10
|
-
config: Config
|
|
11
|
-
orchestrator: OrchestratorInstance
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const runApi = async ({
|
|
15
|
-
config, orchestrator, ...params
|
|
16
|
-
}: RunApiContext) => {
|
|
17
|
-
const logger = new IdLogger(params.logger ?? console, () => 'API')
|
|
18
|
-
const account = await Account.random()
|
|
19
|
-
logger.info(`Running api for account ${account.address} [random]`)
|
|
20
|
-
|
|
21
|
-
const actorParams = await initApiParams({ config, logger })
|
|
22
9
|
|
|
10
|
+
export const runApi = async (
|
|
11
|
+
config: Config,
|
|
12
|
+
orchestrator: OrchestratorInstance,
|
|
13
|
+
locator: ProviderFactoryLocatorInstance,
|
|
14
|
+
) => {
|
|
15
|
+
const account = await initApiWallet({ config, logger: locator.context.logger })
|
|
23
16
|
// Create actors
|
|
24
|
-
const api = await ApiActor.create(
|
|
17
|
+
const api = await ApiActor.create({
|
|
18
|
+
account, config, locator,
|
|
19
|
+
})
|
|
25
20
|
const actors = [api].filter(exists)
|
|
26
21
|
|
|
27
22
|
for (const actor of actors) {
|
package/src/server/app.ts
CHANGED
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
standardErrors,
|
|
9
9
|
standardResponses,
|
|
10
10
|
} from '@xylabs/express'
|
|
11
|
+
import type { CreatableProviderContext } from '@xyo-network/xl1-sdk'
|
|
11
12
|
import compression from 'compression'
|
|
12
13
|
import cors from 'cors'
|
|
13
14
|
import type { Express } from 'express'
|
|
14
15
|
import express from 'express'
|
|
15
16
|
|
|
16
|
-
import type { ApiContext } from '../ApiContext.ts'
|
|
17
17
|
import { addInstrumentation } from './instrumentation.ts'
|
|
18
18
|
import { addRoutes } from './routes/index.ts'
|
|
19
19
|
|
|
20
|
-
export const getApp = async (context:
|
|
20
|
+
export const getApp = async (context: CreatableProviderContext): Promise<Express> => {
|
|
21
21
|
addInstrumentation()
|
|
22
22
|
const app = express()
|
|
23
23
|
app.set('etag', false)
|
package/src/server/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Express } from 'express'
|
|
2
2
|
|
|
3
|
-
import { addNodeRoutes } from './address/index.ts'
|
|
4
3
|
import { addDataLakeRoutes } from './dataLake/index.ts'
|
|
5
4
|
import { addRpcRoutes } from './rpc/index.ts'
|
|
6
5
|
|
|
@@ -9,5 +8,4 @@ export const addRoutes = async (
|
|
|
9
8
|
) => {
|
|
10
9
|
await addRpcRoutes(app)
|
|
11
10
|
addDataLakeRoutes(app)
|
|
12
|
-
addNodeRoutes(app)
|
|
13
11
|
}
|
package/src/server/server.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreatableProviderContext } from '@xyo-network/xl1-sdk'
|
|
2
|
+
|
|
2
3
|
import { getApp } from './app.ts'
|
|
3
4
|
|
|
4
5
|
const hostname = '::'
|
|
5
6
|
|
|
6
|
-
export async function getServer(context:
|
|
7
|
+
export async function getServer(context: CreatableProviderContext) {
|
|
7
8
|
const { logger } = context
|
|
8
|
-
const { port } = context.config.api
|
|
9
|
+
const { port } = context.config.actors.api
|
|
9
10
|
|
|
10
11
|
const app = await getApp(context)
|
|
11
|
-
const server = app.listen(port, hostname, () => logger?.
|
|
12
|
+
const server = app.listen(port, hostname, () => logger?.info(`[API] Server listening at http://${hostname}:${port}`))
|
|
12
13
|
server.setTimeout(20_000)
|
|
13
14
|
return server
|
|
14
15
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiContext.d.ts","sourceRoot":"","sources":["../../src/ApiContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAEpE,MAAM,WAAW,UAAW,SAAQ,wBAAwB;IAC1D,IAAI,EAAE,YAAY,CAAA;CACnB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@xylabs/sdk-js';
|
|
2
|
-
import type { NodeInstance } from '@xyo-network/node-model';
|
|
3
|
-
import type { Config } from '@xyo-network/xl1-sdk';
|
|
4
|
-
import type { ApiActorParams } from '../ApiActor.ts';
|
|
5
|
-
interface InitServerContext {
|
|
6
|
-
config: Config;
|
|
7
|
-
logger?: Logger;
|
|
8
|
-
node?: NodeInstance;
|
|
9
|
-
}
|
|
10
|
-
export declare function initApiParams(params: InitServerContext): Promise<ApiActorParams>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=initApiParams.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initApiParams.d.ts","sourceRoot":"","sources":["../../../src/server/initApiParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAY5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EACkC,MAAM,EAInD,MAAM,sBAAsB,CAAA;AAO7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CA8JtF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AddressPathParams.d.ts","sourceRoot":"","sources":["../../../../../src/server/routes/address/AddressPathParams.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addNodeRoutes.d.ts","sourceRoot":"","sources":["../../../../../src/server/routes/address/addNodeRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,SAczC,CAAA"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Payload } from '@xyo-network/payload-model';
|
|
2
|
-
import type { AddressPathParams } from '../AddressPathParams.ts';
|
|
3
|
-
export declare const getAddress: (req: import("express").Request<AddressPathParams, Payload[], any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<Payload[], Record<string, any>>, next: import("express").NextFunction) => Promise<unknown>;
|
|
4
|
-
//# sourceMappingURL=get.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/get/get.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAsBhE,eAAO,MAAM,UAAU,4OAAwB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/get/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/server/routes/address/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
|
-
import type { ModuleConfig, ModuleInstance } from '@xyo-network/module-model';
|
|
3
|
-
import type { Payload } from '@xyo-network/payload-model';
|
|
4
|
-
import type { Request } from 'express';
|
|
5
|
-
export declare const getQueryConfig: (mod: ModuleInstance, req: Request, bw: QueryBoundWitness, payloads?: Payload[]) => ModuleConfig | undefined;
|
|
6
|
-
//# sourceMappingURL=getQueryConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getQueryConfig.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/post/getQueryConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEtF,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC,eAAO,MAAM,cAAc,GAAI,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,IAAI,iBAAiB,EAAE,WAAW,OAAO,EAAE,KAAG,YAAY,GAAG,SAa9H,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/post/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
|
-
import type { ModuleQueryResult } from '@xyo-network/module-model';
|
|
3
|
-
import type { ModuleError, Payload } from '@xyo-network/payload-model';
|
|
4
|
-
import type { AddressPathParams } from '../AddressPathParams.ts';
|
|
5
|
-
type PostAddressRequestBody = [QueryBoundWitness, undefined | Payload[]];
|
|
6
|
-
export declare const postAddress: (req: import("express").Request<AddressPathParams, ModuleError | ModuleQueryResult, PostAddressRequestBody, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<ModuleError | ModuleQueryResult, Record<string, any>>, next: import("express").NextFunction) => Promise<unknown>;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=post.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/address/post/post.ts"],"names":[],"mappings":"AAOA,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAE7F,OAAO,KAAK,EAAkB,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAItE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAGhE,KAAK,sBAAsB,GAAG,CAAC,iBAAiB,EAAE,SAAS,GAAG,OAAO,EAAE,CAAC,CAAA;AA2DxE,eAAO,MAAM,WAAW,2SAAwB,CAAA"}
|
package/src/ApiContext.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-statements */
|
|
2
|
-
import type { Logger } from '@xylabs/sdk-js'
|
|
3
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
4
|
-
import { Account } from '@xyo-network/account'
|
|
5
|
-
import type { MempoolActorParams, ValidatorActorParams } from '@xyo-network/chain-orchestration'
|
|
6
|
-
import {
|
|
7
|
-
buildTelemetryConfig, initApiWallet, initBalanceSummaryMap, initEvmProvidersIfAvailable, initHealthEndpoints, initServerNode,
|
|
8
|
-
initStatusReporter, initTransferSummaryMap, MempoolActor, ValidatorActor,
|
|
9
|
-
} from '@xyo-network/chain-orchestration'
|
|
10
|
-
import { createBootstrapHead } from '@xyo-network/chain-services'
|
|
11
|
-
import { initTelemetry } from '@xyo-network/chain-telemetry'
|
|
12
|
-
import { startupSpanAsync } from '@xyo-network/chain-utils'
|
|
13
|
-
import { validateHydratedBlock, validateHydratedBlockState } from '@xyo-network/chain-validation'
|
|
14
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
15
|
-
import type {
|
|
16
|
-
AccountBalanceViewer, BlockViewer, ChainId, Config,
|
|
17
|
-
MempoolRunner,
|
|
18
|
-
MempoolViewer,
|
|
19
|
-
XyoViewer,
|
|
20
|
-
} from '@xyo-network/xl1-sdk'
|
|
21
|
-
import {
|
|
22
|
-
AccountBalanceViewerMoniker, asAttoXL1, BlockViewerMoniker, buildLocalProviderLocator, DefaultMetricsScrapePorts, findMostRecentBlock, flattenHydratedBlock,
|
|
23
|
-
MempoolRunnerMoniker, MempoolViewerMoniker, SimpleBlockValidationViewer, SimpleXyoConnection,
|
|
24
|
-
XyoViewerMoniker,
|
|
25
|
-
} from '@xyo-network/xl1-sdk'
|
|
26
|
-
|
|
27
|
-
import type { ApiActorParams } from '../ApiActor.ts'
|
|
28
|
-
import type { ApiContext } from '../ApiContext.ts'
|
|
29
|
-
|
|
30
|
-
interface InitServerContext {
|
|
31
|
-
config: Config
|
|
32
|
-
logger?: Logger
|
|
33
|
-
node?: NodeInstance
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function initApiParams(params: InitServerContext): Promise<ApiActorParams> {
|
|
37
|
-
const { config, node: providedNode } = params
|
|
38
|
-
const { id: configuredChainId } = config.chain
|
|
39
|
-
|
|
40
|
-
const logger = assertEx(params.logger, () => 'Logger is required to init server')
|
|
41
|
-
|
|
42
|
-
const statusReporter = initStatusReporter({ logger })
|
|
43
|
-
|
|
44
|
-
await startupSpanAsync('initHealthEndpoints', () => initHealthEndpoints({
|
|
45
|
-
config, logger, statusReporter,
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
const telemetryConfig = buildTelemetryConfig(config, 'xl1-api', '1.0.0', DefaultMetricsScrapePorts.api)
|
|
49
|
-
|
|
50
|
-
const { traceProvider, meterProvider } = await startupSpanAsync('initTelemetry', () => initTelemetry(telemetryConfig))
|
|
51
|
-
|
|
52
|
-
const initContext = {
|
|
53
|
-
_id: 'init-context',
|
|
54
|
-
config,
|
|
55
|
-
logger,
|
|
56
|
-
statusReporter,
|
|
57
|
-
timeBudgetLimit: 1000,
|
|
58
|
-
meterProvider,
|
|
59
|
-
traceProvider,
|
|
60
|
-
singletons: {},
|
|
61
|
-
caches: {},
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const wallet = await initApiWallet(initContext)
|
|
65
|
-
|
|
66
|
-
const balancesSummaryMap = assertEx(await initBalanceSummaryMap(initContext), () => 'Balance Summary Map not initialized')
|
|
67
|
-
const transfersSummaryMap = assertEx(await initTransferSummaryMap(initContext), () => 'Transfer Summary Map not initialized')
|
|
68
|
-
|
|
69
|
-
const {
|
|
70
|
-
node, writableChainArchivist, readonlyChainArchivist, pendingTransactionsArchivist, pendingBlocksArchivist,
|
|
71
|
-
} = await initServerNode({
|
|
72
|
-
...initContext,
|
|
73
|
-
wallet,
|
|
74
|
-
node: providedNode,
|
|
75
|
-
transfersSummaryMap,
|
|
76
|
-
balancesSummaryMap,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
await writableChainArchivist.start()
|
|
80
|
-
await readonlyChainArchivist.start()
|
|
81
|
-
await pendingTransactionsArchivist.start()
|
|
82
|
-
await pendingBlocksArchivist.start()
|
|
83
|
-
|
|
84
|
-
const possibleHead = await findMostRecentBlock(readonlyChainArchivist)
|
|
85
|
-
if (configuredChainId && possibleHead && possibleHead.chain !== configuredChainId) {
|
|
86
|
-
throw new Error(`Configured chain ID (${configuredChainId}) does not match the existing chain ID (${possibleHead.chain})`)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let possibleChainId: ChainId | undefined = configuredChainId
|
|
90
|
-
|
|
91
|
-
// if there is no configured chain ID and no head, create a new chain
|
|
92
|
-
if (!possibleHead) {
|
|
93
|
-
possibleChainId = possibleChainId ?? (await Account.random()).address
|
|
94
|
-
// If there is no head, create one
|
|
95
|
-
const chain = await createBootstrapHead(
|
|
96
|
-
wallet,
|
|
97
|
-
possibleChainId,
|
|
98
|
-
asAttoXL1(20_000_000_000_000_000_000_000n),
|
|
99
|
-
config.chain.genesisRewardAddress ?? wallet.address,
|
|
100
|
-
)
|
|
101
|
-
const payloads = chain.flatMap(block => flattenHydratedBlock(block))
|
|
102
|
-
await writableChainArchivist.insert(payloads)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const head = possibleHead ?? assertEx(await findMostRecentBlock(readonlyChainArchivist), () => 'No blocks found in chain archivist')
|
|
106
|
-
const chainId = assertEx(possibleChainId, () => 'Chain ID could not be determined')
|
|
107
|
-
assertEx(head.chain === chainId, () => `Chain ID does not match head block chain ID [init] [${head.chain} !== ${chainId}]`)
|
|
108
|
-
|
|
109
|
-
const mods = await node.resolve('*')
|
|
110
|
-
await Promise.all(mods.map((mod) => {
|
|
111
|
-
return mod.start?.() ?? (() => true)
|
|
112
|
-
}))
|
|
113
|
-
|
|
114
|
-
const locator = buildLocalProviderLocator({
|
|
115
|
-
context: initContext,
|
|
116
|
-
finalizedArchivist: writableChainArchivist,
|
|
117
|
-
pendingTransactionsArchivist,
|
|
118
|
-
pendingBlocksArchivist,
|
|
119
|
-
balancesSummaryMap,
|
|
120
|
-
transfersSummaryMap,
|
|
121
|
-
node,
|
|
122
|
-
chainId,
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
await initEvmProvidersIfAvailable(locator)
|
|
126
|
-
|
|
127
|
-
locator.register(SimpleBlockValidationViewer.factory<SimpleBlockValidationViewer>(
|
|
128
|
-
SimpleBlockValidationViewer.dependencies,
|
|
129
|
-
{ state: validateHydratedBlockState, protocol: validateHydratedBlock },
|
|
130
|
-
))
|
|
131
|
-
|
|
132
|
-
locator.register(SimpleXyoConnection.factory<SimpleXyoConnection>(SimpleXyoConnection.dependencies, {}))
|
|
133
|
-
|
|
134
|
-
const apiContext = {
|
|
135
|
-
...initContext,
|
|
136
|
-
...locator.context,
|
|
137
|
-
_id: 'api-context',
|
|
138
|
-
node,
|
|
139
|
-
} satisfies ApiContext
|
|
140
|
-
|
|
141
|
-
const blockViewer = (await locator.getInstance<BlockViewer>(BlockViewerMoniker))
|
|
142
|
-
assertEx(await blockViewer.start(), () => 'Failed to start BlockViewer')
|
|
143
|
-
|
|
144
|
-
const blk = await blockViewer.currentBlock()
|
|
145
|
-
assertEx(blk, () => 'No blocks found after initialization')
|
|
146
|
-
|
|
147
|
-
const accountBalanceViewer = (await locator.getInstance<AccountBalanceViewer>(AccountBalanceViewerMoniker))
|
|
148
|
-
assertEx(await accountBalanceViewer.start(), () => 'Failed to start AccountBalanceViewer')
|
|
149
|
-
|
|
150
|
-
const xyoViewer = (await locator.getInstance<XyoViewer>(XyoViewerMoniker))
|
|
151
|
-
assertEx(await xyoViewer.start(), () => 'Failed to start XyoViewer')
|
|
152
|
-
|
|
153
|
-
const mempoolViewer = (await locator.getInstance<MempoolViewer>(MempoolViewerMoniker))
|
|
154
|
-
assertEx(await mempoolViewer.start(), () => 'Failed to start MempoolViewer')
|
|
155
|
-
|
|
156
|
-
const mempoolRunner = (await locator.getInstance<MempoolRunner>(MempoolRunnerMoniker))
|
|
157
|
-
assertEx(await mempoolRunner.start(), () => 'Failed to start MempoolRunner')
|
|
158
|
-
|
|
159
|
-
console.info(`[API] Current block after initialization: #${blk[0].block} (${blk[0]._hash})`)
|
|
160
|
-
|
|
161
|
-
const validatorActor = config.mempool.enabled
|
|
162
|
-
? undefined
|
|
163
|
-
: await ValidatorActor.create({
|
|
164
|
-
id: 'validator-mempool-server',
|
|
165
|
-
account: wallet,
|
|
166
|
-
context: locator.context,
|
|
167
|
-
finalizedArchivist: writableChainArchivist,
|
|
168
|
-
mempoolViewer,
|
|
169
|
-
blockViewer,
|
|
170
|
-
} satisfies ValidatorActorParams)
|
|
171
|
-
|
|
172
|
-
await validatorActor?.start()
|
|
173
|
-
|
|
174
|
-
const mempoolActor = config.mempool.enabled
|
|
175
|
-
? undefined
|
|
176
|
-
: await MempoolActor.create({
|
|
177
|
-
id: 'mempool-mempool-server',
|
|
178
|
-
account: wallet,
|
|
179
|
-
context: locator.context,
|
|
180
|
-
mempoolRunner,
|
|
181
|
-
pendingBlocksArchivist,
|
|
182
|
-
pendingTransactionsArchivist,
|
|
183
|
-
} satisfies MempoolActorParams)
|
|
184
|
-
|
|
185
|
-
await mempoolActor?.start()
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
id: 'api-actor',
|
|
189
|
-
account: wallet,
|
|
190
|
-
context: apiContext,
|
|
191
|
-
transfersSummaryMap,
|
|
192
|
-
balancesSummaryMap,
|
|
193
|
-
}
|
|
194
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Express } from 'express'
|
|
2
|
-
import { StatusCodes } from 'http-status-codes'
|
|
3
|
-
|
|
4
|
-
import { getAddress } from './get/index.ts'
|
|
5
|
-
import { postAddress } from './post/index.ts'
|
|
6
|
-
|
|
7
|
-
export const addNodeRoutes = (app: Express) => {
|
|
8
|
-
const defaultModule = app.context.node
|
|
9
|
-
const address = defaultModule.address
|
|
10
|
-
const defaultModuleEndpoint = `/${address}`
|
|
11
|
-
app.get('/', (_req, res) => res.redirect(StatusCodes.MOVED_TEMPORARILY, defaultModuleEndpoint))
|
|
12
|
-
app.post('/', (_req, res) => res.redirect(StatusCodes.TEMPORARY_REDIRECT, defaultModuleEndpoint))
|
|
13
|
-
app.get('/:address', getAddress)
|
|
14
|
-
app.post('/:address', postAddress)
|
|
15
|
-
app.get('/:hash', (_req, res) => {
|
|
16
|
-
res.sendStatus(StatusCodes.NOT_FOUND)
|
|
17
|
-
})
|
|
18
|
-
app.post('/:hash', (_req, res) => {
|
|
19
|
-
res.sendStatus(StatusCodes.NOT_FOUND)
|
|
20
|
-
})
|
|
21
|
-
}
|