1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-23 02:00:27 +01:00

metadata fallback hitting MetadataStore directly

This commit is contained in:
Matthias Kretschmann 2020-07-21 13:40:32 +02:00
parent 4684f30df5
commit d1f10f4a2a
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 17 additions and 6 deletions

View File

@ -1,8 +1,7 @@
import { useState } from 'react'
import { useOcean } from '../../providers'
import { feedback } from '../../utils'
import { DID, Logger } from '@oceanprotocol/lib'
import { ServiceType } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Service'
import { DID, Logger, ServiceType } from '@oceanprotocol/lib'
interface UseConsume {
consume: (

View File

@ -1,6 +1,12 @@
import { useState, useEffect } from 'react'
import axios from 'axios'
import { DID, DDO, Metadata } from '@oceanprotocol/lib'
import {
DID,
DDO,
Metadata,
MetadataStore,
Logger,
ConfigHelper
} from '@oceanprotocol/lib'
import { useOcean } from '../../providers'
import ProviderStatus from '../../providers/OceanProvider/ProviderStatus'
@ -20,9 +26,15 @@ function useMetadata(did?: DID | string): UseMetadata {
const [title, setTitle] = useState<string | undefined>()
async function getDDO(did: DID | string): Promise<DDO> {
if (status !== ProviderStatus.CONNECTED) return
if (status === ProviderStatus.CONNECTED) {
const ddo = await ocean.metadatastore.retrieveDDO(did)
return ddo
}
const ddo = await ocean.metadatastore.retrieveDDO(did)
// fallback hitting MetadataStore directly
const { metadataStoreUri } = new ConfigHelper()
const metadataStore = new MetadataStore(metadataStoreUri, Logger)
const ddo = await metadataStore.retrieveDDO(did)
return ddo
}