@lodestar/api 1.20.0-dev.f6d3bce802 → 1.20.0-dev.f8593a9a81
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/README.md +1 -1
- package/lib/beacon/client/beacon.d.ts +4 -3
- package/lib/beacon/client/beacon.js +3 -36
- package/lib/beacon/client/beacon.js.map +1 -1
- package/lib/beacon/client/config.d.ts +4 -3
- package/lib/beacon/client/config.js +3 -6
- package/lib/beacon/client/config.js.map +1 -1
- package/lib/beacon/client/debug.d.ts +4 -3
- package/lib/beacon/client/debug.js +4 -45
- package/lib/beacon/client/debug.js.map +1 -1
- package/lib/beacon/client/events.d.ts +5 -2
- package/lib/beacon/client/events.js +32 -35
- package/lib/beacon/client/events.js.map +1 -1
- package/lib/beacon/client/index.d.ts +6 -3
- package/lib/beacon/client/index.js +2 -2
- package/lib/beacon/client/index.js.map +1 -1
- package/lib/beacon/client/lightclient.d.ts +4 -3
- package/lib/beacon/client/lightclient.js +4 -7
- package/lib/beacon/client/lightclient.js.map +1 -1
- package/lib/beacon/client/lodestar.d.ts +4 -3
- package/lib/beacon/client/lodestar.js +4 -7
- package/lib/beacon/client/lodestar.js.map +1 -1
- package/lib/beacon/client/node.d.ts +4 -3
- package/lib/beacon/client/node.js +4 -7
- package/lib/beacon/client/node.js.map +1 -1
- package/lib/beacon/client/proof.d.ts +5 -4
- package/lib/beacon/client/proof.js +5 -61
- package/lib/beacon/client/proof.js.map +1 -1
- package/lib/beacon/client/validator.d.ts +4 -3
- package/lib/beacon/client/validator.js +4 -7
- package/lib/beacon/client/validator.js.map +1 -1
- package/lib/beacon/index.d.ts +5 -5
- package/lib/beacon/index.js.map +1 -1
- package/lib/beacon/routes/beacon/block.d.ts +282 -164
- package/lib/beacon/routes/beacon/block.js +324 -116
- package/lib/beacon/routes/beacon/block.js.map +1 -1
- package/lib/beacon/routes/beacon/index.d.ts +6 -588
- package/lib/beacon/routes/beacon/index.js +16 -26
- package/lib/beacon/routes/beacon/index.js.map +1 -1
- package/lib/beacon/routes/beacon/pool.d.ts +155 -117
- package/lib/beacon/routes/beacon/pool.js +146 -42
- package/lib/beacon/routes/beacon/pool.js.map +1 -1
- package/lib/beacon/routes/beacon/rewards.d.ts +113 -101
- package/lib/beacon/routes/beacon/rewards.js +98 -63
- package/lib/beacon/routes/beacon/rewards.js.map +1 -1
- package/lib/beacon/routes/beacon/state.d.ts +172 -226
- package/lib/beacon/routes/beacon/state.js +204 -126
- package/lib/beacon/routes/beacon/state.js.map +1 -1
- package/lib/beacon/routes/config.d.ts +21 -36
- package/lib/beacon/routes/config.js +45 -24
- package/lib/beacon/routes/config.js.map +1 -1
- package/lib/beacon/routes/debug.d.ts +32 -95
- package/lib/beacon/routes/debug.js +87 -45
- package/lib/beacon/routes/debug.js.map +1 -1
- package/lib/beacon/routes/events.d.ts +20 -16
- package/lib/beacon/routes/events.js +39 -17
- package/lib/beacon/routes/events.js.map +1 -1
- package/lib/beacon/routes/index.d.ts +19 -19
- package/lib/beacon/routes/index.js +1 -0
- package/lib/beacon/routes/index.js.map +1 -1
- package/lib/beacon/routes/lightclient.d.ts +33 -55
- package/lib/beacon/routes/lightclient.js +107 -47
- package/lib/beacon/routes/lightclient.js.map +1 -1
- package/lib/beacon/routes/lodestar.d.ts +74 -148
- package/lib/beacon/routes/lodestar.js +126 -77
- package/lib/beacon/routes/lodestar.js.map +1 -1
- package/lib/beacon/routes/node.d.ts +48 -82
- package/lib/beacon/routes/node.js +90 -57
- package/lib/beacon/routes/node.js.map +1 -1
- package/lib/beacon/routes/proof.d.ts +25 -31
- package/lib/beacon/routes/proof.js +44 -24
- package/lib/beacon/routes/proof.js.map +1 -1
- package/lib/beacon/routes/validator.d.ts +547 -320
- package/lib/beacon/routes/validator.js +494 -213
- package/lib/beacon/routes/validator.js.map +1 -1
- package/lib/beacon/server/beacon.d.ts +3 -4
- package/lib/beacon/server/beacon.js +4 -57
- package/lib/beacon/server/beacon.js.map +1 -1
- package/lib/beacon/server/config.d.ts +3 -4
- package/lib/beacon/server/config.js +4 -5
- package/lib/beacon/server/config.js.map +1 -1
- package/lib/beacon/server/debug.d.ts +3 -4
- package/lib/beacon/server/debug.js +4 -54
- package/lib/beacon/server/debug.js.map +1 -1
- package/lib/beacon/server/events.d.ts +4 -4
- package/lib/beacon/server/events.js +17 -23
- package/lib/beacon/server/events.js.map +1 -1
- package/lib/beacon/server/index.d.ts +7 -8
- package/lib/beacon/server/index.js +13 -14
- package/lib/beacon/server/index.js.map +1 -1
- package/lib/beacon/server/lightclient.d.ts +3 -4
- package/lib/beacon/server/lightclient.js +4 -5
- package/lib/beacon/server/lightclient.js.map +1 -1
- package/lib/beacon/server/lodestar.d.ts +3 -4
- package/lib/beacon/server/lodestar.js +4 -5
- package/lib/beacon/server/lodestar.js.map +1 -1
- package/lib/beacon/server/node.d.ts +3 -4
- package/lib/beacon/server/node.js +4 -18
- package/lib/beacon/server/node.js.map +1 -1
- package/lib/beacon/server/proof.d.ts +3 -4
- package/lib/beacon/server/proof.js +4 -36
- package/lib/beacon/server/proof.js.map +1 -1
- package/lib/beacon/server/validator.d.ts +3 -4
- package/lib/beacon/server/validator.js +4 -21
- package/lib/beacon/server/validator.js.map +1 -1
- package/lib/builder/client.d.ts +4 -6
- package/lib/builder/client.js +3 -9
- package/lib/builder/client.js.map +1 -1
- package/lib/builder/index.d.ts +8 -5
- package/lib/builder/index.js +4 -1
- package/lib/builder/index.js.map +1 -1
- package/lib/builder/routes.d.ts +24 -38
- package/lib/builder/routes.js +77 -33
- package/lib/builder/routes.js.map +1 -1
- package/lib/builder/server/index.d.ts +6 -6
- package/lib/builder/server/index.js +7 -8
- package/lib/builder/server/index.js.map +1 -1
- package/lib/index.d.ts +8 -6
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/keymanager/client.d.ts +4 -3
- package/lib/keymanager/client.js +4 -7
- package/lib/keymanager/client.js.map +1 -1
- package/lib/keymanager/index.d.ts +5 -4
- package/lib/keymanager/index.js +1 -1
- package/lib/keymanager/index.js.map +1 -1
- package/lib/keymanager/routes.d.ts +155 -177
- package/lib/keymanager/routes.js +236 -123
- package/lib/keymanager/routes.js.map +1 -1
- package/lib/keymanager/server/index.d.ts +6 -6
- package/lib/keymanager/server/index.js +7 -8
- package/lib/keymanager/server/index.js.map +1 -1
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +3 -0
- package/lib/server/index.js.map +1 -0
- package/lib/utils/client/error.d.ts +6 -0
- package/lib/utils/client/error.js +8 -0
- package/lib/utils/client/error.js.map +1 -0
- package/lib/utils/client/httpClient.d.ts +35 -75
- package/lib/utils/client/httpClient.js +201 -153
- package/lib/utils/client/httpClient.js.map +1 -1
- package/lib/utils/client/index.d.ts +6 -2
- package/lib/utils/client/index.js +6 -2
- package/lib/utils/client/index.js.map +1 -1
- package/lib/utils/client/method.d.ts +11 -0
- package/lib/utils/client/method.js +27 -0
- package/lib/utils/client/method.js.map +1 -0
- package/lib/utils/client/request.d.ts +33 -0
- package/lib/utils/client/request.js +66 -0
- package/lib/utils/client/request.js.map +1 -0
- package/lib/utils/client/response.d.ts +35 -0
- package/lib/utils/client/response.js +166 -0
- package/lib/utils/client/response.js.map +1 -0
- package/lib/utils/codecs.d.ts +28 -0
- package/lib/utils/codecs.js +105 -0
- package/lib/utils/codecs.js.map +1 -0
- package/lib/utils/fork.d.ts +8 -0
- package/lib/utils/fork.js +35 -0
- package/lib/utils/fork.js.map +1 -0
- package/lib/utils/headers.d.ts +37 -0
- package/lib/utils/headers.js +135 -0
- package/lib/utils/headers.js.map +1 -0
- package/lib/utils/httpStatusCode.js.map +1 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/metadata.d.ts +88 -0
- package/lib/utils/metadata.js +126 -0
- package/lib/utils/metadata.js.map +1 -0
- package/lib/utils/schema.d.ts +31 -17
- package/lib/utils/schema.js +18 -6
- package/lib/utils/schema.js.map +1 -1
- package/lib/utils/serdes.d.ts +3 -0
- package/lib/utils/serdes.js +13 -0
- package/lib/utils/serdes.js.map +1 -1
- package/lib/utils/server/{errors.d.ts → error.d.ts} +2 -2
- package/lib/utils/server/{errors.js → error.js} +1 -1
- package/lib/utils/server/error.js.map +1 -0
- package/lib/utils/server/handler.d.ts +11 -0
- package/lib/utils/server/handler.js +109 -0
- package/lib/utils/server/handler.js.map +1 -0
- package/lib/utils/server/index.d.ts +5 -4
- package/lib/utils/server/index.js +5 -4
- package/lib/utils/server/index.js.map +1 -1
- package/lib/utils/server/method.d.ts +35 -0
- package/lib/utils/server/method.js +2 -0
- package/lib/utils/server/method.js.map +1 -0
- package/lib/utils/server/parser.d.ts +3 -0
- package/lib/utils/server/parser.js +20 -0
- package/lib/utils/server/parser.js.map +1 -0
- package/lib/utils/server/route.d.ts +20 -0
- package/lib/utils/server/route.js +19 -0
- package/lib/utils/server/route.js.map +1 -0
- package/lib/utils/types.d.ts +116 -104
- package/lib/utils/types.js +2 -155
- package/lib/utils/types.js.map +1 -1
- package/lib/utils/urlFormat.d.ts +2 -2
- package/lib/utils/urlFormat.js +3 -3
- package/lib/utils/urlFormat.js.map +1 -1
- package/lib/utils/wireFormat.d.ts +8 -0
- package/lib/utils/wireFormat.js +23 -0
- package/lib/utils/wireFormat.js.map +1 -0
- package/package.json +9 -6
- package/lib/interfaces.d.ts +0 -44
- package/lib/interfaces.js +0 -2
- package/lib/interfaces.js.map +0 -1
- package/lib/utils/acceptHeader.d.ts +0 -9
- package/lib/utils/acceptHeader.js +0 -62
- package/lib/utils/acceptHeader.js.map +0 -1
- package/lib/utils/client/client.d.ts +0 -29
- package/lib/utils/client/client.js +0 -88
- package/lib/utils/client/client.js.map +0 -1
- package/lib/utils/client/httpStatusCode.js.map +0 -1
- package/lib/utils/routes.d.ts +0 -6
- package/lib/utils/routes.js +0 -31
- package/lib/utils/routes.js.map +0 -1
- package/lib/utils/server/errors.js.map +0 -1
- package/lib/utils/server/genericJsonServer.d.ts +0 -13
- package/lib/utils/server/genericJsonServer.js +0 -32
- package/lib/utils/server/genericJsonServer.js.map +0 -1
- package/lib/utils/server/registerRoute.d.ts +0 -3
- package/lib/utils/server/registerRoute.js +0 -13
- package/lib/utils/server/registerRoute.js.map +0 -1
- package/lib/utils/server/types.d.ts +0 -22
- package/lib/utils/server/types.js +0 -2
- package/lib/utils/server/types.js.map +0 -1
- /package/lib/utils/{client/httpStatusCode.d.ts → httpStatusCode.d.ts} +0 -0
- /package/lib/utils/{client/httpStatusCode.js → httpStatusCode.js} +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Lodestar Eth Consensus API
|
|
2
2
|
|
|
3
3
|
[](https://discord.gg/aMxzVcr)
|
|
4
|
-
[](https://github.com/ethereum/beacon-APIs/releases/tag/v2.5.0)
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/beacon/index.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for beacon routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient):
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=beacon.d.ts.map
|
|
@@ -1,42 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/beacon/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for beacon routes
|
|
5
5
|
*/
|
|
6
6
|
export function getClient(config, httpClient) {
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// Some routes return JSON, use a client auto-generator
|
|
10
|
-
const client = generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
11
|
-
const fetchOptsSerializer = getFetchOptsSerializers(routesData, reqSerializers);
|
|
12
|
-
return {
|
|
13
|
-
...client,
|
|
14
|
-
async getBlock(blockId, format) {
|
|
15
|
-
if (format === "ssz") {
|
|
16
|
-
const res = await httpClient.arrayBuffer({
|
|
17
|
-
...fetchOptsSerializer.getBlock(blockId, format),
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
ok: true,
|
|
21
|
-
response: new Uint8Array(res.body),
|
|
22
|
-
status: res.status,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return client.getBlock(blockId, format);
|
|
26
|
-
},
|
|
27
|
-
async getBlockV2(blockId, format) {
|
|
28
|
-
if (format === "ssz") {
|
|
29
|
-
const res = await httpClient.arrayBuffer({
|
|
30
|
-
...fetchOptsSerializer.getBlockV2(blockId, format),
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
ok: true,
|
|
34
|
-
response: new Uint8Array(res.body),
|
|
35
|
-
status: res.status,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return client.getBlockV2(blockId, format);
|
|
39
|
-
},
|
|
40
|
-
};
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
41
8
|
}
|
|
42
9
|
//# sourceMappingURL=beacon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../src/beacon/client/beacon.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../src/beacon/client/beacon.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAIpE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import { IHttpClient } from "../../utils/client/index.js";
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/config.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for config routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient):
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/config.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for config routes
|
|
5
5
|
*/
|
|
6
6
|
export function getClient(config, httpClient) {
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// All routes return JSON, use a client auto-generator
|
|
10
|
-
return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/beacon/client/config.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/beacon/client/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAI9D;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import { IHttpClient } from "../../utils/client/index.js";
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/debug.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for debug routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -1,50 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getReqSerializers, getReturnTypes, routesData } from "../routes/debug.js";
|
|
4
|
-
// As Jul 2022, it takes up to 3 mins to download states so make this 5 mins for reservation
|
|
5
|
-
const GET_STATE_TIMEOUT_MS = 5 * 60 * 1000;
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/debug.js";
|
|
6
3
|
/**
|
|
7
4
|
* REST HTTP client for debug routes
|
|
8
5
|
*/
|
|
9
|
-
export function getClient(
|
|
10
|
-
|
|
11
|
-
const returnTypes = getReturnTypes();
|
|
12
|
-
// Some routes return JSON, use a client auto-generator
|
|
13
|
-
const client = generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
14
|
-
// For `getState()` generate request serializer
|
|
15
|
-
const fetchOptsSerializers = getFetchOptsSerializers(routesData, reqSerializers);
|
|
16
|
-
return {
|
|
17
|
-
...client,
|
|
18
|
-
// TODO: Debug the type issue
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
-
// @ts-expect-error
|
|
21
|
-
async getState(stateId, format) {
|
|
22
|
-
if (format === "ssz") {
|
|
23
|
-
const res = await httpClient.arrayBuffer({
|
|
24
|
-
...fetchOptsSerializers.getState(stateId, format),
|
|
25
|
-
timeoutMs: GET_STATE_TIMEOUT_MS,
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
ok: true,
|
|
29
|
-
response: new Uint8Array(res.body),
|
|
30
|
-
status: res.status,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return client.getState(stateId, format);
|
|
34
|
-
},
|
|
35
|
-
// TODO: Debug the type issue
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
|
-
// @ts-expect-error
|
|
38
|
-
async getStateV2(stateId, format) {
|
|
39
|
-
if (format === "ssz") {
|
|
40
|
-
const res = await httpClient.arrayBuffer({
|
|
41
|
-
...fetchOptsSerializers.getStateV2(stateId, format),
|
|
42
|
-
timeoutMs: GET_STATE_TIMEOUT_MS,
|
|
43
|
-
});
|
|
44
|
-
return { ok: true, response: new Uint8Array(res.body), status: res.status };
|
|
45
|
-
}
|
|
46
|
-
return client.getStateV2(stateId, format);
|
|
47
|
-
},
|
|
48
|
-
};
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
49
8
|
}
|
|
50
9
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/beacon/client/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/beacon/client/debug.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,sBAAsB,EAAc,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAI7D;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
+
import { ApiClientMethods } from "../../utils/client/method.js";
|
|
3
|
+
import { Endpoints } from "../routes/events.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
2
5
|
/**
|
|
3
6
|
* REST HTTP client for events routes
|
|
4
7
|
*/
|
|
5
|
-
export declare function getClient(baseUrl: string):
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, baseUrl: string): ApiClient;
|
|
6
9
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
import { routesData, getEventSerdes } from "../routes/events.js";
|
|
2
|
-
import { stringifyQuery, urlJoin } from "../../utils/client/format.js";
|
|
3
1
|
import { getEventSource } from "../../utils/client/eventSource.js";
|
|
4
|
-
import {
|
|
2
|
+
import { stringifyQuery, urlJoin } from "../../utils/client/format.js";
|
|
3
|
+
import { ApiResponse } from "../../utils/client/response.js";
|
|
4
|
+
import { getDefinitions, getEventSerdes } from "../routes/events.js";
|
|
5
5
|
/**
|
|
6
6
|
* REST HTTP client for events routes
|
|
7
7
|
*/
|
|
8
|
-
export function getClient(baseUrl) {
|
|
8
|
+
export function getClient(config, baseUrl) {
|
|
9
|
+
const definitions = getDefinitions(config);
|
|
9
10
|
const eventSerdes = getEventSerdes();
|
|
10
11
|
return {
|
|
11
|
-
eventstream: async (topics, signal, onEvent) => {
|
|
12
|
+
eventstream: async ({ topics, signal, onEvent, onError, onClose }) => {
|
|
12
13
|
const query = stringifyQuery({ topics });
|
|
13
|
-
const url = `${urlJoin(baseUrl,
|
|
14
|
+
const url = `${urlJoin(baseUrl, definitions.eventstream.url)}?${query}`;
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
16
|
const EventSource = await getEventSource();
|
|
16
17
|
const eventSource = new EventSource(url);
|
|
17
|
-
|
|
18
|
-
await new Promise((resolve, reject) => {
|
|
19
|
-
for (const topic of topics) {
|
|
20
|
-
eventSource.addEventListener(topic, ((event) => {
|
|
21
|
-
const message = eventSerdes.fromJson(topic, JSON.parse(event.data));
|
|
22
|
-
onEvent({ type: topic, message });
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
// EventSource will try to reconnect always on all errors
|
|
26
|
-
// `eventSource.onerror` events are informative but don't indicate the EventSource closed
|
|
27
|
-
// The only way to abort the connection from the client is via eventSource.close()
|
|
28
|
-
eventSource.onerror = function onerror(err) {
|
|
29
|
-
const errEs = err;
|
|
30
|
-
// Consider 400 and 500 status errors unrecoverable, close the eventsource
|
|
31
|
-
if (errEs.status === 400) {
|
|
32
|
-
reject(Error(`400 Invalid topics: ${errEs.message}`));
|
|
33
|
-
}
|
|
34
|
-
if (errEs.status === 500) {
|
|
35
|
-
reject(Error(`500 Internal Server Error: ${errEs.message}`));
|
|
36
|
-
}
|
|
37
|
-
// TODO: else log the error somewhere
|
|
38
|
-
// console.log("eventstream client error", errEs);
|
|
39
|
-
};
|
|
40
|
-
// And abort resolve the promise so finally {} eventSource.close()
|
|
41
|
-
signal.addEventListener("abort", () => resolve(), { once: true });
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
18
|
+
const close = () => {
|
|
45
19
|
eventSource.close();
|
|
20
|
+
onClose?.();
|
|
21
|
+
signal.removeEventListener("abort", close);
|
|
22
|
+
};
|
|
23
|
+
signal.addEventListener("abort", close, { once: true });
|
|
24
|
+
for (const topic of topics) {
|
|
25
|
+
eventSource.addEventListener(topic, (event) => {
|
|
26
|
+
const message = eventSerdes.fromJson(topic, JSON.parse(event.data));
|
|
27
|
+
onEvent({ type: topic, message });
|
|
28
|
+
});
|
|
46
29
|
}
|
|
47
|
-
|
|
30
|
+
// EventSource will try to reconnect always on all errors
|
|
31
|
+
// `eventSource.onerror` events are informative but don't indicate the EventSource closed
|
|
32
|
+
// The only way to abort the connection from the client is via eventSource.close()
|
|
33
|
+
eventSource.onerror = function onerror(err) {
|
|
34
|
+
const errEs = err;
|
|
35
|
+
// Ignore noisy errors due to beacon node being offline
|
|
36
|
+
if (!errEs.message?.includes("ECONNREFUSED")) {
|
|
37
|
+
onError?.(new Error(errEs.message));
|
|
38
|
+
}
|
|
39
|
+
// Consider 400 and 500 status errors unrecoverable, close the eventsource
|
|
40
|
+
if (errEs.status === 400 || errEs.status === 500) {
|
|
41
|
+
close();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return new ApiResponse(definitions.eventstream);
|
|
48
45
|
},
|
|
49
46
|
};
|
|
50
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/beacon/client/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/beacon/client/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAyB,cAAc,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAI3F;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,OAAe;IAChE,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAC,EAAE,EAAE;YACjE,MAAM,KAAK,GAAG,cAAc,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;YACvC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;YACxE,gEAAgE;YAChE,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;YAC3C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;YAEzC,MAAM,KAAK,GAAG,GAAS,EAAE;gBACvB,WAAW,CAAC,KAAK,EAAE,CAAC;gBACpB,OAAO,EAAE,EAAE,CAAC;gBACZ,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC7C,CAAC,CAAC;YACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;YAEtD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,WAAW,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,KAAmB,EAAE,EAAE;oBAC1D,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;oBACpE,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAgB,CAAC,CAAC;gBACjD,CAAC,CAAC,CAAC;YACL,CAAC;YAED,yDAAyD;YACzD,yFAAyF;YACzF,kFAAkF;YAClF,WAAW,CAAC,OAAO,GAAG,SAAS,OAAO,CAAC,GAAG;gBACxC,MAAM,KAAK,GAAG,GAAkC,CAAC;gBAEjD,uDAAuD;gBACvD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;oBAC7C,OAAO,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,CAAC;gBAED,0EAA0E;gBAC1E,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACjD,KAAK,EAAE,CAAC;gBACV,CAAC;YACH,CAAC,CAAC;YAEF,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,WAA6D,CAAC,CAAC;QACpG,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, HttpClientModules, HttpClientOptions, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/index.js";
|
|
4
4
|
type ClientModules = HttpClientModules & {
|
|
5
5
|
config: ChainForkConfig;
|
|
6
6
|
httpClient?: IHttpClient;
|
|
7
7
|
};
|
|
8
|
+
export type ApiClient = {
|
|
9
|
+
[K in keyof Endpoints]: ApiClientMethods<Endpoints[K]>;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* REST HTTP client for all routes
|
|
10
13
|
*/
|
|
11
|
-
export declare function getClient(opts: HttpClientOptions, modules: ClientModules):
|
|
14
|
+
export declare function getClient(opts: HttpClientOptions, modules: ClientModules): ApiClient;
|
|
12
15
|
export {};
|
|
13
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpClient } from "../../utils/client/index.js";
|
|
1
|
+
import { HttpClient, } from "../../utils/client/index.js";
|
|
2
2
|
import * as beacon from "./beacon.js";
|
|
3
3
|
import * as configApi from "./config.js";
|
|
4
4
|
import * as debug from "./debug.js";
|
|
@@ -18,7 +18,7 @@ export function getClient(opts, modules) {
|
|
|
18
18
|
beacon: beacon.getClient(config, httpClient),
|
|
19
19
|
config: configApi.getClient(config, httpClient),
|
|
20
20
|
debug: debug.getClient(config, httpClient),
|
|
21
|
-
events: events.getClient(httpClient.baseUrl),
|
|
21
|
+
events: events.getClient(config, httpClient.baseUrl),
|
|
22
22
|
lightclient: lightclient.getClient(config, httpClient),
|
|
23
23
|
lodestar: lodestar.getClient(config, httpClient),
|
|
24
24
|
node: node.getClient(config, httpClient),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/beacon/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/beacon/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,GAIX,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAS5C;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAuB,EAAE,OAAsB;IACvE,MAAM,EAAC,MAAM,EAAC,GAAG,OAAO,CAAC;IACzB,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEvE,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QAC5C,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QAC/C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC;QACpD,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QACtD,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QAChD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QACxC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;QAC1C,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/lightclient.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for lightclient routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=lightclient.d.ts.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/lightclient.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for lightclient routes
|
|
5
5
|
*/
|
|
6
|
-
export function getClient(
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// All routes return JSON, use a client auto-generator
|
|
10
|
-
return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=lightclient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightclient.js","sourceRoot":"","sources":["../../../src/beacon/client/lightclient.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"lightclient.js","sourceRoot":"","sources":["../../../src/beacon/client/lightclient.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAInE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/lodestar.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for lodestar routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=lodestar.d.ts.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/lodestar.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for lodestar routes
|
|
5
5
|
*/
|
|
6
|
-
export function getClient(
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// All routes return JSON, use a client auto-generator
|
|
10
|
-
return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=lodestar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lodestar.js","sourceRoot":"","sources":["../../../src/beacon/client/lodestar.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"lodestar.js","sourceRoot":"","sources":["../../../src/beacon/client/lodestar.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAIhE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import { IHttpClient } from "../../utils/client/index.js";
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/node.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for beacon routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/node.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for beacon routes
|
|
5
5
|
*/
|
|
6
|
-
export function getClient(
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// All routes return JSON, use a client auto-generator
|
|
10
|
-
return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/beacon/client/node.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/beacon/client/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAI5D;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/proof.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
|
-
* REST HTTP client for
|
|
6
|
+
* REST HTTP client for proof routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=proof.d.ts.map
|
|
@@ -1,65 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getFetchOptsSerializers, HttpError } from "../../utils/client/index.js";
|
|
4
|
-
import { HttpStatusCode } from "../../utils/client/httpStatusCode.js";
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/proof.js";
|
|
5
3
|
/**
|
|
6
|
-
* REST HTTP client for
|
|
4
|
+
* REST HTTP client for proof routes
|
|
7
5
|
*/
|
|
8
|
-
export function getClient(
|
|
9
|
-
|
|
10
|
-
// For `getStateProof()` generate request serializer
|
|
11
|
-
const fetchOptsSerializers = getFetchOptsSerializers(routesData, reqSerializers);
|
|
12
|
-
return {
|
|
13
|
-
async getStateProof(stateId, descriptor) {
|
|
14
|
-
try {
|
|
15
|
-
const res = await httpClient.arrayBuffer(fetchOptsSerializers.getStateProof(stateId, descriptor));
|
|
16
|
-
// reuse the response ArrayBuffer
|
|
17
|
-
if (!Number.isInteger(res.body.byteLength / 32)) {
|
|
18
|
-
throw new Error("Invalid proof data: Length not divisible by 32");
|
|
19
|
-
}
|
|
20
|
-
const proof = {
|
|
21
|
-
type: ProofType.compactMulti,
|
|
22
|
-
descriptor,
|
|
23
|
-
leaves: Array.from({ length: res.body.byteLength / 32 }, (_, i) => new Uint8Array(res.body, i * 32, 32)),
|
|
24
|
-
};
|
|
25
|
-
return { ok: true, response: { data: proof }, status: HttpStatusCode.OK };
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
if (err instanceof HttpError) {
|
|
29
|
-
return {
|
|
30
|
-
ok: false,
|
|
31
|
-
error: { code: err.status, message: err.message, operationId: "proof.getStateProof" },
|
|
32
|
-
status: err.status,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
async getBlockProof(blockId, descriptor) {
|
|
39
|
-
try {
|
|
40
|
-
const res = await httpClient.arrayBuffer(fetchOptsSerializers.getBlockProof(blockId, descriptor));
|
|
41
|
-
// reuse the response ArrayBuffer
|
|
42
|
-
if (!Number.isInteger(res.body.byteLength / 32)) {
|
|
43
|
-
throw new Error("Invalid proof data: Length not divisible by 32");
|
|
44
|
-
}
|
|
45
|
-
const proof = {
|
|
46
|
-
type: ProofType.compactMulti,
|
|
47
|
-
descriptor,
|
|
48
|
-
leaves: Array.from({ length: res.body.byteLength / 32 }, (_, i) => new Uint8Array(res.body, i * 32, 32)),
|
|
49
|
-
};
|
|
50
|
-
return { ok: true, response: { data: proof }, status: HttpStatusCode.OK };
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
if (err instanceof HttpError) {
|
|
54
|
-
return {
|
|
55
|
-
ok: false,
|
|
56
|
-
error: { code: err.status, message: err.message, operationId: "proof.getStateProof" },
|
|
57
|
-
status: err.status,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
};
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
64
8
|
}
|
|
65
9
|
//# sourceMappingURL=proof.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proof.js","sourceRoot":"","sources":["../../../src/beacon/client/proof.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proof.js","sourceRoot":"","sources":["../../../src/beacon/client/proof.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAI7D;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApiClientMethods, IHttpClient } from "../../utils/client/index.js";
|
|
3
|
+
import { Endpoints } from "../routes/validator.js";
|
|
4
|
+
export type ApiClient = ApiClientMethods<Endpoints>;
|
|
4
5
|
/**
|
|
5
6
|
* REST HTTP client for validator routes
|
|
6
7
|
*/
|
|
7
|
-
export declare function getClient(
|
|
8
|
+
export declare function getClient(config: ChainForkConfig, httpClient: IHttpClient): ApiClient;
|
|
8
9
|
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createApiClientMethods } from "../../utils/client/index.js";
|
|
2
|
+
import { getDefinitions } from "../routes/validator.js";
|
|
3
3
|
/**
|
|
4
4
|
* REST HTTP client for validator routes
|
|
5
5
|
*/
|
|
6
|
-
export function getClient(
|
|
7
|
-
|
|
8
|
-
const returnTypes = getReturnTypes();
|
|
9
|
-
// All routes return JSON, use a client auto-generator
|
|
10
|
-
return generateGenericJsonClient(routesData, reqSerializers, returnTypes, httpClient);
|
|
6
|
+
export function getClient(config, httpClient) {
|
|
7
|
+
return createApiClientMethods(getDefinitions(config), httpClient);
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/beacon/client/validator.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/beacon/client/validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAY,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAIjE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAuB,EAAE,UAAuB;IACxE,OAAO,sBAAsB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC"}
|