@lodestar/api 1.20.0-dev.14855ea72f → 1.20.0-dev.225e67a1e5

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 (228) hide show
  1. package/README.md +2 -2
  2. package/lib/beacon/client/beacon.d.ts +4 -3
  3. package/lib/beacon/client/beacon.js +3 -36
  4. package/lib/beacon/client/beacon.js.map +1 -1
  5. package/lib/beacon/client/config.d.ts +4 -3
  6. package/lib/beacon/client/config.js +3 -6
  7. package/lib/beacon/client/config.js.map +1 -1
  8. package/lib/beacon/client/debug.d.ts +4 -3
  9. package/lib/beacon/client/debug.js +4 -45
  10. package/lib/beacon/client/debug.js.map +1 -1
  11. package/lib/beacon/client/events.d.ts +5 -2
  12. package/lib/beacon/client/events.js +32 -35
  13. package/lib/beacon/client/events.js.map +1 -1
  14. package/lib/beacon/client/index.d.ts +6 -3
  15. package/lib/beacon/client/index.js +2 -2
  16. package/lib/beacon/client/index.js.map +1 -1
  17. package/lib/beacon/client/lightclient.d.ts +4 -3
  18. package/lib/beacon/client/lightclient.js +4 -7
  19. package/lib/beacon/client/lightclient.js.map +1 -1
  20. package/lib/beacon/client/lodestar.d.ts +4 -3
  21. package/lib/beacon/client/lodestar.js +4 -7
  22. package/lib/beacon/client/lodestar.js.map +1 -1
  23. package/lib/beacon/client/node.d.ts +4 -3
  24. package/lib/beacon/client/node.js +4 -7
  25. package/lib/beacon/client/node.js.map +1 -1
  26. package/lib/beacon/client/proof.d.ts +5 -4
  27. package/lib/beacon/client/proof.js +5 -61
  28. package/lib/beacon/client/proof.js.map +1 -1
  29. package/lib/beacon/client/validator.d.ts +4 -3
  30. package/lib/beacon/client/validator.js +4 -7
  31. package/lib/beacon/client/validator.js.map +1 -1
  32. package/lib/beacon/index.d.ts +5 -5
  33. package/lib/beacon/index.js.map +1 -1
  34. package/lib/beacon/routes/beacon/block.d.ts +282 -164
  35. package/lib/beacon/routes/beacon/block.js +324 -116
  36. package/lib/beacon/routes/beacon/block.js.map +1 -1
  37. package/lib/beacon/routes/beacon/index.d.ts +6 -588
  38. package/lib/beacon/routes/beacon/index.js +16 -26
  39. package/lib/beacon/routes/beacon/index.js.map +1 -1
  40. package/lib/beacon/routes/beacon/pool.d.ts +155 -117
  41. package/lib/beacon/routes/beacon/pool.js +146 -42
  42. package/lib/beacon/routes/beacon/pool.js.map +1 -1
  43. package/lib/beacon/routes/beacon/rewards.d.ts +113 -101
  44. package/lib/beacon/routes/beacon/rewards.js +98 -63
  45. package/lib/beacon/routes/beacon/rewards.js.map +1 -1
  46. package/lib/beacon/routes/beacon/state.d.ts +172 -226
  47. package/lib/beacon/routes/beacon/state.js +204 -126
  48. package/lib/beacon/routes/beacon/state.js.map +1 -1
  49. package/lib/beacon/routes/config.d.ts +21 -36
  50. package/lib/beacon/routes/config.js +45 -24
  51. package/lib/beacon/routes/config.js.map +1 -1
  52. package/lib/beacon/routes/debug.d.ts +32 -95
  53. package/lib/beacon/routes/debug.js +87 -45
  54. package/lib/beacon/routes/debug.js.map +1 -1
  55. package/lib/beacon/routes/events.d.ts +20 -16
  56. package/lib/beacon/routes/events.js +39 -17
  57. package/lib/beacon/routes/events.js.map +1 -1
  58. package/lib/beacon/routes/index.d.ts +19 -19
  59. package/lib/beacon/routes/index.js +1 -0
  60. package/lib/beacon/routes/index.js.map +1 -1
  61. package/lib/beacon/routes/lightclient.d.ts +33 -55
  62. package/lib/beacon/routes/lightclient.js +107 -47
  63. package/lib/beacon/routes/lightclient.js.map +1 -1
  64. package/lib/beacon/routes/lodestar.d.ts +74 -148
  65. package/lib/beacon/routes/lodestar.js +126 -77
  66. package/lib/beacon/routes/lodestar.js.map +1 -1
  67. package/lib/beacon/routes/node.d.ts +48 -82
  68. package/lib/beacon/routes/node.js +90 -57
  69. package/lib/beacon/routes/node.js.map +1 -1
  70. package/lib/beacon/routes/proof.d.ts +25 -31
  71. package/lib/beacon/routes/proof.js +44 -24
  72. package/lib/beacon/routes/proof.js.map +1 -1
  73. package/lib/beacon/routes/validator.d.ts +547 -320
  74. package/lib/beacon/routes/validator.js +494 -213
  75. package/lib/beacon/routes/validator.js.map +1 -1
  76. package/lib/beacon/server/beacon.d.ts +3 -4
  77. package/lib/beacon/server/beacon.js +4 -57
  78. package/lib/beacon/server/beacon.js.map +1 -1
  79. package/lib/beacon/server/config.d.ts +3 -4
  80. package/lib/beacon/server/config.js +4 -5
  81. package/lib/beacon/server/config.js.map +1 -1
  82. package/lib/beacon/server/debug.d.ts +3 -4
  83. package/lib/beacon/server/debug.js +4 -54
  84. package/lib/beacon/server/debug.js.map +1 -1
  85. package/lib/beacon/server/events.d.ts +4 -4
  86. package/lib/beacon/server/events.js +17 -23
  87. package/lib/beacon/server/events.js.map +1 -1
  88. package/lib/beacon/server/index.d.ts +7 -8
  89. package/lib/beacon/server/index.js +13 -14
  90. package/lib/beacon/server/index.js.map +1 -1
  91. package/lib/beacon/server/lightclient.d.ts +3 -4
  92. package/lib/beacon/server/lightclient.js +4 -5
  93. package/lib/beacon/server/lightclient.js.map +1 -1
  94. package/lib/beacon/server/lodestar.d.ts +3 -4
  95. package/lib/beacon/server/lodestar.js +4 -5
  96. package/lib/beacon/server/lodestar.js.map +1 -1
  97. package/lib/beacon/server/node.d.ts +3 -4
  98. package/lib/beacon/server/node.js +4 -18
  99. package/lib/beacon/server/node.js.map +1 -1
  100. package/lib/beacon/server/proof.d.ts +3 -4
  101. package/lib/beacon/server/proof.js +4 -36
  102. package/lib/beacon/server/proof.js.map +1 -1
  103. package/lib/beacon/server/validator.d.ts +3 -4
  104. package/lib/beacon/server/validator.js +4 -21
  105. package/lib/beacon/server/validator.js.map +1 -1
  106. package/lib/builder/client.d.ts +4 -6
  107. package/lib/builder/client.js +3 -9
  108. package/lib/builder/client.js.map +1 -1
  109. package/lib/builder/index.d.ts +8 -5
  110. package/lib/builder/index.js +4 -1
  111. package/lib/builder/index.js.map +1 -1
  112. package/lib/builder/routes.d.ts +24 -38
  113. package/lib/builder/routes.js +77 -33
  114. package/lib/builder/routes.js.map +1 -1
  115. package/lib/builder/server/index.d.ts +6 -6
  116. package/lib/builder/server/index.js +7 -8
  117. package/lib/builder/server/index.js.map +1 -1
  118. package/lib/index.d.ts +9 -6
  119. package/lib/index.js +5 -4
  120. package/lib/index.js.map +1 -1
  121. package/lib/keymanager/client.d.ts +4 -3
  122. package/lib/keymanager/client.js +4 -7
  123. package/lib/keymanager/client.js.map +1 -1
  124. package/lib/keymanager/index.d.ts +5 -4
  125. package/lib/keymanager/index.js +1 -1
  126. package/lib/keymanager/index.js.map +1 -1
  127. package/lib/keymanager/routes.d.ts +155 -177
  128. package/lib/keymanager/routes.js +236 -123
  129. package/lib/keymanager/routes.js.map +1 -1
  130. package/lib/keymanager/server/index.d.ts +6 -6
  131. package/lib/keymanager/server/index.js +7 -8
  132. package/lib/keymanager/server/index.js.map +1 -1
  133. package/lib/server/index.d.ts +2 -0
  134. package/lib/server/index.js +3 -0
  135. package/lib/server/index.js.map +1 -0
  136. package/lib/utils/client/error.d.ts +6 -0
  137. package/lib/utils/client/error.js +8 -0
  138. package/lib/utils/client/error.js.map +1 -0
  139. package/lib/utils/client/httpClient.d.ts +35 -75
  140. package/lib/utils/client/httpClient.js +201 -153
  141. package/lib/utils/client/httpClient.js.map +1 -1
  142. package/lib/utils/client/index.d.ts +6 -2
  143. package/lib/utils/client/index.js +6 -2
  144. package/lib/utils/client/index.js.map +1 -1
  145. package/lib/utils/client/method.d.ts +11 -0
  146. package/lib/utils/client/method.js +27 -0
  147. package/lib/utils/client/method.js.map +1 -0
  148. package/lib/utils/client/request.d.ts +33 -0
  149. package/lib/utils/client/request.js +66 -0
  150. package/lib/utils/client/request.js.map +1 -0
  151. package/lib/utils/client/response.d.ts +35 -0
  152. package/lib/utils/client/response.js +166 -0
  153. package/lib/utils/client/response.js.map +1 -0
  154. package/lib/utils/codecs.d.ts +28 -0
  155. package/lib/utils/codecs.js +105 -0
  156. package/lib/utils/codecs.js.map +1 -0
  157. package/lib/utils/fork.d.ts +8 -0
  158. package/lib/utils/fork.js +35 -0
  159. package/lib/utils/fork.js.map +1 -0
  160. package/lib/utils/headers.d.ts +37 -0
  161. package/lib/utils/headers.js +134 -0
  162. package/lib/utils/headers.js.map +1 -0
  163. package/lib/utils/httpStatusCode.js.map +1 -0
  164. package/lib/utils/index.d.ts +1 -1
  165. package/lib/utils/index.js +1 -1
  166. package/lib/utils/index.js.map +1 -1
  167. package/lib/utils/metadata.d.ts +88 -0
  168. package/lib/utils/metadata.js +126 -0
  169. package/lib/utils/metadata.js.map +1 -0
  170. package/lib/utils/schema.d.ts +31 -17
  171. package/lib/utils/schema.js +18 -6
  172. package/lib/utils/schema.js.map +1 -1
  173. package/lib/utils/serdes.d.ts +3 -0
  174. package/lib/utils/serdes.js +13 -0
  175. package/lib/utils/serdes.js.map +1 -1
  176. package/lib/utils/server/{errors.d.ts → error.d.ts} +2 -2
  177. package/lib/utils/server/{errors.js → error.js} +1 -1
  178. package/lib/utils/server/error.js.map +1 -0
  179. package/lib/utils/server/handler.d.ts +11 -0
  180. package/lib/utils/server/handler.js +117 -0
  181. package/lib/utils/server/handler.js.map +1 -0
  182. package/lib/utils/server/index.d.ts +5 -4
  183. package/lib/utils/server/index.js +5 -4
  184. package/lib/utils/server/index.js.map +1 -1
  185. package/lib/utils/server/method.d.ts +35 -0
  186. package/lib/utils/server/method.js +2 -0
  187. package/lib/utils/server/method.js.map +1 -0
  188. package/lib/utils/server/parser.d.ts +3 -0
  189. package/lib/utils/server/parser.js +20 -0
  190. package/lib/utils/server/parser.js.map +1 -0
  191. package/lib/utils/server/route.d.ts +20 -0
  192. package/lib/utils/server/route.js +19 -0
  193. package/lib/utils/server/route.js.map +1 -0
  194. package/lib/utils/types.d.ts +116 -104
  195. package/lib/utils/types.js +2 -155
  196. package/lib/utils/types.js.map +1 -1
  197. package/lib/utils/urlFormat.d.ts +2 -2
  198. package/lib/utils/urlFormat.js +3 -3
  199. package/lib/utils/urlFormat.js.map +1 -1
  200. package/lib/utils/wireFormat.d.ts +8 -0
  201. package/lib/utils/wireFormat.js +23 -0
  202. package/lib/utils/wireFormat.js.map +1 -0
  203. package/package.json +9 -6
  204. package/lib/interfaces.d.ts +0 -44
  205. package/lib/interfaces.js +0 -2
  206. package/lib/interfaces.js.map +0 -1
  207. package/lib/utils/acceptHeader.d.ts +0 -9
  208. package/lib/utils/acceptHeader.js +0 -62
  209. package/lib/utils/acceptHeader.js.map +0 -1
  210. package/lib/utils/client/client.d.ts +0 -29
  211. package/lib/utils/client/client.js +0 -88
  212. package/lib/utils/client/client.js.map +0 -1
  213. package/lib/utils/client/httpStatusCode.js.map +0 -1
  214. package/lib/utils/routes.d.ts +0 -6
  215. package/lib/utils/routes.js +0 -31
  216. package/lib/utils/routes.js.map +0 -1
  217. package/lib/utils/server/errors.js.map +0 -1
  218. package/lib/utils/server/genericJsonServer.d.ts +0 -13
  219. package/lib/utils/server/genericJsonServer.js +0 -32
  220. package/lib/utils/server/genericJsonServer.js.map +0 -1
  221. package/lib/utils/server/registerRoute.d.ts +0 -3
  222. package/lib/utils/server/registerRoute.js +0 -13
  223. package/lib/utils/server/registerRoute.js.map +0 -1
  224. package/lib/utils/server/types.d.ts +0 -22
  225. package/lib/utils/server/types.js +0 -2
  226. package/lib/utils/server/types.js.map +0 -1
  227. /package/lib/utils/{client/httpStatusCode.d.ts → httpStatusCode.d.ts} +0 -0
  228. /package/lib/utils/{client/httpStatusCode.js → httpStatusCode.js} +0 -0
