diff --git a/src/ocean/Compute.ts b/src/ocean/Compute.ts index c69713d8..ab5e196c 100644 --- a/src/ocean/Compute.ts +++ b/src/ocean/Compute.ts @@ -176,12 +176,14 @@ export class Compute extends Instantiable { * @param {Account} consumerAccount The account of the consumer ordering the service. * @param {string} did Decentralized identifier. * @param {string} jobId The ID of the compute job to be stopped + * @param {boolean} sign If the provider request is going to be signed(default) (full status) or not (short status) * @return {Promise} Returns the status */ public async status( consumerAccount: Account, did?: string, - jobId?: string + jobId?: string, + sign = true ): Promise { let provider: Provider @@ -200,7 +202,15 @@ export class Compute extends Instantiable { consumerAccount, undefined, undefined, - jobId + jobId, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + sign ) return computeJobsList as ComputeJob[] diff --git a/src/provider/Provider.ts b/src/provider/Provider.ts index a9061481..fd3d5757 100644 --- a/src/provider/Provider.ts +++ b/src/provider/Provider.ts @@ -171,20 +171,22 @@ export class Provider extends Instantiable { serviceType?: string, tokenAddress?: string, algorithmTransferTxId?: string, - algorithmDataToken?: string + algorithmDataToken?: string, + sign = true ): Promise { const address = consumerAccount.getId() await this.getNonce(consumerAccount.getId()) - let signatureMessage = address - signatureMessage += jobId || '' - signatureMessage += (did && `${noZeroX(did)}`) || '' - signatureMessage += this.nonce - const signature = await this.createHashSignature(consumerAccount, signatureMessage) - - // construct Brizo URL let url = this.getComputeEndpoint() - url += `?signature=${signature}` - url += `&documentId=${noZeroX(did)}` + url += `?documentId=${noZeroX(did)}` + if (sign) { + let signatureMessage = address + signatureMessage += jobId || '' + signatureMessage += (did && `${noZeroX(did)}`) || '' + signatureMessage += this.nonce + const signature = await this.createHashSignature(consumerAccount, signatureMessage) + url += `&signature=${signature}` + } + // continue to construct Provider URL url += (output && `&output=${JSON.stringify(output)}`) || '' url += (algorithmDid && `&algorithmDid=${algorithmDid}`) || '' url += @@ -215,7 +217,6 @@ export class Provider extends Instantiable { // switch fetch method let fetch - switch (method) { case 'post': fetch = this.ocean.utils.fetch.post(url, '') diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 4f377981..b9bf131c 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -352,7 +352,16 @@ describe('Compute flow', () => { jobId = response.jobId assert(response.status >= 10) }) + it('Bob should get status of a compute job without signing', async () => { + assert(jobId != null) + const response = await ocean.compute.status(bob, ddo.id, jobId, false) + assert(response[0].jobId === jobId) + }) + it('should get status of all compute jobs for an address without signing', async () => { + const response = await ocean.compute.status(bob, undefined, undefined, false) + assert(response.length > 0) + }) it('Bob should get status of a compute job', async () => { assert(jobId != null) const response = await ocean.compute.status(bob, ddo.id, jobId)