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

51 lines
1.5 KiB
TypeScript

import { AgreementTemplateBase } from './AgreementTemplateBase'
import { escrowComputeServiceAgreementTemplate } from './EscrowCompute.serviceAgreementTemplate'
export class EscrowComputeExecutionTemplate extends AgreementTemplateBase {
public static templateName: 'EscrowComputeExecutionTemplate'
public async getServiceAgreementTemplate() {
return escrowComputeServiceAgreementTemplate
}
protected async createFullAgreementData(
agreementId: string,
did: string,
amount: number | string,
consumer: string
) {
const {
lockRewardCondition,
computeExecutionCondition,
escrowReward
} = this.conditions
const publisher = await this.didRegistry.getDIDOwner(did)
const lockRewardConditionId = await lockRewardCondition.generateIdHash(
agreementId,
await escrowReward.getAddress(),
amount
)
const computeExecutionConditionId = await computeExecutionCondition.generateIdHash(
agreementId,
did,
consumer
)
const escrowRewardId = await escrowReward.generateIdHash(
agreementId,
String(amount),
publisher,
consumer,
lockRewardConditionId,
computeExecutionConditionId
)
return {
lockRewardConditionId,
computeExecutionConditionId,
escrowRewardId
}
}
}