@lodestar/api 1.20.0-dev.b453b37d53 → 1.20.0-dev.b6e20771c1
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 +8 -15
- package/lib/builder/routes.js +2 -2
- package/lib/builder/routes.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -7,30 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
> This package is part of [ChainSafe's Lodestar](https://lodestar.chainsafe.io) project
|
|
9
9
|
|
|
10
|
-
Typescript REST client for the [Ethereum Consensus API
|
|
10
|
+
Typescript REST client for the [Ethereum Consensus API](https://github.com/ethereum/beacon-apis)
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
The REST client extends the native [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), it behaves very similar in terms of error and response handling. It returns the same [Response object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with additional methods to simplify usage and it allows to override all [Request options](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) if needed.
|
|
15
15
|
|
|
16
16
|
```typescript
|
|
17
|
-
import {getClient
|
|
17
|
+
import {getClient} from "@lodestar/api";
|
|
18
18
|
import {config} from "@lodestar/config/default";
|
|
19
19
|
|
|
20
20
|
const api = getClient({baseUrl: "http://localhost:9596"}, {config});
|
|
21
21
|
|
|
22
|
-
api.beacon
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.then((res) => {
|
|
28
|
-
if (res.ok) {
|
|
29
|
-
console.log("Your balance is:", res.response.data.balance, res.ok, res.status);
|
|
30
|
-
} else {
|
|
31
|
-
console.error(res.status, res.error.code, res.error.message);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
22
|
+
const res = await api.beacon.getStateValidator({stateId: "head", validatorId: 0});
|
|
23
|
+
|
|
24
|
+
const validator = res.value();
|
|
25
|
+
|
|
26
|
+
console.log("The validator balance is: ", validator.balance);
|
|
34
27
|
```
|
|
35
28
|
|
|
36
29
|
## Prerequisites
|
package/lib/builder/routes.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isForkBlobs } from "@lodestar/params";
|
|
|
5
5
|
import { Schema } from "../utils/index.js";
|
|
6
6
|
import { MetaHeader, VersionCodec } from "../utils/metadata.js";
|
|
7
7
|
import { ArrayOf, EmptyRequestCodec, EmptyResponseCodec, JsonOnlyReq, WithVersion, } from "../utils/codecs.js";
|
|
8
|
-
import { getExecutionForkTypes, toForkName } from "../utils/fork.js";
|
|
8
|
+
import { getBlobsForkTypes, getExecutionForkTypes, toForkName } from "../utils/fork.js";
|
|
9
9
|
import { fromHeaders } from "../utils/headers.js";
|
|
10
10
|
const RegistrationsType = ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1);
|
|
11
11
|
// NOTE: Builder API does not support SSZ as per spec, need to keep routes as JSON-only for now
|
|
@@ -76,7 +76,7 @@ export function getDefinitions(config) {
|
|
|
76
76
|
resp: {
|
|
77
77
|
data: WithVersion((fork) => {
|
|
78
78
|
return isForkBlobs(fork)
|
|
79
|
-
?
|
|
79
|
+
? getBlobsForkTypes(fork).ExecutionPayloadAndBlobsBundle
|
|
80
80
|
: getExecutionForkTypes(fork).ExecutionPayload;
|
|
81
81
|
}),
|
|
82
82
|
meta: VersionCodec,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/builder/routes.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,GAAG,GASJ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAW,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAA6B,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAC,UAAU,EAAE,YAAY,EAAc,MAAM,sBAAsB,CAAC;AA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{
|
|
2
2
|
"name": "@lodestar/api",
|
|
3
|
-
"description": "A Typescript
|
|
3
|
+
"description": "A Typescript REST client for the Ethereum Consensus API",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"homepage": "https://github.com/ChainSafe/lodestar#readme",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.20.0-dev.
|
|
14
|
+
"version": "1.20.0-dev.b6e20771c1",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@chainsafe/persistent-merkle-tree": "^0.7.1",
|
|
74
74
|
"@chainsafe/ssz": "^0.15.1",
|
|
75
|
-
"@lodestar/config": "1.20.0-dev.
|
|
76
|
-
"@lodestar/params": "1.20.0-dev.
|
|
77
|
-
"@lodestar/types": "1.20.0-dev.
|
|
78
|
-
"@lodestar/utils": "1.20.0-dev.
|
|
75
|
+
"@lodestar/config": "1.20.0-dev.b6e20771c1",
|
|
76
|
+
"@lodestar/params": "1.20.0-dev.b6e20771c1",
|
|
77
|
+
"@lodestar/types": "1.20.0-dev.b6e20771c1",
|
|
78
|
+
"@lodestar/utils": "1.20.0-dev.b6e20771c1",
|
|
79
79
|
"eventsource": "^2.0.2",
|
|
80
80
|
"qs": "^6.11.1"
|
|
81
81
|
},
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"api",
|
|
93
93
|
"blockchain"
|
|
94
94
|
],
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "8f5467670881cef23944e84e5808b0c619e02ff0"
|
|
96
96
|
}
|