diff --git a/src/brizo/Brizo.ts b/src/brizo/Brizo.ts index 3a85b32..77aa4cb 100644 --- a/src/brizo/Brizo.ts +++ b/src/brizo/Brizo.ts @@ -4,7 +4,7 @@ import { noZeroX } from '../utils' import { Instantiable, InstantiableConfig } from '../Instantiable.abstract' import { DDO } from '../ddo/DDO' import { ServiceType } from '../ddo/Service' -import { ComputeJob } from '../ocean/OceanCompute' +import { ComputeJob, Output } from '../ocean/OceanCompute' const apiPath = '/api/v1/brizo/services' @@ -117,7 +117,7 @@ export class Brizo extends Instantiable { algorithmDid?: string, algorithmMeta?: MetaData, jobId?: string, - output?: Record + output?: Output ): Promise { const signature = await this.createSignature(consumerAccount, serviceAgreementId) const address = consumerAccount.getId() diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 86aece8..5ba2042 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -17,6 +17,19 @@ export enum ComputeJobStatus { Deleted } +export interface Output { + publishAlgorithmLog?: boolean + publishOutput?: boolean + brizoAddress?: string + brizoUrl?: string + metadata?: Record + metadataUrl?: string + nodeUri?: string + owner?: string + secretStoreUrl?: string + whitelist?: Array +} + export interface ComputeJob { owner: string agreementId: string @@ -78,31 +91,26 @@ export class OceanCompute extends Instantiable { * return minimal output object * @return {Promise} Returns output object */ - public async getminimaloutput(): Promise> { - const minimaloutput = Object() - minimaloutput.publishAlgorithmLog = false - minimaloutput.publishOutput = false - return minimaloutput + public async getminimaloutput(): Promise { + const minimaloutput: Output = { + publishAlgorithmLog: false, + publishOutput: false + } + return minimaloutput as Output } /** * Check the output object and add default properties if needed * @param {Account} consumerAccount The account of the consumer ordering the service. * @param {Object} output Output section used for publishing the result. - * @return {Promise} Returns output object + * @return {Promise} Returns output object */ - public async checkoutput( - consumerAccount: Account, - output?: Record - ): Promise> { + public async checkoutput(consumerAccount: Account, output?: Output): Promise { if (!output) { // build a minimal object and return it return this.getminimaloutput() } - if ( - (!output.publishAlgorithmLog || output.publishAlgorithmLog === false) && - (!output.publishOutput || output.publishOutput === false) - ) { + if (!output.publishAlgorithmLog && !output.publishOutput) { return this.getminimaloutput() } if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress @@ -128,7 +136,7 @@ export class OceanCompute extends Instantiable { agreementId: string, algorithmDid?: string, algorithmMeta?: MetaData, - output?: Record + output?: Output ): Promise { output = await this.checkoutput(consumerAccount, output) const status = await this.ocean.brizo.compute(