Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0aaaee5
feat: grouped asset beginning
NeOMakinG Aug 27, 2025
7844241
fix: review feedbacks
NeOMakinG Aug 28, 2025
daa36c4
Merge branch 'develop' into grouped-assets
NeOMakinG Aug 28, 2025
716e0e8
feat: continue
NeOMakinG Aug 29, 2025
c1bc489
fix: review feedbacks
NeOMakinG Aug 29, 2025
92e73f6
feat: finish but hey need cleanup ffs
NeOMakinG Sep 1, 2025
3b1be2b
fix: review feedbacks
NeOMakinG Sep 1, 2025
316e1af
fix: review feedbacks
NeOMakinG Sep 1, 2025
538d83d
Merge branch 'develop' into grouped-assets
NeOMakinG Sep 1, 2025
c542870
chore: trigger ci
NeOMakinG Sep 1, 2025
698bf99
fix: review feedbacks
NeOMakinG Sep 1, 2025
4537aae
fix: review feedbacks
NeOMakinG Sep 2, 2025
69ca5df
fix: more longpress
NeOMakinG Sep 2, 2025
e438d48
fix: review feedbacks
NeOMakinG Sep 2, 2025
21e87eb
fix: fixes
NeOMakinG Sep 2, 2025
6475820
fix: wip related assets base
NeOMakinG Sep 2, 2025
13e68eb
fix: attempt at slices
NeOMakinG Sep 3, 2025
157b534
fix: working ffs
NeOMakinG Sep 4, 2025
046781c
fix: review feedbacks
NeOMakinG Sep 4, 2025
3d9127c
fix: review feedbacks
NeOMakinG Sep 4, 2025
2447eb5
fix: type check
NeOMakinG Sep 4, 2025
4843ee6
fix: review feedbacks
NeOMakinG Sep 4, 2025
8974452
chore: trigger ci
NeOMakinG Sep 4, 2025
e7280c7
fix: review feedbacks
NeOMakinG Sep 4, 2025
5f61f6f
Merge branch 'develop' into grouped-assets
NeOMakinG Sep 5, 2025
09cab7e
fix: review feedbacks
NeOMakinG Sep 5, 2025
fda4b3d
fix: tests
NeOMakinG Sep 5, 2025
556bd19
fix: review feedbacks
NeOMakinG Sep 5, 2025
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
"react-helmet-async": "^1.3.0",
"react-hook-form": "^7.51.5",
"react-icons": "^5.5.0",
"react-infinite-scroll-component": "^6.1.0",
"react-intersection-observer": "^9.13.1",
"react-multi-ref": "^1.0.1",
"react-number-format": "^4.9.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export type Asset = {
explorerTxLink: string
explorerAddressLink: string
relatedAssetKey: AssetId | null | undefined
isPrimary?: boolean
isChainSpecific?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: wat dis?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asset that is only one one chain, it's needed to discriminate as primary assets without related assets might have relatedAssetKey as null

