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

Fix publishing compute service (fill in parameters value in agreement conditions). Update agreement template events and conditions in the sample json.

This commit is contained in:
ssallam 2020-03-05 11:56:58 +01:00
parent 0d6913f5a7
commit 75a0ef05d9
6 changed files with 38 additions and 35 deletions

View File

@ -33,6 +33,7 @@ export interface ServiceComputeAttributes extends ServiceCommonAttributes {
price: string price: string
timeout: number timeout: number
provider?: ServiceComputeProvider provider?: ServiceComputeProvider
name: string
} }
} }

View File

@ -95,24 +95,19 @@ export class Keeper extends Instantiable {
computeExecutionCondition: keeper.instances.computeExecutionCondition computeExecutionCondition: keeper.instances.computeExecutionCondition
} }
// Templates // Templates
keeper.instances.escrowAccessSecretStoreTemplate = new EscrowAccessSecretStoreTemplate( keeper.templates = Object()
keeper.templates.escrowAccessSecretStoreTemplate = new EscrowAccessSecretStoreTemplate(
keeper.templateStoreManager, keeper.templateStoreManager,
keeper.agreementStoreManager, keeper.agreementStoreManager,
keeper.didRegistry, keeper.didRegistry,
keeper.conditions keeper.conditions
) )
keeper.instances.escrowComputeExecutionTemplate = new EscrowComputeExecutionTemplate( keeper.templates.escrowComputeExecutionTemplate = new EscrowComputeExecutionTemplate(
keeper.templateStoreManager, keeper.templateStoreManager,
keeper.agreementStoreManager, keeper.agreementStoreManager,
keeper.didRegistry, keeper.didRegistry,
keeper.conditions keeper.conditions
) )
keeper.templates = {
escrowAccessSecretStoreTemplate:
keeper.instances.escrowAccessSecretStoreTemplate,
escrowComputeExecutionTemplate:
keeper.instances.escrowComputeExecutionTemplate
}
// Utils // Utils
keeper.utils = { keeper.utils = {
eventHandler: new EventHandler(config) eventHandler: new EventHandler(config)

View File

@ -4,10 +4,10 @@ export const escrowAccessServiceAgreementTemplate: ServiceAgreementTemplate = {
contractName: 'EscrowAccessSecretStoreTemplate', contractName: 'EscrowAccessSecretStoreTemplate',
events: [ events: [
{ {
name: 'AgreementCreated', name: 'AgreementActorAdded',
actorType: 'consumer', actorType: 'provider',
handler: { handler: {
moduleName: 'escrowAccessSecretStoreTemplate', moduleName: '',
functionName: 'fulfillLockRewardCondition', functionName: 'fulfillLockRewardCondition',
version: '0.1' version: '0.1'
} }
@ -45,7 +45,7 @@ export const escrowAccessServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'lockRewardCondition', moduleName: 'lockRewardCondition',
functionName: 'fulfillAccessSecretStoreCondition', functionName: 'fulfillAccessSecretStoreCondition',
@ -75,7 +75,7 @@ export const escrowAccessServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'accessSecretStore', moduleName: 'accessSecretStore',
functionName: 'fulfillEscrowRewardCondition', functionName: 'fulfillEscrowRewardCondition',
@ -87,7 +87,7 @@ export const escrowAccessServiceAgreementTemplate: ServiceAgreementTemplate = {
actorType: 'consumer', actorType: 'consumer',
handler: { handler: {
moduleName: 'accessSecretStore', moduleName: 'accessSecretStore',
functionName: 'fulfillEscrowRewardCondition', functionName: 'refundReward',
version: '0.1' version: '0.1'
} }
} }
@ -129,7 +129,7 @@ export const escrowAccessServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'escrowRewardCondition', moduleName: 'escrowRewardCondition',
functionName: 'verifyRewardTokens', functionName: 'verifyRewardTokens',

View File

@ -4,10 +4,10 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
contractName: 'EscrowComputeExecutionTemplate', contractName: 'EscrowComputeExecutionTemplate',
events: [ events: [
{ {
name: 'AgreementCreated', name: 'AgreementActorAdded',
actorType: 'consumer', actorType: 'provider',
handler: { handler: {
moduleName: 'serviceExecutionTemplate', moduleName: '',
functionName: 'fulfillLockRewardCondition', functionName: 'fulfillLockRewardCondition',
version: '0.1' version: '0.1'
} }
@ -15,13 +15,13 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
], ],
fulfillmentOrder: [ fulfillmentOrder: [
'lockReward.fulfill', 'lockReward.fulfill',
'serviceExecution.fulfill', 'computeExecution.fulfill',
'escrowReward.fulfill' 'escrowReward.fulfill'
], ],
conditionDependency: { conditionDependency: {
lockReward: [], lockReward: [],
serviceExecution: [], serviceExecution: [],
escrowReward: ['lockReward', 'serviceExecution'] escrowReward: ['lockReward', 'computeExecution']
}, },
conditions: [ conditions: [
{ {
@ -45,17 +45,17 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'lockRewardCondition', moduleName: 'lockRewardExecutionCondition',
functionName: 'fulfillServiceExecutionCondition', functionName: 'fulfillComputeExecutionCondition',
version: '0.1' version: '0.1'
} }
} }
] ]
}, },
{ {
name: 'serviceExecution', name: 'computeExecution',
timelock: 0, timelock: 0,
timeout: 0, timeout: 0,
contractName: 'ComputeExecutionCondition', contractName: 'ComputeExecutionCondition',
@ -75,10 +75,10 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'serviceExecution', moduleName: 'accessSecretStore',
functionName: 'fulfillServiceExecutionCondition', functionName: 'fulfillEscrowRewardCondition',
version: '0.1' version: '0.1'
} }
}, },
@ -86,8 +86,8 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
name: 'TimedOut', name: 'TimedOut',
actorType: 'consumer', actorType: 'consumer',
handler: { handler: {
moduleName: 'serviceExec', moduleName: 'accessSecretStore',
functionName: 'fulfillServiceExecutionCondition', functionName: 'refundReward',
version: '0.1' version: '0.1'
} }
} }
@ -129,7 +129,7 @@ export const escrowComputeServiceAgreementTemplate: ServiceAgreementTemplate = {
events: [ events: [
{ {
name: 'Fulfilled', name: 'Fulfilled',
actorType: 'publisher', actorType: 'provider',
handler: { handler: {
moduleName: 'escrowRewardCondition', moduleName: 'escrowRewardCondition',
functionName: 'verifyRewardTokens', functionName: 'verifyRewardTokens',

View File

@ -159,9 +159,14 @@ export class OceanAssets extends Instantiable {
}) })
// Overwrite initial service agreement conditions // Overwrite initial service agreement conditions
const rawConditions = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions() let rawConditions = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions()
const conditions = fillConditionsWithDDO(rawConditions, ddo) serviceAgreementTemplate.conditions = fillConditionsWithDDO(rawConditions, ddo)
serviceAgreementTemplate.conditions = conditions for (let service of services) {
if (service.type === 'compute') {
const rawConditions = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplateConditions()
service.attributes.serviceAgreementTemplate.conditions = fillConditionsWithDDO(rawConditions, ddo)
}
}
this.logger.log('Generating proof') this.logger.log('Generating proof')
observer.next(CreateProgressStep.GeneratingProof) observer.next(CreateProgressStep.GeneratingProof)

View File

@ -87,17 +87,19 @@ export const createComputeService = async (
const { templates } = ocean.keeper const { templates } = ocean.keeper
const serviceAgreementTemplate = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplate() const serviceAgreementTemplate = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplate()
const name = 'dataAssetComputingServiceAgreement'
return { return {
type: 'compute', type: 'compute',
index: 3, index: 3,
serviceEndpoint: ocean.brizo.getComputeEndpoint(), serviceEndpoint: ocean.brizo.getComputeEndpoint(),
templateId: templates.escrowAccessSecretStoreTemplate.getId(), templateId: templates.escrowComputeExecutionTemplate.getId(),
attributes: { attributes: {
main: { main: {
creator: publisher.getId(), creator: publisher.getId(),
datePublished, datePublished,
price, price,
timeout: 3600 timeout: 3600,
name
}, },
serviceAgreementTemplate serviceAgreementTemplate
} }