1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Fix agreement status generation.

This commit is contained in:
Pedro Gutiérrez 2019-03-14 02:10:21 +01:00 committed by Pedro Gutiérrez
parent 4f469b2ab5
commit b1715be11a

View File

@ -96,14 +96,16 @@ export abstract class AgreementTemplate extends ContractBase {
const dependencies = await this.getServiceAgreementTemplateDependencies()
const {conditionIds} = await agreementStore.getAgreement(agreementId)
const conditionIdByConddition = (await this.getConditions())
.reduce((acc, {contractName}, i) => ({...acc, [contractName]: conditionIds[i]}), {})
const statesPromises = Object.keys(dependencies)
.map(async (ref, i) => {
const condition = await this.getServiceAgreementTemplateConditionByRef(ref)
const {contractName} = await this.getServiceAgreementTemplateConditionByRef(ref)
return {
ref,
contractName: condition.contractName,
state: (await conditionStore.getCondition(conditionIds[i])).state
contractName,
state: (await conditionStore.getCondition(conditionIdByConddition[contractName])).state
}
})
const states = await Promise.all(statesPromises)