@lodestar/api 1.35.0-dev.f80d2d52da → 1.35.0-dev.fcf8d024ea

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 (180) hide show
  1. package/lib/beacon/client/beacon.d.ts.map +1 -0
  2. package/lib/beacon/client/config.d.ts.map +1 -0
  3. package/lib/beacon/client/debug.d.ts.map +1 -0
  4. package/lib/beacon/client/events.d.ts.map +1 -0
  5. package/lib/beacon/client/index.d.ts.map +1 -0
  6. package/lib/beacon/client/index.js.map +1 -1
  7. package/lib/beacon/client/lightclient.d.ts.map +1 -0
  8. package/lib/beacon/client/lodestar.d.ts.map +1 -0
  9. package/lib/beacon/client/node.d.ts.map +1 -0
  10. package/lib/beacon/client/proof.d.ts.map +1 -0
  11. package/lib/beacon/client/validator.d.ts.map +1 -0
  12. package/lib/beacon/index.d.ts +1 -1
  13. package/lib/beacon/index.d.ts.map +1 -0
  14. package/lib/beacon/index.js.map +1 -1
  15. package/lib/beacon/routes/beacon/block.d.ts.map +1 -0
  16. package/lib/beacon/routes/beacon/index.d.ts +3 -3
  17. package/lib/beacon/routes/beacon/index.d.ts.map +1 -0
  18. package/lib/beacon/routes/beacon/index.js.map +1 -1
  19. package/lib/beacon/routes/beacon/pool.d.ts +1 -1
  20. package/lib/beacon/routes/beacon/pool.d.ts.map +1 -0
  21. package/lib/beacon/routes/beacon/rewards.d.ts.map +1 -0
  22. package/lib/beacon/routes/beacon/rewards.js.map +1 -1
  23. package/lib/beacon/routes/beacon/state.d.ts +2 -2
  24. package/lib/beacon/routes/beacon/state.d.ts.map +1 -0
  25. package/lib/beacon/routes/config.d.ts +1 -1
  26. package/lib/beacon/routes/config.d.ts.map +1 -0
  27. package/lib/beacon/routes/debug.d.ts.map +1 -0
  28. package/lib/beacon/routes/events.d.ts.map +1 -0
  29. package/lib/beacon/routes/events.js.map +1 -1
  30. package/lib/beacon/routes/index.d.ts.map +1 -0
  31. package/lib/beacon/routes/index.js.map +1 -1
  32. package/lib/beacon/routes/lightclient.d.ts.map +1 -0
  33. package/lib/beacon/routes/lodestar.d.ts.map +1 -0
  34. package/lib/beacon/routes/node.d.ts.map +1 -0
  35. package/lib/beacon/routes/proof.d.ts.map +1 -0
  36. package/lib/beacon/routes/validator.d.ts +1 -1
  37. package/lib/beacon/routes/validator.d.ts.map +1 -0
  38. package/lib/beacon/server/beacon.d.ts.map +1 -0
  39. package/lib/beacon/server/config.d.ts.map +1 -0
  40. package/lib/beacon/server/debug.d.ts.map +1 -0
  41. package/lib/beacon/server/events.d.ts.map +1 -0
  42. package/lib/beacon/server/index.d.ts +1 -1
  43. package/lib/beacon/server/index.d.ts.map +1 -0
  44. package/lib/beacon/server/index.js.map +1 -1
  45. package/lib/beacon/server/lightclient.d.ts.map +1 -0
  46. package/lib/beacon/server/lodestar.d.ts.map +1 -0
  47. package/lib/beacon/server/node.d.ts.map +1 -0
  48. package/lib/beacon/server/proof.d.ts.map +1 -0
  49. package/lib/beacon/server/validator.d.ts.map +1 -0
  50. package/lib/builder/client.d.ts.map +1 -0
  51. package/lib/builder/index.d.ts.map +1 -0
  52. package/lib/builder/index.js.map +1 -1
  53. package/lib/builder/routes.d.ts.map +1 -0
  54. package/lib/builder/routes.js.map +1 -1
  55. package/lib/builder/server/index.d.ts +1 -1
  56. package/lib/builder/server/index.d.ts.map +1 -0
  57. package/lib/index.d.ts +6 -6
  58. package/lib/index.d.ts.map +1 -0
  59. package/lib/index.js +3 -3
  60. package/lib/index.js.map +1 -1
  61. package/lib/keymanager/client.d.ts.map +1 -0
  62. package/lib/keymanager/index.d.ts +2 -2
  63. package/lib/keymanager/index.d.ts.map +1 -0
  64. package/lib/keymanager/index.js +1 -2
  65. package/lib/keymanager/index.js.map +1 -1
  66. package/lib/keymanager/routes.d.ts.map +1 -0
  67. package/lib/keymanager/server/index.d.ts +1 -1
  68. package/lib/keymanager/server/index.d.ts.map +1 -0
  69. package/lib/server/index.d.ts.map +1 -0
  70. package/lib/utils/client/error.d.ts.map +1 -0
  71. package/lib/utils/client/error.js +2 -0
  72. package/lib/utils/client/error.js.map +1 -1
  73. package/lib/utils/client/eventSource.d.ts.map +1 -0
  74. package/lib/utils/client/format.d.ts.map +1 -0
  75. package/lib/utils/client/httpClient.d.ts +1 -2
  76. package/lib/utils/client/httpClient.d.ts.map +1 -0
  77. package/lib/utils/client/httpClient.js +13 -9
  78. package/lib/utils/client/httpClient.js.map +1 -1
  79. package/lib/utils/client/index.d.ts +1 -1
  80. package/lib/utils/client/index.d.ts.map +1 -0
  81. package/lib/utils/client/index.js +1 -1
  82. package/lib/utils/client/index.js.map +1 -1
  83. package/lib/utils/client/method.d.ts.map +1 -0
  84. package/lib/utils/client/metrics.d.ts.map +1 -0
  85. package/lib/utils/client/request.d.ts.map +1 -0
  86. package/lib/utils/client/response.d.ts.map +1 -0
  87. package/lib/utils/client/response.js +6 -0
  88. package/lib/utils/client/response.js.map +1 -1
  89. package/lib/utils/codecs.d.ts.map +1 -0
  90. package/lib/utils/fork.d.ts.map +1 -0
  91. package/lib/utils/headers.d.ts.map +1 -0
  92. package/lib/utils/httpStatusCode.d.ts.map +1 -0
  93. package/lib/utils/index.d.ts.map +1 -0
  94. package/lib/utils/metadata.d.ts.map +1 -0
  95. package/lib/utils/schema.d.ts.map +1 -0
  96. package/lib/utils/serdes.d.ts.map +1 -0
  97. package/lib/utils/server/error.d.ts.map +1 -0
  98. package/lib/utils/server/error.js +1 -0
  99. package/lib/utils/server/error.js.map +1 -1
  100. package/lib/utils/server/handler.d.ts.map +1 -0
  101. package/lib/utils/server/index.d.ts.map +1 -0
  102. package/lib/utils/server/method.d.ts.map +1 -0
  103. package/lib/utils/server/parser.d.ts.map +1 -0
  104. package/lib/utils/server/route.d.ts.map +1 -0
  105. package/lib/utils/server/route.js.map +1 -1
  106. package/lib/utils/types.d.ts.map +1 -0
  107. package/lib/utils/urlFormat.d.ts.map +1 -0
  108. package/lib/utils/wireFormat.d.ts.map +1 -0
  109. package/package.json +17 -11
  110. package/src/beacon/client/beacon.ts +12 -0
  111. package/src/beacon/client/config.ts +12 -0
  112. package/src/beacon/client/debug.ts +12 -0
  113. package/src/beacon/client/events.ts +69 -0
  114. package/src/beacon/client/index.ts +46 -0
  115. package/src/beacon/client/lightclient.ts +12 -0
  116. package/src/beacon/client/lodestar.ts +12 -0
  117. package/src/beacon/client/node.ts +12 -0
  118. package/src/beacon/client/proof.ts +12 -0
  119. package/src/beacon/client/validator.ts +12 -0
  120. package/src/beacon/index.ts +24 -0
  121. package/src/beacon/routes/beacon/block.ts +602 -0
  122. package/src/beacon/routes/beacon/index.ts +66 -0
  123. package/src/beacon/routes/beacon/pool.ts +503 -0
  124. package/src/beacon/routes/beacon/rewards.ts +216 -0
  125. package/src/beacon/routes/beacon/state.ts +588 -0
  126. package/src/beacon/routes/config.ts +114 -0
  127. package/src/beacon/routes/debug.ts +231 -0
  128. package/src/beacon/routes/events.ts +337 -0
  129. package/src/beacon/routes/index.ts +33 -0
  130. package/src/beacon/routes/lightclient.ts +241 -0
  131. package/src/beacon/routes/lodestar.ts +456 -0
  132. package/src/beacon/routes/node.ts +286 -0
  133. package/src/beacon/routes/proof.ts +79 -0
  134. package/src/beacon/routes/validator.ts +1014 -0
  135. package/src/beacon/server/beacon.ts +7 -0
  136. package/src/beacon/server/config.ts +7 -0
  137. package/src/beacon/server/debug.ts +7 -0
  138. package/src/beacon/server/events.ts +73 -0
  139. package/src/beacon/server/index.ts +55 -0
  140. package/src/beacon/server/lightclient.ts +7 -0
  141. package/src/beacon/server/lodestar.ts +7 -0
  142. package/src/beacon/server/node.ts +7 -0
  143. package/src/beacon/server/proof.ts +7 -0
  144. package/src/beacon/server/validator.ts +7 -0
  145. package/src/builder/client.ts +9 -0
  146. package/src/builder/index.ts +26 -0
  147. package/src/builder/routes.ts +227 -0
  148. package/src/builder/server/index.ts +19 -0
  149. package/src/index.ts +19 -0
  150. package/src/keymanager/client.ts +9 -0
  151. package/src/keymanager/index.ts +39 -0
  152. package/src/keymanager/routes.ts +699 -0
  153. package/src/keymanager/server/index.ts +19 -0
  154. package/src/server/index.ts +2 -0
  155. package/src/utils/client/error.ts +10 -0
  156. package/src/utils/client/eventSource.ts +7 -0
  157. package/src/utils/client/format.ts +22 -0
  158. package/src/utils/client/httpClient.ts +444 -0
  159. package/src/utils/client/index.ts +6 -0
  160. package/src/utils/client/method.ts +50 -0
  161. package/src/utils/client/metrics.ts +9 -0
  162. package/src/utils/client/request.ts +113 -0
  163. package/src/utils/client/response.ts +205 -0
  164. package/src/utils/codecs.ts +143 -0
  165. package/src/utils/fork.ts +44 -0
  166. package/src/utils/headers.ts +173 -0
  167. package/src/utils/httpStatusCode.ts +392 -0
  168. package/src/utils/index.ts +3 -0
  169. package/src/utils/metadata.ts +170 -0
  170. package/src/utils/schema.ts +141 -0
  171. package/src/utils/serdes.ts +120 -0
  172. package/src/utils/server/error.ts +9 -0
  173. package/src/utils/server/handler.ts +149 -0
  174. package/src/utils/server/index.ts +5 -0
  175. package/src/utils/server/method.ts +38 -0
  176. package/src/utils/server/parser.ts +15 -0
  177. package/src/utils/server/route.ts +45 -0
  178. package/src/utils/types.ts +161 -0
  179. package/src/utils/urlFormat.ts +112 -0
  180. package/src/utils/wireFormat.ts +24 -0