@@ -1,10 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  import { ContainerType, fromHexString, toHexString } from "@chainsafe/ssz";
2
- import { ForkName, isForkBlobs, isForkExecution } from "@lodestar/params";
3
- import { ssz, StringType, ProducedBlockSource, } from "@lodestar/types";
4
- import { HttpStatusCode } from "../../utils/client/httpStatusCode.js";
5
- import { ArrayOf, Schema, WithVersion, WithBlockValues, reqOnlyBody, jsonType, ContainerDataExecutionOptimistic, ContainerData, } from "../../utils/index.js";
6
- import { fromU64Str, fromGraffitiHex, toU64Str, toGraffitiHex } from "../../utils/serdes.js";
7
- import { allForksBlockContentsResSerializer } from "../../utils/routes.js";
3
+ import { isForkBlobs } from "@lodestar/params";
4
+ import { ssz, ProducedBlockSource, stringType, } from "@lodestar/types";
5
+ import { Schema } from "../../utils/index.js";
6
+ import { fromGraffitiHex, toBoolean, toGraffitiHex } from "../../utils/serdes.js";
7
+ import { getBlindedForkTypes, toForkName } from "../../utils/fork.js";
8
+ import { ArrayOf, EmptyMetaCodec, EmptyResponseCodec, JsonOnlyReq, WithMeta, WithVersion, } from "../../utils/codecs.js";
9
+ import { ExecutionOptimisticAndDependentRootCodec, ExecutionOptimisticCodec, MetaHeader, VersionCodec, VersionType, } from "../../utils/metadata.js";
10
+ // See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
8
11
  export var BuilderSelection;
