From 2cfb32199a384efdacdf45959ce5506a4bdc43c5 Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Tue, 20 Nov 2018 11:25:10 +0100 Subject: [PATCH] added logging, reworked consumer account on execute agreement --- src/ocean/ServiceAgreements/ServiceAgreement.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ocean/ServiceAgreements/ServiceAgreement.ts b/src/ocean/ServiceAgreements/ServiceAgreement.ts index 29d208b..0232e3c 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreement.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreement.ts @@ -14,6 +14,8 @@ export default class ServiceAgreement extends OceanBase { serviceAgreementId: string, consumer: Account): Promise { + // Logger.log("signing SA", serviceAgreementId) + const service: Service = ddo.findServiceById(serviceDefinitionId) const values: ValuePair[] = ServiceAgreement.getValuesFromService(service, serviceAgreementId) const valueHashes = ServiceAgreement.createValueHashes(values) @@ -29,14 +31,17 @@ export default class ServiceAgreement extends OceanBase { serviceAgreementId: string, serviceAgreementHashSignature: string, consumer: Account, publisher: Account): Promise { + // Logger.log("executing SA", serviceAgreementId) + const service: Service = ddo.findServiceById(serviceDefinitionId) const values: ValuePair[] = ServiceAgreement.getValuesFromService(service, serviceAgreementId) const valueHashes = ServiceAgreement.createValueHashes(values) const timeoutValues: number[] = ServiceAgreement.getTimeoutValuesFromService(service) + // todo get consumer from ddo const serviceAgreement: ServiceAgreement = await ServiceAgreement.executeAgreement(ddo, serviceDefinitionId, serviceAgreementId, valueHashes, timeoutValues, serviceAgreementHashSignature, - consumer, publisher) + consumer.getId(), publisher) return serviceAgreement } @@ -64,7 +69,8 @@ export default class ServiceAgreement extends OceanBase { private static async executeAgreement(ddo: DDO, serviceDefinitionId: string, serviceAgreementId: string, valueHashes: string[], timeoutValues: number[], - serviceAgreementHashSignature: string, consumer: Account, publisher: Account) + serviceAgreementHashSignature: string, consumerAddress: string, + publisher: Account) : Promise { const {serviceAgreement} = await Keeper.getInstance() @@ -76,7 +82,7 @@ export default class ServiceAgreement extends OceanBase { } const executeAgreementReceipt = await serviceAgreement.executeAgreement( - service.templateId, serviceAgreementHashSignature, consumer.getId(), valueHashes, + service.templateId, serviceAgreementHashSignature, consumerAddress, valueHashes, timeoutValues, serviceAgreementId, ddo.id, publisher.getId()) if (executeAgreementReceipt.events.ExecuteAgreement.returnValues.state === false) { @@ -87,7 +93,7 @@ export default class ServiceAgreement extends OceanBase { executeAgreementReceipt.events.ExecuteAgreement.returnValues.serviceAgreementId, ddo, publisher, - consumer, + new Account(consumerAddress), executeAgreementReceipt.events.ExecuteAgreement.returnValues.state, executeAgreementReceipt.events.ExecuteAgreement.returnValues.status, )