From 903b9500ad1d0ac465efb47e9956e642bfcdd68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 23 Feb 2024 14:09:31 +0100 Subject: [PATCH] [#280] Fix get drep voting power request --- CHANGELOG.md | 1 + govtool/frontend/src/App.tsx | 2 +- .../src/hooks/queries/useGetDRepVotingPowerQuery.ts | 11 +++++++++-- govtool/frontend/src/models/api.ts | 8 +++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9e33261..90954bacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ changes. - Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59) - Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82) - Fixed deployment scripts to address [Issue 171](https://github.com/IntersectMBO/govtool/issues/171). +- Fixed get drep voting power incorrectly executed endpoint [Issue 280](https://github.com/IntersectMBO/govtool/issues/280) ### Changed - Update Cardano-Serialization-Lib to 12.0.0-alpha.16 [Issue 156](https://github.com/IntersectMBO/govtool/issues/156) diff --git a/govtool/frontend/src/App.tsx b/govtool/frontend/src/App.tsx index 91dab6356..f744e94f3 100644 --- a/govtool/frontend/src/App.tsx +++ b/govtool/frontend/src/App.tsx @@ -49,7 +49,7 @@ export default function App() { const timer = setTimeout(() => setIsDrepLoading(false), 1000); return () => clearTimeout(timer); - }, [data?.isRegistered]); + }, [data?.isRegisteredAsDRep]); const checkTheWalletIsActive = useCallback(() => { const hrefCondition = diff --git a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts index 5df7a3af1..eaaac91d0 100644 --- a/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDRepVotingPowerQuery.ts @@ -7,12 +7,19 @@ import { getDRepVotingPower } from "@services"; export const useGetDRepVotingPowerQuery = () => { const { dRepID, dRep } = useCardano(); + console.log({ dRepID, dRep, cond: !!dRepID && dRep?.isRegisteredAsDRep }); + const { data, isLoading } = useQuery({ - queryKey: [QUERY_KEYS.useGetDRepVotingPowerKey, dRepID, dRep?.isRegistered], + queryKey: [ + QUERY_KEYS.useGetDRepVotingPowerKey, + dRepID, + dRep?.isRegisteredAsDRep, + ], queryFn: async () => { + console.log({ dRepID }); return await getDRepVotingPower({ dRepID }); }, - enabled: !!dRepID && dRep?.isRegistered, + enabled: !!dRepID && dRep?.isRegisteredAsDRep, }); return { dRepVotingPower: data, isDRepVotingPowerLoading: isLoading }; diff --git a/govtool/frontend/src/models/api.ts b/govtool/frontend/src/models/api.ts index 03fec9e2b..9aaa053c0 100644 --- a/govtool/frontend/src/models/api.ts +++ b/govtool/frontend/src/models/api.ts @@ -1,7 +1,9 @@ export interface DRepInfo { - isRegistered: boolean; - wasRegistered: boolean; - deposit: number; + isRegisteredAsDRep: boolean; + isRegisteredAsSoleVoter: boolean; + wasRegisteredAsDRep: boolean; + wasRegisteredAsSoleVoter: boolean; + deposit: number | null; } export interface DRepData {