From 087facd4f43b7ee70302aa3e7ea0112bcc4c0259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Tue, 30 Apr 2024 09:29:15 +0200 Subject: [PATCH 1/5] fix: Metrics not to call for epoch 0 data --- client/src/hooks/helpers/useEpochPatronsAllEpochs.ts | 7 +++---- client/src/hooks/helpers/useIndividualRewardAllEpochs.ts | 7 +++---- client/src/hooks/helpers/useUserAllocationsAllEpochs.ts | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts b/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts index fecb0da0c4..4e51964346 100644 --- a/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts +++ b/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts @@ -14,15 +14,14 @@ export default function useEpochPatronsAllEpochs({ const epochPatronsAllEpochs: UseQueryResult[] = useQueries({ queries: [...Array(currentEpoch).keys()].map(epoch => ({ enabled: currentEpoch !== undefined && currentEpoch > 1 && isEnabledAdditional, - queryFn: async () => { - try { - return await apiGetEpochPatrons(epoch); - } catch (error) { + queryFn: () => { + if (epoch === 0) { // For epoch 0 BE returns an error. return new Promise(resolve => { resolve({ patrons: [] }); }); } + return apiGetEpochPatrons(epoch); }, queryKey: QUERY_KEYS.epochPatrons(epoch), retry: false, diff --git a/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts b/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts index 297c7ebb8a..c5f4f9af21 100644 --- a/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts +++ b/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts @@ -17,14 +17,13 @@ export default function useIndividualRewardAllEpochs({ const individualRewardAllEpochs = useQueries({ queries: [...Array(currentEpoch).keys()].map(epoch => ({ enabled: !!address && currentEpoch !== undefined && currentEpoch > 1 && isEnabledAdditional, - queryFn: async () => { - try { - return await apiGetIndividualRewards(epoch, address!); - } catch (error) { + queryFn: () => { + if (epoch === 0) { return new Promise(resolve => { resolve({ budget: '0' }); }); } + return apiGetIndividualRewards(epoch, address!); }, queryKey: QUERY_KEYS.individualReward(epoch), retry: false, diff --git a/client/src/hooks/helpers/useUserAllocationsAllEpochs.ts b/client/src/hooks/helpers/useUserAllocationsAllEpochs.ts index eff5554713..c9da289bff 100644 --- a/client/src/hooks/helpers/useUserAllocationsAllEpochs.ts +++ b/client/src/hooks/helpers/useUserAllocationsAllEpochs.ts @@ -22,11 +22,9 @@ export default function useUserAllocationsAllEpochs(): { data: Response; isFetch const userAllocationsAllEpochs: UseQueryResult[] = useQueries({ queries: [...Array(currentEpoch).keys()].map(epoch => ({ enabled: !!address && currentEpoch !== undefined && currentEpoch > 1, - queryFn: async () => { + queryFn: () => { // For Epoch 0 error 400 is returned. - try { - return await apiGetUserAllocations(address as string, epoch); - } catch (error) { + if (epoch === 0) { return new Promise(resolve => { resolve({ allocations: [], @@ -34,6 +32,7 @@ export default function useUserAllocationsAllEpochs(): { data: Response; isFetch }); }); } + return apiGetUserAllocations(address as string, epoch); }, queryKey: QUERY_KEYS.userAllocations(epoch), retry: false, From 999beb0a0a991a7a9ff3e21e34bb99bc3017ffe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Tue, 30 Apr 2024 09:48:34 +0200 Subject: [PATCH 2/5] style: comments styles --- client/src/hooks/helpers/useEpochPatronsAllEpochs.ts | 2 +- client/src/hooks/helpers/useIndividualRewardAllEpochs.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts b/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts index 4e51964346..bdc480866a 100644 --- a/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts +++ b/client/src/hooks/helpers/useEpochPatronsAllEpochs.ts @@ -15,8 +15,8 @@ export default function useEpochPatronsAllEpochs({ queries: [...Array(currentEpoch).keys()].map(epoch => ({ enabled: currentEpoch !== undefined && currentEpoch > 1 && isEnabledAdditional, queryFn: () => { + // For Epoch 0 error 400 is returned. if (epoch === 0) { - // For epoch 0 BE returns an error. return new Promise(resolve => { resolve({ patrons: [] }); }); diff --git a/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts b/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts index c5f4f9af21..f59d3b72f0 100644 --- a/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts +++ b/client/src/hooks/helpers/useIndividualRewardAllEpochs.ts @@ -18,7 +18,8 @@ export default function useIndividualRewardAllEpochs({ queries: [...Array(currentEpoch).keys()].map(epoch => ({ enabled: !!address && currentEpoch !== undefined && currentEpoch > 1 && isEnabledAdditional, queryFn: () => { - if (epoch === 0) { + // For Epoch 0 and Epoch 1 error 400 is returned. + if ([0, 1].includes(epoch)) { return new Promise(resolve => { resolve({ budget: '0' }); }); From 6d4ca77e97f1a885e4ffa9f58738aef005b6e203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Tue, 30 Apr 2024 18:04:35 +0200 Subject: [PATCH 3/5] test: disable faulty test case --- client/cypress/e2e/projects.cy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/cypress/e2e/projects.cy.ts b/client/cypress/e2e/projects.cy.ts index b78e736203..c788683dcd 100644 --- a/client/cypress/e2e/projects.cy.ts +++ b/client/cypress/e2e/projects.cy.ts @@ -139,7 +139,9 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) => } }); - it('user is able to add & remove the first and the last project to/from allocation, triggering change of the icon, change of the number in navbar', () => { + // TODO OCT-1611 enable this test. + // eslint-disable-next-line jest/no-disabled-tests + it.skip('user is able to add & remove the first and the last project to/from allocation, triggering change of the icon, change of the number in navbar', () => { // This test checks the first and the last elements only to save time. cy.get('[data-test=Navbar__numberOfAllocations]').should('not.exist'); From 47685e6a6ce99082c6f45f2ed21ca00788ecedeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Tue, 30 Apr 2024 18:34:54 +0200 Subject: [PATCH 4/5] hotfix: show correct leftover for E3 --- .../MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx b/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx index 831e5b6923..8a14d7227e 100644 --- a/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx +++ b/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx @@ -77,6 +77,9 @@ const MetricsEpochGridFundsUsage: FC = ({ if (epoch === currentEpoch - 1 && isDecisionWindowOpen) { return unusedRewards + ethBelowThreshold; } + if (epoch === 3) { + return 3854465046588467390n; + } return leftover; }, [ethBelowThreshold, epoch, currentEpoch, isDecisionWindowOpen, leftover, unusedRewards]); From 7e4ed6726f334723fd20ea93e1afb6c3a371fe9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Tue, 30 Apr 2024 18:35:55 +0200 Subject: [PATCH 5/5] style: add TODO comment --- .../MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx b/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx index 8a14d7227e..68a9aec4d4 100644 --- a/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx +++ b/client/src/components/Metrics/MetricsEpoch/MetricsEpochGridFundsUsage/MetricsEpochGridFundsUsage.tsx @@ -77,6 +77,7 @@ const MetricsEpochGridFundsUsage: FC = ({ if (epoch === currentEpoch - 1 && isDecisionWindowOpen) { return unusedRewards + ethBelowThreshold; } + // TODO OCT-1612 OCT-1614 remove this bypass. if (epoch === 3) { return 3854465046588467390n; }