@@ -1125,6 +1125,81 @@ pub fn serve<T: BeaconChainTypes>(
11251125 } ,
11261126 ) ;
11271127
1128+ // GET beacon/states/{state_id}/pending_deposits
1129+ let get_beacon_state_pending_deposits = beacon_states_path
1130+ . clone ( )
1131+ . and ( warp:: path ( "pending_deposits" ) )
1132+ . and ( warp:: path:: end ( ) )
1133+ . then (
1134+ |state_id : StateId ,
1135+ task_spawner : TaskSpawner < T :: EthSpec > ,
1136+ chain : Arc < BeaconChain < T > > | {
1137+ task_spawner. blocking_json_task ( Priority :: P1 , move || {
1138+ let ( data, execution_optimistic, finalized) = state_id
1139+ . map_state_and_execution_optimistic_and_finalized (
1140+ & chain,
1141+ |state, execution_optimistic, finalized| {
1142+ if !state. fork_name_unchecked ( ) . electra_enabled ( ) {
1143+ return Err ( warp_utils:: reject:: pre_electra_not_supported (
1144+ format ! ( "state at epoch {} is not activated for Electra" , state. current_epoch( ) )
1145+ ) ) ;
1146+ }
1147+
1148+ let Ok ( deposits) = state. pending_deposits ( ) else {
1149+ return Err ( warp_utils:: reject:: custom_bad_request ( "Pending deposits not found" . to_string ( ) ) ) ;
1150+ } ;
1151+
1152+ Ok ( ( deposits. iter ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) , execution_optimistic, finalized) )
1153+ }
1154+ ) ?;
1155+
1156+ Ok ( api_types:: ExecutionOptimisticFinalizedResponse {
1157+ data,
1158+ execution_optimistic : Some ( execution_optimistic) ,
1159+ finalized : Some ( finalized) ,
1160+ } )
1161+ } )
1162+ } ,
1163+ ) ;
1164+
1165+ // GET beacon/states/{state_id}/pending_partial_withdrawals
1166+ let get_beacon_state_pending_partial_withdrawals = beacon_states_path
1167+ . clone ( )
1168+ . and ( warp:: path ( "pending_partial_withdrawals" ) )
1169+ . and ( warp:: path:: end ( ) )
1170+ . then (
1171+ |state_id : StateId ,
1172+ task_spawner : TaskSpawner < T :: EthSpec > ,
1173+ chain : Arc < BeaconChain < T > > | {
1174+ task_spawner. blocking_json_task ( Priority :: P1 , move || {
1175+ let ( data, execution_optimistic, finalized) = state_id
1176+ . map_state_and_execution_optimistic_and_finalized (
1177+ & chain,
1178+ |state, execution_optimistic, finalized| {
1179+ if !state. fork_name_unchecked ( ) . electra_enabled ( ) {
1180+ return Err ( warp_utils:: reject:: pre_electra_not_supported (
1181+ format ! ( "state at epoch {} is not activated for Electra" , state. current_epoch( ) )
1182+ ) ) ;
1183+ }
1184+
1185+ let Ok ( withdrawals) = state. pending_partial_withdrawals ( ) else {
1186+ return Err ( warp_utils:: reject:: custom_bad_request ( "Pending withdrawals not found" . to_string ( ) ) ) ;
1187+ } ;
1188+
1189+ Ok ( ( withdrawals. iter ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) , execution_optimistic, finalized) )
1190+ }
1191+ ) ?;
1192+
1193+ Ok ( api_types:: ExecutionOptimisticFinalizedResponse {
1194+ data,
1195+ execution_optimistic : Some ( execution_optimistic) ,
1196+ finalized : Some ( finalized) ,
1197+ } )
1198+ } )
1199+ } ,
1200+ ) ;
1201+
1202+
11281203 // GET beacon/headers
11291204 //
11301205 // Note: this endpoint only returns information about blocks in the canonical chain. Given that
@@ -4673,6 +4748,8 @@ pub fn serve<T: BeaconChainTypes>(
46734748 . uor ( get_beacon_state_committees)
46744749 . uor ( get_beacon_state_sync_committees)
46754750 . uor ( get_beacon_state_randao)
4751+ . uor ( get_beacon_state_pending_deposits)
4752+ . uor ( get_beacon_state_pending_partial_withdrawals)
46764753 . uor ( get_beacon_headers)
46774754 . uor ( get_beacon_headers_block_id)
46784755 . uor ( get_beacon_block)
0 commit comments