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

Generate fulfillmentIndices from service agreement conditions, set fulfillmentOperator to 1 (or operator), fix typo.

This commit is contained in:
ssallam 2018-11-21 15:58:59 +01:00
parent 779b5794d8
commit 1a3bb2f8b1
3 changed files with 11 additions and 4 deletions

View File

@ -11,13 +11,14 @@ export default class ServiceAgreement extends ContractBase {
}
public async setupAgreementTemplate(templateId: string, methodReflections: MethodReflection[],
dependencyMatrix: number[], name: any, fulfilmentOperator: number,
dependencyMatrix: number[], name: any, fulfillmentIndices: number[],
fulfillmentOperator: number,
ownerAddress: string)
: Promise<Receipt> {
return this.send("setupAgreementTemplate", ownerAddress, [
templateId, methodReflections.map((r) => r.address),
methodReflections.map((r) => r.signature), dependencyMatrix, name, [0], fulfilmentOperator,
methodReflections.map((r) => r.signature), dependencyMatrix, name, fulfillmentIndices, fulfillmentOperator,
])
}

View File

@ -34,6 +34,10 @@ export default class ServiceAgreementTemplate extends OceanBase {
return this.compressDependencies(method.dependencies, method.dependencyTimeoutFlags)
}))
const fulfillmentIndices: number[] = this.template.Methods
.map((method: Method, i: number) => method.isTerminalCondition ? i : undefined)
.filter((index: number) => index !== undefined)
const {serviceAgreement} = await Keeper.getInstance()
const methodReflections = await this.getMethodReflections()
@ -57,7 +61,9 @@ export default class ServiceAgreementTemplate extends OceanBase {
methodReflections,
dependencyMatrix,
Web3Provider.getWeb3().utils.fromAscii(this.template.templateName),
this.template.fulfilmentOperator, templateOwnerAddress)
fulfillmentIndices,
this.template.fulfillmentOperator,
templateOwnerAddress)
const {serviceTemplateId, provider} = receipt.events.SetupAgreementTemplate.returnValues

View File

@ -3,6 +3,6 @@ import Method from "../Method"
export default abstract class TemplateBase {
public Methods: Method[]
public templateName: string
public fulfilmentOperator: number = 0
public fulfillmentOperator: number = 1
public id: string = "0x00000000000000000000000000000000000000000000000000000000000000"
}