mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Move access service template used on the DDO to each agreement template.
This commit is contained in:
parent
4f28092014
commit
136250b70c
@ -55,6 +55,7 @@ export default class Brizo {
|
||||
decodeURI(JSON.stringify(args)),
|
||||
)
|
||||
} catch (e) {
|
||||
Logger.error(e)
|
||||
throw new Error("HTTP request failed")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import ContractBase from "../ContractBase"
|
||||
import { Condition } from "../conditions/Condition.abstract"
|
||||
import Keeper from "../../Keeper"
|
||||
import { ServiceAgreementTemplate, ServiceAgreementTemplateCondition } from '../../../ddo/ServiceAgreementTemplate'
|
||||
import { zeroX } from "../../../utils"
|
||||
|
||||
export abstract class AgreementTemplate extends ContractBase {
|
||||
@ -50,4 +51,11 @@ export abstract class AgreementTemplate extends ContractBase {
|
||||
.map(address => keeper.getConditionByAddress(address))
|
||||
|
||||
}
|
||||
|
||||
abstract getServiceAgreementTemplate(): Promise<ServiceAgreementTemplate>
|
||||
|
||||
public async getServiceAgreementTemplateConditions(): Promise<ServiceAgreementTemplateCondition[]> {
|
||||
const serviceAgreementTemplate = await this.getServiceAgreementTemplate()
|
||||
return serviceAgreementTemplate.conditions
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,145 @@
|
||||
import { ServiceAgreementTemplate } from '../../../ddo/ServiceAgreementTemplate'
|
||||
|
||||
export const escrowAccessSecretStoreTemplateServiceAgreementTemplate: ServiceAgreementTemplate = {
|
||||
"contractName": "EscrowAccessSecretStoreTemplate",
|
||||
"events": [
|
||||
{
|
||||
"name": "AgreementCreated",
|
||||
"actorType": "consumer",
|
||||
"handler": {
|
||||
"moduleName": "escrowAccessSecretStoreTemplate",
|
||||
"functionName": "fulfillLockRewardCondition",
|
||||
"version": "0.1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"fulfillmentOrder": [
|
||||
"lockReward.fulfill",
|
||||
"accessSecretStore.fulfill",
|
||||
"escrowReward.fulfill"
|
||||
],
|
||||
"conditionDependency": {
|
||||
"lockReward": [],
|
||||
"grantSecretStoreAccess": [],
|
||||
"releaseReward": [
|
||||
"lockReward",
|
||||
"accessSecretStore"
|
||||
]
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"name": "lockReward",
|
||||
"timelock": 0,
|
||||
"timeout": 0,
|
||||
"contractName": "LockRewardCondition",
|
||||
"functionName": "fulfill",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "_rewardAddress",
|
||||
"type": "address",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "Fulfilled",
|
||||
"actorType": "publisher",
|
||||
"handler": {
|
||||
"moduleName": "lockRewardCondition",
|
||||
"functionName": "fulfillAccessSecretStoreCondition",
|
||||
"version": "0.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "accessSecretStore",
|
||||
"timelock": 0,
|
||||
"timeout": 0,
|
||||
"contractName": "AccessSecretStoreCondition",
|
||||
"functionName": "fulfill",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "_documentId",
|
||||
"type": "bytes32",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_grantee",
|
||||
"type": "address",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "Fulfilled",
|
||||
"actorType": "publisher",
|
||||
"handler": {
|
||||
"moduleName": "accessSecretStore",
|
||||
"functionName": "fulfillEscrowRewardCondition",
|
||||
"version": "0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TimedOut",
|
||||
"actorType": "consumer",
|
||||
"handler": {
|
||||
"moduleName": "accessSecretStore",
|
||||
"functionName": "fulfillEscrowRewardCondition",
|
||||
"version": "0.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "escrowReward",
|
||||
"timelock": 0,
|
||||
"timeout": 0,
|
||||
"contractName": "EscrowReward",
|
||||
"functionName": "fulfill",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_receiver",
|
||||
"type": "address",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_sender",
|
||||
"type": "address",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_lockCondition",
|
||||
"type": "bytes32",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "_releaseCondition",
|
||||
"type": "bytes32",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "Fulfilled",
|
||||
"actorType": "publisher",
|
||||
"handler": {
|
||||
"moduleName": "escrowRewardCondition",
|
||||
"functionName": "verifyRewardTokens",
|
||||
"version": "0.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -3,12 +3,18 @@ import { LockRewardCondition, EscrowReward, AccessSecretStoreCondition } from '.
|
||||
import DIDRegistry from '../DIDRegistry'
|
||||
import { generateId } from '../../../utils/GeneratorHelpers'
|
||||
|
||||
import { escrowAccessSecretStoreTemplateServiceAgreementTemplate } from "./EscrowAccessSecretStoreTemplate.serviceAgreementTemplate"
|
||||
|
||||
export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
||||
|
||||
public static async getInstance(): Promise<EscrowAccessSecretStoreTemplate> {
|
||||
return AgreementTemplate.getInstance("EscrowAccessSecretStoreTemplate", EscrowAccessSecretStoreTemplate)
|
||||
}
|
||||
|
||||
public async getServiceAgreementTemplate() {
|
||||
return escrowAccessSecretStoreTemplateServiceAgreementTemplate
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a agreement using EscrowAccessSecretStoreTemplate.
|
||||
* @param {string} agreementId Generated agreement ID.
|
||||
@ -69,6 +75,7 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
||||
conditionIdLock,
|
||||
conditionIdAccess,
|
||||
)
|
||||
|
||||
await this.createAgreement(
|
||||
agreementId,
|
||||
did,
|
||||
|
Loading…
Reference in New Issue
Block a user