Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(dashboard): cleanup epoch time hooks returning different types #5844

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ function UnlockConditionLabel({ groupKey, isTimelocked: isTimelocked }: UnlockCo
const { data: currentEpochEndTimestampMs, isLoading: isLoadingEpochEnd } =
useGetCurrentEpochEndTimestamp();

const epochStartMs = currentEpochStartTimestampMs ?? '0';
const epochStartMs = currentEpochStartTimestampMs ?? 0;
const epochEndMs = currentEpochEndTimestampMs ?? 0;

const unlockConditionTimestampMs = parseInt(groupKey) * MILLISECONDS_PER_SECOND;
const isUnlockConditionExpired =
!isLoadingEpochStart && unlockConditionTimestampMs <= parseInt(epochStartMs);
!isLoadingEpochStart && unlockConditionTimestampMs <= epochStartMs;
const isInAFutureEpoch = !isLoadingEpochEnd && unlockConditionTimestampMs > epochEndMs;
// If the unlock condition is within the current epoch, we can show a better estimated time
// as the current epoch end time + buffer time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function useGetCurrentEpochStartTimestamp() {
queryKey: ['current-epoch-start-timestamp'],
queryFn: async () => {
const iotaSystemState = await client.getLatestIotaSystemState();
return iotaSystemState.epochStartTimestampMs;
return parseInt(iotaSystemState.epochStartTimestampMs);
},
staleTime: 10 * 60 * 1000, // 10 minutes
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function useGetStardustMigratableObjects(address: string) {
sharedNftOutputObjects,
],
queryFn: () => {
const epochMs = Number(currentEpochMs) || 0;
const epochMs = currentEpochMs || 0;

const { migratable: migratableBasicOutputs, timelocked: timelockedBasicOutputs } =
groupStardustObjectsByMigrationStatus(
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-dashboard/hooks/useGroupedStardustObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useGroupedStardustObjects(
const { data: currentEpochStartTimestampMs } = useGetCurrentEpochStartTimestamp();
const { data: currentEpochEndTimestampMs } = useGetCurrentEpochEndTimestamp();

const epochStartMs = currentEpochStartTimestampMs ? parseInt(currentEpochStartTimestampMs) : 0;
const epochStartMs = currentEpochStartTimestampMs ? currentEpochStartTimestampMs : 0;
const epochEndMs = currentEpochEndTimestampMs ? currentEpochEndTimestampMs : 0;

return useQuery({
Expand Down