2
2
3
3
import { use$ } from '@legendapp/state/react'
4
4
import { AlertCircle , Loader2 } from 'lucide-react'
5
- import Image from 'next/image'
6
5
import { useMemo , useState } from 'react'
7
6
import { AppStatus } from 'state/ledger'
8
7
import { uiState$ } from 'state/ui'
@@ -15,15 +14,14 @@ import { Progress } from '@/components/ui/progress'
15
14
import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from '@/components/ui/select'
16
15
import type { AppId } from '@/config/apps'
17
16
import { appsConfigs , getChainName , polkadotAppConfig } from '@/config/apps'
17
+ import type { RangeField , ScanType } from '@/lib/types/scan'
18
+ import { RangeFieldEnum , SCAN_LIMITS , ScanTypeEnum } from '@/lib/types/scan'
18
19
import { cn , getAppTotalAccounts } from '@/lib/utils'
20
+ import { formatIndexDisplay , parseIndexConfig , validateIndexConfig } from '@/lib/utils/scan-indices'
19
21
import type { App } from '@/state/ledger'
20
22
import { IndexInputSection } from './index-input-section'
21
23
import { LedgerUnlockReminder } from './ledger-unlock-reminder'
22
24
23
- import type { ScanType , RangeField } from '@/lib/types/scan'
24
- import { ScanTypeEnum , RangeFieldEnum } from '@/lib/types/scan'
25
- import { parseIndexConfig , validateIndexConfig , formatIndexDisplay } from '@/lib/utils/scan-indices'
26
-
27
25
interface DeepScanModalProps {
28
26
isOpen : boolean
29
27
onClose : ( ) => void
@@ -66,14 +64,15 @@ export function DeepScanModal({
66
64
onCancel,
67
65
onDone,
68
66
} : DeepScanModalProps ) {
67
+ const icons = use$ ( uiState$ . icons )
69
68
const [ accountScanType , setAccountScanType ] = useState < ScanType > ( ScanTypeEnum . SINGLE )
70
69
const [ addressScanType , setAddressScanType ] = useState < ScanType > ( ScanTypeEnum . SINGLE )
71
- const [ accountIndex , setAccountIndex ] = useState < string > ( '1' )
72
- const [ accountStartIndex , setAccountStartIndex ] = useState < string > ( '1' )
73
- const [ accountEndIndex , setAccountEndIndex ] = useState < string > ( '5' )
74
- const [ addressIndex , setAddressIndex ] = useState < string > ( '0' )
75
- const [ addressStartIndex , setAddressStartIndex ] = useState < string > ( '0' )
76
- const [ addressEndIndex , setAddressEndIndex ] = useState < string > ( '5' )
70
+ const [ accountIndex , setAccountIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_SINGLE . toString ( ) )
71
+ const [ accountStartIndex , setAccountStartIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_RANGE_START . toString ( ) )
72
+ const [ accountEndIndex , setAccountEndIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_RANGE_END . toString ( ) )
73
+ const [ addressIndex , setAddressIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_SINGLE . toString ( ) )
74
+ const [ addressStartIndex , setAddressStartIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_RANGE_START . toString ( ) )
75
+ const [ addressEndIndex , setAddressEndIndex ] = useState < string > ( SCAN_LIMITS . DEFAULT_RANGE_END . toString ( ) )
77
76
const [ selectedChain , setSelectedChain ] = useState < AppId | 'all' > ( 'all' )
78
77
79
78
// Get available chains from config
@@ -216,7 +215,7 @@ export function DeepScanModal({
216
215
{ /* Scanning Apps Grid */ }
217
216
{ scanningApps && scanningApps . length > 0 && (
218
217
< div className = "pt-2 mb-4" >
219
- < div className = "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3" >
218
+ < div className = "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3" >
220
219
{ scanningApps . map ( app => (
221
220
< DeepScanAppItem key = { app . id } app = { app } />
222
221
) ) }
@@ -274,18 +273,22 @@ export function DeepScanModal({
274
273
275
274
return (
276
275
< CustomTooltip tooltipBody = { statusText } >
277
- < div className = { cn ( 'flex flex-col items-center p-4 rounded-lg border transition-all min-h-[80px] ' , statusClass ) } >
276
+ < div className = { cn ( 'flex flex-col items-center p-3 rounded-lg border transition-all' , statusClass ) } >
278
277
< div className = "relative mb-2" >
279
278
< TokenIcon icon = { icon } symbol = { appName . substring ( 0 , 3 ) } size = "md" />
280
279
{ displayBadge && (
281
280
< div className = "absolute -right-2 -bottom-2" >
282
- < Badge variant = "outline" className = "bg-white h-5 min-w-5 px-0 justify-center rounded-full text-xs" >
281
+ < Badge
282
+ variant = "outline"
283
+ className = "bg-white h-5 min-w-5 px-0 justify-center rounded-full text-xs"
284
+ data-testid = "app-sync-badge"
285
+ >
283
286
{ statusIcon }
284
287
</ Badge >
285
288
</ div >
286
289
) }
287
290
</ div >
288
- < span className = "text-xs font-medium text-center leading-tight " > { appName } </ span >
291
+ < span className = "text-xs font-medium truncate max-w-full " > { appName } </ span >
289
292
</ div >
290
293
</ CustomTooltip >
291
294
)
@@ -336,37 +339,18 @@ export function DeepScanModal({
336
339
< span > All Chains</ span >
337
340
</ div >
338
341
</ SelectItem >
339
- { availableChains . map ( chain => (
340
- < SelectItem key = { chain . id } value = { chain . id } >
341
- < div className = "flex items-center gap-2" >
342
- { chain . token . logoId ? (
343
- < Image
344
- src = { `/images/logos/${ chain . token . logoId } .svg` }
345
- alt = { chain . name }
346
- width = { 20 }
347
- height = { 20 }
348
- className = "w-5 h-5"
349
- onError = { e => {
350
- e . currentTarget . style . display = 'none'
351
- } }
352
- />
353
- ) : (
354
- < Image
355
- src = { `/images/logos/${ chain . id } .svg` }
356
- alt = { chain . name }
357
- width = { 20 }
358
- height = { 20 }
359
- className = "w-5 h-5"
360
- onError = { e => {
361
- e . currentTarget . style . display = 'none'
362
- } }
363
- />
364
- ) }
365
- < span > { chain . name } </ span >
366
- < span className = "text-xs text-gray-500" > ({ chain . token . symbol } )</ span >
367
- </ div >
368
- </ SelectItem >
369
- ) ) }
342
+ { availableChains . map ( chain => {
343
+ const icon = icons [ chain . id ]
344
+ return (
345
+ < SelectItem key = { chain . id } value = { chain . id } >
346
+ < div className = "flex items-center gap-2" >
347
+ < TokenIcon icon = { icon } symbol = { chain . name . substring ( 0 , 3 ) } size = "sm" />
348
+ < span > { chain . name } </ span >
349
+ < span className = "text-xs text-gray-500" > ({ chain . token . symbol } )</ span >
350
+ </ div >
351
+ </ SelectItem >
352
+ )
353
+ } ) }
370
354
</ SelectContent >
371
355
</ Select >
372
356
</ div >
0 commit comments