9
12
  (function (BuilderSelection) {
10
13
  BuilderSelection["Default"] = "default";
@@ -16,260 +19,538 @@ export var BuilderSelection;
16
19
  /** Only builds execution block*/
17
20
  BuilderSelection["ExecutionOnly"] = "executiononly";
18
21
  })(BuilderSelection || (BuilderSelection = {}));
22
+ export const ProduceBlockV3MetaType = new ContainerType({
23
+ ...VersionType.fields,
24
+ /** Specifies whether the response contains full or blinded block */
25
+ executionPayloadBlinded: ssz.Boolean,
26
+ /** Execution payload value in Wei */
27
+ executionPayloadValue: ssz.UintBn64,
28
+ /** Consensus rewards paid to the proposer for this block, in Wei */
29
+ consensusBlockValue: ssz.UintBn64,
30
+ }, { jsonCase: "eth2" });
31
+ export const BlockContentsType = new ContainerType({
32
+ block: ssz.deneb.BeaconBlock,
33
+ kzgProofs: ssz.deneb.KZGProofs,
34
+ blobs: ssz.deneb.Blobs,
35
+ }, { jsonCase: "eth2" });
36
+ export const AttesterDutyType = new ContainerType({
37
+ /** The validator's public key, uniquely identifying them */
38
+ pubkey: ssz.BLSPubkey,
39
+ /** Index of validator in validator registry */
40
+ validatorIndex: ssz.ValidatorIndex,
41
+ /** Index of the committee */
42
+ committeeIndex: ssz.CommitteeIndex,
43
+ /** Number of validators in committee */
44
+ committeeLength: ssz.UintNum64,
45
+ /** Number of committees at the provided slot */
46
+ committeesAtSlot: ssz.UintNum64,
47
+ /** Index of validator in committee */
48
+ validatorCommitteeIndex: ssz.UintNum64,
49
+ /** The slot at which the validator must attest */
50
+ slot: ssz.Slot,
51
+ }, { jsonCase: "eth2" });
52
+ export const ProposerDutyType = new ContainerType({
53
+ slot: ssz.Slot,
54
+ validatorIndex: ssz.ValidatorIndex,
55
+ pubkey: ssz.BLSPubkey,
56
+ }, { jsonCase: "eth2" });
57
+ /**
58
+ * From https://github.com/ethereum/beacon-APIs/pull/134
59
+ */
60
+ export const SyncDutyType = new ContainerType({
61
+ pubkey: ssz.BLSPubkey,
62
+ /** Index of validator in validator registry. */
63
+ validatorIndex: ssz.ValidatorIndex,
64
+ /** The indices of the validator in the sync committee. */
65
+ validatorSyncCommitteeIndices: ArrayOf(ssz.CommitteeIndex),
66
+ }, { jsonCase: "eth2" });
67
+ export const BeaconCommitteeSubscriptionType = new ContainerType({
68
+ validatorIndex: ssz.ValidatorIndex,
69
+ committeeIndex: ssz.CommitteeIndex,
70
+ committeesAtSlot: ssz.Slot,
71
+ slot: ssz.Slot,
72
+ isAggregator: ssz.Boolean,
73
+ }, { jsonCase: "eth2" });
19
74
  /**
20
- * Define javascript values for each route
75
+ * From https://github.com/ethereum/beacon-APIs/pull/136
21
76
  */
