diff --git a/apps/core/src/constants/coins.constants.ts b/apps/core/src/constants/coins.constants.ts index 11fba0c12a0..b0e38e586cd 100644 --- a/apps/core/src/constants/coins.constants.ts +++ b/apps/core/src/constants/coins.constants.ts @@ -3,3 +3,4 @@ export const COINS_QUERY_REFETCH_INTERVAL = 20_000; export const COINS_QUERY_STALE_TIME = 20_000; +export const COIN_TYPE = '0x2::coin::Coin'; diff --git a/apps/wallet-dashboard/app/(protected)/assets/page.tsx b/apps/wallet-dashboard/app/(protected)/assets/page.tsx index 7007cc86c5c..9af8669a717 100644 --- a/apps/wallet-dashboard/app/(protected)/assets/page.tsx +++ b/apps/wallet-dashboard/app/(protected)/assets/page.tsx @@ -4,7 +4,7 @@ 'use client'; import { Panel, Title, Chip, TitleSize } from '@iota/apps-ui-kit'; -import { hasDisplayData, useGetOwnedObjects } from '@iota/core'; +import { COIN_TYPE, hasDisplayData, useGetOwnedObjects } from '@iota/core'; import { useCurrentAccount } from '@iota/dapp-kit'; import { IotaObjectData } from '@iota/iota-sdk/client'; import { useState } from 'react'; @@ -31,25 +31,28 @@ export default function AssetsDashboardPage(): React.JSX.Element { const account = useCurrentAccount(); const { data, isFetching, fetchNextPage, hasNextPage, refetch } = useGetOwnedObjects( account?.address, - undefined, + { + MatchNone: [{ StructType: COIN_TYPE }], + }, OBJECTS_PER_REQ, ); - const assets: IotaObjectData[] = []; - - for (const page of data?.pages || []) { - for (const asset of page.data) { - if (asset.data && asset.data.objectId) { - if (selectedCategory == AssetCategory.Visual) { - if (hasDisplayData(asset)) { - assets.push(asset.data); - } - } else if (selectedCategory == AssetCategory.Other) { - assets.push(asset.data); - } + const assets = (data?.pages || []) + .flatMap((page) => page.data) + .filter((asset) => { + if (!asset.data || !asset.data.objectId) { + return false; } - } - } + if (selectedCategory === AssetCategory.Visual) { + return hasDisplayData(asset); + } + if (selectedCategory === AssetCategory.Other) { + return !hasDisplayData(asset); + } + return false; + }) + .map((asset) => asset.data) + .filter((data): data is IotaObjectData => data !== null && data !== undefined); function onAssetClick(asset: IotaObjectData) { setSelectedAsset(asset); diff --git a/apps/wallet-dashboard/components/tiles/AssetTileLink.tsx b/apps/wallet-dashboard/components/tiles/AssetTileLink.tsx index 64c4d805513..6d5d25d23b7 100644 --- a/apps/wallet-dashboard/components/tiles/AssetTileLink.tsx +++ b/apps/wallet-dashboard/components/tiles/AssetTileLink.tsx @@ -25,7 +25,7 @@ export function AssetTileLink({ asset, type, onClick }: AssetTileLinkProps): Rea {type === AssetCategory.Visual ? ( } onClick={handleClick} /> ) : ( - + )} ); diff --git a/apps/wallet-dashboard/components/tiles/NonVisualAssetTile.tsx b/apps/wallet-dashboard/components/tiles/NonVisualAssetTile.tsx index 0758714510e..c73c519bcd9 100644 --- a/apps/wallet-dashboard/components/tiles/NonVisualAssetTile.tsx +++ b/apps/wallet-dashboard/components/tiles/NonVisualAssetTile.tsx @@ -5,21 +5,25 @@ import { Card, CardAction, CardActionType, CardBody, CardType } from '@iota/apps import { IotaObjectData } from '@iota/iota-sdk/client'; import { formatAddress, parseStructTag } from '@iota/iota-sdk/utils'; import { ArrowTopRight } from '@iota/ui-icons'; +import { ExplorerLink } from '../ExplorerLink'; +import { ExplorerLinkType } from '@iota/core'; type NonVisualAssetCardProps = { asset: IotaObjectData; -} & Pick, 'onClick'>; +} & React.ComponentProps; -export function NonVisualAssetCard({ asset, onClick }: NonVisualAssetCardProps): React.JSX.Element { +export function NonVisualAssetCard({ asset }: NonVisualAssetCardProps): React.JSX.Element { const { address, module, name } = parseStructTag(asset.type!); return ( - - - } /> - + + + + } /> + + ); }