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-02-01 15:42:02 +02:00
parent eb73d6604c
commit 6e2289b27d
2 changed files with 28 additions and 29 deletions

View File

@ -117,7 +117,7 @@ export class Brizo extends Instantiable {
algorithmDid?: string,
algorithmMeta?: MetaData,
jobId?: string,
output?: Object
output?: Record<string, any>
): Promise<ComputeJob | ComputeJob[]> {
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
const address = consumerAccount.getId()

View File

@ -78,43 +78,42 @@ export class OceanCompute extends Instantiable {
* return minimal output object
* @return {Promise<Object>} Returns output object
*/
public async minimal_output_object():Promise<Object> {
var minimal_output=Object()
minimal_output["publishAlgorithmLog"]=false
minimal_output["publishOutput"]=false
return minimal_output
public async getminimaloutput(): Promise<Record<string, any>> {
const minimaloutput = Object()
minimaloutput.publishAlgorithmLog = false
minimaloutput.publishOutput = false
return minimaloutput
}
/**
* 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<Object>} Returns output object
*/
public async check_output_dict(
public async checkoutput(
consumerAccount: Account,
output?:Object
): Promise<Object> {
output?: Record<string, any>
): Promise<Record<string, any>> {
if (!output) {
// build a minimal object and return it
return (await this.minimal_output_object())
return this.getminimaloutput()
}
if((!output["publishAlgorithmLog"] || output["publishAlgorithmLog"]==false) && (!output["publishOutput"] || output["publishOutput"]==false)){
return (await this.minimal_output_object())
if (
(!output.publishAlgorithmLog || output.publishAlgorithmLog === false) &&
(!output.publishOutput || output.publishOutput === false)
) {
return this.getminimaloutput()
}
if(!output["brizoAddress"])
output["brizoAddress"]=this.config.brizoAddress
if(!output["brizoUrl"])
output["brizoUrl"]=this.config.brizoUri
if(!output["metadataUrl"])
output["metadataUrl"]=this.config.aquariusUri
if(!output["nodeUri"])
output["nodeUri"]=this.config.nodeUri
if(!output["owner"])
output["owner"]=consumerAccount.getId()
if(!output["secretStoreUrl"])
output["secretStoreUrl"]=this.config.secretStoreUri
if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress
if (!output.brizoUrl) output.brizoUrl = this.config.brizoUri
if (!output.metadataUrl) output.metadataUrl = this.config.aquariusUri
if (!output.nodeUri) output.nodeUri = this.config.nodeUri
if (!output.owner) output.owner = consumerAccount.getId()
if (!output.secretStoreUrl) output.secretStoreUrl = this.config.secretStoreUri
return output
}
/**
* Start the execution of a compute job.
* @param {Account} consumerAccount The account of the consumer ordering the service.
@ -129,9 +128,9 @@ export class OceanCompute extends Instantiable {
agreementId: string,
algorithmDid?: string,
algorithmMeta?: MetaData,
output?:Object
output?: Record<string, any>
): Promise<ComputeJob> {
output=await this.check_output_dict(consumerAccount,output)
output = await this.checkoutput(consumerAccount, output)
const status = await this.ocean.brizo.compute(
'post',
agreementId,