22
- export const routesData = {
23
- getAttesterDuties: { url: "/eth/v1/validator/duties/attester/{epoch}", method: "POST" },
24
- getProposerDuties: { url: "/eth/v1/validator/duties/proposer/{epoch}", method: "GET" },
25
- getSyncCommitteeDuties: { url: "/eth/v1/validator/duties/sync/{epoch}", method: "POST" },
26
- produceBlock: { url: "/eth/v1/validator/blocks/{slot}", method: "GET" },
27
- produceBlockV2: { url: "/eth/v2/validator/blocks/{slot}", method: "GET" },
28
- produceBlockV3: { url: "/eth/v3/validator/blocks/{slot}", method: "GET" },
29
- produceBlindedBlock: { url: "/eth/v1/validator/blinded_blocks/{slot}", method: "GET" },
30
- produceAttestationData: { url: "/eth/v1/validator/attestation_data", method: "GET" },
31
- produceSyncCommitteeContribution: { url: "/eth/v1/validator/sync_committee_contribution", method: "GET" },
32
- getAggregatedAttestation: { url: "/eth/v1/validator/aggregate_attestation", method: "GET" },
33
- publishAggregateAndProofs: { url: "/eth/v1/validator/aggregate_and_proofs", method: "POST" },
34
- publishContributionAndProofs: { url: "/eth/v1/validator/contribution_and_proofs", method: "POST" },
35
- prepareBeaconCommitteeSubnet: { url: "/eth/v1/validator/beacon_committee_subscriptions", method: "POST" },
36
- prepareSyncCommitteeSubnets: { url: "/eth/v1/validator/sync_committee_subscriptions", method: "POST" },
37
- prepareBeaconProposer: { url: "/eth/v1/validator/prepare_beacon_proposer", method: "POST" },
38
- submitBeaconCommitteeSelections: { url: "/eth/v1/validator/beacon_committee_selections", method: "POST" },
39
- submitSyncCommitteeSelections: { url: "/eth/v1/validator/sync_committee_selections", method: "POST" },
40
- getLiveness: { url: "/eth/v1/validator/liveness/{epoch}", method: "POST" },
41
- registerValidator: { url: "/eth/v1/validator/register_validator", method: "POST" },
42
- };
43
- const BeaconCommitteeSelection = new ContainerType({
77
+ export const SyncCommitteeSubscriptionType = new ContainerType({
78
+ validatorIndex: ssz.ValidatorIndex,
79
+ syncCommitteeIndices: ArrayOf(ssz.CommitteeIndex),
80
+ untilEpoch: ssz.Epoch,
81
+ }, { jsonCase: "eth2" });
82
+ export const ProposerPreparationDataType = new ContainerType({
44
83
  validatorIndex: ssz.ValidatorIndex,
84
+ feeRecipient: stringType,
85
+ }, { jsonCase: "eth2" });
86
+ /**
87
+ * From https://github.com/ethereum/beacon-APIs/pull/224
88
+ */
89
+ export const BeaconCommitteeSelectionType = new ContainerType({
90
+ /** Index of the validator */
91
+ validatorIndex: ssz.ValidatorIndex,
92
+ /** The slot at which a validator is assigned to attest */
45
93
  slot: ssz.Slot,
94
+ /** The `slot_signature` calculated by the validator for the upcoming attestation slot */
46
95
  selectionProof: ssz.BLSSignature,
47
96
  }, { jsonCase: "eth2" });
48
- const SyncCommitteeSelection = new ContainerType({
97
+ /**
98
+ * From https://github.com/ethereum/beacon-APIs/pull/224
99
+ */
100
+ export const SyncCommitteeSelectionType = new ContainerType({
101
+ /** Index of the validator */
49
102
  validatorIndex: ssz.ValidatorIndex,
103
+ /** The slot at which validator is assigned to produce a sync committee contribution */
50
104
  slot: ssz.Slot,
105
+ /** SubcommitteeIndex to which the validator is assigned */
51
106
  subcommitteeIndex: ssz.SubcommitteeIndex,
107
+ /** The `slot_signature` calculated by the validator for the upcoming sync committee slot */
52
108
  selectionProof: ssz.BLSSignature,
53
109
  }, { jsonCase: "eth2" });
54
- export function getReqSerializers() {
55
- const BeaconCommitteeSubscription = new ContainerType({
56
- validatorIndex: ssz.ValidatorIndex,
57
- committeeIndex: ssz.CommitteeIndex,
58
- committeesAtSlot: ssz.Slot,
59
- slot: ssz.Slot,
60
- isAggregator: ssz.Boolean,
61
- }, { jsonCase: "eth2" });
62
- const SyncCommitteeSubscription = new ContainerType({
63
- validatorIndex: ssz.ValidatorIndex,
64
- syncCommitteeIndices: ArrayOf(ssz.CommitteeIndex),
65
- untilEpoch: ssz.Epoch,
66
- }, { jsonCase: "eth2" });
67
- const produceBlockV3 = {
68
- writeReq: (slot, randaoReveal, graffiti, skipRandaoVerification, opts) => ({
69
- params: { slot },
70
- query: {
71
- randao_reveal: toHexString(randaoReveal),
72
- graffiti: toGraffitiHex(graffiti),
73
- fee_recipient: opts?.feeRecipient,
74
- ...(skipRandaoVerification && { skip_randao_verification: "" }),
75
- builder_selection: opts?.builderSelection,
76
- builder_boost_factor: opts?.builderBoostFactor?.toString(),
77
- strict_fee_recipient_check: opts?.strictFeeRecipientCheck,
78
- blinded_local: opts?.blindedLocal,
79
- },
80
- }),
81
- parseReq: ({ params, query }) => [
82
- params.slot,
83
- fromHexString(query.randao_reveal),
84
- fromGraffitiHex(query.graffiti),
85
- parseSkipRandaoVerification(query.skip_randao_verification),
86
- {
87
- feeRecipient: query.fee_recipient,
88
- builderSelection: query.builder_selection,
89
- builderBoostFactor: parseBuilderBoostFactor(query.builder_boost_factor),
90
- strictFeeRecipientCheck: query.strict_fee_recipient_check,
91
- blindedLocal: query.blinded_local,
92
- },
93
- ],
94
- schema: {
95
- params: { slot: Schema.UintRequired },
96
- query: {
97
- randao_reveal: Schema.StringRequired,
98
- graffiti: Schema.String,
99
- fee_recipient: Schema.String,
100
- skip_randao_verification: Schema.String,
101
- builder_selection: Schema.String,
102
- builder_boost_factor: Schema.String,
103
- strict_fee_recipient_check: Schema.Boolean,
104
- blinded_local: Schema.Boolean,
105
- },
106
- },
107
- };
110
+ export const LivenessResponseDataType = new ContainerType({
111
+ index: ssz.ValidatorIndex,
112
+ isLive: ssz.Boolean,
113
+ }, { jsonCase: "eth2" });
114
+ export const ValidatorIndicesType = ArrayOf(ssz.ValidatorIndex);
115
+ export const AttesterDutyListType = ArrayOf(AttesterDutyType);
116
+ export const ProposerDutyListType = ArrayOf(ProposerDutyType);
117
+ export const SyncDutyListType = ArrayOf(SyncDutyType);
118
+ export const SignedAggregateAndProofListType = ArrayOf(ssz.phase0.SignedAggregateAndProof);
119
+ export const SignedContributionAndProofListType = ArrayOf(ssz.altair.SignedContributionAndProof);
120
+ export const BeaconCommitteeSubscriptionListType = ArrayOf(BeaconCommitteeSubscriptionType);
121
+ export const SyncCommitteeSubscriptionListType = ArrayOf(SyncCommitteeSubscriptionType);
122
+ export const ProposerPreparationDataListType = ArrayOf(ProposerPreparationDataType);
123
+ export const BeaconCommitteeSelectionListType = ArrayOf(BeaconCommitteeSelectionType);
124
+ export const SyncCommitteeSelectionListType = ArrayOf(SyncCommitteeSelectionType);
125
+ export const LivenessResponseDataListType = ArrayOf(LivenessResponseDataType);
126
+ export const SignedValidatorRegistrationV1ListType = ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1);
127
+ export function getDefinitions(_config) {
108
128
  return {
109
129
  getAttesterDuties: {
110
- writeReq: (epoch, indexes) => ({ params: { epoch }, body: indexes.map((i) => toU64Str(i)) }),
111
- parseReq: ({ params, body }) => [params.epoch, body.map((i) => fromU64Str(i))],
112
- schema: {
113
- params: { epoch: Schema.UintRequired },
114
- body: Schema.StringArray,
130
+ url: "/eth/v1/validator/duties/attester/{epoch}",
131
+ method: "POST",
132
+ req: {
133
+ writeReqJson: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.toJson(indices) }),
134
+ parseReqJson: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.fromJson(body) }),
135
+ writeReqSsz: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.serialize(indices) }),
136
+ parseReqSsz: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.deserialize(body) }),
137
+ schema: {
138
+ params: { epoch: Schema.UintRequired },
139
+ body: Schema.StringArray,
140
+ },
141
+ },
142
+ resp: {
143
+ data: AttesterDutyListType,
144
+ meta: ExecutionOptimisticAndDependentRootCodec,
115
145
  },
