diff --git a/frontend/context/RewardProvider.tsx b/frontend/context/RewardProvider.tsx index 30f225eef..2a109c586 100644 --- a/frontend/context/RewardProvider.tsx +++ b/frontend/context/RewardProvider.tsx @@ -68,15 +68,24 @@ const useStakingRewardsDetails = () => { token!, ), queryFn: async () => { + if (!multisig || !token || !selectedStakingProgramId) return; const response = await currentAgent.serviceApi.getAgentStakingRewardsInfo( { - agentMultisigAddress: multisig!, - serviceId: token!, - stakingProgramId: selectedStakingProgramId!, + agentMultisigAddress: multisig, + serviceId: token, + stakingProgramId: selectedStakingProgramId, chainId: currentChainId, }, ); - return StakingRewardsInfoSchema.parse(response); + + if (!response) return; + + try { + const parsed = StakingRewardsInfoSchema.parse(response); + return parsed; + } catch (e) { + console.error('Error parsing staking rewards info', e); + } }, enabled: !!isOnline && @@ -133,6 +142,7 @@ export const RewardProvider = ({ children }: PropsWithChildren) => { refetch: refetchStakingRewardsDetails, isFetched: isStakingRewardsDetailsFetched, } = useStakingRewardsDetails(); + const { data: availableRewardsForEpoch, refetch: refetchAvailableRewardsForEpoch, diff --git a/frontend/types/Autonolas.ts b/frontend/types/Autonolas.ts index e023bf555..42619296c 100644 --- a/frontend/types/Autonolas.ts +++ b/frontend/types/Autonolas.ts @@ -1,11 +1,16 @@ import { z } from 'zod'; +const zodBigNumber = z.object({ + _isBigNumber: z.boolean(), + _hex: z.string().startsWith('0x'), +}); + export const StakingRewardsInfoSchema = z.object({ // mechRequestCount: z.number(), serviceInfo: z.array(z.unknown()), - livenessPeriod: z.number(), - livenessRatio: z.number(), - rewardsPerSecond: z.number(), + livenessPeriod: zodBigNumber, + livenessRatio: zodBigNumber, + rewardsPerSecond: zodBigNumber, isEligibleForRewards: z.boolean(), availableRewardsForEpoch: z.number(), accruedServiceStakingRewards: z.number(),