mirror of
https://github.com/oceanprotocol/react.git
synced 2024-11-22 17:50:15 +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 { ComputeValue } from './ComputeOptions'
|
||||
import { feedback } from './../../utils'
|
||||
import { LoggerInstance } from '@oceanprotocol/squid/dist/node/utils/Logger'
|
||||
interface UseCompute {
|
||||
compute: (
|
||||
did: DID | string,
|
||||
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
})
|
||||
)
|
||||
@ -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
|
||||
)
|
||||
try {
|
||||
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
|
||||
job.agreementId
|
||||
)
|
||||
|
||||
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 { 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user