116
146
  },
117
147
  getProposerDuties: {
118
- writeReq: (epoch) => ({ params: { epoch } }),
119
- parseReq: ({ params }) => [params.epoch],
120
- schema: {
121
- params: { epoch: Schema.UintRequired },
148
+ url: "/eth/v1/validator/duties/proposer/{epoch}",
149
+ method: "GET",
150
+ req: {
151
+ writeReq: ({ epoch }) => ({ params: { epoch } }),
152
+ parseReq: ({ params }) => ({ epoch: params.epoch }),
153
+ schema: {
154
+ params: { epoch: Schema.UintRequired },
155
+ },
156
+ },
157
+ resp: {
158
+ data: ProposerDutyListType,
159
+ meta: ExecutionOptimisticAndDependentRootCodec,
122
160
  },
123
161
  },
124
162
  getSyncCommitteeDuties: {
125
- writeReq: (epoch, indexes) => ({ params: { epoch }, body: indexes.map((i) => toU64Str(i)) }),
126
- parseReq: ({ params, body }) => [params.epoch, body.map((i) => fromU64Str(i))],
127
- schema: {
128
- params: { epoch: Schema.UintRequired },
129
- body: Schema.StringArray,
163
+ url: "/eth/v1/validator/duties/sync/{epoch}",
164
+ method: "POST",
165
+ req: {
166
+ writeReqJson: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.toJson(indices) }),
167
+ parseReqJson: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.fromJson(body) }),
168
+ writeReqSsz: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.serialize(indices) }),
169
+ parseReqSsz: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.deserialize(body) }),
170
+ schema: {
171
+ params: { epoch: Schema.UintRequired },
172
+ body: Schema.StringArray,
173
+ },
174
+ },
175
+ resp: {
176
+ data: SyncDutyListType,
177
+ meta: ExecutionOptimisticCodec,
178
+ },
179
+ },
180
+ produceBlock: {
181
+ url: "/eth/v1/validator/blocks/{slot}",
182
+ method: "GET",
183
+ req: {
184
+ writeReq: ({ slot, randaoReveal, graffiti }) => ({
185
+ params: { slot },
186
+ query: { randao_reveal: toHexString(randaoReveal), graffiti: toGraffitiHex(graffiti) },
187
+ }),
188
+ parseReq: ({ params, query }) => ({
189
+ slot: params.slot,
190
+ randaoReveal: fromHexString(query.randao_reveal),
191
+ graffiti: fromGraffitiHex(query.graffiti),
192
+ }),
193
+ schema: {
194
+ params: { slot: Schema.UintRequired },
195
+ query: {
196
+ randao_reveal: Schema.StringRequired,
197
+ graffiti: Schema.String,
198
+ },
199
+ },
200
+ },
201
+ resp: {
202
+ data: WithVersion((fork) => ssz[fork].BeaconBlock),
203
+ meta: VersionCodec,
204
+ },
205
+ },
206
+ produceBlockV2: {
207
+ url: "/eth/v2/validator/blocks/{slot}",
208
+ method: "GET",
209
+ req: {
210
+ writeReq: ({ slot, randaoReveal, graffiti, feeRecipient, builderSelection, strictFeeRecipientCheck }) => ({
211
+ params: { slot },
212
+ query: {
213
+ randao_reveal: toHexString(randaoReveal),
214
+ graffiti: toGraffitiHex(graffiti),
215
+ fee_recipient: feeRecipient,
216
+ builder_selection: builderSelection,
217
+ strict_fee_recipient_check: strictFeeRecipientCheck,
218
+ },
219
+ }),
220
+ parseReq: ({ params, query }) => ({
221
+ slot: params.slot,
222
+ randaoReveal: fromHexString(query.randao_reveal),
223
+ graffiti: fromGraffitiHex(query.graffiti),
224
+ feeRecipient: query.fee_recipient,
225
+ builderSelection: query.builder_selection,
226
+ strictFeeRecipientCheck: query.strict_fee_recipient_check,
227
+ }),
228
+ schema: {
229
+ params: { slot: Schema.UintRequired },
230
+ query: {
231
+ randao_reveal: Schema.StringRequired,
232
+ graffiti: Schema.String,
233
+ fee_recipient: Schema.String,
234
+ builder_selection: Schema.String,
235
+ strict_fee_recipient_check: Schema.Boolean,
236
+ },
237
+ },
238
+ },
239
+ resp: {
240
+ data: WithVersion((fork) => (isForkBlobs(fork) ? BlockContentsType : ssz[fork].BeaconBlock)),
241
+ meta: VersionCodec,
242
+ },
243
+ },
244
+ produceBlockV3: {
245
+ url: "/eth/v3/validator/blocks/{slot}",
246
+ method: "GET",
247
+ req: {
248
+ writeReq: ({ slot, randaoReveal, graffiti, skipRandaoVerification, feeRecipient, builderSelection, builderBoostFactor, strictFeeRecipientCheck, blindedLocal, }) => ({
249
+ params: { slot },
250
+ query: {
251
+ randao_reveal: toHexString(randaoReveal),
252
+ graffiti: toGraffitiHex(graffiti),
253
+ skip_randao_verification: writeSkipRandaoVerification(skipRandaoVerification),
254
+ fee_recipient: feeRecipient,
255
+ builder_selection: builderSelection,
256
+ builder_boost_factor: builderBoostFactor?.toString(),
257
+ strict_fee_recipient_check: strictFeeRecipientCheck,
258
+ blinded_local: blindedLocal,
259
+ },
260
+ }),
261
+ parseReq: ({ params, query }) => ({
262
+ slot: params.slot,
263
+ randaoReveal: fromHexString(query.randao_reveal),
264
+ graffiti: fromGraffitiHex(query.graffiti),
265
+ skipRandaoVerification: parseSkipRandaoVerification(query.skip_randao_verification),
266
+ feeRecipient: query.fee_recipient,
267
+ builderSelection: query.builder_selection,
268
+ builderBoostFactor: parseBuilderBoostFactor(query.builder_boost_factor),
269
+ strictFeeRecipientCheck: query.strict_fee_recipient_check,
270
+ blindedLocal: query.blinded_local,
271
+ }),
272
+ schema: {
273
+ params: { slot: Schema.UintRequired },
274
+ query: {
275
+ randao_reveal: Schema.StringRequired,
276
+ graffiti: Schema.String,
277
+ skip_randao_verification: Schema.String,
278
+ fee_recipient: Schema.String,
279
+ builder_selection: Schema.String,
280
+ builder_boost_factor: Schema.String,
281
+ strict_fee_recipient_check: Schema.Boolean,
282
+ blinded_local: Schema.Boolean,
283
+ },
284
+ },
285
+ },
286
+ resp: {
287
+ data: WithMeta(({ version, executionPayloadBlinded }) => (executionPayloadBlinded
288
+ ? getBlindedForkTypes(version).BeaconBlock
289
+ : isForkBlobs(version)
290
+ ? BlockContentsType
291
+ : ssz[version].BeaconBlock)),
292
+ meta: {
293
+ toJson: (meta) => ({
294
+ ...ProduceBlockV3MetaType.toJson(meta),
295
+ execution_payload_source: meta.executionPayloadSource,
296
+ }),
297
+ fromJson: (val) => {
298
+ const { executionPayloadBlinded, ...meta } = ProduceBlockV3MetaType.fromJson(val);
299
+ // Extract source from the data and assign defaults in the spec compliant manner if not present
300
+ const executionPayloadSource = val.execution_payload_source ??
301
+ (executionPayloadBlinded === true ? ProducedBlockSource.builder : ProducedBlockSource.engine);
302
+ return { ...meta, executionPayloadBlinded, executionPayloadSource };
303
+ },
304
+ toHeadersObject: (meta) => ({
305
+ [MetaHeader.Version]: meta.version,
306
+ [MetaHeader.ExecutionPayloadBlinded]: meta.executionPayloadBlinded.toString(),
307
+ [MetaHeader.ExecutionPayloadSource]: meta.executionPayloadSource.toString(),
308
+ [MetaHeader.ExecutionPayloadValue]: meta.executionPayloadValue.toString(),
309
+ [MetaHeader.ConsensusBlockValue]: meta.consensusBlockValue.toString(),
310
+ }),
311
+ fromHeaders: (headers) => {
312
+ const executionPayloadBlinded = toBoolean(headers.getRequired(MetaHeader.ExecutionPayloadBlinded));
313
+ // Extract source from the headers and assign defaults in a spec compliant manner if not present
314
+ const executionPayloadSource = headers.get(MetaHeader.ExecutionPayloadSource) ??
315
+ (executionPayloadBlinded === true ? ProducedBlockSource.builder : ProducedBlockSource.engine);
316
+ return {
317
+ version: toForkName(headers.getRequired(MetaHeader.Version)),
318
+ executionPayloadBlinded,
319
+ executionPayloadSource,
320
+ executionPayloadValue: BigInt(headers.getRequired(MetaHeader.ExecutionPayloadValue)),
321
+ consensusBlockValue: BigInt(headers.getRequired(MetaHeader.ConsensusBlockValue)),
322
+ };
323
+ },
324
+ },
325
+ },
326
+ },
327
+ produceBlindedBlock: {
328
+ url: "/eth/v1/validator/blinded_blocks/{slot}",
329
+ method: "GET",
330
+ req: {
331
+ writeReq: ({ slot, randaoReveal, graffiti }) => ({
332
+ params: { slot },
333
+ query: { randao_reveal: toHexString(randaoReveal), graffiti: toGraffitiHex(graffiti) },
334
+ }),
335
+ parseReq: ({ params, query }) => ({
336
+ slot: params.slot,
337
+ randaoReveal: fromHexString(query.randao_reveal),
338
+ graffiti: fromGraffitiHex(query.graffiti),
339
+ }),
340
+ schema: {
341
+ params: { slot: Schema.UintRequired },
342
+ query: {
343
+ randao_reveal: Schema.StringRequired,
344
+ graffiti: Schema.String,
345
+ },
346
+ },
347
+ },
348
+ resp: {
349
+ data: WithVersion((fork) => getBlindedForkTypes(fork).BeaconBlock),
350
+ meta: VersionCodec,
130
351
  },
131
352
  },
