mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
remove v3 asset check (#1712)
This commit is contained in:
parent
74a9d074ed
commit
ccab96b0ef
@ -9,14 +9,6 @@ module.exports = {
|
|||||||
process.env.NEXT_PUBLIC_METADATACACHE_URI ||
|
process.env.NEXT_PUBLIC_METADATACACHE_URI ||
|
||||||
'https://v4.aquarius.oceanprotocol.com',
|
'https://v4.aquarius.oceanprotocol.com',
|
||||||
|
|
||||||
v3MetadataCacheUri:
|
|
||||||
process.env.NEXT_PUBLIC_V3_METADATACACHE_URI ||
|
|
||||||
'https://aquarius.oceanprotocol.com',
|
|
||||||
|
|
||||||
v3MarketUri:
|
|
||||||
process.env.NEXT_PUBLIC_V3_MARKET_URI ||
|
|
||||||
'https://v3.market.oceanprotocol.com',
|
|
||||||
|
|
||||||
// List of chainIds which metadata cache queries will return by default.
|
// List of chainIds which metadata cache queries will return by default.
|
||||||
// This preselects the Chains user preferences.
|
// This preselects the Chains user preferences.
|
||||||
chainIds: [1, 137, 56, 246, 1285],
|
chainIds: [1, 137, 56, 246, 1285],
|
||||||
|
@ -9,7 +9,7 @@ import React, {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import { Config, LoggerInstance, Purgatory } from '@oceanprotocol/lib'
|
import { Config, LoggerInstance, Purgatory } from '@oceanprotocol/lib'
|
||||||
import { CancelToken } from 'axios'
|
import { CancelToken } from 'axios'
|
||||||
import { checkV3Asset, retrieveAsset } from '@utils/aquarius'
|
import { retrieveAsset } from '@utils/aquarius'
|
||||||
import { useWeb3 } from './Web3'
|
import { useWeb3 } from './Web3'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
import { getOceanConfig, getDevelopmentConfig } from '@utils/ocean'
|
import { getOceanConfig, getDevelopmentConfig } from '@utils/ocean'
|
||||||
@ -25,7 +25,6 @@ export interface AssetProviderValue {
|
|||||||
owner: string
|
owner: string
|
||||||
error?: string
|
error?: string
|
||||||
isAssetNetwork: boolean
|
isAssetNetwork: boolean
|
||||||
isV3Asset: boolean
|
|
||||||
isOwner: boolean
|
isOwner: boolean
|
||||||
oceanConfig: Config
|
oceanConfig: Config
|
||||||
loading: boolean
|
loading: boolean
|
||||||
@ -53,7 +52,6 @@ function AssetProvider({
|
|||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [isAssetNetwork, setIsAssetNetwork] = useState<boolean>()
|
const [isAssetNetwork, setIsAssetNetwork] = useState<boolean>()
|
||||||
const [isV3Asset, setIsV3Asset] = useState<boolean>()
|
|
||||||
const [oceanConfig, setOceanConfig] = useState<Config>()
|
const [oceanConfig, setOceanConfig] = useState<Config>()
|
||||||
|
|
||||||
const newCancelToken = useCancelToken()
|
const newCancelToken = useCancelToken()
|
||||||
@ -71,7 +69,6 @@ function AssetProvider({
|
|||||||
const asset = await retrieveAsset(did, token)
|
const asset = await retrieveAsset(did, token)
|
||||||
|
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
setIsV3Asset(await checkV3Asset(did, token))
|
|
||||||
setError(
|
setError(
|
||||||
`\`${did}\`` +
|
`\`${did}\`` +
|
||||||
'\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.'
|
||||||
@ -96,7 +93,6 @@ function AssetProvider({
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTitle(`This asset has been flagged as "${state}" by the publisher`)
|
setTitle(`This asset has been flagged as "${state}" by the publisher`)
|
||||||
setIsV3Asset(await checkV3Asset(did, token))
|
|
||||||
setError(`\`${did}\`` + `\n\nPublisher Address: ${asset.nft.owner}`)
|
setError(`\`${did}\`` + `\n\nPublisher Address: ${asset.nft.owner}`)
|
||||||
LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
|
LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
|
||||||
return
|
return
|
||||||
@ -208,7 +204,6 @@ function AssetProvider({
|
|||||||
loading,
|
loading,
|
||||||
fetchAsset,
|
fetchAsset,
|
||||||
isAssetNetwork,
|
isAssetNetwork,
|
||||||
isV3Asset,
|
|
||||||
isOwner,
|
isOwner,
|
||||||
oceanConfig
|
oceanConfig
|
||||||
} as AssetProviderValue
|
} as AssetProviderValue
|
||||||
|
@ -26,8 +26,6 @@ export interface AppConfig {
|
|||||||
classNameLight: string
|
classNameLight: string
|
||||||
storageKey: string
|
storageKey: string
|
||||||
}
|
}
|
||||||
v3MetadataCacheUri: string
|
|
||||||
v3MarketUri: string
|
|
||||||
}
|
}
|
||||||
export interface SiteContent {
|
export interface SiteContent {
|
||||||
siteTitle: string
|
siteTitle: string
|
||||||
|
@ -2,7 +2,7 @@ import { Asset, LoggerInstance } from '@oceanprotocol/lib'
|
|||||||
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
||||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||||
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
||||||
import { metadataCacheUri, v3MetadataCacheUri } from '../../app.config'
|
import { metadataCacheUri } from '../../app.config'
|
||||||
import {
|
import {
|
||||||
SortDirectionOptions,
|
SortDirectionOptions,
|
||||||
SortTermOptions
|
SortTermOptions
|
||||||
@ -145,28 +145,6 @@ export async function retrieveAsset(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkV3Asset(
|
|
||||||
did: string,
|
|
||||||
cancelToken: CancelToken
|
|
||||||
): Promise<boolean> {
|
|
||||||
try {
|
|
||||||
const response: AxiosResponse<Asset> = await axios.get(
|
|
||||||
`${v3MetadataCacheUri}/api/v1/aquarius/assets/ddo/${did}`,
|
|
||||||
{ cancelToken }
|
|
||||||
)
|
|
||||||
if (!response || response.status !== 200 || !response.data) return false
|
|
||||||
|
|
||||||
return true
|
|
||||||
} catch (error) {
|
|
||||||
if (axios.isCancel(error)) {
|
|
||||||
LoggerInstance.log(error.message)
|
|
||||||
} else {
|
|
||||||
LoggerInstance.error(error.message)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAssetsNames(
|
export async function getAssetsNames(
|
||||||
didList: string[],
|
didList: string[],
|
||||||
cancelToken: CancelToken
|
cancelToken: CancelToken
|
||||||
|
@ -5,29 +5,25 @@ import Alert from '@shared/atoms/Alert'
|
|||||||
import Loader from '@shared/atoms/Loader'
|
import Loader from '@shared/atoms/Loader'
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
import AssetContent from './AssetContent'
|
import AssetContent from './AssetContent'
|
||||||
import { v3MarketUri } from 'app.config'
|
|
||||||
|
|
||||||
export default function AssetDetails({ uri }: { uri: string }): ReactElement {
|
export default function AssetDetails({ uri }: { uri: string }): ReactElement {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { asset, title, error, isInPurgatory, loading, isV3Asset } = useAsset()
|
const { asset, title, error, isInPurgatory, loading } = useAsset()
|
||||||
const [pageTitle, setPageTitle] = useState<string>()
|
const [pageTitle, setPageTitle] = useState<string>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isV3Asset) {
|
|
||||||
router.push(`${v3MarketUri}${uri}`)
|
|
||||||
}
|
|
||||||
if (!asset || error) {
|
if (!asset || error) {
|
||||||
setPageTitle(title || 'Could not retrieve asset')
|
setPageTitle(title || 'Could not retrieve asset')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setPageTitle(isInPurgatory ? '' : title)
|
setPageTitle(isInPurgatory ? '' : title)
|
||||||
}, [asset, error, isInPurgatory, isV3Asset, router, title, uri])
|
}, [asset, error, isInPurgatory, router, title, uri])
|
||||||
|
|
||||||
return asset && pageTitle !== undefined && !loading ? (
|
return asset && pageTitle !== undefined && !loading ? (
|
||||||
<Page title={pageTitle} uri={uri}>
|
<Page title={pageTitle} uri={uri}>
|
||||||
<AssetContent asset={asset} />
|
<AssetContent asset={asset} />
|
||||||
</Page>
|
</Page>
|
||||||
) : error && isV3Asset === false ? (
|
) : error ? (
|
||||||
<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>
|
||||||
|
Loading…
Reference in New Issue
Block a user