From c8ea5f77c2ec541fdbfb6f77cdabcd5691e4bffa Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 23 Jan 2020 10:33:02 +0100 Subject: [PATCH] merge fixes --- src/ocean/OceanAssets.ts | 2 +- src/ocean/OceanCompute.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index d6b4370..4ad9107 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -292,7 +292,7 @@ export class OceanAssets extends Instantiable { public order( did: string, index: number, - consumerAccount: Account + consumerAccount: Account, provider?: string ): SubscribablePromise { return new SubscribablePromise(async observer => { diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 9eb8860..5fc2437 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -44,7 +44,8 @@ export class OceanCompute extends Instantiable { */ public order( consumerAccount: Account, - datasetDid: string + datasetDid: string, + provider?: string ): SubscribablePromise { return new SubscribablePromise(async observer => { const { keeper, assets, agreements } = this.ocean @@ -95,12 +96,23 @@ export class OceanCompute extends Instantiable { observer.next(OrderProgressStep.CreatingAgreement) this.logger.log('Creating agreement') + + // Get provider from didRegistry if not given in arguments + let _provider = provider + if (!provider) { + const providers = await keeper.didRegistry.getDIDProviders(ddo.shortId()) + if (providers) { + _provider = providers[0] + } + } + await agreements.create( datasetDid, agreementId, index, undefined, consumerAccount, + _provider, consumerAccount ) this.logger.log('Agreement created')