132
- produceBlock: produceBlockV3,
133
- produceBlockV2: produceBlockV3,
134
- produceBlockV3,
135
- produceBlindedBlock: produceBlockV3,
136
353
  produceAttestationData: {
137
- writeReq: (index, slot) => ({ query: { slot, committee_index: index } }),
138
- parseReq: ({ query }) => [query.committee_index, query.slot],
139
- schema: {
140
- query: { slot: Schema.UintRequired, committee_index: Schema.UintRequired },
354
+ url: "/eth/v1/validator/attestation_data",
355
+ method: "GET",
356
+ req: {
357
+ writeReq: ({ committeeIndex, slot }) => ({ query: { slot, committee_index: committeeIndex } }),
358
+ parseReq: ({ query }) => ({ committeeIndex: query.committee_index, slot: query.slot }),
359
+ schema: {
360
+ query: { slot: Schema.UintRequired, committee_index: Schema.UintRequired },
361
+ },
362
+ },
363
+ resp: {
364
+ data: ssz.phase0.AttestationData,
365
+ meta: EmptyMetaCodec,
141
366
  },
142
367
  },
143
368
  produceSyncCommitteeContribution: {
144
- writeReq: (slot, index, root) => ({
145
- query: { slot, subcommittee_index: index, beacon_block_root: toHexString(root) },
146
- }),
147
- parseReq: ({ query }) => [query.slot, query.subcommittee_index, fromHexString(query.beacon_block_root)],
148
- schema: {
149
- query: {
150
- slot: Schema.UintRequired,
151
- subcommittee_index: Schema.UintRequired,
152
- beacon_block_root: Schema.StringRequired,
369
+ url: "/eth/v1/validator/sync_committee_contribution",
370
+ method: "GET",
371
+ req: {
372
+ writeReq: ({ slot, subcommitteeIndex, beaconBlockRoot }) => ({
373
+ query: { slot, subcommittee_index: subcommitteeIndex, beacon_block_root: toHexString(beaconBlockRoot) },
374
+ }),
375
+ parseReq: ({ query }) => ({
376
+ slot: query.slot,
377
+ subcommitteeIndex: query.subcommittee_index,
378
+ beaconBlockRoot: fromHexString(query.beacon_block_root),
379
+ }),
380
+ schema: {
381
+ query: {
382
+ slot: Schema.UintRequired,
383
+ subcommittee_index: Schema.UintRequired,
384
+ beacon_block_root: Schema.StringRequired,
385
+ },
153
386
  },
154
387
  },
388
+ resp: {
389
+ data: ssz.altair.SyncCommitteeContribution,
390
+ meta: EmptyMetaCodec,
391
+ },
155
392
  },
156
393
  getAggregatedAttestation: {
157
- writeReq: (root, slot) => ({ query: { attestation_data_root: toHexString(root), slot } }),
158
- parseReq: ({ query }) => [fromHexString(query.attestation_data_root), query.slot],
159
- schema: {
160
- query: { attestation_data_root: Schema.StringRequired, slot: Schema.UintRequired },
394
+ url: "/eth/v1/validator/aggregate_attestation",
395
+ method: "GET",
396
+ req: {
397
+ writeReq: ({ attestationDataRoot, slot }) => ({
398
+ query: { attestation_data_root: toHexString(attestationDataRoot), slot },
399
+ }),
400
+ parseReq: ({ query }) => ({ attestationDataRoot: fromHexString(query.attestation_data_root), slot: query.slot }),
401
+ schema: {
402
+ query: { attestation_data_root: Schema.StringRequired, slot: Schema.UintRequired },
403
+ },
404
+ },
405
+ resp: {
406
+ data: ssz.phase0.Attestation,
407
+ meta: EmptyMetaCodec,
408
+ },
409
+ },
410
+ publishAggregateAndProofs: {
411
+ url: "/eth/v1/validator/aggregate_and_proofs",
412
+ method: "POST",
413
+ req: {
414
+ writeReqJson: ({ signedAggregateAndProofs }) => ({
415
+ body: SignedAggregateAndProofListType.toJson(signedAggregateAndProofs),
416
+ }),
417
+ parseReqJson: ({ body }) => ({ signedAggregateAndProofs: SignedAggregateAndProofListType.fromJson(body) }),
418
+ writeReqSsz: ({ signedAggregateAndProofs }) => ({
419
+ body: SignedAggregateAndProofListType.serialize(signedAggregateAndProofs),
420
+ }),
421
+ parseReqSsz: ({ body }) => ({ signedAggregateAndProofs: SignedAggregateAndProofListType.deserialize(body) }),
422
+ schema: {
423
+ body: Schema.ObjectArray,
424
+ },
425
+ },
426
+ resp: EmptyResponseCodec,
427
+ },
428
+ publishContributionAndProofs: {
429
+ url: "/eth/v1/validator/contribution_and_proofs",
430
+ method: "POST",
431
+ req: {
432
+ writeReqJson: ({ contributionAndProofs }) => ({
433
+ body: SignedContributionAndProofListType.toJson(contributionAndProofs),
434
+ }),
435
+ parseReqJson: ({ body }) => ({ contributionAndProofs: SignedContributionAndProofListType.fromJson(body) }),
436
+ writeReqSsz: ({ contributionAndProofs }) => ({
437
+ body: SignedContributionAndProofListType.serialize(contributionAndProofs),
438
+ }),
439
+ parseReqSsz: ({ body }) => ({ contributionAndProofs: SignedContributionAndProofListType.deserialize(body) }),
440
+ schema: {
441
+ body: Schema.ObjectArray,
442
+ },
443
+ },
444
+ resp: EmptyResponseCodec,
445
+ },
446
+ prepareBeaconCommitteeSubnet: {
447
+ url: "/eth/v1/validator/beacon_committee_subscriptions",
448
+ method: "POST",
449
+ req: {
450
+ writeReqJson: ({ subscriptions }) => ({ body: BeaconCommitteeSubscriptionListType.toJson(subscriptions) }),
451
+ parseReqJson: ({ body }) => ({ subscriptions: BeaconCommitteeSubscriptionListType.fromJson(body) }),
452
+ writeReqSsz: ({ subscriptions }) => ({ body: BeaconCommitteeSubscriptionListType.serialize(subscriptions) }),
453
+ parseReqSsz: ({ body }) => ({ subscriptions: BeaconCommitteeSubscriptionListType.deserialize(body) }),
454
+ schema: { body: Schema.ObjectArray },
161
455
  },
456
+ resp: EmptyResponseCodec,
457
+ },
458
+ prepareSyncCommitteeSubnets: {
459
+ url: "/eth/v1/validator/sync_committee_subscriptions",
460
+ method: "POST",
461
+ req: {
462
+ writeReqJson: ({ subscriptions }) => ({ body: SyncCommitteeSubscriptionListType.toJson(subscriptions) }),
463
+ parseReqJson: ({ body }) => ({ subscriptions: SyncCommitteeSubscriptionListType.fromJson(body) }),
464
+ writeReqSsz: ({ subscriptions }) => ({ body: SyncCommitteeSubscriptionListType.serialize(subscriptions) }),
465
+ parseReqSsz: ({ body }) => ({ subscriptions: SyncCommitteeSubscriptionListType.deserialize(body) }),
466
+ schema: { body: Schema.ObjectArray },
467
+ },
468
+ resp: EmptyResponseCodec,
162
469
  },
163
- publishAggregateAndProofs: reqOnlyBody(ArrayOf(ssz.phase0.SignedAggregateAndProof), Schema.ObjectArray),
164
- publishContributionAndProofs: reqOnlyBody(ArrayOf(ssz.altair.SignedContributionAndProof), Schema.ObjectArray),
165
- prepareBeaconCommitteeSubnet: reqOnlyBody(ArrayOf(BeaconCommitteeSubscription), Schema.ObjectArray),
166
- prepareSyncCommitteeSubnets: reqOnlyBody(ArrayOf(SyncCommitteeSubscription), Schema.ObjectArray),
167
470
  prepareBeaconProposer: {
168
- writeReq: (items) => ({ body: items.map((item) => jsonType("snake").toJson(item)) }),
169
- parseReq: ({ body }) => [
170
- body.map((item) => jsonType("snake").fromJson(item)),
171
- ],
172
- schema: { body: Schema.ObjectArray },
471
+ url: "/eth/v1/validator/prepare_beacon_proposer",
472
+ method: "POST",
473
+ req: JsonOnlyReq({
474
+ writeReqJson: ({ proposers }) => ({ body: ProposerPreparationDataListType.toJson(proposers) }),
475
+ parseReqJson: ({ body }) => ({ proposers: ProposerPreparationDataListType.fromJson(body) }),
476
+ schema: { body: Schema.ObjectArray },
477
+ }),
478
+ resp: EmptyResponseCodec,
173
479
  },
174
480
  submitBeaconCommitteeSelections: {
175
- writeReq: (items) => ({ body: ArrayOf(BeaconCommitteeSelection).toJson(items) }),
176
- parseReq: () => [[]],
481
+ url: "/eth/v1/validator/beacon_committee_selections",
482
+ method: "POST",
483
+ req: {
484
+ writeReqJson: ({ selections }) => ({ body: BeaconCommitteeSelectionListType.toJson(selections) }),
485
+ parseReqJson: ({ body }) => ({ selections: BeaconCommitteeSelectionListType.fromJson(body) }),
486
+ writeReqSsz: ({ selections }) => ({ body: BeaconCommitteeSelectionListType.serialize(selections) }),
487
+ parseReqSsz: ({ body }) => ({ selections: BeaconCommitteeSelectionListType.deserialize(body) }),
488
+ schema: {
489
+ body: Schema.ObjectArray,
490
+ },
491
+ },
492
+ resp: {
493
+ data: BeaconCommitteeSelectionListType,
494
+ meta: EmptyMetaCodec,
495
+ },
177
496
  },
178
497
  submitSyncCommitteeSelections: {
179
- writeReq: (items) => ({ body: ArrayOf(SyncCommitteeSelection).toJson(items) }),
180
- parseReq: () => [[]],
498
+ url: "/eth/v1/validator/sync_committee_selections",
499
+ method: "POST",
500
+ req: {
501
+ writeReqJson: ({ selections }) => ({ body: SyncCommitteeSelectionListType.toJson(selections) }),
502
+ parseReqJson: ({ body }) => ({ selections: SyncCommitteeSelectionListType.fromJson(body) }),
503
+ writeReqSsz: ({ selections }) => ({ body: SyncCommitteeSelectionListType.serialize(selections) }),
504
+ parseReqSsz: ({ body }) => ({ selections: SyncCommitteeSelectionListType.deserialize(body) }),
505
+ schema: {
506
+ body: Schema.ObjectArray,
507
+ },
508
+ },
509
+ resp: {
510
+ data: SyncCommitteeSelectionListType,
511
+ meta: EmptyMetaCodec,
512
+ },
181
513
  },
182
514
  getLiveness: {
183
- writeReq: (epoch, indexes) => ({ params: { epoch }, body: indexes.map((i) => toU64Str(i)) }),
184
- parseReq: ({ params, body }) => [params.epoch, body.map((i) => fromU64Str(i))],
185
- schema: {
186
- params: { epoch: Schema.UintRequired },
187
- body: Schema.StringArray,
515
+ url: "/eth/v1/validator/liveness/{epoch}",
516
+ method: "POST",
517
+ req: {
518
+ writeReqJson: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.toJson(indices) }),
519
+ parseReqJson: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.fromJson(body) }),
520
+ writeReqSsz: ({ epoch, indices }) => ({ params: { epoch }, body: ValidatorIndicesType.serialize(indices) }),
521
+ parseReqSsz: ({ params, body }) => ({ epoch: params.epoch, indices: ValidatorIndicesType.deserialize(body) }),
522
+ schema: {
523
+ params: { epoch: Schema.UintRequired },
524
+ body: Schema.StringArray,
525
+ },
188
526
  },
189
- },
190
- registerValidator: reqOnlyBody(ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1), Schema.ObjectArray),
191
- };
192
- }
193
- export function getReturnTypes() {
194
- const rootHexType = new StringType();
195
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
196
- const WithDependentRootExecutionOptimistic = (dataType) => new ContainerType({
197
- executionOptimistic: ssz.Boolean,
198
- data: dataType,
199
- dependentRoot: rootHexType,
200
- }, { jsonCase: "eth2" });
201
- const AttesterDuty = new ContainerType({
202
- pubkey: ssz.BLSPubkey,
203
- validatorIndex: ssz.ValidatorIndex,
204
- committeeIndex: ssz.CommitteeIndex,
205
- committeeLength: ssz.UintNum64,
206
- committeesAtSlot: ssz.UintNum64,
207
- validatorCommitteeIndex: ssz.UintNum64,
208
- slot: ssz.Slot,
209
- }, { jsonCase: "eth2" });
210
- const ProposerDuty = new ContainerType({
211
- slot: ssz.Slot,
212
- validatorIndex: ssz.ValidatorIndex,
213
- pubkey: ssz.BLSPubkey,
214
- }, { jsonCase: "eth2" });
215
- const SyncDuty = new ContainerType({
216
- pubkey: ssz.BLSPubkey,
217
- validatorIndex: ssz.ValidatorIndex,
218
- validatorSyncCommitteeIndices: ArrayOf(ssz.UintNum64),
219
- }, { jsonCase: "eth2" });
220
- const produceBlockOrContents = WithBlockValues(WithVersion((fork) => isForkBlobs(fork) ? allForksBlockContentsResSerializer(fork) : ssz[fork].BeaconBlock));
221
- const produceBlindedBlock = WithBlockValues(WithVersion((fork) => ssz.allForksBlinded[isForkExecution(fork) ? fork : ForkName.bellatrix].BeaconBlock));
222
- return {
223
- getAttesterDuties: WithDependentRootExecutionOptimistic(ArrayOf(AttesterDuty)),
224
- getProposerDuties: WithDependentRootExecutionOptimistic(ArrayOf(ProposerDuty)),
225
- getSyncCommitteeDuties: ContainerDataExecutionOptimistic(ArrayOf(SyncDuty)),
226
- produceBlock: ContainerData(ssz.phase0.BeaconBlock),
227
- produceBlockV2: produceBlockOrContents,
228
- produceBlockV3: {
229
- toJson: (data) => {
230
- if (data.executionPayloadBlinded) {
231
- return {
232
- execution_payload_blinded: true,
233
- execution_payload_source: data.executionPayloadSource,
234
- ...produceBlindedBlock.toJson(data),
235
- };
236
- }
237
- else {
238
- return {
239
- execution_payload_blinded: false,
240
- execution_payload_source: data.executionPayloadSource,
241
- ...produceBlockOrContents.toJson(data),
242
- };
243
- }
527
+ resp: {
528
+ data: LivenessResponseDataListType,
529
+ meta: EmptyMetaCodec,
244
530
  },
245
- fromJson: (data) => {
246
- const executionPayloadBlinded = data.execution_payload_blinded;
247
- if (executionPayloadBlinded === undefined) {
248
- throw Error(`Invalid executionPayloadBlinded=${executionPayloadBlinded} for fromJson deserialization`);
249
- }
250
- // extract source from the data and assign defaults in the spec complaint manner if not present in response
251
- const executionPayloadSource = data.execution_payload_source ??
252
- (executionPayloadBlinded ? ProducedBlockSource.builder : ProducedBlockSource.engine);
253
- if (executionPayloadBlinded) {
254
- return { executionPayloadBlinded, executionPayloadSource, ...produceBlindedBlock.fromJson(data) };
255
- }
256
- else {
257
- return { executionPayloadBlinded, executionPayloadSource, ...produceBlockOrContents.fromJson(data) };
258
- }
531
+ },
532
+ registerValidator: {
533
+ url: "/eth/v1/validator/register_validator",
534
+ method: "POST",
535
+ req: {
536
+ writeReqJson: ({ registrations }) => ({ body: SignedValidatorRegistrationV1ListType.toJson(registrations) }),
537
+ parseReqJson: ({ body }) => ({ registrations: SignedValidatorRegistrationV1ListType.fromJson(body) }),
538
+ writeReqSsz: ({ registrations }) => ({ body: SignedValidatorRegistrationV1ListType.serialize(registrations) }),
539
+ parseReqSsz: ({ body }) => ({ registrations: SignedValidatorRegistrationV1ListType.deserialize(body) }),
540
+ schema: {
541
+ body: Schema.ObjectArray,
542
+ },
259
543
  },
544
+ resp: EmptyResponseCodec,
260
545
  },
261
- produceBlindedBlock,
262
- produceAttestationData: ContainerData(ssz.phase0.AttestationData),
263
- produceSyncCommitteeContribution: ContainerData(ssz.altair.SyncCommitteeContribution),
264
- getAggregatedAttestation: ContainerData(ssz.phase0.Attestation),
265
- submitBeaconCommitteeSelections: ContainerData(ArrayOf(BeaconCommitteeSelection)),
266
- submitSyncCommitteeSelections: ContainerData(ArrayOf(SyncCommitteeSelection)),
267
- getLiveness: jsonType("snake"),
268
546
  };
269
547
  }
270
548
  function parseBuilderBoostFactor(builderBoostFactorInput) {
271
549
  return builderBoostFactorInput !== undefined ? BigInt(builderBoostFactorInput) : undefined;
272
550
  }
551
+ function writeSkipRandaoVerification(skipRandaoVerification) {
552
+ return skipRandaoVerification === true ? "" : undefined;
553
+ }
273
554
  function parseSkipRandaoVerification(skipRandaoVerification) {
274
555
  return skipRandaoVerification !== undefined && skipRandaoVerification === "";
275
556
  }