mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Use asset's ddo.purgatory (#1006)
* set purgatory state * merge v4 changes, use ddo.purgatory * delete commented code, fix verification * unused files and function deleted, small fix * comment removed * use purgatory.state for filtering assets * remove unnecessary check Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com>
This commit is contained in:
parent
2622a807f6
commit
42323cb8c4
@ -8,7 +8,6 @@ import React, {
|
||||
ReactNode
|
||||
} from 'react'
|
||||
import { Asset, Config, LoggerInstance, Purgatory } from '@oceanprotocol/lib'
|
||||
import getAssetPurgatoryData from '@utils/purgatory'
|
||||
import { CancelToken } from 'axios'
|
||||
import { retrieveDDO } from '@utils/aquarius'
|
||||
import { getPrice } from '@utils/subgraph'
|
||||
@ -83,19 +82,6 @@ function AssetProvider({
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
const setPurgatory = useCallback(async (did: string): Promise<void> => {
|
||||
if (!did) return
|
||||
|
||||
try {
|
||||
const result = await getAssetPurgatoryData(did)
|
||||
const isInPurgatory = result?.state === true
|
||||
setIsInPurgatory(isInPurgatory)
|
||||
isInPurgatory && setPurgatoryData(result)
|
||||
} catch (error) {
|
||||
LoggerInstance.error(error)
|
||||
}
|
||||
}, [])
|
||||
|
||||
// -----------------------------------
|
||||
// Get and set DDO based on passed DID
|
||||
// -----------------------------------
|
||||
@ -111,9 +97,9 @@ function AssetProvider({
|
||||
setDDO(ddo)
|
||||
setTitle(ddo.metadata.name)
|
||||
setOwner(ddo.nft.owner)
|
||||
// TODO: restore asset purgatory once Aquarius supports it, ref #953
|
||||
// setIsInPurgatory(ddo.purgatory.state === true)
|
||||
await setPurgatory(ddo.id)
|
||||
setIsInPurgatory(ddo.purgatory?.state)
|
||||
setPurgatoryData(ddo.purgatory)
|
||||
// setPurgatory(ddo.purgatory)
|
||||
}
|
||||
init()
|
||||
return () => {
|
||||
|
@ -48,7 +48,7 @@ export function generateBaseQuery(
|
||||
getFilterTerm('_index', 'aquarius'),
|
||||
...(baseQueryParams.ignorePurgatory
|
||||
? []
|
||||
: [getFilterTerm('stats.isInPurgatory', 'false')])
|
||||
: [getFilterTerm('purgatory.state', 'false')])
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -8,16 +8,6 @@ export interface PurgatoryDataAccount {
|
||||
reason: string
|
||||
}
|
||||
|
||||
export default async function getAssetPurgatoryData(
|
||||
did: string
|
||||
): Promise<Purgatory> {
|
||||
const data = (await fetchData(
|
||||
`${purgatoryUrl}asset?did=${did}`
|
||||
)) as Purgatory[]
|
||||
|
||||
return { state: data[0]?.state, reason: data[0]?.reason }
|
||||
}
|
||||
|
||||
export async function getAccountPurgatoryData(
|
||||
address: string
|
||||
): Promise<PurgatoryDataAccount> {
|
||||
|
@ -35,9 +35,9 @@ export default function AssetContent({
|
||||
<div>
|
||||
<div className={styles.content}>
|
||||
<MetaMain ddo={ddo} />
|
||||
{price?.datatoken && <Bookmark did={ddo?.id} />}
|
||||
{price?.datatoken !== null && <Bookmark did={ddo?.id} />}
|
||||
|
||||
{isInPurgatory ? (
|
||||
{isInPurgatory === true ? (
|
||||
<Alert
|
||||
title={content.asset.title}
|
||||
badge={`Reason: ${purgatoryData?.reason}`}
|
||||
@ -55,10 +55,8 @@ export default function AssetContent({
|
||||
)}
|
||||
|
||||
<MetaFull ddo={ddo} />
|
||||
{price?.datatoken && <EditHistory />}
|
||||
{price?.datatoken && debug === true && (
|
||||
<DebugOutput title="DDO" output={ddo} />
|
||||
)}
|
||||
<EditHistory />
|
||||
{debug === true && <DebugOutput title="DDO" output={ddo} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user