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
timeout: number
provider?: ServiceComputeProvider
name: string
}
}

View File

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

View File

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

View File

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

View File

@ -159,9 +159,14 @@ export class OceanAssets extends Instantiable {
})
// Overwrite initial service agreement conditions
const rawConditions = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions()
const conditions = fillConditionsWithDDO(rawConditions, ddo)
serviceAgreementTemplate.conditions = conditions
let rawConditions = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions()
serviceAgreementTemplate.conditions = fillConditionsWithDDO(rawConditions, ddo)
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')
observer.next(CreateProgressStep.GeneratingProof)

View File

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