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)),
|
decodeURI(JSON.stringify(args)),
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Logger.error(e)
|
||||||
throw new Error("HTTP request failed")
|
throw new Error("HTTP request failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import ContractBase from "../ContractBase"
|
import ContractBase from "../ContractBase"
|
||||||
import { Condition } from "../conditions/Condition.abstract"
|
import { Condition } from "../conditions/Condition.abstract"
|
||||||
import Keeper from "../../Keeper"
|
import Keeper from "../../Keeper"
|
||||||
|
import { ServiceAgreementTemplate, ServiceAgreementTemplateCondition } from '../../../ddo/ServiceAgreementTemplate'
|
||||||
import { zeroX } from "../../../utils"
|
import { zeroX } from "../../../utils"
|
||||||
|
|
||||||
export abstract class AgreementTemplate extends ContractBase {
|
export abstract class AgreementTemplate extends ContractBase {
|
||||||
@ -50,4 +51,11 @@ export abstract class AgreementTemplate extends ContractBase {
|
|||||||
.map(address => keeper.getConditionByAddress(address))
|
.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 DIDRegistry from '../DIDRegistry'
|
||||||
import { generateId } from '../../../utils/GeneratorHelpers'
|
import { generateId } from '../../../utils/GeneratorHelpers'
|
||||||
|
|
||||||
|
import { escrowAccessSecretStoreTemplateServiceAgreementTemplate } from "./EscrowAccessSecretStoreTemplate.serviceAgreementTemplate"
|
||||||
|
|
||||||
export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
||||||
|
|
||||||
public static async getInstance(): Promise<EscrowAccessSecretStoreTemplate> {
|
public static async getInstance(): Promise<EscrowAccessSecretStoreTemplate> {
|
||||||
return AgreementTemplate.getInstance("EscrowAccessSecretStoreTemplate", EscrowAccessSecretStoreTemplate)
|
return AgreementTemplate.getInstance("EscrowAccessSecretStoreTemplate", EscrowAccessSecretStoreTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getServiceAgreementTemplate() {
|
||||||
|
return escrowAccessSecretStoreTemplateServiceAgreementTemplate
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a agreement using EscrowAccessSecretStoreTemplate.
|
* Create a agreement using EscrowAccessSecretStoreTemplate.
|
||||||
* @param {string} agreementId Generated agreement ID.
|
* @param {string} agreementId Generated agreement ID.
|
||||||
@ -69,6 +75,7 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
|||||||
conditionIdLock,
|
conditionIdLock,
|
||||||
conditionIdAccess,
|
conditionIdAccess,
|
||||||
)
|
)
|
||||||
|
|
||||||
await this.createAgreement(
|
await this.createAgreement(
|
||||||
agreementId,
|
agreementId,
|
||||||
did,
|
did,
|
||||||
|
Loading…
Reference in New Issue
Block a user