1
0
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:
EnzoVezzaro 2022-07-26 07:48:30 -04:00 committed by GitHub
parent 09f21eb917
commit 4baee6aaff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 4 deletions

View File

@ -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.' '\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) 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) setError(undefined)
setAsset((prevState) => ({ setAsset((prevState) => ({
...prevState, ...prevState,

View File

@ -60,7 +60,7 @@ export default function AssetContent({
<> <>
<Markdown <Markdown
className={styles.description} className={styles.description}
text={asset?.metadata.description || ''} text={asset?.metadata?.description || ''}
/> />
<MetaSecondary ddo={asset} /> <MetaSecondary ddo={asset} />
</> </>

View File

@ -17,7 +17,7 @@ export default function AssetDetails({ uri }: { uri: string }): ReactElement {
router.push(`${v3MarketUri}${uri}`) router.push(`${v3MarketUri}${uri}`)
} }
if (!asset || error) { if (!asset || error) {
setPageTitle('Could not retrieve asset') setPageTitle(title || 'Could not retrieve asset')
return return
} }
setPageTitle(isInPurgatory ? '' : title) setPageTitle(isInPurgatory ? '' : title)
@ -29,7 +29,7 @@ export default function AssetDetails({ uri }: { uri: string }): ReactElement {
</Page> </Page>
) : error && isV3Asset === false ? ( ) : error && isV3Asset === false ? (
<Page title={pageTitle} noPageHeader uri={uri}> <Page title={pageTitle} noPageHeader uri={uri}>
<Alert title={pageTitle} text={error} state="error" /> <Alert title={pageTitle} text={error} state={'error'} />
</Page> </Page>
) : ( ) : (
<Page title={undefined} uri={uri}> <Page title={undefined} uri={uri}>