1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +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==" "integrity": "sha512-0dasqU7PL8xZOxvn6ID2IJ6TgQZbkcwtZqiMiYvtsv9+fQr/n13qXYXwkmNEjQb3YL4IeSVUnHehk5KpGRPFWA=="
}, },
"@oceanprotocol/lib": { "@oceanprotocol/lib": {
"version": "0.13.0", "version": "0.14.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.13.0.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.14.0.tgz",
"integrity": "sha512-+LoN16bo1hcqfxsxLV22ZEbObdif0RJXg5GlndlF/VQGNVrSm+XYxUp+si5HCWa8sBeYH/hOSQRnrD8YXnyWrw==", "integrity": "sha512-0CxrhQuu9tA4HNzytPDEGd+8ceCdFDSPuQJivvnuOH3GWtZNgfJb9wyQnl0YHQgdtWWHkIcnnPL0NsAXKLF+ew==",
"requires": { "requires": {
"@ethereum-navigator/navigator": "^0.5.2", "@ethereum-navigator/navigator": "^0.5.2",
"@oceanprotocol/contracts": "^0.5.10", "@oceanprotocol/contracts": "^0.5.10",
@ -16704,7 +16704,7 @@
} }
}, },
"ethereumjs-abi": { "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", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": { "requires": {
"bn.js": "^4.11.8", "bn.js": "^4.11.8",

View File

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

View File

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

View File

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