diff --git a/src/app/api/getPoints.ts b/src/app/api/getPoints.ts index 6619885e..49ea86cb 100644 --- a/src/app/api/getPoints.ts +++ b/src/app/api/getPoints.ts @@ -4,12 +4,16 @@ import { Pagination } from "../types/api"; import { pointsApiWrapper } from "./pointsApiWrapper"; -export interface StakerPoints { +interface StakerPointsAPIResponse { + data: StakerPointsAPI[]; +} + +export interface StakerPointsAPI { staker_btc_pk: string; points: number; } -export interface DelegationPoints { +export interface DelegationPointsAPI { staking_tx_hash_hex: string; staker: { pk: string; @@ -24,18 +28,14 @@ export interface DelegationPoints { expiry_height: number; } -export interface PaginatedDelegationsPoints { - data: DelegationPoints[]; +interface PaginatedDelegationsPointsAPIResponse { + data: DelegationPointsAPI[]; pagination: Pagination; } -export interface DelegationsPoints { - data: DelegationPoints[]; -} - export const getStakersPoints = async ( stakerBtcPks: string[], -): Promise => { +): Promise => { const params = new URLSearchParams(); stakerBtcPks.forEach((pk) => { @@ -49,13 +49,14 @@ export const getStakersPoints = async ( params, ); - return response.data; + const responseData: StakerPointsAPIResponse = response.data; + return responseData.data; }; // Get delegation points by staking transaction hash hex export const getDelegationPointsByStakingTxHashHexes = async ( stakingTxHashHexes: string[], -): Promise => { +): Promise => { const response = await pointsApiWrapper( "POST", "/v1/points/delegations", @@ -63,5 +64,6 @@ export const getDelegationPointsByStakingTxHashHexes = async ( { staking_tx_hash_hex: stakingTxHashHexes }, ); - return response.data; + const responseData: PaginatedDelegationsPointsAPIResponse = response.data; + return responseData.data; }; diff --git a/src/app/context/api/DelegationsPointsProvider.tsx b/src/app/context/api/DelegationsPointsProvider.tsx index 6b058d04..816f3493 100644 --- a/src/app/context/api/DelegationsPointsProvider.tsx +++ b/src/app/context/api/DelegationsPointsProvider.tsx @@ -19,7 +19,7 @@ interface DelegationsPointsProviderProps { address: string; } -const MAX_DELEGATION_POINTS_BATCH_SIZE = 60; +const MAX_DELEGATION_POINTS_BATCH_SIZE = 200; const DelegationsPointsContext = createContext( undefined, ); @@ -68,7 +68,7 @@ export const DelegationsPointsProvider: React.FC< chunks.map((chunk) => getDelegationPointsByStakingTxHashHexes(chunk)), ); - return results.flatMap((result) => result.data); + return results.flatMap((result) => result); }; const { data, isLoading, error } = useQuery({