isPool?: boolean
}

Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/assetData/decodeAssetData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const decodeAssetData = (
asset.name = `${asset.name} on ${baseAsset.networkName}`
}
asset.relatedAssetKey = relatedAssetId
asset.isPrimary = relatedAssetId === null || relatedAssetId === asset.assetId
asset.isChainSpecific = relatedAssetId === null
break
}
case 'name':
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/makeAsset/makeAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ export const makeAsset = (
color,
icon,
relatedAssetKey: null,
isPrimary: true,
isChainSpecific: true,
})
}
3 changes: 3 additions & 0 deletions src/components/AssetSearch/AssetSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export type AssetSearchProps = {
onAssetClick?: (asset: Asset) => void
formProps?: BoxProps
allowWalletUnsupportedAssets?: boolean
showRelatedAssets?: boolean
}
export const AssetSearch: FC<AssetSearchProps> = ({
assets,
onAssetClick,
formProps,
allowWalletUnsupportedAssets,
showRelatedAssets,
}) => {
const translate = useTranslate()
const navigate = useNavigate()
Expand Down Expand Up @@ -134,6 +136,7 @@ export const AssetSearch: FC<AssetSearchProps> = ({
assets={listAssets}
handleClick={handleClick}
disableUnsupported={!allowWalletUnsupportedAssets}
showRelatedAssets={showRelatedAssets}
/>
</Box>
</>
Expand Down
48 changes: 39 additions & 9 deletions src/components/AssetSearch/components/AssetList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { ListProps } from '@chakra-ui/react'
import { Center, Flex, Icon, Skeleton } from '@chakra-ui/react'
import { Box, Center, Flex, Icon, Skeleton } from '@chakra-ui/react'
import type { Asset } from '@shapeshiftoss/types'
import { range } from 'lodash'
import type { CSSProperties, FC } from 'react'
import { useCallback, useMemo } from 'react'
import { FaRegCompass } from 'react-icons/fa6'
import { Virtuoso } from 'react-virtuoso'

import type { AssetRowData } from './AssetRow'
import { AssetRow } from './AssetRow'

import { Text } from '@/components/Text'
Expand All @@ -18,10 +19,12 @@ export type AssetData = {
handleLongPress?: (asset: Asset) => void
disableUnsupported?: boolean
hideZeroBalanceAmounts?: boolean
rowComponent?: FC<{ asset: Asset; index: number; data: AssetData }>
rowComponent?: FC<AssetRowData>
isLoading?: boolean
portalsAssets?: PortalsAssets
height?: string
showPrice?: boolean
onImportClick?: (asset: Asset) => void
showRelatedAssets?: boolean
}

type AssetListProps = AssetData & ListProps
Expand All @@ -31,7 +34,7 @@ const scrollbarStyle: CSSProperties = {
msOverflowStyle: 'none',
}

const INCREASE_VIEWPORT_BY = { top: 100, bottom: 100 } as const
export const INCREASE_VIEWPORT_BY = { top: 300, bottom: 100 } as const

export const AssetList: FC<AssetListProps> = ({
assets,
Expand All @@ -42,11 +45,14 @@ export const AssetList: FC<AssetListProps> = ({
rowComponent = AssetRow,
isLoading = false,
portalsAssets,
showPrice = false,
height = '50vh',
onImportClick,
showRelatedAssets = false,
}) => {
const virtuosoStyle = useMemo(
() => ({
height,
height: typeof height === 'string' ? height : `${height}px`,
...scrollbarStyle,
}),
[height],
Expand All @@ -60,6 +66,8 @@ export const AssetList: FC<AssetListProps> = ({
disableUnsupported,
hideZeroBalanceAmounts,
portalsAssets,
onImportClick,
showRelatedAssets,
}),
[
assets,
Expand All @@ -68,21 +76,33 @@ export const AssetList: FC<AssetListProps> = ({
handleLongPress,
hideZeroBalanceAmounts,
portalsAssets,
onImportClick,
showRelatedAssets,
],
)

const renderRow = useCallback(
(index: number) => {
const asset = assets[index]
const RowComponent = rowComponent
return <RowComponent asset={asset} index={index} data={itemData} />

return (
<RowComponent
asset={asset}
index={index}
data={itemData}
showPrice={showPrice}
onImportClick={onImportClick}
showRelatedAssets={showRelatedAssets}
/>
)
},
[assets, itemData, rowComponent],
[assets, itemData, rowComponent, showPrice, onImportClick, showRelatedAssets],
)

if (isLoading) {
return (
<Flex flexDir='column' width='100%' overflowY='auto' flex='1' minHeight={0} mt={4}>
<Flex flexDir='column' width='100%' overflowY='auto' flex='1' minHeight={0} mt={4} px={2}>
{range(3).map(index => (
<Flex key={index} align='center' width='100%' justifyContent='space-between' mb={4}>
<Flex align='center'>
Expand Down Expand Up @@ -111,12 +131,22 @@ export const AssetList: FC<AssetListProps> = ({
)
}

if (assets.length <= 10) {
return (
<Box maxHeight={height} overflow='auto' height='auto'>
{assets.map((asset, index) => (
<Box key={asset.assetId}>{renderRow(index)}</Box>
))}
</Box>
)
}

return (
<Virtuoso
data={assets}
itemContent={renderRow}
style={virtuosoStyle}
overscan={200}
overscan={1000}
increaseViewportBy={INCREASE_VIEWPORT_BY}
/>
)
Expand Down
Loading
Loading