11import { endpoint } from "@/api" ;
22import { api } from "@/lib/api-client" ;
3+ import {
4+ validatorsSearchParamsSerializer ,
5+ type ValidatorsSearchSchema ,
6+ } from "@/lib/search-parsers/validators-search-parsers" ;
37import { formatClusterData , getDefaultClusterData } from "@/lib/utils/cluster" ;
48import { mapBeaconChainStatus } from "@/lib/utils/validator-status-mapping" ;
59import type {
610 GetClusterResponse ,
711 GetPaginatedClustersResponse ,
8- PaginatedValidatorsResponse ,
12+ PaginatedSearchValidatorsResponse ,
913} from "@/types/api" ;
1014import type { Address } from "abitype" ;
1115
@@ -56,27 +60,17 @@ export const getPaginatedAccountClusters = ({
5660 } ) ) ;
5761} ;
5862
59- export type GetPaginatedClusterValidators = {
60- hash : string ;
61- page ?: number ;
62- perPage ?: number ;
63- } ;
63+ export type GetPaginatedClusterValidators = Partial < ValidatorsSearchSchema > ;
64+
65+ export const getPaginatedClusterValidators = (
66+ params : GetPaginatedClusterValidators ,
67+ ) => {
68+ const searchParams = validatorsSearchParamsSerializer ( params ) ;
69+ console . log ( "searchParams:" , searchParams ) ;
6470
65- export const getPaginatedClusterValidators = ( {
66- hash,
67- page = 1 ,
68- perPage = 10 ,
69- } : GetPaginatedClusterValidators ) => {
7071 return api
71- . get < PaginatedValidatorsResponse > (
72- endpoint (
73- "clusters/hash" ,
74- hash ,
75- `?${ new URLSearchParams ( {
76- page : page . toString ( ) ,
77- perPage : perPage . toString ( ) ,
78- } ) . toString ( ) } `,
79- ) ,
72+ . get < PaginatedSearchValidatorsResponse > (
73+ endpoint ( "validators" , `?${ searchParams } ` ) ,
8074 )
8175 . then ( ( response ) => ( {
8276 ...response ,
@@ -88,10 +82,6 @@ export const getPaginatedClusterValidators = ({
8882 isValid : validator . is_valid ,
8983 } ) ,
9084 } ) ) ,
91- pagination : {
92- ...response . pagination ,
93- page : response . pagination . page || 1 ,
94- pages : response . pagination . pages || 1 ,
95- } ,
85+ pagination : response . pagination ,
9686 } ) ) ;
9787} ;
0 commit comments