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/EscrowAccessSecretStoreTemplate.ts
2020-01-17 15:35:11 +01:00

51 lines
1.5 KiB
TypeScript

import { AgreementTemplateBase } from './AgreementTemplateBase'
import { escrowAccessServiceAgreementTemplate } from './EscrowAccess.serviceAgreementTemplate'
export class EscrowAccessSecretStoreTemplate extends AgreementTemplateBase {
public templateName: 'EscrowAccessSecretStoreTemplate'
public async getServiceAgreementTemplate() {
return escrowAccessServiceAgreementTemplate
}
protected async createFullAgreementData(
agreementId: string,
did: string,
amount: number | string,
consumer: string
) {
const {
lockRewardCondition,
accessSecretStoreCondition,
escrowReward
} = this.conditions
const publisher = await this.didRegistry.getDIDOwner(did)
const lockRewardConditionId = await lockRewardCondition.generateIdHash(
agreementId,
await escrowReward.getAddress(),
String(amount)
)
const accessSecretStoreConditionId = await accessSecretStoreCondition.generateIdHash(
agreementId,
did,
consumer
)
const escrowRewardId = await escrowReward.generateIdHash(
agreementId,
String(amount),
publisher,
consumer,
lockRewardConditionId,
accessSecretStoreConditionId
)
return [
lockRewardConditionId,
accessSecretStoreConditionId,
escrowRewardId
]
}
}