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

add events to template

This commit is contained in:
Sebastian Gerske 2018-11-23 09:57:26 +01:00
parent 8d018633a9
commit 43db4412ee
4 changed files with 78 additions and 8 deletions

View File

@ -0,0 +1,7 @@
import EventHandler from "./EventHandler"
export default class Event {
public name: string = "PaymentLocked"
public actorType: string = "publisher"
public handler: EventHandler
}

View File

@ -0,0 +1,5 @@
export default class EventHandler {
public moduleName: string = "accessControl"
public functionName: string = "grantAccess"
public version: string = "0.1"
}

View File

@ -1,3 +1,4 @@
import Event from "./Event"
import Parameter from "./Parameter"
export default class Method {
@ -6,6 +7,7 @@ export default class Method {
public methodName: string
public timeout: number
public parameters: Parameter[]
public events: Event[]
public dependencies: string[]
public dependencyTimeoutFlags: number[]
public isTerminalCondition: boolean

View File

@ -1,4 +1,7 @@
import Event from "../Event"
import EventHandler from "../EventHandler"
import Method from "../Method"
import Parameter from "../Parameter"
import TemplateBase from "./TemplateBase"
export default class Access extends TemplateBase {
@ -15,11 +18,22 @@ export default class Access extends TemplateBase {
{
name: "assetId",
type: "bytes32",
},
} as Parameter,
{
name: "price",
type: "uint256",
},
} as Parameter,
],
events: [
{
name: "PaymentLocked",
actorType: "publisher",
handler: {
moduleName: "accessControl",
functionName: "grantAccess",
version: "0.1",
} as EventHandler,
} as Event,
],
dependencies: [],
dependencyTimeoutFlags: [],
@ -34,11 +48,31 @@ export default class Access extends TemplateBase {
{
name: "assetId",
type: "bytes32",
},
} as Parameter,
{
name: "documentKeyId",
type: "bytes32",
},
} as Parameter,
],
events: [
{
name: "AccessGranted",
actorType: "consumer",
handler: {
moduleName: "asset",
functionName: "consumeService",
version: "0.1",
} as EventHandler,
} as Event,
{
name: "AccessGranted",
actorType: "publisher",
handler: {
moduleName: "payment",
functionName: "releasePayment",
version: "0.1",
} as EventHandler,
} as Event,
],
dependencies: ["lockPayment"],
dependencyTimeoutFlags: [0],
@ -53,11 +87,22 @@ export default class Access extends TemplateBase {
{
name: "assetId",
type: "bytes32",
},
} as Parameter,
{
name: "price",
type: "uint256",
},
} as Parameter,
],
events: [
{
name: "PaymentReleased",
actorType: "publisher",
handler: {
moduleName: "serviceAgreement",
functionName: "fulfillAgreement",
version: "0.1",
} as EventHandler,
} as Event,
],
dependencies: ["grantAccess"],
dependencyTimeoutFlags: [0],
@ -72,11 +117,22 @@ export default class Access extends TemplateBase {
{
name: "assetId",
type: "bytes32",
},
} as Parameter,
{
name: "price",
type: "uint256",
},
} as Parameter,
],
events: [
{
name: "PaymentRefund",
actorType: "consumer",
handler: {
moduleName: "serviceAgreement",
functionName: "fulfillAgreement",
version: "0.1",
} as EventHandler,
} as Event,
],
dependencies: ["lockPayment", "grantAccess"],
dependencyTimeoutFlags: [0, 1],