From d925d5bd6369c8ca6355fbb046e8fb3fbb6da5ad Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Tue, 11 Feb 2025 14:54:21 -0800 Subject: [PATCH] Switch to latest reward server semantics --- .../ui/rewards/hooks/useClaimableRewards.ts | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts b/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts index 08dd3054a..ac11efc5d 100644 --- a/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts +++ b/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts @@ -54,25 +54,14 @@ async function fetchHyperdriveRewardApi( baseUrl: import.meta.env.VITE_REWARDS_BASE_URL, }); - try { - const response = await rewardsApi.get.rewardsUserDetail(account); - // TODO: Remove this once claimbableAmount is no longer formatted server side - return response.rewards.map((r) => ({ - ...r, - chainId: rewardsFork.id, - merkleType: "HyperdriveMerkle", - claimableAmount: parseFixed(r.claimableAmount).bigint.toString(), - })); - } catch (error: any) { - // This throws a 404 if the account does not have any rewards, which - // is fine, just return an empty array and display no rewards - if (error.error.error === "No rewards found for this address") { - console.log("No rewards found for this address"); - return []; - } - // There are no other well-known errors we can catch, so re-throw - throw error; - } + const response = await rewardsApi.get.rewardsUserDetail(account); + // TODO: Remove this once claimbableAmount is no longer formatted server side + return response.rewards.map((r) => ({ + ...r, + chainId: rewardsFork.id, + merkleType: "HyperdriveMerkle", + claimableAmount: parseFixed(r.claimableAmount).bigint.toString(), + })); } /** *