@@ -10,6 +10,7 @@ import {
1010 Schema ,
1111 ReqSerializers ,
1212 ReqSerializer ,
13+ WithFinalized ,
1314} from "../../../utils/index.js" ;
1415
1516// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
@@ -23,6 +24,11 @@ export type ValidatorId = string | number;
2324 */
2425export type ExecutionOptimistic = boolean ;
2526
27+ /**
28+ * True if the response references the finalized history of the chain, as determined by fork choice.
29+ */
30+ export type Finalized = boolean ;
31+
2632export type ValidatorStatus =
2733 | "active"
2834 | "pending_initialized"
@@ -85,11 +91,15 @@ export type Api = {
8591 * @param stateId State identifier.
8692 * Can be one of: "head" (canonical head in node's view), "genesis", "finalized", "justified", \<slot\>, \<hex encoded stateRoot with 0x prefix\>.
8793 */
88- getStateRoot (
89- stateId : StateId
90- ) : Promise <
94+ getStateRoot ( stateId : StateId ) : Promise <
9195 ApiClientResponse <
92- { [ HttpStatusCode . OK ] : { data : { root : Root } ; executionOptimistic : ExecutionOptimistic } } ,
96+ {
97+ [ HttpStatusCode . OK ] : {
98+ data : { root : Root } ;
99+ executionOptimistic : ExecutionOptimistic ;
100+ finalized : Finalized ;
101+ } ;
102+ } ,
93103 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
94104 >
95105 > ;
@@ -100,11 +110,15 @@ export type Api = {
100110 * @param stateId State identifier.
101111 * Can be one of: "head" (canonical head in node's view), "genesis", "finalized", "justified", \<slot\>, \<hex encoded stateRoot with 0x prefix\>.
102112 */
103- getStateFork (
104- stateId : StateId
105- ) : Promise <
113+ getStateFork ( stateId : StateId ) : Promise <
106114 ApiClientResponse <
107- { [ HttpStatusCode . OK ] : { data : phase0 . Fork ; executionOptimistic : ExecutionOptimistic } } ,
115+ {
116+ [ HttpStatusCode . OK ] : {
117+ data : phase0 . Fork ;
118+ executionOptimistic : ExecutionOptimistic ;
119+ finalized : Finalized ;
120+ } ;
121+ } ,
108122 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
109123 >
110124 > ;
@@ -121,7 +135,13 @@ export type Api = {
121135 epoch ?: Epoch
122136 ) : Promise <
123137 ApiClientResponse <
124- { [ HttpStatusCode . OK ] : { data : { randao : Root } ; executionOptimistic : ExecutionOptimistic } } ,
138+ {
139+ [ HttpStatusCode . OK ] : {
140+ data : { randao : Root } ;
141+ executionOptimistic : ExecutionOptimistic ;
142+ finalized : Finalized ;
143+ } ;
144+ } ,
125145 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
126146 >
127147 > ;
@@ -133,11 +153,15 @@ export type Api = {
133153 * @param stateId State identifier.
134154 * Can be one of: "head" (canonical head in node's view), "genesis", "finalized", "justified", \<slot\>, \<hex encoded stateRoot with 0x prefix\>.
135155 */
136- getStateFinalityCheckpoints (
137- stateId : StateId
138- ) : Promise <
156+ getStateFinalityCheckpoints ( stateId : StateId ) : Promise <
139157 ApiClientResponse <
140- { [ HttpStatusCode . OK ] : { data : FinalityCheckpoints ; executionOptimistic : ExecutionOptimistic } } ,
158+ {
159+ [ HttpStatusCode . OK ] : {
160+ data : FinalityCheckpoints ;
161+ executionOptimistic : ExecutionOptimistic ;
162+ finalized : Finalized ;
163+ } ;
164+ } ,
141165 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
142166 >
143167 > ;
@@ -155,7 +179,13 @@ export type Api = {
155179 filters ?: ValidatorFilters
156180 ) : Promise <
157181 ApiClientResponse <
158- { [ HttpStatusCode . OK ] : { data : ValidatorResponse [ ] ; executionOptimistic : ExecutionOptimistic } } ,
182+ {
183+ [ HttpStatusCode . OK ] : {
184+ data : ValidatorResponse [ ] ;
185+ executionOptimistic : ExecutionOptimistic ;
186+ finalized : Finalized ;
187+ } ;
188+ } ,
159189 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
160190 >
161191 > ;
@@ -172,7 +202,13 @@ export type Api = {
172202 validatorId : ValidatorId
173203 ) : Promise <
174204 ApiClientResponse <
175- { [ HttpStatusCode . OK ] : { data : ValidatorResponse ; executionOptimistic : ExecutionOptimistic } } ,
205+ {
206+ [ HttpStatusCode . OK ] : {
207+ data : ValidatorResponse ;
208+ executionOptimistic : ExecutionOptimistic ;
209+ finalized : Finalized ;
210+ } ;
211+ } ,
176212 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
177213 >
178214 > ;
@@ -189,7 +225,13 @@ export type Api = {
189225 indices ?: ValidatorId [ ]
190226 ) : Promise <
191227 ApiClientResponse <
192- { [ HttpStatusCode . OK ] : { data : ValidatorBalance [ ] ; executionOptimistic : ExecutionOptimistic } } ,
228+ {
229+ [ HttpStatusCode . OK ] : {
230+ data : ValidatorBalance [ ] ;
231+ executionOptimistic : ExecutionOptimistic ;
232+ finalized : Finalized ;
233+ } ;
234+ } ,
193235 HttpStatusCode . BAD_REQUEST
194236 >
195237 > ;
@@ -208,7 +250,13 @@ export type Api = {
208250 filters ?: CommitteesFilters
209251 ) : Promise <
210252 ApiClientResponse <
211- { [ HttpStatusCode . OK ] : { data : EpochCommitteeResponse [ ] ; executionOptimistic : ExecutionOptimistic } } ,
253+ {
254+ [ HttpStatusCode . OK ] : {
255+ data : EpochCommitteeResponse [ ] ;
256+ executionOptimistic : ExecutionOptimistic ;
257+ finalized : Finalized ;
258+ } ;
259+ } ,
212260 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
213261 >
214262 > ;
@@ -218,7 +266,13 @@ export type Api = {
218266 epoch ?: Epoch
219267 ) : Promise <
220268 ApiClientResponse <
221- { [ HttpStatusCode . OK ] : { data : EpochSyncCommitteeResponse ; executionOptimistic : ExecutionOptimistic } } ,
269+ {
270+ [ HttpStatusCode . OK ] : {
271+ data : EpochSyncCommitteeResponse ;
272+ executionOptimistic : ExecutionOptimistic ;
273+ finalized : Finalized ;
274+ } ;
275+ } ,
222276 HttpStatusCode . BAD_REQUEST | HttpStatusCode . NOT_FOUND
223277 >
224278 > ;
@@ -376,14 +430,14 @@ export function getReturnTypes(): ReturnTypes<Api> {
376430 ) ;
377431
378432 return {
379- getStateRoot : ContainerDataExecutionOptimistic ( RootContainer ) ,
380- getStateFork : ContainerDataExecutionOptimistic ( ssz . phase0 . Fork ) ,
381- getStateRandao : ContainerDataExecutionOptimistic ( RandaoContainer ) ,
382- getStateFinalityCheckpoints : ContainerDataExecutionOptimistic ( FinalityCheckpoints ) ,
383- getStateValidators : ContainerDataExecutionOptimistic ( ArrayOf ( ValidatorResponse ) ) ,
384- getStateValidator : ContainerDataExecutionOptimistic ( ValidatorResponse ) ,
385- getStateValidatorBalances : ContainerDataExecutionOptimistic ( ArrayOf ( ValidatorBalance ) ) ,
386- getEpochCommittees : ContainerDataExecutionOptimistic ( ArrayOf ( EpochCommitteeResponse ) ) ,
387- getEpochSyncCommittees : ContainerDataExecutionOptimistic ( EpochSyncCommitteesResponse ) ,
433+ getStateRoot : WithFinalized ( ContainerDataExecutionOptimistic ( RootContainer ) ) ,
434+ getStateFork : WithFinalized ( ContainerDataExecutionOptimistic ( ssz . phase0 . Fork ) ) ,
435+ getStateRandao : WithFinalized ( ContainerDataExecutionOptimistic ( RandaoContainer ) ) ,
436+ getStateFinalityCheckpoints : WithFinalized ( ContainerDataExecutionOptimistic ( FinalityCheckpoints ) ) ,
437+ getStateValidators : WithFinalized ( ContainerDataExecutionOptimistic ( ArrayOf ( ValidatorResponse ) ) ) ,
438+ getStateValidator : WithFinalized ( ContainerDataExecutionOptimistic ( ValidatorResponse ) ) ,
439+ getStateValidatorBalances : WithFinalized ( ContainerDataExecutionOptimistic ( ArrayOf ( ValidatorBalance ) ) ) ,
440+ getEpochCommittees : WithFinalized ( ContainerDataExecutionOptimistic ( ArrayOf ( EpochCommitteeResponse ) ) ) ,
441+ getEpochSyncCommittees : WithFinalized ( ContainerDataExecutionOptimistic ( EpochSyncCommitteesResponse ) ) ,
388442 } ;
389443}
0 commit comments