mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
catch nft state on asset detail (#1601)
* catch nft state * use warnings for nft state * update disabled message * changes to messages * removed case 4 * change message title * fix similar block codeclimate * restore `error` state instead of `warning` * removed unnecessary warning state * removed warning completely
This commit is contained in:
parent
09f21eb917
commit
4baee6aaff
@ -78,7 +78,32 @@ function AssetProvider({
|
||||
'\n\nWe could not find an asset for this DID in the cache. If you just published a new asset, wait some seconds and refresh this page.'
|
||||
)
|
||||
LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
if (asset.nft.state) {
|
||||
// handle nft states as documented in https://docs.oceanprotocol.com/concepts/did-ddo/#state
|
||||
let state
|
||||
switch (asset.nft.state) {
|
||||
case 1:
|
||||
state = 'end-of-life'
|
||||
break
|
||||
case 2:
|
||||
state = 'deprecated'
|
||||
break
|
||||
case 3:
|
||||
state = 'revoked'
|
||||
break
|
||||
}
|
||||
|
||||
setTitle(`This asset has been flagged as "${state}" by the publisher`)
|
||||
setIsV3Asset(await checkV3Asset(did, token))
|
||||
setError(`\`${did}\`` + `\n\nPublisher Address: ${asset.nft.owner}`)
|
||||
LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
|
||||
return
|
||||
}
|
||||
|
||||
if (asset) {
|
||||
setError(undefined)
|
||||
setAsset((prevState) => ({
|
||||
...prevState,
|
||||
|
@ -60,7 +60,7 @@ export default function AssetContent({
|
||||
<>
|
||||
<Markdown
|
||||
className={styles.description}
|
||||
text={asset?.metadata.description || ''}
|
||||
text={asset?.metadata?.description || ''}
|
||||
/>
|
||||
<MetaSecondary ddo={asset} />
|
||||
</>
|
||||
|
@ -17,7 +17,7 @@ export default function AssetDetails({ uri }: { uri: string }): ReactElement {
|
||||
router.push(`${v3MarketUri}${uri}`)
|
||||
}
|
||||
if (!asset || error) {
|
||||
setPageTitle('Could not retrieve asset')
|
||||
setPageTitle(title || 'Could not retrieve asset')
|
||||
return
|
||||
}
|
||||
setPageTitle(isInPurgatory ? '' : title)
|
||||
@ -29,7 +29,7 @@ export default function AssetDetails({ uri }: { uri: string }): ReactElement {
|
||||
</Page>
|
||||
) : error && isV3Asset === false ? (
|
||||
<Page title={pageTitle} noPageHeader uri={uri}>
|
||||
<Alert title={pageTitle} text={error} state="error" />
|
||||
<Alert title={pageTitle} text={error} state={'error'} />
|
||||
</Page>
|
||||
) : (
|
||||
<Page title={undefined} uri={uri}>
|
||||
|
Loading…
Reference in New Issue
Block a user