From 04aa6d6700b49a730019499edc7ba57c82261242 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 21 Jan 2020 15:13:02 +0100 Subject: [PATCH] add ocean.compute.result --- src/ocean/OceanCompute.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 3d22611..4bf943d 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -144,7 +144,7 @@ export class OceanCompute extends Instantiable { * @param {Account} consumerAccount The account of the consumer ordering the service. * @param {string} agreementId The service agreement ID. * @param {string} jobId The ID of the compute job to be stopped - * @return {Promise} Returns the status + * @return {Promise} Returns the status */ public async status( consumerAccount: Account, @@ -160,4 +160,26 @@ export class OceanCompute extends Instantiable { return status } + + /** + * Returns the final result of a specific compute job published as an asset. + * @param {string} agreementId The service agreement ID. + * @param {Account} consumerAccount The account of the consumer ordering the service. + * @param {string} jobId The ID of the compute job to be stopped. + * @return {Promise} Returns the DDO of the result asset. + */ + public async result( + consumerAccount: Account, + agreementId: string, + jobId: string + ): Promise { + const status = await this.ocean.brizo.computeService( + 'get', + agreementId, + consumerAccount, + jobId + ) + + return status[0].ddo ? status[0].ddo : null + } }