mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Merge pull request #53 from oceanprotocol/feature/generate-fulfillment-indices
Generate fulfillmentIndices from service agreement conditions, set fu…
This commit is contained in:
commit
17e6540031
@ -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,
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user