@@ -0,0 +1,503 @@
1
+ import {ValueOf} from "@chainsafe/ssz";
2
+ import {ChainForkConfig} from "@lodestar/config";
3
+ import {ForkPostElectra, ForkPreElectra, isForkPostElectra} from "@lodestar/params";
4
+ import {
5
+ AttesterSlashing,
6
+ CommitteeIndex,
7
+ SingleAttestation,
8
+ Slot,
9
+ capella,
10
+ electra,
11
+ phase0,
12
+ ssz,
13
+ } from "@lodestar/types";
14
+ import {
15
+ ArrayOf,
16
+ EmptyArgs,
17
+ EmptyMeta,
18
+ EmptyMetaCodec,
19
+ EmptyRequest,
20
+ EmptyRequestCodec,
21
+ EmptyResponseCodec,
22
+ EmptyResponseData,
23
+ WithVersion,
24
+ } from "../../../utils/codecs.js";
25
+ import {toForkName} from "../../../utils/fork.js";
26
+ import {fromHeaders} from "../../../utils/headers.js";
27
+ import {Endpoint, RouteDefinitions, Schema} from "../../../utils/index.js";
28
+ import {MetaHeader, VersionCodec, VersionMeta} from "../../../utils/metadata.js";
29
+
30
+ const SingleAttestationListTypePhase0 = ArrayOf(ssz.phase0.Attestation);
31
+ const SingleAttestationListTypeElectra = ArrayOf(ssz.electra.SingleAttestation);
32
+ const AttestationListTypePhase0 = ArrayOf(ssz.phase0.Attestation);
33
+ const AttestationListTypeElectra = ArrayOf(ssz.electra.Attestation);
34
+ const AttesterSlashingListTypePhase0 = ArrayOf(ssz.phase0.AttesterSlashing);
35
+ const AttesterSlashingListTypeElectra = ArrayOf(ssz.electra.AttesterSlashing);
36
+ const ProposerSlashingListType = ArrayOf(ssz.phase0.ProposerSlashing);
37
+ const SignedVoluntaryExitListType = ArrayOf(ssz.phase0.SignedVoluntaryExit);
38
+ const SignedBLSToExecutionChangeListType = ArrayOf(ssz.capella.SignedBLSToExecutionChange);
39
+ const SyncCommitteeMessageListType = ArrayOf(ssz.altair.SyncCommitteeMessage);
40
+
41
+ type AttestationListPhase0 = ValueOf<typeof AttestationListTypePhase0>;
42
+ type AttestationListElectra = ValueOf<typeof AttestationListTypeElectra>;
43
+ type AttestationList = AttestationListPhase0 | AttestationListElectra;
44
+
45
+ type AttesterSlashingListPhase0 = ValueOf<typeof AttesterSlashingListTypePhase0>;
46
+ type AttesterSlashingListElectra = ValueOf<typeof AttesterSlashingListTypeElectra>;
47
+ type AttesterSlashingList = AttesterSlashingListPhase0 | AttesterSlashingListElectra;
48
+
49
+ type ProposerSlashingList = ValueOf<typeof ProposerSlashingListType>;
50
+ type SignedVoluntaryExitList = ValueOf<typeof SignedVoluntaryExitListType>;
51
+ type SignedBLSToExecutionChangeList = ValueOf<typeof SignedBLSToExecutionChangeListType>;
52
+ type SyncCommitteeMessageList = ValueOf<typeof SyncCommitteeMessageListType>;
53
+
54
+ export type Endpoints = {
55
+ /**
56
+ * Get Attestations from operations pool
57
+ * Retrieves attestations known by the node but not necessarily incorporated into any block
58
+ */
59
+ getPoolAttestations: Endpoint<
60
+ "GET",
61
+ {slot?: Slot; committeeIndex?: CommitteeIndex},
62
+ {query: {slot?: number; committee_index?: number}},
63
+ AttestationListPhase0,
64
+ EmptyMeta
65
+ >;
66
+
67
+ /**
68
+ * Get Attestations from operations pool
69
+ * Retrieves attestations known by the node but not necessarily incorporated into any block
70
+ */
71
+ getPoolAttestationsV2: Endpoint<
72
+ "GET",
73
+ {slot?: Slot; committeeIndex?: CommitteeIndex},
74
+ {query: {slot?: number; committee_index?: number}},
75
+ AttestationList,
76
+ VersionMeta
77
+ >;
78
+
79
+ /**
80
+ * Get AttesterSlashings from operations pool
81
+ * Retrieves attester slashings known by the node but not necessarily incorporated into any block
82
+ */
83
+ getPoolAttesterSlashings: Endpoint<
84
+ // ⏎
85
+ "GET",
86
+ EmptyArgs,
87
+ EmptyRequest,
88
+ AttesterSlashingListPhase0,
89
+ EmptyMeta
90
+ >;
91
+
92
+ /**
93
+ * Get AttesterSlashings from operations pool
94
+ * Retrieves attester slashings known by the node but not necessarily incorporated into any block
95
+ */
96
+ getPoolAttesterSlashingsV2: Endpoint<
97
+ // ⏎
98
+ "GET",
99
+ EmptyArgs,
100
+ EmptyRequest,
101
+ AttesterSlashingList,
102
+ VersionMeta
103
+ >;
104
+
105
+ /**
106
+ * Get ProposerSlashings from operations pool
107
+ * Retrieves proposer slashings known by the node but not necessarily incorporated into any block
108
+ */
109
+ getPoolProposerSlashings: Endpoint<
110
+ // ⏎
111
+ "GET",
112
+ EmptyArgs,
113
+ EmptyRequest,
114
+ ProposerSlashingList,
115
+ EmptyMeta
116
+ >;
117
+
118
+ /**
119
+ * Get SignedVoluntaryExit from operations pool
120
+ * Retrieves voluntary exits known by the node but not necessarily incorporated into any block
121
+ */
122
+ getPoolVoluntaryExits: Endpoint<
123
+ // ⏎
124
+ "GET",
125
+ EmptyArgs,
126
+ EmptyRequest,
127
+ SignedVoluntaryExitList,
128
+ EmptyMeta
129
+ >;
130
+
131
+ /**
132
+ * Get SignedBLSToExecutionChange from operations pool
133
+ * Retrieves BLSToExecutionChange known by the node but not necessarily incorporated into any block
134
+ */
135
+ getPoolBLSToExecutionChanges: Endpoint<
136
+ // ⏎
137
+ "GET",
138
+ EmptyArgs,
139
+ EmptyRequest,
140
+ SignedBLSToExecutionChangeList,
141
+ EmptyMeta
142
+ >;
143
+
144
+ /**
145
+ * Submit Attestation objects to node
146
+ * Submits Attestation objects to the node. Each attestation in the request body is processed individually.
147
+ *
148
+ * If an attestation is validated successfully the node MUST publish that attestation on the appropriate subnet.
149
+ *
150
+ * If one or more attestations fail validation the node MUST return a 400 error with details of which attestations have failed, and why.
151
+ */
152
+ submitPoolAttestations: Endpoint<
153
+ "POST",
154
+ {signedAttestations: SingleAttestation<ForkPreElectra>[]},
155
+ {body: unknown},
156
+ EmptyResponseData,
157
+ EmptyMeta
158
+ >;
159
+
160
+ /**
161
+ * Submit Attestation objects to node
162
+ * Submits Attestation objects to the node. Each attestation in the request body is processed individually.
163
+ *
164
+ * If an attestation is validated successfully the node MUST publish that attestation on the appropriate subnet.
165
+ *
166
+ * If one or more attestations fail validation the node MUST return a 400 error with details of which attestations have failed, and why.
167
+ */
168
+ submitPoolAttestationsV2: Endpoint<
169
+ "POST",
170
+ {signedAttestations: SingleAttestation[]},
171
+ {body: unknown; headers: {[MetaHeader.Version]: string}},
172
+ EmptyResponseData,
173
+ EmptyMeta
174
+ >;
175
+
176
+ /**
177
+ * Submit AttesterSlashing object to node's pool
178
+ * Submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.
179
+ */
180
+ submitPoolAttesterSlashings: Endpoint<
181
+ "POST",
182
+ {attesterSlashing: phase0.AttesterSlashing},
183
+ {body: unknown},
184
+ EmptyResponseData,
185
+ EmptyMeta
186
+ >;
187
+
188
+ /**
189
+ * Submit AttesterSlashing object to node's pool
190
+ * Submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.
191
+ */
192
+ submitPoolAttesterSlashingsV2: Endpoint<
193
+ "POST",
194
+ {attesterSlashing: AttesterSlashing},
195
+ {body: unknown; headers: {[MetaHeader.Version]: string}},
196
+ EmptyResponseData,
197
+ EmptyMeta
198
+ >;
199
+
200
+ /**
201
+ * Submit ProposerSlashing object to node's pool
202
+ * Submits ProposerSlashing object to node's pool and if passes validation node MUST broadcast it to network.
203
+ */
204
+ submitPoolProposerSlashings: Endpoint<
205
+ "POST",
206
+ {proposerSlashing: phase0.ProposerSlashing},
207
+ {body: unknown},
208
+ EmptyResponseData,
209
+ EmptyMeta
210
+ >;
211
+
212
+ /**
213
+ * Submit SignedVoluntaryExit object to node's pool
214
+ * Submits SignedVoluntaryExit object to node's pool and if passes validation node MUST broadcast it to network.
215
+ */
216
+ submitPoolVoluntaryExit: Endpoint<
217
+ "POST",
218
+ {signedVoluntaryExit: phase0.SignedVoluntaryExit},
219
+ {body: unknown},
220
+ EmptyResponseData,
221
+ EmptyMeta
222
+ >;
223
+
224
+ /**
225
+ * Submit SignedBLSToExecutionChange objects to node's pool
226
+ * Submits SignedBLSToExecutionChange objects to node's pool and if passes validation node MUST broadcast it to network.
227
+ */
228
+ submitPoolBLSToExecutionChange: Endpoint<
229
+ "POST",
230
+ {blsToExecutionChanges: capella.SignedBLSToExecutionChange[]},
231
+ {body: unknown},
232
+ EmptyResponseData,
233
+ EmptyMeta
234
+ >;
235
+
236
+ /**
237
+ * Submit SyncCommitteeMessage objects to node's pool
238
+ * Submits SyncCommitteeMessage objects to node's pool and if passes validation node MUST broadcast it to network.
239
+ */
240
+ submitPoolSyncCommitteeSignatures: Endpoint<
241
+ "POST",
242
+ {signatures: SyncCommitteeMessageList},
243
+ {body: unknown},
244
+ EmptyResponseData,
245
+ EmptyMeta
246
+ >;
247
+ };
248
+
249
+ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoints> {
250
+ return {
251
+ getPoolAttestations: {
252
+ url: "/eth/v1/beacon/pool/attestations",
253
+ method: "GET",
254
+ req: {
255
+ writeReq: ({slot, committeeIndex}) => ({query: {slot, committee_index: committeeIndex}}),
256
+ parseReq: ({query}) => ({slot: query.slot, committeeIndex: query.committee_index}),
257
+ schema: {query: {slot: Schema.Uint, committee_index: Schema.Uint}},
258
+ },
259
+ resp: {
260
+ data: AttestationListTypePhase0,
261
+ meta: EmptyMetaCodec,
262
+ },
263
+ },
264
+ getPoolAttestationsV2: {
265
+ url: "/eth/v2/beacon/pool/attestations",
266
+ method: "GET",
267
+ req: {
268
+ writeReq: ({slot, committeeIndex}) => ({query: {slot, committee_index: committeeIndex}}),
269
+ parseReq: ({query}) => ({slot: query.slot, committeeIndex: query.committee_index}),
270
+ schema: {query: {slot: Schema.Uint, committee_index: Schema.Uint}},
271
+ },
272
+ resp: {
273
+ data: WithVersion((fork) => (isForkPostElectra(fork) ? AttestationListTypeElectra : AttestationListTypePhase0)),
274
+ meta: VersionCodec,
275
+ },
276
+ },
277
+ getPoolAttesterSlashings: {
278
+ url: "/eth/v1/beacon/pool/attester_slashings",
279
+ method: "GET",
280
+ req: EmptyRequestCodec,
281
+ resp: {
282
+ data: AttesterSlashingListTypePhase0,
283
+ meta: EmptyMetaCodec,
284
+ },
285
+ },
286
+ getPoolAttesterSlashingsV2: {
287
+ url: "/eth/v2/beacon/pool/attester_slashings",
288
+ method: "GET",
289
+ req: EmptyRequestCodec,
290
+ resp: {
291
+ data: WithVersion((fork) =>
292
+ isForkPostElectra(fork) ? AttesterSlashingListTypeElectra : AttesterSlashingListTypePhase0
293
+ ),
294
+ meta: VersionCodec,
295
+ },
296
+ },
297
+ getPoolProposerSlashings: {
298
+ url: "/eth/v1/beacon/pool/proposer_slashings",
299
+ method: "GET",
300
+ req: EmptyRequestCodec,
301
+ resp: {
302
+ data: ProposerSlashingListType,
303
+ meta: EmptyMetaCodec,
304
+ },
305
+ },
306
+ getPoolVoluntaryExits: {
307
+ url: "/eth/v1/beacon/pool/voluntary_exits",
308
+ method: "GET",
309
+ req: EmptyRequestCodec,
310
+ resp: {
311
+ data: SignedVoluntaryExitListType,
312
+ meta: EmptyMetaCodec,
313
+ },
314
+ },
315
+ getPoolBLSToExecutionChanges: {
316
+ url: "/eth/v1/beacon/pool/bls_to_execution_changes",
317
+ method: "GET",
318
+ req: EmptyRequestCodec,
319
+ resp: {
320
+ data: SignedBLSToExecutionChangeListType,
321
+ meta: EmptyMetaCodec,
322
+ },
323
+ },
324
+ submitPoolAttestations: {
325
+ url: "/eth/v1/beacon/pool/attestations",
326
+ method: "POST",
327
+ req: {
328
+ writeReqJson: ({signedAttestations}) => ({body: SingleAttestationListTypePhase0.toJson(signedAttestations)}),
329
+ parseReqJson: ({body}) => ({signedAttestations: SingleAttestationListTypePhase0.fromJson(body)}),
330
+ writeReqSsz: ({signedAttestations}) => ({body: SingleAttestationListTypePhase0.serialize(signedAttestations)}),
331
+ parseReqSsz: ({body}) => ({signedAttestations: SingleAttestationListTypePhase0.deserialize(body)}),
332
+ schema: {
333
+ body: Schema.ObjectArray,
334
+ },
335
+ },
336
+ resp: EmptyResponseCodec,
337
+ },
338
+ submitPoolAttestationsV2: {
339
+ url: "/eth/v2/beacon/pool/attestations",
340
+ method: "POST",
341
+ req: {
342
+ writeReqJson: ({signedAttestations}) => {
343
+ const fork = config.getForkName(signedAttestations[0]?.data.slot ?? 0);
344
+ return {
345
+ body: isForkPostElectra(fork)
346
+ ? SingleAttestationListTypeElectra.toJson(signedAttestations as SingleAttestation<ForkPostElectra>[])
347
+ : SingleAttestationListTypePhase0.toJson(signedAttestations as SingleAttestation<ForkPreElectra>[]),
348
+ headers: {[MetaHeader.Version]: fork},
349
+ };
350
+ },
351
+ parseReqJson: ({body, headers}) => {
352
+ const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
353
+ return {
354
+ signedAttestations: isForkPostElectra(fork)
355
+ ? SingleAttestationListTypeElectra.fromJson(body)
356
+ : SingleAttestationListTypePhase0.fromJson(body),
357
+ };
358
+ },
359
+ writeReqSsz: ({signedAttestations}) => {
360
+ const fork = config.getForkName(signedAttestations[0]?.data.slot ?? 0);
361
+ return {
362
+ body: isForkPostElectra(fork)
363
+ ? SingleAttestationListTypeElectra.serialize(signedAttestations as SingleAttestation<ForkPostElectra>[])
364
+ : SingleAttestationListTypePhase0.serialize(signedAttestations as SingleAttestation<ForkPreElectra>[]),
365
+ headers: {[MetaHeader.Version]: fork},
366
+ };
367
+ },
368
+ parseReqSsz: ({body, headers}) => {
369
+ const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
370
+ return {
371
+ signedAttestations: isForkPostElectra(fork)
372
+ ? SingleAttestationListTypeElectra.deserialize(body)
373
+ : SingleAttestationListTypePhase0.deserialize(body),
374
+ };
375
+ },
376
+ schema: {
377
+ body: Schema.ObjectArray,
378
+ headers: {[MetaHeader.Version]: Schema.String},
379
+ },
380
+ },
381
+ resp: EmptyResponseCodec,
382
+ },
383
+ submitPoolAttesterSlashings: {
384
+ url: "/eth/v1/beacon/pool/attester_slashings",
385
+ method: "POST",
386
+ req: {
387
+ writeReqJson: ({attesterSlashing}) => ({body: ssz.phase0.AttesterSlashing.toJson(attesterSlashing)}),
388
+ parseReqJson: ({body}) => ({attesterSlashing: ssz.phase0.AttesterSlashing.fromJson(body)}),
389
+ writeReqSsz: ({attesterSlashing}) => ({body: ssz.phase0.AttesterSlashing.serialize(attesterSlashing)}),
390
+ parseReqSsz: ({body}) => ({attesterSlashing: ssz.phase0.AttesterSlashing.deserialize(body)}),
391
+ schema: {
392
+ body: Schema.Object,
393
+ },
394
+ },
395
+ resp: EmptyResponseCodec,
396
+ },
397
+ submitPoolAttesterSlashingsV2: {
398
+ url: "/eth/v2/beacon/pool/attester_slashings",
399
+ method: "POST",
400
+ req: {
401
+ writeReqJson: ({attesterSlashing}) => {
402
+ const fork = config.getForkName(Number(attesterSlashing.attestation1.data.slot));
403
+ return {
404
+ body: isForkPostElectra(fork)
405
+ ? ssz.electra.AttesterSlashing.toJson(attesterSlashing)
406
+ : ssz.phase0.AttesterSlashing.toJson(attesterSlashing),
407
+ headers: {[MetaHeader.Version]: fork},
408
+ };
409
+ },
410
+ parseReqJson: ({body, headers}) => {
411
+ const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
412
+ return {
413
+ attesterSlashing: isForkPostElectra(fork)
414
+ ? ssz.electra.AttesterSlashing.fromJson(body)
415
+ : ssz.phase0.AttesterSlashing.fromJson(body),
416
+ };
417
+ },
418
+ writeReqSsz: ({attesterSlashing}) => {
419
+ const fork = config.getForkName(Number(attesterSlashing.attestation1.data.slot));
420
+ return {
421
+ body: isForkPostElectra(fork)
422
+ ? ssz.electra.AttesterSlashing.serialize(attesterSlashing as electra.AttesterSlashing)
423
+ : ssz.phase0.AttesterSlashing.serialize(attesterSlashing as phase0.AttesterSlashing),
424
+ headers: {[MetaHeader.Version]: fork},
425
+ };
426
+ },
427
+ parseReqSsz: ({body, headers}) => {
428
+ const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
429
+ return {
430
+ attesterSlashing: isForkPostElectra(fork)
431
+ ? ssz.electra.AttesterSlashing.deserialize(body)
432
+ : ssz.phase0.AttesterSlashing.deserialize(body),
433
+ };
434
+ },
435
+ schema: {
436
+ body: Schema.Object,
437
+ headers: {[MetaHeader.Version]: Schema.String},
438
+ },
439
+ },
440
+ resp: EmptyResponseCodec,
441
+ },
442
+ submitPoolProposerSlashings: {
443
+ url: "/eth/v1/beacon/pool/proposer_slashings",
444
+ method: "POST",
445
+ req: {
446
+ writeReqJson: ({proposerSlashing}) => ({body: ssz.phase0.ProposerSlashing.toJson(proposerSlashing)}),
447
+ parseReqJson: ({body}) => ({proposerSlashing: ssz.phase0.ProposerSlashing.fromJson(body)}),
448
+ writeReqSsz: ({proposerSlashing}) => ({body: ssz.phase0.ProposerSlashing.serialize(proposerSlashing)}),
449
+ parseReqSsz: ({body}) => ({proposerSlashing: ssz.phase0.ProposerSlashing.deserialize(body)}),
450
+ schema: {
451
+ body: Schema.Object,
452
+ },
453
+ },
454
+ resp: EmptyResponseCodec,
455
+ },
456
+ submitPoolVoluntaryExit: {
457
+ url: "/eth/v1/beacon/pool/voluntary_exits",
458
+ method: "POST",
459
+ req: {
460
+ writeReqJson: ({signedVoluntaryExit}) => ({body: ssz.phase0.SignedVoluntaryExit.toJson(signedVoluntaryExit)}),
461
+ parseReqJson: ({body}) => ({signedVoluntaryExit: ssz.phase0.SignedVoluntaryExit.fromJson(body)}),
462
+ writeReqSsz: ({signedVoluntaryExit}) => ({body: ssz.phase0.SignedVoluntaryExit.serialize(signedVoluntaryExit)}),
463
+ parseReqSsz: ({body}) => ({signedVoluntaryExit: ssz.phase0.SignedVoluntaryExit.deserialize(body)}),
464
+ schema: {
465
+ body: Schema.Object,
466
+ },
467
+ },
468
+ resp: EmptyResponseCodec,
469
+ },
470
+ submitPoolBLSToExecutionChange: {
471
+ url: "/eth/v1/beacon/pool/bls_to_execution_changes",
472
+ method: "POST",
473
+ req: {
474
+ writeReqJson: ({blsToExecutionChanges}) => ({
475
+ body: SignedBLSToExecutionChangeListType.toJson(blsToExecutionChanges),
476
+ }),
477
+ parseReqJson: ({body}) => ({blsToExecutionChanges: SignedBLSToExecutionChangeListType.fromJson(body)}),
478
+ writeReqSsz: ({blsToExecutionChanges}) => ({
479
+ body: SignedBLSToExecutionChangeListType.serialize(blsToExecutionChanges),
480
+ }),
481
+ parseReqSsz: ({body}) => ({blsToExecutionChanges: SignedBLSToExecutionChangeListType.deserialize(body)}),
482
+ schema: {
483
+ body: Schema.ObjectArray,
484
+ },
485
+ },
486
+ resp: EmptyResponseCodec,
487
+ },
488
+ submitPoolSyncCommitteeSignatures: {
489
+ url: "/eth/v1/beacon/pool/sync_committees",
490
+ method: "POST",
491
+ req: {
492
+ writeReqJson: ({signatures}) => ({body: SyncCommitteeMessageListType.toJson(signatures)}),
493
+ parseReqJson: ({body}) => ({signatures: SyncCommitteeMessageListType.fromJson(body)}),
494
+ writeReqSsz: ({signatures}) => ({body: SyncCommitteeMessageListType.serialize(signatures)}),
495
+ parseReqSsz: ({body}) => ({signatures: SyncCommitteeMessageListType.deserialize(body)}),
496
+ schema: {
497
+ body: Schema.ObjectArray,
498
+ },
499
+ },
500
+ resp: EmptyResponseCodec,
501
+ },
502
+ };
503
+ }