1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-02-14 21:10:38 +01:00

update compute

This commit is contained in:
Matthias Kretschmann 2020-10-09 20:47:03 +02:00
parent 803c5f9717
commit 232e08e177
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -1,7 +1,7 @@
import { useState } from 'react' import { useState } from 'react'
import { useOcean } from 'providers' import { useOcean } from 'providers'
import { ComputeValue } from './ComputeOptions' import { ComputeValue } from './ComputeOptions'
import { Logger } from '@oceanprotocol/lib' import { Logger, ServiceCompute } from '@oceanprotocol/lib'
import { MetadataAlgorithm } from '@oceanprotocol/lib/dist/node/ddo/interfaces/MetadataAlgorithm' import { MetadataAlgorithm } from '@oceanprotocol/lib/dist/node/ddo/interfaces/MetadataAlgorithm'
import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/ComputeJob' import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/ComputeJob'
import { checkAndBuyDT } from 'utils/dtUtils' import { checkAndBuyDT } from 'utils/dtUtils'
@ -9,10 +9,11 @@ import { checkAndBuyDT } from 'utils/dtUtils'
interface UseCompute { interface UseCompute {
compute: ( compute: (
did: string, did: string,
computeService: any, computeService: ServiceCompute,
dataTokenAddress: string, dataTokenAddress: string,
algorithmRawCode: string, algorithmRawCode: string,
computeContainer: ComputeValue computeContainer: ComputeValue,
marketFeeAddress: string
) => Promise<ComputeJob | void> ) => Promise<ComputeJob | void>
computeStep?: number computeStep?: number
computeStepText?: string computeStepText?: string
@ -57,10 +58,11 @@ function useCompute(): UseCompute {
async function compute( async function compute(
did: string, did: string,
computeService: any, computeService: ServiceCompute,
dataTokenAddress: string, dataTokenAddress: string,
algorithmRawCode: string, algorithmRawCode: string,
computeContainer: ComputeValue computeContainer: ComputeValue,
marketFeeAddress: string
): Promise<ComputeJob | void> { ): Promise<ComputeJob | void> {
if (!ocean || !account) return if (!ocean || !account) return
@ -80,14 +82,16 @@ function useCompute(): UseCompute {
accountId, accountId,
did, did,
computeService, computeService,
rawAlgorithmMeta rawAlgorithmMeta,
marketFeeAddress
) )
const tokenTransfer = await ocean.compute.order( const tokenTransfer = await ocean.compute.order(
accountId, accountId,
did, did,
computeService.index, computeService.index,
undefined, undefined,
rawAlgorithmMeta rawAlgorithmMeta,
marketFeeAddress
) )
setStep(1) setStep(1)
@ -108,7 +112,7 @@ function useCompute(): UseCompute {
undefined, undefined,
rawAlgorithmMeta, rawAlgorithmMeta,
output, output,
computeService.index, `${computeService.index}`,
computeService.type computeService.type
) )
return response return response