mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
compute fix
This commit is contained in:
parent
0c1724726c
commit
ca2a0ec0d4
@ -3,6 +3,7 @@ import { DID, MetaDataAlgorithm, Logger } from '@oceanprotocol/squid'
|
|||||||
import { useOcean } from '../../providers'
|
import { useOcean } from '../../providers'
|
||||||
import { ComputeValue } from './ComputeOptions'
|
import { ComputeValue } from './ComputeOptions'
|
||||||
import { feedback } from './../../utils'
|
import { feedback } from './../../utils'
|
||||||
|
import { LoggerInstance } from '@oceanprotocol/squid/dist/node/utils/Logger'
|
||||||
interface UseCompute {
|
interface UseCompute {
|
||||||
compute: (
|
compute: (
|
||||||
did: DID | string,
|
did: DID | string,
|
||||||
@ -59,15 +60,13 @@ function useCompute(): UseCompute {
|
|||||||
owner: accountId,
|
owner: accountId,
|
||||||
secretStoreUri: config.secretStoreUri
|
secretStoreUri: config.secretStoreUri
|
||||||
}
|
}
|
||||||
Logger.debug('useCompute computeOutput', computeOutput)
|
|
||||||
|
|
||||||
const agreement = await ocean.compute
|
const agreement = await ocean.compute
|
||||||
.order(account, did as string)
|
.order(account, did as string)
|
||||||
.next((step: number) => {
|
.next((step: number) => {
|
||||||
setComputeStep(step)
|
setComputeStep(step)
|
||||||
setComputeStepText(computeFeedback[step])
|
setComputeStepText(computeFeedback[step])
|
||||||
})
|
})
|
||||||
Logger.debug('useCompute agreement', agreement)
|
|
||||||
rawAlgorithmMeta.container = computeContainer
|
rawAlgorithmMeta.container = computeContainer
|
||||||
rawAlgorithmMeta.rawcode = algorithmRawCode
|
rawAlgorithmMeta.rawcode = algorithmRawCode
|
||||||
setComputeStep(4)
|
setComputeStep(4)
|
||||||
|
@ -65,13 +65,17 @@ function useSearch(): UseSearch {
|
|||||||
const consumed = await ocean.assets.consumerAssets(accountId)
|
const consumed = await ocean.assets.consumerAssets(accountId)
|
||||||
const consumedItems = await Promise.all(
|
const consumedItems = await Promise.all(
|
||||||
consumed.map(async (did) => {
|
consumed.map(async (did) => {
|
||||||
const ddo = await ocean.assets.resolve(did)
|
try {
|
||||||
if (ddo) {
|
const ddo = await ocean.assets.resolve(did)
|
||||||
// Since we are getting assets from chain there might be
|
if (ddo) {
|
||||||
// assets from other marketplaces. So return only those assets
|
// Since we are getting assets from chain there might be
|
||||||
// whose serviceEndpoint contains the configured Aquarius URI.
|
// assets from other marketplaces. So return only those assets
|
||||||
const { serviceEndpoint } = ddo.findServiceByType('metadata')
|
// whose serviceEndpoint contains the configured Aquarius URI.
|
||||||
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
|
const { serviceEndpoint } = ddo.findServiceByType('metadata')
|
||||||
|
if (serviceEndpoint?.includes(config.aquariusUri)) return ddo
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
Logger.error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -87,25 +91,33 @@ function useSearch(): UseSearch {
|
|||||||
const computeItems = await Promise.all(
|
const computeItems = await Promise.all(
|
||||||
jobList.map(async (job) => {
|
jobList.map(async (job) => {
|
||||||
if (!job) return
|
if (!job) return
|
||||||
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
|
try {
|
||||||
job.agreementId
|
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
|
||||||
)
|
job.agreementId
|
||||||
|
)
|
||||||
|
|
||||||
const ddo = await ocean.assets.resolve(did)
|
const ddo = await ocean.assets.resolve(did)
|
||||||
|
if (
|
||||||
if (ddo) {
|
did ===
|
||||||
// Since we are getting assets from chain there might be
|
'0x0000000000000000000000000000000000000000000000000000000000000000'
|
||||||
// assets from other marketplaces. So return only those assets
|
)
|
||||||
// whose serviceEndpoint contains the configured Aquarius URI.
|
return
|
||||||
const { serviceEndpoint } = ddo.findServiceByType('metadata')
|
if (ddo) {
|
||||||
if (serviceEndpoint?.includes(config.aquariusUri)) {
|
// Since we are getting assets from chain there might be
|
||||||
return { job, ddo }
|
// 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(
|
const filteredComputeItems = computeItems.filter(
|
||||||
(value) => typeof value.ddo !== 'undefined'
|
(value) => value !== undefined && typeof value.ddo !== 'undefined'
|
||||||
)
|
)
|
||||||
return filteredComputeItems
|
return filteredComputeItems
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user