mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix asset route (#1836)
This commit is contained in:
parent
3c9dd3bbd0
commit
686f4d1803
@ -16,6 +16,7 @@ import { getOceanConfig, getDevelopmentConfig } from '@utils/ocean'
|
|||||||
import { getAccessDetails } from '@utils/accessDetailsAndPricing'
|
import { getAccessDetails } from '@utils/accessDetailsAndPricing'
|
||||||
import { useIsMounted } from '@hooks/useIsMounted'
|
import { useIsMounted } from '@hooks/useIsMounted'
|
||||||
import { useMarketMetadata } from './MarketMetadata'
|
import { useMarketMetadata } from './MarketMetadata'
|
||||||
|
import { isValidDid } from '@utils/ddo'
|
||||||
|
|
||||||
export interface AssetProviderValue {
|
export interface AssetProviderValue {
|
||||||
isInPurgatory: boolean
|
isInPurgatory: boolean
|
||||||
@ -63,6 +64,13 @@ function AssetProvider({
|
|||||||
const fetchAsset = useCallback(
|
const fetchAsset = useCallback(
|
||||||
async (token?: CancelToken) => {
|
async (token?: CancelToken) => {
|
||||||
if (!did) return
|
if (!did) return
|
||||||
|
const isDid = isValidDid(did)
|
||||||
|
|
||||||
|
if (!isDid) {
|
||||||
|
setError(`The url is not for a valid DID`)
|
||||||
|
LoggerInstance.error(`[asset] Not a valid DID`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
LoggerInstance.log('[asset] Fetching asset...')
|
LoggerInstance.log('[asset] Fetching asset...')
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
||||||
|
|
||||||
|
export function isValidDid(did: string): boolean {
|
||||||
|
const regex = /did:op:[A-Za-z0-9]{64}/
|
||||||
|
return regex.test(did)
|
||||||
|
}
|
||||||
|
|
||||||
export function getServiceByName(
|
export function getServiceByName(
|
||||||
ddo: Asset | DDO,
|
ddo: Asset | DDO,
|
||||||
name: 'access' | 'compute'
|
name: 'access' | 'compute'
|
||||||
|
Loading…
Reference in New Issue
Block a user