diff --git a/apps/govern/common-util/functions/time.ts b/apps/govern/common-util/functions/time.ts
index a74d93f0..b2629f4b 100644
--- a/apps/govern/common-util/functions/time.ts
+++ b/apps/govern/common-util/functions/time.ts
@@ -5,11 +5,11 @@ export const getUnixNextWeekStartTimestamp = () => {
const dayOfWeek = now.getDay();
const daysUntilNextThursday = (4 - dayOfWeek + 7) % 7;
- const nextThursday = new Date(now);
- nextThursday.setDate(now.getDate() + daysUntilNextThursday);
- nextThursday.setHours(0, 0, 0, 0);
+ const result = new Date(now);
+ result.setDate(now.getDate() + daysUntilNextThursday);
+ result.setHours(0, 0, 0, 0);
- return nextThursday.getTime() / 1000;
+ return result.getTime() / 1000;
};
// Returns the closest Thursday in the past
@@ -18,10 +18,10 @@ export const getUnixWeekStartTimestamp = () => {
const now = new Date();
const dayOfWeek = now.getDay();
const daysSinceThursday = ((dayOfWeek + 2) % 7) + 1;
- const thursday = new Date(now);
+ const result = new Date(now);
- thursday.setDate(now.getDate() - daysSinceThursday);
- thursday.setHours(0, 0, 0, 0);
+ result.setDate(now.getDate() - daysSinceThursday);
+ result.setHours(0, 0, 0, 0);
- return thursday.getTime() / 1000;
+ return result.getTime() / 1000;
};
diff --git a/apps/govern/components/Contracts/ContractsList.tsx b/apps/govern/components/Contracts/ContractsList.tsx
index 326d7cd1..5e7870b2 100644
--- a/apps/govern/components/Contracts/ContractsList.tsx
+++ b/apps/govern/components/Contracts/ContractsList.tsx
@@ -67,7 +67,7 @@ const getColumns = ({
{
title: (
- {`Next week's weight`}{' '}
+ Next week's weight
),
diff --git a/apps/govern/components/Contracts/EditVotes/validations.tsx b/apps/govern/components/Contracts/EditVotes/validations.tsx
index fb8c1821..1770e45b 100644
--- a/apps/govern/components/Contracts/EditVotes/validations.tsx
+++ b/apps/govern/components/Contracts/EditVotes/validations.tsx
@@ -25,7 +25,7 @@ const getRemovedNomineesError = (removedNominees: Address[], allocations: Alloca
);
-const NO_veOLAS_ERROR = `You don't have enough veOLAS to vote`;
+const NO_VEOLAS_ERROR = `You don't have enough veOLAS to vote`;
// Checks if any of the nominees were removed from voting
export const checkNoRemovedNominees = async (allocations: Allocation[]) => {
@@ -59,7 +59,7 @@ export const checkNoDisabledContracts = async (allocations: Allocation[]) => {
export const checkNotNegativeSlope = async (account: Address) => {
const isNegativeSlope = await checkNegativeSlope(account);
if (isNegativeSlope) {
- notification.error({ message: NO_veOLAS_ERROR });
+ notification.error({ message: NO_VEOLAS_ERROR });
return false;
}
@@ -70,7 +70,7 @@ export const checkNotNegativeSlope = async (account: Address) => {
export const checkLockNotExpired = async (account: Address) => {
const isLockExpired = await checkLockExpired(account);
if (isLockExpired) {
- notification.error({ message: NO_veOLAS_ERROR });
+ notification.error({ message: NO_VEOLAS_ERROR });
return false;
}
diff --git a/apps/govern/hooks/useFetchStakingContractsList.ts b/apps/govern/hooks/useFetchStakingContractsList.ts
index aa4ecab4..df8d80da 100644
--- a/apps/govern/hooks/useFetchStakingContractsList.ts
+++ b/apps/govern/hooks/useFetchStakingContractsList.ts
@@ -16,7 +16,14 @@ import { useNominees } from './useNominees';
import { useNomineesMetadata } from './useNomineesMetadata';
import { useNomineesWeights } from './useNomineesWeights';
-const WEEK = 604_800;
+const WEEK_IN_SECONDS = 604_800;
+
+const getCurrentWeightTimestamp = (timeSum: number | undefined) => {
+ if (!timeSum) return null;
+ // If timeSum is in the future, subtract a week from it
+ if (timeSum * 1000 > Date.now()) return timeSum - WEEK_IN_SECONDS;
+ return timeSum;
+};
export const useFetchStakingContractsList = () => {
const dispatch = useAppDispatch();
@@ -26,6 +33,7 @@ export const useFetchStakingContractsList = () => {
const { data: nominees } = useNominees();
// Get last scheduled time (next week) from the contract
+ // Has the timestamp when the last votes should be applied
const { data: timeSum } = useReadContract({
address: (VOTE_WEIGHTING.addresses as Record)[mainnet.id],
abi: VOTE_WEIGHTING.abi,
@@ -39,12 +47,7 @@ export const useFetchStakingContractsList = () => {
// Get contracts current week weights
const { data: currentWeight } = useNomineesWeights(
nominees || [],
- timeSum
- ? // If timeSum is in the future, subtract a week from it
- timeSum * 1000 > Date.now()
- ? timeSum - WEEK
- : timeSum
- : null,
+ getCurrentWeightTimestamp(timeSum),
);
// Get contracts next week weights