1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
This commit is contained in:
alexcos20 2020-03-10 13:57:17 +02:00
parent bd831c2c61
commit 8cfbd4024c
2 changed files with 13 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import { DDO } from '../ddo/DDO'
import { SubscribablePromise } from '../utils'
import { OrderProgressStep } from './utils/ServiceUtils'
import { DID } from '../squid'
import {ServiceCompute} from '../ddo/Service'
export const ComputeJobStatus = Object.freeze({
Started: 10,
@ -262,12 +263,17 @@ export class OceanCompute extends Instantiable {
return computeJobsList[0] as ComputeJob
}
public async create_compute_service_attributes(consumerAccount: Account,price: string,datePublished: string){
public async create_compute_service_attributes(
consumerAccount: Account,
price: string,
datePublished: string
): Promise<ServiceCompute> {
const { templates } = this.ocean.keeper
const serviceAgreementTemplate = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplate()
const name = 'dataAssetComputingServiceAgreement'
const service = {
return {
type: 'compute',
index: 3,
serviceEndpoint: this.ocean.brizo.getComputeEndpoint(),
templateId: templates.escrowComputeExecutionTemplate.getId(),
attributes: {
@ -280,6 +286,6 @@ export class OceanCompute extends Instantiable {
},
serviceAgreementTemplate
}
}
return(service)
}
}
}

View File

@ -2,7 +2,8 @@ import { assert } from 'chai'
import { config } from '../config'
import { Ocean, Account, DDO, MetaData, ComputeJobStatus, Config } from '../../../src'
import { getMetadata, createComputeService } from '../utils'
import { getMetadata} from '../utils'
import { ServiceCompute } from '../../../src/ddo/Service'
const metadataAsset = getMetadata()
@ -38,7 +39,7 @@ describe('Compute', () => {
it('should publish a dataset with a compute service object', async () => {
const stepsAsset = []
const computeService= await ocean.compute.create_compute_service_attributes(account,"1000",metadataAsset.main.datePublished)
computeService= await ocean.compute.create_compute_service_attributes(account,"1000",metadataAsset.main.datePublished)
dataset = await ocean.assets
.create(metadataAsset as MetaData, account, [computeService])
.next(step => stepsAsset.push(step))