diff --git a/apps/wallet-dashboard/app/(protected)/migrations/page.tsx b/apps/wallet-dashboard/app/(protected)/migrations/page.tsx index e933cca2553..b042465c49e 100644 --- a/apps/wallet-dashboard/app/(protected)/migrations/page.tsx +++ b/apps/wallet-dashboard/app/(protected)/migrations/page.tsx @@ -7,7 +7,7 @@ import { useState, useMemo, useCallback } from 'react'; import { useQueryClient } from '@tanstack/react-query'; import clsx from 'clsx'; import { useGetStardustMigratableObjects } from '@/hooks'; -import { summarizeMigratableObjectValues, summarizeUnmigratableObjectValues } from '@/lib/utils'; +import { summarizeMigratableObjectValues, summarizeTimelockedObjectValues } from '@/lib/utils'; import { Button, ButtonSize, @@ -41,8 +41,8 @@ function MigrationDashboardPage(): JSX.Element { const { migratableBasicOutputs, migratableNftOutputs, - unmigratableBasicOutputs, - unmigratableNftOutputs, + timelockedBasicOutputs, + timelockedNftOutputs, } = stardustMigrationObjects || {}; const { @@ -54,9 +54,9 @@ function MigrationDashboardPage(): JSX.Element { nftOutputs: migratableNftOutputs, address, }); - const { totalUnmigratableObjects } = summarizeUnmigratableObjectValues({ - basicOutputs: unmigratableBasicOutputs, - nftOutputs: unmigratableNftOutputs, + const { totalTimelockedObjects } = summarizeTimelockedObjectValues({ + basicOutputs: timelockedBasicOutputs, + nftOutputs: timelockedNftOutputs, }); const hasMigratableObjects = @@ -106,7 +106,7 @@ function MigrationDashboardPage(): JSX.Element { const TIMELOCKED_ASSETS_CARDS: MigrationDisplayCardProps[] = [ { - title: `${totalUnmigratableObjects}`, + title: `${totalTimelockedObjects}`, subtitle: 'Time-locked', icon: Clock, }, @@ -123,8 +123,8 @@ function MigrationDashboardPage(): JSX.Element { selectedStardustObjectsCategory === StardustOutputMigrationStatus.TimeLocked ) { return [ - ...stardustMigrationObjects.unmigratableBasicOutputs, - ...stardustMigrationObjects.unmigratableNftOutputs, + ...stardustMigrationObjects.timelockedBasicOutputs, + ...stardustMigrationObjects.timelockedNftOutputs, ]; } } @@ -216,7 +216,7 @@ function MigrationDashboardPage(): JSX.Element { disabled={ selectedStardustObjectsCategory === StardustOutputMigrationStatus.TimeLocked || - !totalUnmigratableObjects + !totalTimelockedObjects } onClick={() => setSelectedStardustObjectsCategory( diff --git a/apps/wallet-dashboard/components/migration/MigrationObjectsPanel.tsx b/apps/wallet-dashboard/components/migration/MigrationObjectsPanel.tsx index 4d5d80d0af3..915cc56dda5 100644 --- a/apps/wallet-dashboard/components/migration/MigrationObjectsPanel.tsx +++ b/apps/wallet-dashboard/components/migration/MigrationObjectsPanel.tsx @@ -6,7 +6,7 @@ import { useGroupedMigrationObjectsByExpirationDate } from '@/hooks'; import { STARDUST_MIGRATABLE_OBJECTS_FILTER_LIST, - STARDUST_UNMIGRATABLE_OBJECTS_FILTER_LIST, + STARDUST_TIMELOCKED_OBJECTS_FILTER_LIST, } from '@/lib/constants'; import { StardustOutputDetailsFilter } from '@/lib/enums'; import { @@ -33,7 +33,7 @@ import { filterMigrationObjects } from '@/lib/utils'; const FILTERS = { migratable: STARDUST_MIGRATABLE_OBJECTS_FILTER_LIST, - unmigratable: STARDUST_UNMIGRATABLE_OBJECTS_FILTER_LIST, + timelocked: STARDUST_TIMELOCKED_OBJECTS_FILTER_LIST, }; interface MigrationObjectsPanelProps { @@ -58,7 +58,7 @@ export function MigrationObjectsPanel({ const filteredObjects = filterMigrationObjects(resolvedObjects, stardustOutputDetailsFilter); - const filters = isTimelocked ? FILTERS.unmigratable : FILTERS.migratable; + const filters = isTimelocked ? FILTERS.timelocked : FILTERS.migratable; const isHidden = selectedObjects.length === 0; return ( diff --git a/apps/wallet-dashboard/hooks/useGetStardustMigratableObjects.ts b/apps/wallet-dashboard/hooks/useGetStardustMigratableObjects.ts index 8480e9d9e2a..e17bb3d6b3b 100644 --- a/apps/wallet-dashboard/hooks/useGetStardustMigratableObjects.ts +++ b/apps/wallet-dashboard/hooks/useGetStardustMigratableObjects.ts @@ -31,17 +31,17 @@ export function useGetStardustMigratableObjects(address: string) { queryFn: () => { const epochMs = Number(currentEpochMs) || 0; - const { migratable: migratableBasicOutputs, unmigratable: unmigratableBasicOutputs } = + const { migratable: migratableBasicOutputs, timelocked: timelockedBasicOutputs } = groupStardustObjectsByMigrationStatus(basicOutputObjects ?? [], epochMs, address); - const { migratable: migratableNftOutputs, unmigratable: unmigratableNftOutputs } = + const { migratable: migratableNftOutputs, timelocked: timelockedNftOutputs } = groupStardustObjectsByMigrationStatus(nftOutputObjects ?? [], epochMs, address); return { migratableBasicOutputs, - unmigratableBasicOutputs, + timelockedBasicOutputs, migratableNftOutputs, - unmigratableNftOutputs, + timelockedNftOutputs, }; }, enabled: @@ -52,9 +52,9 @@ export function useGetStardustMigratableObjects(address: string) { staleTime: TimeUnit.ONE_SECOND * TimeUnit.ONE_MINUTE * 5, placeholderData: { migratableBasicOutputs: [], - unmigratableBasicOutputs: [], + timelockedBasicOutputs: [], migratableNftOutputs: [], - unmigratableNftOutputs: [], + timelockedNftOutputs: [], }, }); } diff --git a/apps/wallet-dashboard/lib/constants/migration.constants.ts b/apps/wallet-dashboard/lib/constants/migration.constants.ts index 5aa2c5a5c0f..1a203fc50e9 100644 --- a/apps/wallet-dashboard/lib/constants/migration.constants.ts +++ b/apps/wallet-dashboard/lib/constants/migration.constants.ts @@ -7,9 +7,8 @@ export const STARDUST_MIGRATABLE_OBJECTS_FILTER_LIST: StardustOutputDetailsFilte StardustOutputDetailsFilter, ); -export const STARDUST_UNMIGRATABLE_OBJECTS_FILTER_LIST: StardustOutputDetailsFilter[] = - Object.values(StardustOutputDetailsFilter).filter( - (element) => element !== StardustOutputDetailsFilter.WithExpiration, - ); +export const STARDUST_TIMELOCKED_OBJECTS_FILTER_LIST: StardustOutputDetailsFilter[] = Object.values( + StardustOutputDetailsFilter, +).filter((element) => element !== StardustOutputDetailsFilter.WithExpiration); export const MIGRATION_OBJECT_WITHOUT_UC_KEY = 'no-unlock-condition-timestamp'; diff --git a/apps/wallet-dashboard/lib/utils/migration/groupStardustObjectsByMigrationStatus.ts b/apps/wallet-dashboard/lib/utils/migration/groupStardustObjectsByMigrationStatus.ts index b036aacf55c..b10f1cf4218 100644 --- a/apps/wallet-dashboard/lib/utils/migration/groupStardustObjectsByMigrationStatus.ts +++ b/apps/wallet-dashboard/lib/utils/migration/groupStardustObjectsByMigrationStatus.ts @@ -6,7 +6,7 @@ import { IotaObjectData } from '@iota/iota-sdk/client'; export type StardustMigrationGroupedObjects = { migratable: IotaObjectData[]; - unmigratable: IotaObjectData[]; + timelocked: IotaObjectData[]; }; export function groupStardustObjectsByMigrationStatus( @@ -15,13 +15,21 @@ export function groupStardustObjectsByMigrationStatus( address: string, ): StardustMigrationGroupedObjects { const migratable: IotaObjectData[] = []; - const unmigratable: IotaObjectData[] = []; + const timelocked: IotaObjectData[] = []; const epochUnix = epochTimestampMs / MILLISECONDS_PER_SECOND; for (const outputObject of stardustOutputObjects) { const outputObjectFields = extractMigrationOutputFields(outputObject); + if ( + outputObjectFields.timelock_uc && + outputObjectFields.timelock_uc.fields.unix_time > epochUnix + ) { + timelocked.push(outputObject); + continue; + } + if (outputObjectFields.expiration_uc) { const unlockableAddress = outputObjectFields.expiration_uc.fields.unix_time <= epochUnix @@ -29,23 +37,14 @@ export function groupStardustObjectsByMigrationStatus( : outputObjectFields.expiration_uc.fields.owner; if (unlockableAddress !== address) { - unmigratable.push(outputObject); continue; } } - if ( - outputObjectFields.timelock_uc && - outputObjectFields.timelock_uc.fields.unix_time > epochUnix - ) { - unmigratable.push(outputObject); - continue; - } - migratable.push(outputObject); } - return { migratable, unmigratable }; + return { migratable, timelocked }; } interface MigratableObjectsData { @@ -93,10 +92,10 @@ export function summarizeMigratableObjectValues({ } interface UnmmigratableObjectsData { - totalUnmigratableObjects: number; + totalTimelockedObjects: number; } -export function summarizeUnmigratableObjectValues({ +export function summarizeTimelockedObjectValues({ basicOutputs = [], nftOutputs = [], }: Omit): UnmmigratableObjectsData { @@ -110,9 +109,9 @@ export function summarizeUnmigratableObjectValues({ nativeTokens += parseInt(outputObjectFields.native_tokens.fields.size); } - const totalUnmigratableObjects = basicObjects + nativeTokens + nftObjects; + const totalTimelockedObjects = basicObjects + nativeTokens + nftObjects; - return { totalUnmigratableObjects }; + return { totalTimelockedObjects }; } export function extractOwnedStorageDepositReturnAmount(