mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge branch 'v4main' into issue-1342-rewrite-publish-flow-test
This commit is contained in:
commit
a7ff5df3a3
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -58,8 +58,6 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
run: |
|
run: |
|
||||||
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
|
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
|
||||||
env:
|
|
||||||
CONTRACTS_VERSION: v1.0.0-alpha.31
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Wait for contracts deployment
|
- name: Wait for contracts deployment
|
||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
@ -117,8 +115,6 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
run: |
|
run: |
|
||||||
bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log &
|
bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log &
|
||||||
env:
|
|
||||||
CONTRACTS_VERSION: v1.0.0-alpha.31
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build:metadata
|
- run: npm run build:metadata
|
||||||
|
|
||||||
|
2835
CHANGELOG.md
2835
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
32
package-lock.json
generated
32
package-lock.json
generated
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@oceanprotocol/lib",
|
"name": "@oceanprotocol/lib",
|
||||||
"version": "1.0.0-next.41",
|
"version": "1.0.0-next.42",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@oceanprotocol/lib",
|
"name": "@oceanprotocol/lib",
|
||||||
"version": "1.0.0-next.40",
|
"version": "1.0.0-next.42",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "^1.0.0-alpha.31",
|
"@oceanprotocol/contracts": "^1.0.0-alpha.32",
|
||||||
"bignumber.js": "^9.0.2",
|
"bignumber.js": "^9.0.2",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
@ -24,7 +24,7 @@
|
|||||||
"@types/chai-spies": "^1.0.3",
|
"@types/chai-spies": "^1.0.3",
|
||||||
"@types/crypto-js": "^4.1.1",
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/mocha": "^9.1.1",
|
"@types/mocha": "^9.1.1",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.32",
|
||||||
"@types/node-fetch": "^3.0.3",
|
"@types/node-fetch": "^3.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||||
"@typescript-eslint/parser": "^4.33.0",
|
"@typescript-eslint/parser": "^4.33.0",
|
||||||
@ -2471,9 +2471,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@oceanprotocol/contracts": {
|
"node_modules/@oceanprotocol/contracts": {
|
||||||
"version": "1.0.0-alpha.31",
|
"version": "1.0.0-alpha.32",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.31.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.32.tgz",
|
||||||
"integrity": "sha512-WqrhjO0Qu8Bxdr2dAkdUL1Q/rHEkTuhx8OT4J/uJltnlxykCo6F8raNQAlhdh+84hm2Bv1irXE+PdpizNLwntQ=="
|
"integrity": "sha512-gCHw4ZVnNjSozzCVT/cQiDqLNP0Xvy4fe+g5PKy8rwMR/h2rRW65Txi6wkb4HfZiUPKCdHbzpUFOwYfJFbW0Jw=="
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/auth-token": {
|
"node_modules/@octokit/auth-token": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
@ -3021,9 +3021,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "17.0.31",
|
"version": "17.0.32",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz",
|
||||||
"integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
|
"integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/node-fetch": {
|
"node_modules/@types/node-fetch": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
@ -19610,9 +19610,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@oceanprotocol/contracts": {
|
"@oceanprotocol/contracts": {
|
||||||
"version": "1.0.0-alpha.31",
|
"version": "1.0.0-alpha.32",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.31.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.32.tgz",
|
||||||
"integrity": "sha512-WqrhjO0Qu8Bxdr2dAkdUL1Q/rHEkTuhx8OT4J/uJltnlxykCo6F8raNQAlhdh+84hm2Bv1irXE+PdpizNLwntQ=="
|
"integrity": "sha512-gCHw4ZVnNjSozzCVT/cQiDqLNP0Xvy4fe+g5PKy8rwMR/h2rRW65Txi6wkb4HfZiUPKCdHbzpUFOwYfJFbW0Jw=="
|
||||||
},
|
},
|
||||||
"@octokit/auth-token": {
|
"@octokit/auth-token": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
@ -20079,9 +20079,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "17.0.31",
|
"version": "17.0.32",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz",
|
||||||
"integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
|
"integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw=="
|
||||||
},
|
},
|
||||||
"@types/node-fetch": {
|
"@types/node-fetch": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@oceanprotocol/lib",
|
"name": "@oceanprotocol/lib",
|
||||||
"source": "./src/index.ts",
|
"source": "./src/index.ts",
|
||||||
"version": "1.0.0-next.41",
|
"version": "1.0.0-next.42",
|
||||||
"description": "JavaScript client library for Ocean Protocol",
|
"description": "JavaScript client library for Ocean Protocol",
|
||||||
"main": "./dist/lib.js",
|
"main": "./dist/lib.js",
|
||||||
"umd:main": "dist/lib.umd.js",
|
"umd:main": "dist/lib.umd.js",
|
||||||
@ -58,7 +58,7 @@
|
|||||||
"web3": "^1.7.3"
|
"web3": "^1.7.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "^1.0.0-alpha.31",
|
"@oceanprotocol/contracts": "^1.0.0-alpha.32",
|
||||||
"bignumber.js": "^9.0.2",
|
"bignumber.js": "^9.0.2",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
@ -73,7 +73,7 @@
|
|||||||
"@types/chai-spies": "^1.0.3",
|
"@types/chai-spies": "^1.0.3",
|
||||||
"@types/crypto-js": "^4.1.1",
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/mocha": "^9.1.1",
|
"@types/mocha": "^9.1.1",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.32",
|
||||||
"@types/node-fetch": "^3.0.3",
|
"@types/node-fetch": "^3.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||||
"@typescript-eslint/parser": "^4.33.0",
|
"@typescript-eslint/parser": "^4.33.0",
|
||||||
|
@ -15,3 +15,14 @@ export interface ProviderInitialize {
|
|||||||
computeAddress: string
|
computeAddress: string
|
||||||
providerFee: ProviderFees
|
providerFee: ProviderFees
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ProviderComputeInitialize {
|
||||||
|
datatoken?: string
|
||||||
|
validOrder?: string
|
||||||
|
providerFee?: ProviderFees
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProviderComputeInitializeResults {
|
||||||
|
algorithm?: ProviderComputeInitialize
|
||||||
|
datasets?: ProviderComputeInitialize[]
|
||||||
|
}
|
||||||
|
@ -1153,13 +1153,15 @@ export class Pool {
|
|||||||
* @param {String} poolAddress
|
* @param {String} poolAddress
|
||||||
* @param {String} tokenAmountIn exact number of base tokens to spend
|
* @param {String} tokenAmountIn exact number of base tokens to spend
|
||||||
* @param {String} minPoolAmountOut minimum of pool shares expectex
|
* @param {String} minPoolAmountOut minimum of pool shares expectex
|
||||||
|
* @param {number} tokenInDecimals optional number of decimals of the token
|
||||||
* @return {TransactionReceipt}
|
* @return {TransactionReceipt}
|
||||||
*/
|
*/
|
||||||
async joinswapExternAmountIn(
|
async joinswapExternAmountIn(
|
||||||
account: string,
|
account: string,
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
tokenAmountIn: string,
|
tokenAmountIn: string,
|
||||||
minPoolAmountOut: string
|
minPoolAmountOut: string,
|
||||||
|
tokenInDecimals?: number
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const pool = setContractDefaults(
|
const pool = setContractDefaults(
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||||
@ -1172,7 +1174,11 @@ export class Pool {
|
|||||||
throw new Error(`tokenAmountOut is greater than ${maxSwap.toString()}`)
|
throw new Error(`tokenAmountOut is greater than ${maxSwap.toString()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const amountInFormatted = await this.amountToUnits(tokenIn, tokenAmountIn)
|
const amountInFormatted = await this.amountToUnits(
|
||||||
|
tokenIn,
|
||||||
|
tokenAmountIn,
|
||||||
|
tokenInDecimals
|
||||||
|
)
|
||||||
const estGas = await this.estJoinswapExternAmountIn(
|
const estGas = await this.estJoinswapExternAmountIn(
|
||||||
account,
|
account,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
@ -1241,13 +1247,15 @@ export class Pool {
|
|||||||
* @param {String} poolAddress
|
* @param {String} poolAddress
|
||||||
* @param {String} poolAmountIn exact number of pool shares to spend
|
* @param {String} poolAmountIn exact number of pool shares to spend
|
||||||
* @param {String} minTokenAmountOut minimum amount of basetokens expected
|
* @param {String} minTokenAmountOut minimum amount of basetokens expected
|
||||||
|
* @param {number} poolDecimals optional number of decimals of the poool
|
||||||
* @return {TransactionReceipt}
|
* @return {TransactionReceipt}
|
||||||
*/
|
*/
|
||||||
async exitswapPoolAmountIn(
|
async exitswapPoolAmountIn(
|
||||||
account: string,
|
account: string,
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
poolAmountIn: string,
|
poolAmountIn: string,
|
||||||
minTokenAmountOut: string
|
minTokenAmountOut: string,
|
||||||
|
poolDecimals?: number
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const pool = setContractDefaults(
|
const pool = setContractDefaults(
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||||
@ -1269,7 +1277,8 @@ export class Pool {
|
|||||||
|
|
||||||
const minTokenOutFormatted = await this.amountToUnits(
|
const minTokenOutFormatted = await this.amountToUnits(
|
||||||
await this.getBaseToken(poolAddress),
|
await this.getBaseToken(poolAddress),
|
||||||
minTokenAmountOut
|
minTokenAmountOut,
|
||||||
|
poolDecimals
|
||||||
)
|
)
|
||||||
const estGas = await this.estExitswapPoolAmountIn(
|
const estGas = await this.estExitswapPoolAmountIn(
|
||||||
account,
|
account,
|
||||||
|
@ -7,7 +7,8 @@ import {
|
|||||||
ComputeAlgorithm,
|
ComputeAlgorithm,
|
||||||
ComputeAsset,
|
ComputeAsset,
|
||||||
ComputeEnvironment,
|
ComputeEnvironment,
|
||||||
ProviderInitialize
|
ProviderInitialize,
|
||||||
|
ProviderComputeInitializeResults
|
||||||
} from '../@types/'
|
} from '../@types/'
|
||||||
import { noZeroX } from '../utils/ConversionTypeHelper'
|
import { noZeroX } from '../utils/ConversionTypeHelper'
|
||||||
import fetch from 'cross-fetch'
|
import fetch from 'cross-fetch'
|
||||||
@ -327,6 +328,60 @@ export class Provider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Initialize a compute request.
|
||||||
|
* @param {ComputeAsset} assets
|
||||||
|
* @param {ComputeAlgorithmber} algorithm
|
||||||
|
* @param {string} computeEnv
|
||||||
|
* @param {number} validUntil
|
||||||
|
* @param {string} providerUri Identifier of the asset to be registered in ocean
|
||||||
|
* @param {string} accountId
|
||||||
|
* @param {AbortSignal} signal abort signal
|
||||||
|
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
||||||
|
*/
|
||||||
|
public async initializeCompute(
|
||||||
|
assets: ComputeAsset[],
|
||||||
|
algorithm: ComputeAlgorithm,
|
||||||
|
computeEnv: string,
|
||||||
|
validUntil: number,
|
||||||
|
providerUri: string,
|
||||||
|
accountId: string,
|
||||||
|
signal?: AbortSignal
|
||||||
|
): Promise<ProviderComputeInitializeResults> {
|
||||||
|
const providerEndpoints = await this.getEndpoints(providerUri)
|
||||||
|
const serviceEndpoints = await this.getServiceEndpoints(
|
||||||
|
providerUri,
|
||||||
|
providerEndpoints
|
||||||
|
)
|
||||||
|
const providerData = {
|
||||||
|
datasets: assets,
|
||||||
|
algorithm: algorithm,
|
||||||
|
compute: {
|
||||||
|
env: computeEnv,
|
||||||
|
validUntil: validUntil
|
||||||
|
},
|
||||||
|
consumerAddress: accountId
|
||||||
|
}
|
||||||
|
const initializeUrl = this.getEndpointURL(serviceEndpoints, 'initializeCompute')
|
||||||
|
? this.getEndpointURL(serviceEndpoints, 'initializeCompute').urlPath
|
||||||
|
: null
|
||||||
|
if (!initializeUrl) return null
|
||||||
|
try {
|
||||||
|
const response = await fetch(initializeUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(providerData),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
signal: signal
|
||||||
|
})
|
||||||
|
const results = await response.json()
|
||||||
|
return results
|
||||||
|
} catch (e) {
|
||||||
|
LoggerInstance.error(e)
|
||||||
|
throw new Error('ComputeJob cannot be initialized')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets fully signed URL for download
|
/** Gets fully signed URL for download
|
||||||
* @param {string} did
|
* @param {string} did
|
||||||
* @param {string} accountId
|
* @param {string} accountId
|
||||||
|
@ -8,11 +8,39 @@ import {
|
|||||||
NftFactory,
|
NftFactory,
|
||||||
NftCreateData,
|
NftCreateData,
|
||||||
Datatoken,
|
Datatoken,
|
||||||
getHash,
|
|
||||||
Nft,
|
Nft,
|
||||||
sleep
|
sleep,
|
||||||
|
ZERO_ADDRESS
|
||||||
} from '../../src'
|
} from '../../src'
|
||||||
import { ProviderFees, Erc20CreateParams, ComputeJob, Asset } from '../../src/@types'
|
import {
|
||||||
|
Erc20CreateParams,
|
||||||
|
ComputeJob,
|
||||||
|
ComputeAsset,
|
||||||
|
ComputeAlgorithm,
|
||||||
|
ProviderComputeInitialize,
|
||||||
|
ConsumeMarketFee
|
||||||
|
} from '../../src/@types'
|
||||||
|
|
||||||
|
let config: Config
|
||||||
|
|
||||||
|
let aquarius: Aquarius
|
||||||
|
let datatoken: Datatoken
|
||||||
|
let providerUrl: string
|
||||||
|
let consumerAccount: string
|
||||||
|
let publisherAccount: string
|
||||||
|
let computeJobId: string
|
||||||
|
let providerInitializeComputeResults
|
||||||
|
let computeEnvs
|
||||||
|
let addresses: any
|
||||||
|
let ddoWith1mTimeoutId
|
||||||
|
let ddoWithNoTimeoutId
|
||||||
|
let algoDdoWith1mTimeoutId
|
||||||
|
let algoDdoWithNoTimeoutId
|
||||||
|
|
||||||
|
let resolvedDdoWith1mTimeout
|
||||||
|
let resolvedDdoWithNoTimeout
|
||||||
|
let resolvedAlgoDdoWith1mTimeout
|
||||||
|
let resolvedAlgoDdoWithNoTimeout
|
||||||
|
|
||||||
const assetUrl = [
|
const assetUrl = [
|
||||||
{
|
{
|
||||||
@ -21,7 +49,7 @@ const assetUrl = [
|
|||||||
method: 'GET'
|
method: 'GET'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const ddo = {
|
const ddoWithNoTimeout = {
|
||||||
'@context': ['https://w3id.org/did/v1'],
|
'@context': ['https://w3id.org/did/v1'],
|
||||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||||
version: '4.0.0',
|
version: '4.0.0',
|
||||||
@ -52,13 +80,44 @@ const ddo = {
|
|||||||
publisherTrustedAlgorithmPublishers: [],
|
publisherTrustedAlgorithmPublishers: [],
|
||||||
publisherTrustedAlgorithms: [],
|
publisherTrustedAlgorithms: [],
|
||||||
allowRawAlgorithm: true,
|
allowRawAlgorithm: true,
|
||||||
allowNetworkAccess: true,
|
allowNetworkAccess: true
|
||||||
namespace: 'ocean-compute',
|
}
|
||||||
cpus: 2,
|
}
|
||||||
gpus: 4,
|
]
|
||||||
gpuType: 'NVIDIA Tesla V100 GPU',
|
}
|
||||||
memory: '128M',
|
|
||||||
volumeSize: '2G'
|
const ddoWith1mTimeout = {
|
||||||
|
'@context': ['https://w3id.org/did/v1'],
|
||||||
|
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||||
|
version: '4.0.0',
|
||||||
|
chainId: 4,
|
||||||
|
nftAddress: '0x0',
|
||||||
|
metadata: {
|
||||||
|
created: '2021-12-20T14:35:20Z',
|
||||||
|
updated: '2021-12-20T14:35:20Z',
|
||||||
|
type: 'dataset',
|
||||||
|
name: 'dfgdfgdg',
|
||||||
|
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||||
|
tags: [''],
|
||||||
|
author: 'dd',
|
||||||
|
license: 'https://market.oceanprotocol.com/terms',
|
||||||
|
additionalInformation: {
|
||||||
|
termsAndConditions: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
services: [
|
||||||
|
{
|
||||||
|
id: 'notAnId',
|
||||||
|
type: 'compute',
|
||||||
|
files: '',
|
||||||
|
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||||
|
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||||
|
timeout: 60,
|
||||||
|
compute: {
|
||||||
|
publisherTrustedAlgorithmPublishers: [],
|
||||||
|
publisherTrustedAlgorithms: [],
|
||||||
|
allowRawAlgorithm: true,
|
||||||
|
allowNetworkAccess: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -70,7 +129,7 @@ const algoAssetUrl = [
|
|||||||
method: 'GET'
|
method: 'GET'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const algoDdo = {
|
const algoDdoWithNoTimeout = {
|
||||||
'@context': ['https://w3id.org/did/v1'],
|
'@context': ['https://w3id.org/did/v1'],
|
||||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||||
version: '4.0.0',
|
version: '4.0.0',
|
||||||
@ -110,144 +169,246 @@ const algoDdo = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
let providerUrl: string
|
|
||||||
let consumerAccount: string
|
const algoDdoWith1mTimeout = {
|
||||||
let computeJobId: string
|
'@context': ['https://w3id.org/did/v1'],
|
||||||
let resolvedDDOAsset: Asset
|
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||||
|
version: '4.0.0',
|
||||||
|
chainId: 4,
|
||||||
|
nftAddress: '0x0',
|
||||||
|
metadata: {
|
||||||
|
created: '2021-12-20T14:35:20Z',
|
||||||
|
updated: '2021-12-20T14:35:20Z',
|
||||||
|
type: 'algorithm',
|
||||||
|
name: 'dfgdfgdg',
|
||||||
|
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||||
|
tags: [''],
|
||||||
|
author: 'dd',
|
||||||
|
license: 'https://market.oceanprotocol.com/terms',
|
||||||
|
additionalInformation: {
|
||||||
|
termsAndConditions: true
|
||||||
|
},
|
||||||
|
algorithm: {
|
||||||
|
language: 'Node.js',
|
||||||
|
version: '1.0.0',
|
||||||
|
container: {
|
||||||
|
entrypoint: 'node $ALGO',
|
||||||
|
image: 'ubuntu',
|
||||||
|
tag: 'latest',
|
||||||
|
checksum: '44e10daa6637893f4276bb8d7301eb35306ece50f61ca34dcab550'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
services: [
|
||||||
|
{
|
||||||
|
id: 'notAnId',
|
||||||
|
type: 'access',
|
||||||
|
files: '',
|
||||||
|
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||||
|
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||||
|
timeout: 60
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createAsset(
|
||||||
|
name: string,
|
||||||
|
symbol: string,
|
||||||
|
owner: string,
|
||||||
|
assetUrl: any,
|
||||||
|
ddo: any,
|
||||||
|
providerUrl: string
|
||||||
|
) {
|
||||||
|
const nft = new Nft(web3)
|
||||||
|
const Factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||||
|
|
||||||
|
const chain = await web3.eth.getChainId()
|
||||||
|
ddo.chainId = parseInt(chain.toString(10))
|
||||||
|
const nftParamsAsset: NftCreateData = {
|
||||||
|
name: name,
|
||||||
|
symbol: symbol,
|
||||||
|
templateIndex: 1,
|
||||||
|
tokenURI: 'aaa',
|
||||||
|
transferable: true,
|
||||||
|
owner: owner
|
||||||
|
}
|
||||||
|
const erc20ParamsAsset: Erc20CreateParams = {
|
||||||
|
templateIndex: 1,
|
||||||
|
cap: '100000',
|
||||||
|
feeAmount: '0',
|
||||||
|
paymentCollector: ZERO_ADDRESS,
|
||||||
|
feeToken: ZERO_ADDRESS,
|
||||||
|
minter: owner,
|
||||||
|
mpFeeAddress: ZERO_ADDRESS
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await Factory.createNftWithErc20(owner, nftParamsAsset, erc20ParamsAsset)
|
||||||
|
|
||||||
|
const erc721AddressAsset = result.events.NFTCreated.returnValues[0]
|
||||||
|
const datatokenAddressAsset = result.events.TokenCreated.returnValues[0]
|
||||||
|
// create the files encrypted string
|
||||||
|
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
||||||
|
ddo.services[0].files = await providerResponse
|
||||||
|
ddo.services[0].datatokenAddress = datatokenAddressAsset
|
||||||
|
ddo.services[0].serviceEndpoint = providerUrl
|
||||||
|
// update ddo and set the right did
|
||||||
|
ddo.nftAddress = web3.utils.toChecksumAddress(erc721AddressAsset)
|
||||||
|
ddo.id =
|
||||||
|
'did:op:' +
|
||||||
|
SHA256(web3.utils.toChecksumAddress(erc721AddressAsset) + chain.toString(10))
|
||||||
|
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
||||||
|
const encryptedResponse = await providerResponse
|
||||||
|
const validateResult = await aquarius.validate(ddo)
|
||||||
|
assert(validateResult.valid, 'Could not validate metadata')
|
||||||
|
await nft.setMetadata(
|
||||||
|
erc721AddressAsset,
|
||||||
|
owner,
|
||||||
|
0,
|
||||||
|
providerUrl,
|
||||||
|
'',
|
||||||
|
'0x2',
|
||||||
|
encryptedResponse,
|
||||||
|
validateResult.hash
|
||||||
|
)
|
||||||
|
return ddo.id
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleOrder(
|
||||||
|
order: ProviderComputeInitialize,
|
||||||
|
datatokenAddress: string,
|
||||||
|
payerAccount: string,
|
||||||
|
consumerAccount: string,
|
||||||
|
serviceIndex: number,
|
||||||
|
consumeMarkerFee?: ConsumeMarketFee
|
||||||
|
) {
|
||||||
|
/* We do have 3 possible situations:
|
||||||
|
- have validOrder and no providerFees -> then order is valid, providerFees are valid, just use it in startCompute
|
||||||
|
- have validOrder and providerFees -> then order is valid but providerFees are not valid, we need to call reuseOrder and pay only providerFees
|
||||||
|
- no validOrder -> we need to call startOrder, to pay 1 DT & providerFees
|
||||||
|
*/
|
||||||
|
if (order.providerFee && order.providerFee.providerFeeAmount) {
|
||||||
|
await datatoken.approve(
|
||||||
|
order.providerFee.providerFeeToken,
|
||||||
|
datatokenAddress,
|
||||||
|
order.providerFee.providerFeeAmount,
|
||||||
|
payerAccount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (order.validOrder) {
|
||||||
|
if (!order.providerFee) return order.validOrder
|
||||||
|
const tx = await datatoken.reuseOrder(
|
||||||
|
datatokenAddress,
|
||||||
|
payerAccount,
|
||||||
|
order.validOrder,
|
||||||
|
order.providerFee
|
||||||
|
)
|
||||||
|
return tx.transactionHash
|
||||||
|
}
|
||||||
|
const tx = await datatoken.startOrder(
|
||||||
|
datatokenAddress,
|
||||||
|
payerAccount,
|
||||||
|
consumerAccount,
|
||||||
|
serviceIndex,
|
||||||
|
order.providerFee,
|
||||||
|
consumeMarkerFee
|
||||||
|
)
|
||||||
|
return tx.transactionHash
|
||||||
|
}
|
||||||
|
|
||||||
describe('Simple compute tests', async () => {
|
describe('Simple compute tests', async () => {
|
||||||
let config: Config
|
|
||||||
let addresses: any
|
|
||||||
let aquarius: Aquarius
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
config = await getTestConfig(web3)
|
config = await getTestConfig(web3)
|
||||||
addresses = getAddresses()
|
addresses = getAddresses()
|
||||||
aquarius = new Aquarius(config.metadataCacheUri)
|
aquarius = new Aquarius(config.metadataCacheUri)
|
||||||
providerUrl = config.providerUri
|
providerUrl = config.providerUri
|
||||||
|
datatoken = new Datatoken(web3)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should publish a dataset, algorithm and start a compute job', async () => {
|
it('should publish datasets and algorithms', async () => {
|
||||||
const nft = new Nft(web3)
|
|
||||||
const datatoken = new Datatoken(web3)
|
|
||||||
const Factory = new NftFactory(addresses.ERC721Factory, web3)
|
|
||||||
const accounts = await web3.eth.getAccounts()
|
const accounts = await web3.eth.getAccounts()
|
||||||
const publisherAccount = accounts[0]
|
publisherAccount = accounts[0]
|
||||||
consumerAccount = accounts[1]
|
consumerAccount = accounts[1]
|
||||||
const chain = await web3.eth.getChainId()
|
ddoWith1mTimeoutId = await createAsset(
|
||||||
const nftParamsAsset: NftCreateData = {
|
'D1Min',
|
||||||
name: 'testNFT',
|
'D1M',
|
||||||
symbol: 'TST',
|
|
||||||
templateIndex: 1,
|
|
||||||
tokenURI: 'aaa',
|
|
||||||
transferable: true,
|
|
||||||
owner: publisherAccount
|
|
||||||
}
|
|
||||||
const erc20ParamsAsset: Erc20CreateParams = {
|
|
||||||
templateIndex: 1,
|
|
||||||
cap: '100000',
|
|
||||||
feeAmount: '0',
|
|
||||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
|
||||||
feeToken: '0x0000000000000000000000000000000000000000',
|
|
||||||
minter: publisherAccount,
|
|
||||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await Factory.createNftWithErc20(
|
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
nftParamsAsset,
|
assetUrl,
|
||||||
erc20ParamsAsset
|
ddoWith1mTimeout,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
|
ddoWithNoTimeoutId = await createAsset(
|
||||||
|
'D1Min',
|
||||||
|
'D1M',
|
||||||
|
publisherAccount,
|
||||||
|
assetUrl,
|
||||||
|
ddoWithNoTimeout,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
|
algoDdoWith1mTimeoutId = await createAsset(
|
||||||
|
'A1Min',
|
||||||
|
'A1M',
|
||||||
|
publisherAccount,
|
||||||
|
algoAssetUrl,
|
||||||
|
algoDdoWith1mTimeout,
|
||||||
|
providerUrl
|
||||||
)
|
)
|
||||||
|
|
||||||
const erc721AddressAsset = result.events.NFTCreated.returnValues[0]
|
algoDdoWithNoTimeoutId = await createAsset(
|
||||||
const datatokenAddressAsset = result.events.TokenCreated.returnValues[0]
|
'A1Min',
|
||||||
// create the files encrypted string
|
'A1M',
|
||||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
|
||||||
ddo.services[0].files = await providerResponse
|
|
||||||
ddo.services[0].datatokenAddress = datatokenAddressAsset
|
|
||||||
// update ddo and set the right did
|
|
||||||
ddo.nftAddress = erc721AddressAsset
|
|
||||||
ddo.id =
|
|
||||||
'did:op:' +
|
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721AddressAsset) + chain.toString(10))
|
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
|
||||||
|
|
||||||
let encryptedResponse = await providerResponse
|
|
||||||
let metadataHash = getHash(JSON.stringify(ddo))
|
|
||||||
let res = await nft.setMetadata(
|
|
||||||
erc721AddressAsset,
|
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
0,
|
algoAssetUrl,
|
||||||
providerUrl,
|
algoDdoWithNoTimeout,
|
||||||
'',
|
providerUrl
|
||||||
'0x2',
|
|
||||||
encryptedResponse,
|
|
||||||
'0x' + metadataHash
|
|
||||||
)
|
)
|
||||||
// let's publish the algorithm as well
|
})
|
||||||
const nftParamsAlgo: NftCreateData = {
|
|
||||||
name: 'testNFT',
|
it('should resolve published datasets and algorithms', async () => {
|
||||||
symbol: 'TST',
|
resolvedDdoWith1mTimeout = await aquarius.waitForAqua(ddoWith1mTimeoutId)
|
||||||
templateIndex: 1,
|
assert(resolvedDdoWith1mTimeout, 'Cannot fetch DDO from Aquarius')
|
||||||
tokenURI: '',
|
resolvedDdoWithNoTimeout = await aquarius.waitForAqua(ddoWithNoTimeoutId)
|
||||||
transferable: true,
|
assert(resolvedDdoWithNoTimeout, 'Cannot fetch DDO from Aquarius')
|
||||||
owner: publisherAccount
|
resolvedAlgoDdoWith1mTimeout = await aquarius.waitForAqua(algoDdoWith1mTimeoutId)
|
||||||
}
|
assert(resolvedAlgoDdoWith1mTimeout, 'Cannot fetch DDO from Aquarius')
|
||||||
const erc20ParamsAlgo: Erc20CreateParams = {
|
resolvedAlgoDdoWithNoTimeout = await aquarius.waitForAqua(algoDdoWithNoTimeoutId)
|
||||||
templateIndex: 1,
|
assert(resolvedAlgoDdoWithNoTimeout, 'Cannot fetch DDO from Aquarius')
|
||||||
cap: '100000',
|
})
|
||||||
feeAmount: '0',
|
|
||||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
it('should send DT to consumer', async () => {
|
||||||
feeToken: '0x0000000000000000000000000000000000000000',
|
const datatoken = new Datatoken(web3)
|
||||||
minter: publisherAccount,
|
await datatoken.mint(
|
||||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
resolvedDdoWith1mTimeout.services[0].datatokenAddress,
|
||||||
}
|
|
||||||
const resultAlgo = await Factory.createNftWithErc20(
|
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
nftParamsAlgo,
|
'10',
|
||||||
erc20ParamsAlgo
|
consumerAccount
|
||||||
)
|
)
|
||||||
const erc721AddressAlgo = resultAlgo.events.NFTCreated.returnValues[0]
|
await datatoken.mint(
|
||||||
const datatokenAddressAlgo = resultAlgo.events.TokenCreated.returnValues[0]
|
resolvedDdoWithNoTimeout.services[0].datatokenAddress,
|
||||||
|
|
||||||
// create the files encrypted string
|
|
||||||
providerResponse = await ProviderInstance.encrypt(algoAssetUrl, providerUrl)
|
|
||||||
algoDdo.services[0].files = await providerResponse
|
|
||||||
algoDdo.services[0].datatokenAddress = datatokenAddressAlgo
|
|
||||||
// update ddo and set the right did
|
|
||||||
algoDdo.nftAddress = erc721AddressAlgo
|
|
||||||
|
|
||||||
algoDdo.id =
|
|
||||||
'did:op:' +
|
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721AddressAlgo) + chain.toString(10))
|
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(algoDdo, providerUrl)
|
|
||||||
encryptedResponse = await providerResponse
|
|
||||||
metadataHash = getHash(JSON.stringify(algoDdo))
|
|
||||||
res = await nft.setMetadata(
|
|
||||||
erc721AddressAlgo,
|
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
0,
|
'10',
|
||||||
providerUrl,
|
consumerAccount
|
||||||
'',
|
|
||||||
'0x2',
|
|
||||||
encryptedResponse,
|
|
||||||
'0x' + metadataHash
|
|
||||||
)
|
)
|
||||||
|
await datatoken.mint(
|
||||||
|
resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress,
|
||||||
|
publisherAccount,
|
||||||
|
'10',
|
||||||
|
consumerAccount
|
||||||
|
)
|
||||||
|
await datatoken.mint(
|
||||||
|
resolvedAlgoDdoWithNoTimeout.services[0].datatokenAddress,
|
||||||
|
publisherAccount,
|
||||||
|
'10',
|
||||||
|
consumerAccount
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// let's wait
|
it('should fetch compute environments from provider', async () => {
|
||||||
resolvedDDOAsset = await aquarius.waitForAqua(ddo.id)
|
|
||||||
assert(resolvedDDOAsset, 'Cannot fetch DDO from Aquarius')
|
|
||||||
const resolvedDDOAlgo = await aquarius.waitForAqua(algoDdo.id)
|
|
||||||
assert(resolvedDDOAlgo, 'Cannot fetch DDO from Aquarius')
|
|
||||||
// mint 1 ERC20 and send it to the consumer
|
|
||||||
await datatoken.mint(datatokenAddressAsset, publisherAccount, '1', consumerAccount)
|
|
||||||
await datatoken.mint(datatokenAddressAlgo, publisherAccount, '1', consumerAccount)
|
|
||||||
|
|
||||||
// get compute environments
|
// get compute environments
|
||||||
const computeEnvs = await ProviderInstance.getComputeEnvironments(providerUrl)
|
computeEnvs = await ProviderInstance.getComputeEnvironments(providerUrl)
|
||||||
assert(computeEnvs, 'No Compute environments found')
|
assert(computeEnvs, 'No Compute environments found')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should start a computeJob', async () => {
|
||||||
// we choose the first env
|
// we choose the first env
|
||||||
const computeEnv = computeEnvs[0].id
|
const computeEnv = computeEnvs[0].id
|
||||||
const computeConsumerAddress = computeEnvs[0].consumerAddress
|
const computeConsumerAddress = computeEnvs[0].consumerAddress
|
||||||
@ -255,89 +416,53 @@ describe('Simple compute tests', async () => {
|
|||||||
const mytime = new Date()
|
const mytime = new Date()
|
||||||
mytime.setMinutes(mytime.getMinutes() + 19)
|
mytime.setMinutes(mytime.getMinutes() + 19)
|
||||||
const computeValidUntil = Math.floor(mytime.getTime() / 1000)
|
const computeValidUntil = Math.floor(mytime.getTime() / 1000)
|
||||||
// initialize provider orders for algo
|
const assets: ComputeAsset[] = [
|
||||||
const initializeDataAlgo = await ProviderInstance.initialize(
|
{
|
||||||
resolvedDDOAlgo.id,
|
documentId: resolvedDdoWith1mTimeout.id,
|
||||||
resolvedDDOAlgo.services[0].id,
|
serviceId: resolvedDdoWith1mTimeout.services[0].id
|
||||||
0,
|
}
|
||||||
consumerAccount,
|
]
|
||||||
providerUrl,
|
const dtAddressArray = [resolvedDdoWith1mTimeout.services[0].datatokenAddress]
|
||||||
null,
|
const algo: ComputeAlgorithm = {
|
||||||
null,
|
documentId: resolvedAlgoDdoWith1mTimeout.id,
|
||||||
computeEnv,
|
serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id
|
||||||
computeValidUntil
|
|
||||||
)
|
|
||||||
const providerAlgoFees: ProviderFees = {
|
|
||||||
providerFeeAddress: initializeDataAlgo.providerFee.providerFeeAddress,
|
|
||||||
providerFeeToken: initializeDataAlgo.providerFee.providerFeeToken,
|
|
||||||
providerFeeAmount: initializeDataAlgo.providerFee.providerFeeAmount,
|
|
||||||
v: initializeDataAlgo.providerFee.v,
|
|
||||||
r: initializeDataAlgo.providerFee.r,
|
|
||||||
s: initializeDataAlgo.providerFee.s,
|
|
||||||
providerData: initializeDataAlgo.providerFee.providerData,
|
|
||||||
validUntil: initializeDataAlgo.providerFee.validUntil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the payment
|
providerInitializeComputeResults = await ProviderInstance.initializeCompute(
|
||||||
const txidAlgo = await datatoken.startOrder(
|
assets,
|
||||||
datatokenAddressAlgo,
|
algo,
|
||||||
consumerAccount,
|
|
||||||
computeConsumerAddress, // this is important because the c2d is the consumer, and user is the payer. Otherwise, c2d will have no access to the asset
|
|
||||||
0,
|
|
||||||
providerAlgoFees
|
|
||||||
)
|
|
||||||
assert(txidAlgo, 'Failed to order algo')
|
|
||||||
|
|
||||||
const providerValidUntil = new Date()
|
|
||||||
providerValidUntil.setHours(providerValidUntil.getHours() + 1)
|
|
||||||
|
|
||||||
// initialize provider orders for asset
|
|
||||||
const initializeData = await ProviderInstance.initialize(
|
|
||||||
resolvedDDOAsset.id,
|
|
||||||
resolvedDDOAsset.services[0].id,
|
|
||||||
0,
|
|
||||||
consumerAccount,
|
|
||||||
providerUrl,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
computeEnv,
|
computeEnv,
|
||||||
computeValidUntil
|
computeValidUntil,
|
||||||
|
providerUrl,
|
||||||
|
consumerAccount
|
||||||
)
|
)
|
||||||
const providerDatasetFees: ProviderFees = {
|
assert(
|
||||||
providerFeeAddress: initializeData.providerFee.providerFeeAddress,
|
!('error' in providerInitializeComputeResults.algorithm),
|
||||||
providerFeeToken: initializeData.providerFee.providerFeeToken,
|
'Cannot order algorithm'
|
||||||
providerFeeAmount: initializeData.providerFee.providerFeeAmount,
|
)
|
||||||
v: initializeData.providerFee.v,
|
algo.transferTxId = await handleOrder(
|
||||||
r: initializeData.providerFee.r,
|
providerInitializeComputeResults.algorithm,
|
||||||
s: initializeData.providerFee.s,
|
resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress,
|
||||||
providerData: initializeData.providerFee.providerData,
|
|
||||||
validUntil: initializeData.providerFee.validUntil
|
|
||||||
}
|
|
||||||
// make the payment
|
|
||||||
const txidAsset = await datatoken.startOrder(
|
|
||||||
datatokenAddressAsset,
|
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
computeConsumerAddress, // this is important because the c2d is the consumer, and user is the payer. Otherwise, c2d will have no access to the asset
|
computeConsumerAddress,
|
||||||
0,
|
0
|
||||||
providerDatasetFees
|
|
||||||
)
|
)
|
||||||
assert(txidAsset, 'Failed to order algo')
|
for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
|
||||||
// start the compute job
|
assets[i].transferTxId = await handleOrder(
|
||||||
|
providerInitializeComputeResults.datasets[i],
|
||||||
|
dtAddressArray[i],
|
||||||
|
consumerAccount,
|
||||||
|
computeConsumerAddress,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
const computeJobs = await ProviderInstance.computeStart(
|
const computeJobs = await ProviderInstance.computeStart(
|
||||||
providerUrl,
|
providerUrl,
|
||||||
web3,
|
web3,
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
computeEnv,
|
computeEnv,
|
||||||
{
|
assets[0],
|
||||||
documentId: resolvedDDOAsset.id,
|
algo
|
||||||
serviceId: resolvedDDOAsset.services[0].id,
|
|
||||||
transferTxId: txidAsset.transactionHash
|
|
||||||
},
|
|
||||||
{
|
|
||||||
documentId: resolvedDDOAlgo.id,
|
|
||||||
serviceId: resolvedDDOAlgo.services[0].id,
|
|
||||||
transferTxId: txidAlgo.transactionHash
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
assert(computeJobs, 'Cannot start compute job')
|
assert(computeJobs, 'Cannot start compute job')
|
||||||
computeJobId = computeJobs[0].jobId
|
computeJobId = computeJobs[0].jobId
|
||||||
@ -348,7 +473,7 @@ describe('Simple compute tests', async () => {
|
|||||||
providerUrl,
|
providerUrl,
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
computeJobId,
|
computeJobId,
|
||||||
resolvedDDOAsset.id
|
resolvedDdoWith1mTimeout.id
|
||||||
)) as ComputeJob
|
)) as ComputeJob
|
||||||
assert(jobStatus, 'Cannot retrieve compute status!')
|
assert(jobStatus, 'Cannot retrieve compute status!')
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user