mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-28 16:47:52 +02:00
* 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>
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
import Copy from '@shared/atoms/Copy'
|
|
import External from '@images/external.svg'
|
|
import ExplorerLink from '@shared/ExplorerLink'
|
|
import { NftMetadata } from '@utils/nft'
|
|
import React, { ReactElement } from 'react'
|
|
import styles from './NftTooltip.module.css'
|
|
import explorerLinkStyles from '@shared/ExplorerLink/index.module.css'
|
|
import { accountTruncate } from '@utils/web3'
|
|
|
|
export default function NftTooltip({
|
|
nft,
|
|
address,
|
|
chainId,
|
|
isBlockscoutExplorer
|
|
}: {
|
|
nft: NftMetadata
|
|
address: string
|
|
chainId: number
|
|
isBlockscoutExplorer: boolean
|
|
}): ReactElement {
|
|
// Currently Ocean NFTs are not displayed correctly on OpenSea
|
|
// Code prepared to easily integrate this feature once this is fixed
|
|
//
|
|
// Supported OpeanSea networks:
|
|
// https://support.opensea.io/hc/en-us/articles/4404027708051-Which-blockchains-does-OpenSea-support-
|
|
const openseaNetworks = [1, 137]
|
|
const openseaTestNetworks = [4]
|
|
const openSeaSupported = openseaNetworks
|
|
.concat(openseaTestNetworks)
|
|
.includes(chainId)
|
|
|
|
const openSeaBaseUri = openSeaSupported
|
|
? openseaTestNetworks.includes(chainId)
|
|
? 'https://testnets.opensea.io'
|
|
: 'https://opensea.io'
|
|
: undefined
|
|
|
|
return (
|
|
<div className={styles.wrapper}>
|
|
{nft && <img src={nft.image_data} alt={nft?.name} />}
|
|
<div className={styles.info}>
|
|
{nft && <h5>{nft.name}</h5>}
|
|
{address && (
|
|
<span title={address} className={styles.address}>
|
|
{accountTruncate(address)} <Copy text={address} />
|
|
</span>
|
|
)}
|
|
<div className={styles.links}>
|
|
{address && (
|
|
<ExplorerLink
|
|
networkId={chainId}
|
|
path={
|
|
isBlockscoutExplorer ? `tokens/${address}` : `token/${address}`
|
|
}
|
|
>
|
|
View on explorer
|
|
</ExplorerLink>
|
|
)}
|
|
|
|
{openSeaSupported && nft && address && (
|
|
<a
|
|
href={`${openSeaBaseUri}/assets/${address}/1`}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className={explorerLinkStyles.link}
|
|
>
|
|
View on OpeanSea <External />
|
|
</a>
|
|
)}
|
|
</div>
|
|
{!nft?.image_data && (
|
|
<p className={styles.fallback}>
|
|
This Data NFT was not created on Ocean Market
|
|
</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|