Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
compute fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaisc committed May 27, 2020
1 parent 0c17247 commit ca2a0ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/hooks/useCompute/useCompute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DID, MetaDataAlgorithm, Logger } from '@oceanprotocol/squid'
import { useOcean } from '../../providers'
import { ComputeValue } from './ComputeOptions'
import { feedback } from './../../utils'
import { LoggerInstance } from '@oceanprotocol/squid/dist/node/utils/Logger'
interface UseCompute {
compute: (
did: DID | string,
Expand Down Expand Up @@ -59,15 +60,13 @@ function useCompute(): UseCompute {
owner: accountId,
secretStoreUri: config.secretStoreUri
}
Logger.debug('useCompute computeOutput', computeOutput)

const agreement = await ocean.compute
.order(account, did as string)
.next((step: number) => {
setComputeStep(step)
setComputeStepText(computeFeedback[step])
})
Logger.debug('useCompute agreement', agreement)

rawAlgorithmMeta.container = computeContainer
rawAlgorithmMeta.rawcode = algorithmRawCode
setComputeStep(4)
Expand Down
52 changes: 32 additions & 20 deletions src/hooks/useSearch/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ function useSearch(): UseSearch {
const consumed = await ocean.assets.consumerAssets(accountId)
const consumedItems = await Promise.all(
consumed.map(async (did) => {
const ddo = await ocean.assets.resolve(did)
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
try {
const ddo = await ocean.assets.resolve(did)
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
}
} catch (err) {
Logger.error(err)
}
})
)
Expand All @@ -87,25 +91,33 @@ function useSearch(): UseSearch {
const computeItems = await Promise.all(
jobList.map(async (job) => {
if (!job) return
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
job.agreementId
)

const ddo = await ocean.assets.resolve(did)
try {
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
job.agreementId
)

if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) {
return { job, ddo }
const ddo = await ocean.assets.resolve(did)
if (
did ===
'0x0000000000000000000000000000000000000000000000000000000000000000'
)
return
if (ddo) {
// Since we are getting assets from chain there might be
// assets from other marketplaces. So return only those assets
// whose serviceEndpoint contains the configured Aquarius URI.
const { serviceEndpoint } = ddo.findServiceByType('metadata')
if (serviceEndpoint?.includes(config.aquariusUri)) {
return { job, ddo }
}
}
} catch (err) {
Logger.error(err)
}
})
)
const filteredComputeItems = computeItems.filter(
(value) => typeof value.ddo !== 'undefined'
(value) => value !== undefined && typeof value.ddo !== 'undefined'
)
return filteredComputeItems
}
Expand Down

0 comments on commit ca2a0ec

Please sign in to comment.