1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-13 16:54:53 +01:00

Refactor compute methods calls (#502)

* prepare compute for oceanJs method refactor

* bump oceanjs to 0.14.0
This commit is contained in:
Bogdan Fazakas 2021-04-14 10:21:59 +03:00 committed by GitHub
parent fa53b024fa
commit b87d50aa09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 18 deletions

8
package-lock.json generated
View File

@ -3625,9 +3625,9 @@
"integrity": "sha512-0dasqU7PL8xZOxvn6ID2IJ6TgQZbkcwtZqiMiYvtsv9+fQr/n13qXYXwkmNEjQb3YL4IeSVUnHehk5KpGRPFWA=="
},
"@oceanprotocol/lib": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.13.0.tgz",
"integrity": "sha512-+LoN16bo1hcqfxsxLV22ZEbObdif0RJXg5GlndlF/VQGNVrSm+XYxUp+si5HCWa8sBeYH/hOSQRnrD8YXnyWrw==",
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.14.0.tgz",
"integrity": "sha512-0CxrhQuu9tA4HNzytPDEGd+8ceCdFDSPuQJivvnuOH3GWtZNgfJb9wyQnl0YHQgdtWWHkIcnnPL0NsAXKLF+ew==",
"requires": {
"@ethereum-navigator/navigator": "^0.5.2",
"@oceanprotocol/contracts": "^0.5.10",
@ -16704,7 +16704,7 @@
}
},
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1ce6a1d64235fabe2aaf827fd606def55693508f",
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1a27c59c15ab1e95ee8e5c4ed6ad814c49cc439e",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": {
"bn.js": "^4.11.8",

View File

@ -27,7 +27,7 @@
"@coingecko/cryptoformat": "^0.4.2",
"@loadable/component": "^5.14.1",
"@oceanprotocol/art": "^3.0.0",
"@oceanprotocol/lib": "^0.13.0",
"@oceanprotocol/lib": "^0.14.0",
"@oceanprotocol/typographies": "^0.1.0",
"@portis/web3": "^3.0.3",
"@sindresorhus/slugify": "^1.0.0",

View File

@ -38,6 +38,7 @@ import { gql, useQuery } from '@apollo/client'
import { FrePrice } from '../../../../@types/apollo/FrePrice'
import { PoolPrice } from '../../../../@types/apollo/PoolPrice'
import { secondsToString } from '../../../../utils/metadata'
import { ComputeAlgorithm } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute'
const SuccessAction = () => (
<Button style="text" to="/history" size="small">
@ -291,10 +292,15 @@ export default function Compute({
? selectedAlgorithmAsset.findServiceByType('access')
: selectedAlgorithmAsset.findServiceByType('compute')
const computeAlgorithm: ComputeAlgorithm = {
did: selectedAlgorithmAsset.id,
serviceIndex: serviceAlgo.index,
dataToken: selectedAlgorithmAsset.dataToken
}
const allowed = await ocean.compute.isOrderable(
ddo.id,
computeService.index,
selectedAlgorithmAsset.id
computeAlgorithm
)
Logger.log('[compute] Is data set orderable?', allowed)
@ -342,8 +348,7 @@ export default function Compute({
accountId,
ddo.id,
computeService.index,
undefined,
undefined,
computeAlgorithm,
marketFeeAddress
)
@ -378,6 +383,7 @@ export default function Compute({
return
}
computeAlgorithm.transferTxId = algorithmAssetOrderId
Logger.log('[compute] Starting compute job.')
const output = {}
@ -386,13 +392,10 @@ export default function Compute({
assetOrderId,
ddo.dataToken,
account,
algorithmId,
undefined,
computeAlgorithm,
output,
`${computeService.index}`,
computeService.type,
algorithmAssetOrderId,
selectedAlgorithmAsset.dataToken
computeService.type
)
if (!response) {

View File

@ -1,7 +1,10 @@
import { useState } from 'react'
import { Logger, ServiceCompute } from '@oceanprotocol/lib'
import { MetadataAlgorithm } from '@oceanprotocol/lib/dist/node/ddo/interfaces/MetadataAlgorithm'
import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/ComputeJob'
import {
ComputeJob,
ComputeAlgorithm
} from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute'
import { computeFeedback } from '../utils/feedback'
import { useOcean } from '../providers/Ocean'
import { useWeb3 } from '../providers/Web3'
@ -97,6 +100,9 @@ function useCompute(): UseCompute {
setStep(0)
rawAlgorithmMeta.container = computeContainer
rawAlgorithmMeta.rawcode = algorithmRawCode
const computeAlgorithm: ComputeAlgorithm = {
meta: rawAlgorithmMeta
}
const output = {}
if (!orderId) {
const userOwnedTokens = await ocean.accounts.getTokenBalance(
@ -118,8 +124,7 @@ function useCompute(): UseCompute {
accountId,
did,
computeService.index,
undefined,
rawAlgorithmMeta,
computeAlgorithm,
marketFeeAddress
)
setStep(1)
@ -132,8 +137,7 @@ function useCompute(): UseCompute {
orderId,
dataTokenAddress,
account,
undefined,
rawAlgorithmMeta,
computeAlgorithm,
output,
`${computeService.index}`,
computeService.type