diff --git a/packages/extension-base/src/koni/api/nft/inscription/index.ts b/packages/extension-base/src/koni/api/nft/inscription/index.ts index a753e4d32c..fa50604d9b 100644 --- a/packages/extension-base/src/koni/api/nft/inscription/index.ts +++ b/packages/extension-base/src/koni/api/nft/inscription/index.ts @@ -50,11 +50,11 @@ export class InscriptionApi extends BaseNftApi { } private parseInsUrl (id: string, type: string) { - if (type.startsWith('audio/') || type.startsWith('text/html') || type.startsWith('image/svg') || type.startsWith('model/gltf')) { + if (type.startsWith('image/svg') || type.startsWith('model/gltf') || type.startsWith('image/gif')) { return this.createIframePreviewUrl(id); } - if (type.startsWith('video/')) { + if (type.startsWith('video/') || type.startsWith('audio/') || type.startsWith('text/html') || type.startsWith('image/png') || type.startsWith('image/jpeg') || type.startsWith('image/webp') || type.startsWith('image/gif')) { return `https://ordinals.com/content/${id}`; } @@ -63,8 +63,7 @@ export class InscriptionApi extends BaseNftApi { } if (type.startsWith('image/')) { - return `${HIRO_API.list_of_incriptions}/${id}/content`; - // return getPreviewUrl(id); + return `https://ordinals.com/content/${id}`; } return undefined; diff --git a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollectionDetail.tsx b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollectionDetail.tsx index d82fbef4c6..169d10bc7e 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollectionDetail.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollectionDetail.tsx @@ -120,11 +120,12 @@ function Component ({ className = '' }: Props): React.ReactElement { return ( diff --git a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollections.tsx b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollections.tsx index 84f3b77f63..d09ece8e38 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollections.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollections.tsx @@ -7,7 +7,7 @@ import { DataContext } from '@subwallet/extension-koni-ui/contexts/DataContext'; import { useGetNftByAccount, useNotification, useSetCurrentPage, useTranslation } from '@subwallet/extension-koni-ui/hooks'; import { reloadCron } from '@subwallet/extension-koni-ui/messaging'; import { NftGalleryWrapper } from '@subwallet/extension-koni-ui/Popup/Home/Nfts/component/NftGalleryWrapper'; -import { getTotalCollectionItems, INftCollectionDetail } from '@subwallet/extension-koni-ui/Popup/Home/Nfts/utils'; +import { ContentType, determineContentType, getContentType, getTotalCollectionItems, INftCollectionDetail } from '@subwallet/extension-koni-ui/Popup/Home/Nfts/utils'; import { RootState } from '@subwallet/extension-koni-ui/stores'; import { ThemeProps } from '@subwallet/extension-koni-ui/types'; import { ActivityIndicator, ButtonProps, Icon, SwList } from '@subwallet/react-ui'; @@ -90,11 +90,13 @@ function Component ({ className = '' }: Props): React.ReactElement { const renderNftCollection = useCallback((nftCollection: NftCollection) => { const nftList = getNftsByCollection(nftCollection); - let fallbackImage: string | undefined; + let fallbackImage: { image: string; contentType?: ContentType } | undefined; for (const nft of nftList) { // fallback to any nft image + const contentType = determineContentType(getContentType(nft?.properties)); + if (nft.image) { - fallbackImage = nft.image; + fallbackImage = { image: nft.image, contentType: contentType }; break; } } diff --git a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftItemDetail.tsx b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftItemDetail.tsx index 351c0dead1..49b8d403aa 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Nfts/NftItemDetail.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Nfts/NftItemDetail.tsx @@ -13,7 +13,7 @@ import useDefaultNavigate from '@subwallet/extension-koni-ui/hooks/router/useDef import useGetChainInfo from '@subwallet/extension-koni-ui/hooks/screen/common/useFetchChainInfo'; import useGetAccountInfoByAddress from '@subwallet/extension-koni-ui/hooks/screen/common/useGetAccountInfoByAddress'; import InscriptionImage from '@subwallet/extension-koni-ui/Popup/Home/Nfts/component/InscriptionImage'; -import { INftItemDetail, isValidJson } from '@subwallet/extension-koni-ui/Popup/Home/Nfts/utils'; +import { ContentType, determineContentType, getContentType, INftItemDetail, isValidJson } from '@subwallet/extension-koni-ui/Popup/Home/Nfts/utils'; import { RootState } from '@subwallet/extension-koni-ui/stores'; import { Theme, ThemeProps } from '@subwallet/extension-koni-ui/types'; import { BackgroundIcon, Field, Icon, Image, Logo, ModalContext, SwModal } from '@subwallet/react-ui'; @@ -146,6 +146,87 @@ function Component ({ className = '' }: Props): React.ReactElement { return false; }, [ordinalNftItem]); + const renderAppJsonContent = () => { + const ordinalNftDescription = nftItem?.description && isValidJson(nftItem.description) + ? JSON.parse(nftItem.description) as Record + : undefined; + + if (!ordinalNftDescription || Object.keys(ordinalNftDescription).length === 0) { + return ( + + ); + } + + return ( +
+
+          
+            {JSON.stringify(ordinalNftDescription, null, 2)}
+          
+        
+
+ ); + }; + + const renderNftContent = () => { + const contentType = determineContentType(getContentType(nftItem.properties)); + + switch (contentType) { + case ContentType.Audio: + return ( +
+ +
+ ); + + case ContentType.AppJson: + return renderAppJsonContent(); + + case ContentType.TextHTML: + case ContentType.ImageSVG: + case ContentType.ModelGltf: + case ContentType.ImageGIF: + return ( +
+