1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-28 16:47:52 +02:00
market/src/components/Asset/AssetContent/MetaMain/MetaInfo.tsx
Moritz Kirstein 9d1b7794a3
Feat: Display NFT in asset details (#1125)
* feat: add decodeTokenUri helper

* refactor: restructure of MetaMain component

* feat: add nft tooltip

* feat: add opensea link for nfts

* style: adjust nft image size in tooltip

* feat: add nft data to publish preview

* fix: readd owner to nft metadata

* refactor: conditional display of nft tooltip

* style: fix link styles in nft tooltip

* feat: add placeholder graphic as fallback if nft data does not contain one

* fix: display openSea link only on supported networks

* fix: rename ddo props to asset in metamain related components

* feat: add original publisher to asset details

* chore: remove unused imports

* fix: remove unused prop

* feat: convert publisher address to checksum address

* chore: remove console.error when decoding tokenURI

* Revert "chore: remove console.error when decoding tokenURI"

This reverts commit f387175970.

* feat: shorten nft address in tooltip preview

* fix: use Web3.utils instead of the actual web3 instance to convert wei in ether

Co-authored-by: Luca Milanese <luca.milanese90@gmail.com>
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-03-16 19:01:51 +00:00

48 lines
1.3 KiB
TypeScript

import { Asset } from '@oceanprotocol/lib'
import AssetType from '@shared/AssetType'
import Time from '@shared/atoms/Time'
import Publisher from '@shared/Publisher'
import { getServiceByName } from '@utils/ddo'
import React, { ReactElement } from 'react'
import styles from './MetaInfo.module.css'
export default function MetaInfo({
asset,
nftPublisher
}: {
asset: Asset
nftPublisher: string
}): ReactElement {
const isCompute = Boolean(getServiceByName(asset, 'compute'))
const accessType = isCompute ? 'compute' : 'access'
const nftOwner = asset?.nft?.owner
return (
<div className={styles.wrapper}>
<AssetType
type={asset?.metadata.type}
accessType={accessType}
className={styles.assetType}
/>
<div className={styles.byline}>
<p>
Published <Time date={asset?.metadata.created} relative />
{nftPublisher && nftPublisher !== nftOwner && (
<span>
{' by '} <Publisher account={nftPublisher} />
</span>
)}
{asset?.metadata.created !== asset?.metadata.updated && (
<>
{' — '}
<span className={styles.updated}>
updated <Time date={asset?.metadata.updated} relative />
</span>
</>
)}
</p>
</div>
</div>
)
}