From 920ae0dc354850c3f117dba0f9e1da34144d5310 Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 10:56:06 +0100 Subject: [PATCH 1/6] added more logging --- src/keeper/contracts/ContractBase.ts | 9 ++++-- .../ServiceAgreementTemplate.ts | 31 +++++++++++++------ test/ocean/ServiceAgreement.test.ts | 28 ++++++++++++++--- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/keeper/contracts/ContractBase.ts b/src/keeper/contracts/ContractBase.ts index f9eb9c4..e3e7ecd 100644 --- a/src/keeper/contracts/ContractBase.ts +++ b/src/keeper/contracts/ContractBase.ts @@ -60,16 +60,18 @@ export default abstract class ContractBase { if (!this.contract.methods[name]) { throw new Error(`Method "${name}" is not part of contract "${this.contractName}"`) } + // Logger.log(name) const method = this.contract.methods[name] try { - const tx = method(...args) - const estimatedGas = await tx.estimateGas(args, { + const methodInstance = method(...args) + const estimatedGas = await methodInstance.estimateGas(args, { from, }) - return tx.send({ + const tx = methodInstance.send({ from, gas: estimatedGas, }) + return tx } catch (err) { const mappedArgs = this.searchMethod(name).inputs.map((input, i) => { return { @@ -87,6 +89,7 @@ export default abstract class ContractBase { if (!this.contract.methods[name]) { throw new Error(`Method ${name} is not part of contract ${this.contractName}`) } + // Logger.log(name) try { const method = this.contract.methods[name](...args) return method.call(from ? {from} : null) diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index c111f2d..85499d9 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -38,6 +38,8 @@ export default class ServiceAgreementTemplate extends OceanBase { .map((method: Method, i: number) => method.isTerminalCondition ? i : undefined) .filter((index: number) => index !== undefined) + Logger.log(dependencyMatrix, fulfillmentIndices, this.template.fulfillmentOperator) + const {serviceAgreement} = await Keeper.getInstance() const methodReflections = await this.getMethodReflections() @@ -128,18 +130,29 @@ export default class ServiceAgreementTemplate extends OceanBase { const mappedDependencies: number[] = dependencies.map((dep: string) => { return this.template.Methods.findIndex((m) => m.name === dep) }) + Logger.log("========================") - let compressedDependencyValue = 0 - const numBits = 2 // 1st for dependency, 2nd for timeout flag - for (let i = 0; i < mappedDependencies.length; i++) { - const dependencyIndex = mappedDependencies[i] - const timeout = dependencyTimeoutFlags[i] - const offset = i * numBits + Logger.log(dependencies, mappedDependencies, dependencyTimeoutFlags) + + let compressedDependencyValue: number = 0 + const numBits: number = 2 // 1st for dependency, 2nd for timeout flag + mappedDependencies.forEach((d: number, i: number) => { + const timeout: number = dependencyTimeoutFlags[i] + const offset: number = i * numBits + Logger.log("index", i, "offset", offset) + const depShift: number = d * 2 ** (offset + 0) + Logger.log("ds", depShift) // tslint:disable-next-line - compressedDependencyValue |= dependencyIndex * 2 ** (offset + 0) // the dependency bit + compressedDependencyValue ^= depShift // the dependency bit + const timeShift: number = timeout * 2 ** (offset + 1) + Logger.log("ts", timeShift) // tslint:disable-next-line - compressedDependencyValue |= timeout * 2 ** (offset + 1) // the timeout bit - } + compressedDependencyValue ^= timeShift // the timeout bit + }) + + Logger.log(compressedDependencyValue) + + Logger.log("========================") return compressedDependencyValue } diff --git a/test/ocean/ServiceAgreement.test.ts b/test/ocean/ServiceAgreement.test.ts index c11d35a..3b5a0c2 100644 --- a/test/ocean/ServiceAgreement.test.ts +++ b/test/ocean/ServiceAgreement.test.ts @@ -14,7 +14,6 @@ import Condition from "../../src/ocean/ServiceAgreements/Condition" import ServiceAgreement from "../../src/ocean/ServiceAgreements/ServiceAgreement" import ServiceAgreementTemplate from "../../src/ocean/ServiceAgreements/ServiceAgreementTemplate" import Access from "../../src/ocean/ServiceAgreements/Templates/Access" -import Logger from "../../src/utils/Logger" import WebServiceConnectorProvider from "../../src/utils/WebServiceConnectorProvider" import config from "../config" import TestContractHandler from "../keeper/TestContractHandler" @@ -209,8 +208,6 @@ describe("ServiceAgreement", () => { // get funds await consumerAccount.requestTokens(metaDataService.metadata.base.price) - Logger.log(await consumerAccount.getBalance()) - const paid: boolean = await serviceAgreement.lockPayment(assetId, metaDataService.metadata.base.price, consumerAccount) assert(paid) @@ -218,7 +215,7 @@ describe("ServiceAgreement", () => { }) describe("#grantAccess()", () => { - xit("should grant access in that service agreement", async () => { + it("should grant access in that service agreement", async () => { const id: string = IdGenerator.generateId() const did: string = `did:op:${id}` @@ -247,5 +244,28 @@ describe("ServiceAgreement", () => { const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, IdGenerator.generateId()) assert(accessGranted) }) + + xit("should fail to grant grant access if there is no payment", async () => { + + const id: string = IdGenerator.generateId() + const did: string = `did:op:${id}` + const ddo = new DDO({id: did, service: [accessService]}) + const serviceAgreementId: string = IdGenerator.generateId() + + // @ts-ignore + WebServiceConnectorProvider.setConnector(new WebServiceConnectorMock(ddo)) + const serviceAgreementSignature: string = + await ServiceAgreement.signServiceAgreement(assetId, ddo, accessService.serviceDefinitionId, + serviceAgreementId, consumerAccount) + assert(serviceAgreementSignature) + + const serviceAgreement: ServiceAgreement = + await ServiceAgreement.executeServiceAgreement(assetId, ddo, accessService.serviceDefinitionId, + serviceAgreementId, serviceAgreementSignature, consumerAccount, publisherAccount) + assert(serviceAgreement) + + const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, IdGenerator.generateId()) + assert(!accessGranted) + }) }) }) From 8390c125991b699edf95efbfa7a8701dc547da98 Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 10:58:24 +0100 Subject: [PATCH 2/6] fix shifting --- src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index 85499d9..bdd8fc3 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -143,11 +143,11 @@ export default class ServiceAgreementTemplate extends OceanBase { const depShift: number = d * 2 ** (offset + 0) Logger.log("ds", depShift) // tslint:disable-next-line - compressedDependencyValue ^= depShift // the dependency bit + compressedDependencyValue |= depShift // the dependency bit const timeShift: number = timeout * 2 ** (offset + 1) Logger.log("ts", timeShift) // tslint:disable-next-line - compressedDependencyValue ^= timeShift // the timeout bit + compressedDependencyValue |= timeShift // the timeout bit }) Logger.log(compressedDependencyValue) From 8a68715fcef640dc22fa337b3ee795f3bb3ca6ed Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 11:32:06 +0100 Subject: [PATCH 3/6] getting closer to compressed deps --- .../ServiceAgreementTemplate.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index bdd8fc3..2f4cb14 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -127,27 +127,31 @@ export default class ServiceAgreementTemplate extends OceanBase { } // map name to index - const mappedDependencies: number[] = dependencies.map((dep: string) => { - return this.template.Methods.findIndex((m) => m.name === dep) + const mappedDependencies: number[] = [] + const mappedDependencyTimeoutFlags: number[] = [] + + this.template.Methods.forEach((m, i) => { + mappedDependencies.push(dependencies.findIndex((d) => d === m.name) > -1 ? i : 0) + mappedDependencyTimeoutFlags.push(dependencyTimeoutFlags[i] ? dependencyTimeoutFlags[i] : 0) }) + Logger.log("========================") - Logger.log(dependencies, mappedDependencies, dependencyTimeoutFlags) + if (mappedDependencies.length !== mappedDependencyTimeoutFlags.length) { + throw new Error("Deps and timeouts need the same length") + } + + Logger.log(dependencies, mappedDependencies, dependencyTimeoutFlags, mappedDependencyTimeoutFlags) let compressedDependencyValue: number = 0 const numBits: number = 2 // 1st for dependency, 2nd for timeout flag mappedDependencies.forEach((d: number, i: number) => { - const timeout: number = dependencyTimeoutFlags[i] + const t: number = mappedDependencyTimeoutFlags[i] const offset: number = i * numBits - Logger.log("index", i, "offset", offset) - const depShift: number = d * 2 ** (offset + 0) - Logger.log("ds", depShift) // tslint:disable-next-line - compressedDependencyValue |= depShift // the dependency bit - const timeShift: number = timeout * 2 ** (offset + 1) - Logger.log("ts", timeShift) + compressedDependencyValue |= d * 2 ** (offset + 0) // the dependency bit // tslint:disable-next-line - compressedDependencyValue |= timeShift // the timeout bit + compressedDependencyValue |= t * 2 ** (offset + 1) // the timeout bit }) Logger.log(compressedDependencyValue) From 42959d8fc7c6b0676faff51d222f446baba26978 Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 11:38:00 +0100 Subject: [PATCH 4/6] fix compressed deps --- src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index 2f4cb14..5b472b8 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -131,8 +131,9 @@ export default class ServiceAgreementTemplate extends OceanBase { const mappedDependencyTimeoutFlags: number[] = [] this.template.Methods.forEach((m, i) => { - mappedDependencies.push(dependencies.findIndex((d) => d === m.name) > -1 ? i : 0) - mappedDependencyTimeoutFlags.push(dependencyTimeoutFlags[i] ? dependencyTimeoutFlags[i] : 0) + const di = dependencies.findIndex((d) => d === m.name) + mappedDependencies.push(di > -1 ? 1 : 0) + mappedDependencyTimeoutFlags.push(dependencyTimeoutFlags[i] ? 1 : 0) }) Logger.log("========================") From 2d41535bab5aa3d6456a6ead8b120a2fef79c05a Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 11:39:20 +0100 Subject: [PATCH 5/6] remove logs --- src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index 5b472b8..9bc4186 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -136,8 +136,6 @@ export default class ServiceAgreementTemplate extends OceanBase { mappedDependencyTimeoutFlags.push(dependencyTimeoutFlags[i] ? 1 : 0) }) - Logger.log("========================") - if (mappedDependencies.length !== mappedDependencyTimeoutFlags.length) { throw new Error("Deps and timeouts need the same length") } @@ -155,10 +153,6 @@ export default class ServiceAgreementTemplate extends OceanBase { compressedDependencyValue |= t * 2 ** (offset + 1) // the timeout bit }) - Logger.log(compressedDependencyValue) - - Logger.log("========================") - return compressedDependencyValue } From a6c09d0f8884bf15f013bab31cba2b9799e69314 Mon Sep 17 00:00:00 2001 From: Sebastian Gerske Date: Thu, 22 Nov 2018 13:14:38 +0100 Subject: [PATCH 6/6] fix lock Payment --- package-lock.json | 1794 +---------------- package.json | 4 +- src/keeper/contracts/ContractBase.ts | 2 +- src/keeper/contracts/ServiceAgreement.ts | 6 +- .../ServiceAgreements/ServiceAgreement.ts | 8 +- .../ServiceAgreementTemplate.ts | 15 +- test/ocean/ServiceAgreement.test.ts | 36 +- 7 files changed, 55 insertions(+), 1810 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbbca29..c9db5e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -120,1766 +120,16 @@ } }, "@oceanprotocol/keeper-contracts": { - "version": "0.3.23", - "resolved": "https://registry.npmjs.org/@oceanprotocol/keeper-contracts/-/keeper-contracts-0.3.23.tgz", - "integrity": "sha512-nuO5j27VJrx7OkqUrEI3b8PZOFOL1+M7IYFqUKHWZxmkUf+on6xW+oDV208AC9jymkfYADtgrgX2rc6nbq+7zQ==" + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@oceanprotocol/keeper-contracts/-/keeper-contracts-0.3.25.tgz", + "integrity": "sha512-lW/36WYYCIHSX4OVnbk6KcKnnV7vsBbrEQPW+6cWUDokEWoBfxpdMIeTxCOyKZKavv7MrtFHDrb8BgjfTIIhsA==" }, "@oceanprotocol/secret-store-client": { "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@oceanprotocol/secret-store-client/-/secret-store-client-0.0.12.tgz", + "integrity": "sha512-qQMIZNwEgL6W93e3ryUVELgRxDO1WzaN7Dj2Kvhjkk/miwXmZXRFyf2p3fh0UESKwHiFGK6re3YA55fO43Dvnw==", "requires": { "node-fetch": "^2.3.0" - }, - "dependencies": { - "@babel/code-frame": { - "version": "7.0.0", - "bundled": true, - "requires": { - "@babel/highlight": "^7.0.0" - } - }, - "@babel/generator": { - "version": "7.1.3", - "bundled": true, - "requires": { - "@babel/types": "^7.1.3", - "jsesc": "^2.5.1", - "lodash": "^4.17.10", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - } - }, - "@babel/helper-function-name": { - "version": "7.1.0", - "bundled": true, - "requires": { - "@babel/helper-get-function-arity": "^7.0.0", - "@babel/template": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.0.0", - "bundled": true, - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.0.0", - "bundled": true, - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@babel/highlight": { - "version": "7.0.0", - "bundled": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^4.0.0" - } - }, - "@babel/parser": { - "version": "7.1.3", - "bundled": true - }, - "@babel/template": { - "version": "7.1.2", - "bundled": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.1.2", - "@babel/types": "^7.1.2" - } - }, - "@babel/traverse": { - "version": "7.1.4", - "bundled": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.1.3", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/parser": "^7.1.3", - "@babel/types": "^7.1.3", - "debug": "^3.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.10" - } - }, - "@babel/types": { - "version": "7.1.3", - "bundled": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.10", - "to-fast-properties": "^2.0.0" - } - }, - "@types/events": { - "version": "1.2.0", - "bundled": true - }, - "@types/fs-extra": { - "version": "5.0.4", - "bundled": true, - "requires": { - "@types/node": "*" - } - }, - "@types/glob": { - "version": "7.1.1", - "bundled": true, - "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" - } - }, - "@types/handlebars": { - "version": "4.0.39", - "bundled": true - }, - "@types/highlight.js": { - "version": "9.12.3", - "bundled": true - }, - "@types/lodash": { - "version": "4.14.117", - "bundled": true - }, - "@types/marked": { - "version": "0.4.2", - "bundled": true - }, - "@types/minimatch": { - "version": "3.0.3", - "bundled": true - }, - "@types/mocha": { - "version": "5.2.5", - "bundled": true - }, - "@types/node": { - "version": "10.12.0", - "bundled": true - }, - "@types/shelljs": { - "version": "0.8.0", - "bundled": true, - "requires": { - "@types/glob": "*", - "@types/node": "*" - } - }, - "ansi-styles": { - "version": "3.2.1", - "bundled": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "argparse": { - "version": "1.0.10", - "bundled": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "arrify": { - "version": "1.0.1", - "bundled": true - }, - "assertion-error": { - "version": "1.1.0", - "bundled": true - }, - "async": { - "version": "2.6.1", - "bundled": true, - "requires": { - "lodash": "^4.17.10" - } - }, - "babel-code-frame": { - "version": "6.26.0", - "bundled": true, - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "bundled": true - }, - "ansi-styles": { - "version": "2.2.1", - "bundled": true - }, - "chalk": { - "version": "1.1.3", - "bundled": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "js-tokens": { - "version": "3.0.2", - "bundled": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "bundled": true - } - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "bundled": true - }, - "buffer-from": { - "version": "1.1.1", - "bundled": true - }, - "builtin-modules": { - "version": "1.1.1", - "bundled": true - }, - "chai": { - "version": "4.2.0", - "bundled": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" - } - }, - "chalk": { - "version": "2.4.1", - "bundled": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "check-error": { - "version": "1.0.2", - "bundled": true - }, - "color-convert": { - "version": "1.9.3", - "bundled": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "bundled": true - }, - "commander": { - "version": "2.19.0", - "bundled": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "debug": { - "version": "3.2.6", - "bundled": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-eql": { - "version": "3.0.1", - "bundled": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "diff": { - "version": "3.5.0", - "bundled": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "bundled": true - }, - "esprima": { - "version": "4.0.1", - "bundled": true - }, - "esutils": { - "version": "2.0.2", - "bundled": true - }, - "fs-extra": { - "version": "7.0.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "get-func-name": { - "version": "2.0.0", - "bundled": true - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "globals": { - "version": "11.8.0", - "bundled": true - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "growl": { - "version": "1.10.5", - "bundled": true - }, - "handlebars": { - "version": "4.0.12", - "bundled": true, - "requires": { - "async": "^2.5.0", - "optimist": "^0.6.1", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "bundled": true - } - } - }, - "has-ansi": { - "version": "2.0.0", - "bundled": true, - "requires": { - "ansi-regex": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "bundled": true - } - } - }, - "has-flag": { - "version": "3.0.0", - "bundled": true - }, - "he": { - "version": "1.1.1", - "bundled": true - }, - "highlight.js": { - "version": "9.13.1", - "bundled": true - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "interpret": { - "version": "1.1.0", - "bundled": true - }, - "istanbul-lib-coverage": { - "version": "2.0.1", - "bundled": true - }, - "istanbul-lib-instrument": { - "version": "3.0.0", - "bundled": true, - "requires": { - "@babel/generator": "^7.0.0", - "@babel/parser": "^7.0.0", - "@babel/template": "^7.0.0", - "@babel/traverse": "^7.0.0", - "@babel/types": "^7.0.0", - "istanbul-lib-coverage": "^2.0.1", - "semver": "^5.5.0" - } - }, - "js-sha256": { - "version": "0.9.0", - "bundled": true - }, - "js-tokens": { - "version": "4.0.0", - "bundled": true - }, - "js-yaml": { - "version": "3.12.0", - "bundled": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "jsesc": { - "version": "2.5.1", - "bundled": true - }, - "jsonfile": { - "version": "4.0.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "lodash": { - "version": "4.17.11", - "bundled": true - }, - "make-error": { - "version": "1.3.5", - "bundled": true - }, - "marked": { - "version": "0.4.0", - "bundled": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "bundled": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "dependencies": { - "commander": { - "version": "2.15.1", - "bundled": true - }, - "debug": { - "version": "3.1.0", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, - "supports-color": { - "version": "5.4.0", - "bundled": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "ms": { - "version": "2.1.1", - "bundled": true - }, - "node-fetch": { - "version": "2.3.0", - "bundled": true - }, - "nyc": { - "version": "13.1.0", - "bundled": true, - "requires": { - "archy": "^1.0.0", - "arrify": "^1.0.1", - "caching-transform": "^2.0.0", - "convert-source-map": "^1.6.0", - "debug-log": "^1.0.1", - "find-cache-dir": "^2.0.0", - "find-up": "^3.0.0", - "foreground-child": "^1.5.6", - "glob": "^7.1.3", - "istanbul-lib-coverage": "^2.0.1", - "istanbul-lib-hook": "^2.0.1", - "istanbul-lib-instrument": "^3.0.0", - "istanbul-lib-report": "^2.0.2", - "istanbul-lib-source-maps": "^2.0.1", - "istanbul-reports": "^2.0.1", - "make-dir": "^1.3.0", - "merge-source-map": "^1.1.0", - "resolve-from": "^4.0.0", - "rimraf": "^2.6.2", - "signal-exit": "^3.0.2", - "spawn-wrap": "^1.4.2", - "test-exclude": "^5.0.0", - "uuid": "^3.3.2", - "yargs": "11.1.0", - "yargs-parser": "^9.0.2" - }, - "dependencies": { - "align-text": { - "version": "0.1.4", - "bundled": true, - "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" - } - }, - "amdefine": { - "version": "1.0.1", - "bundled": true - }, - "ansi-regex": { - "version": "3.0.0", - "bundled": true - }, - "append-transform": { - "version": "1.0.0", - "bundled": true, - "requires": { - "default-require-extensions": "^2.0.0" - } - }, - "archy": { - "version": "1.0.0", - "bundled": true - }, - "arrify": { - "version": "1.0.1", - "bundled": true - }, - "async": { - "version": "1.5.2", - "bundled": true - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "builtin-modules": { - "version": "1.1.1", - "bundled": true - }, - "caching-transform": { - "version": "2.0.0", - "bundled": true, - "requires": { - "make-dir": "^1.0.0", - "md5-hex": "^2.0.0", - "package-hash": "^2.0.0", - "write-file-atomic": "^2.0.0" - } - }, - "camelcase": { - "version": "1.2.1", - "bundled": true, - "optional": true - }, - "center-align": { - "version": "0.1.3", - "bundled": true, - "optional": true, - "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" - } - }, - "cliui": { - "version": "2.1.0", - "bundled": true, - "optional": true, - "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", - "wordwrap": "0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "bundled": true, - "optional": true - } - } - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true - }, - "commondir": { - "version": "1.0.1", - "bundled": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "convert-source-map": { - "version": "1.6.0", - "bundled": true, - "requires": { - "safe-buffer": "~5.1.1" - } - }, - "cross-spawn": { - "version": "4.0.2", - "bundled": true, - "requires": { - "lru-cache": "^4.0.1", - "which": "^1.2.9" - } - }, - "debug": { - "version": "3.1.0", - "bundled": true, - "requires": { - "ms": "2.0.0" - } - }, - "debug-log": { - "version": "1.0.1", - "bundled": true - }, - "decamelize": { - "version": "1.2.0", - "bundled": true - }, - "default-require-extensions": { - "version": "2.0.0", - "bundled": true, - "requires": { - "strip-bom": "^3.0.0" - } - }, - "error-ex": { - "version": "1.3.2", - "bundled": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es6-error": { - "version": "4.1.1", - "bundled": true - }, - "execa": { - "version": "0.7.0", - "bundled": true, - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "5.1.0", - "bundled": true, - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - } - } - }, - "find-cache-dir": { - "version": "2.0.0", - "bundled": true, - "requires": { - "commondir": "^1.0.1", - "make-dir": "^1.0.0", - "pkg-dir": "^3.0.0" - } - }, - "find-up": { - "version": "3.0.0", - "bundled": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "foreground-child": { - "version": "1.5.6", - "bundled": true, - "requires": { - "cross-spawn": "^4", - "signal-exit": "^3.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "get-caller-file": { - "version": "1.0.3", - "bundled": true - }, - "get-stream": { - "version": "3.0.0", - "bundled": true - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "handlebars": { - "version": "4.0.11", - "bundled": true, - "requires": { - "async": "^1.4.0", - "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" - }, - "dependencies": { - "source-map": { - "version": "0.4.4", - "bundled": true, - "requires": { - "amdefine": ">=0.0.4" - } - } - } - }, - "has-flag": { - "version": "3.0.0", - "bundled": true - }, - "hosted-git-info": { - "version": "2.7.1", - "bundled": true - }, - "imurmurhash": { - "version": "0.1.4", - "bundled": true - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "invert-kv": { - "version": "1.0.0", - "bundled": true - }, - "is-arrayish": { - "version": "0.2.1", - "bundled": true - }, - "is-buffer": { - "version": "1.1.6", - "bundled": true - }, - "is-builtin-module": { - "version": "1.0.0", - "bundled": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "bundled": true - }, - "is-stream": { - "version": "1.1.0", - "bundled": true - }, - "isexe": { - "version": "2.0.0", - "bundled": true - }, - "istanbul-lib-coverage": { - "version": "2.0.1", - "bundled": true - }, - "istanbul-lib-hook": { - "version": "2.0.1", - "bundled": true, - "requires": { - "append-transform": "^1.0.0" - } - }, - "istanbul-lib-report": { - "version": "2.0.2", - "bundled": true, - "requires": { - "istanbul-lib-coverage": "^2.0.1", - "make-dir": "^1.3.0", - "supports-color": "^5.4.0" - } - }, - "istanbul-lib-source-maps": { - "version": "2.0.1", - "bundled": true, - "requires": { - "debug": "^3.1.0", - "istanbul-lib-coverage": "^2.0.1", - "make-dir": "^1.3.0", - "rimraf": "^2.6.2", - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "bundled": true - } - } - }, - "istanbul-reports": { - "version": "2.0.1", - "bundled": true, - "requires": { - "handlebars": "^4.0.11" - } - }, - "json-parse-better-errors": { - "version": "1.0.2", - "bundled": true - }, - "kind-of": { - "version": "3.2.2", - "bundled": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "lazy-cache": { - "version": "1.0.4", - "bundled": true, - "optional": true - }, - "lcid": { - "version": "1.0.0", - "bundled": true, - "requires": { - "invert-kv": "^1.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "bundled": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "lodash.flattendeep": { - "version": "4.4.0", - "bundled": true - }, - "longest": { - "version": "1.0.1", - "bundled": true - }, - "lru-cache": { - "version": "4.1.3", - "bundled": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "make-dir": { - "version": "1.3.0", - "bundled": true, - "requires": { - "pify": "^3.0.0" - } - }, - "md5-hex": { - "version": "2.0.0", - "bundled": true, - "requires": { - "md5-o-matic": "^0.1.1" - } - }, - "md5-o-matic": { - "version": "0.1.1", - "bundled": true - }, - "mem": { - "version": "1.1.0", - "bundled": true, - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "merge-source-map": { - "version": "1.1.0", - "bundled": true, - "requires": { - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "bundled": true - } - } - }, - "mimic-fn": { - "version": "1.2.0", - "bundled": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.10", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "bundled": true - } - } - }, - "ms": { - "version": "2.0.0", - "bundled": true - }, - "normalize-package-data": { - "version": "2.4.0", - "bundled": true, - "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "npm-run-path": { - "version": "2.0.2", - "bundled": true, - "requires": { - "path-key": "^2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1" - } - }, - "optimist": { - "version": "0.6.1", - "bundled": true, - "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true - }, - "os-locale": { - "version": "2.1.0", - "bundled": true, - "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" - } - }, - "p-finally": { - "version": "1.0.0", - "bundled": true - }, - "p-limit": { - "version": "2.0.0", - "bundled": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "bundled": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.0.0", - "bundled": true - }, - "package-hash": { - "version": "2.0.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.11", - "lodash.flattendeep": "^4.4.0", - "md5-hex": "^2.0.0", - "release-zalgo": "^1.0.0" - } - }, - "parse-json": { - "version": "4.0.0", - "bundled": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-exists": { - "version": "3.0.0", - "bundled": true - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "path-key": { - "version": "2.0.1", - "bundled": true - }, - "path-type": { - "version": "3.0.0", - "bundled": true, - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "bundled": true - }, - "pkg-dir": { - "version": "3.0.0", - "bundled": true, - "requires": { - "find-up": "^3.0.0" - } - }, - "pseudomap": { - "version": "1.0.2", - "bundled": true - }, - "read-pkg": { - "version": "3.0.0", - "bundled": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "4.0.0", - "bundled": true, - "requires": { - "find-up": "^3.0.0", - "read-pkg": "^3.0.0" - } - }, - "release-zalgo": { - "version": "1.0.0", - "bundled": true, - "requires": { - "es6-error": "^4.0.1" - } - }, - "repeat-string": { - "version": "1.6.1", - "bundled": true - }, - "require-directory": { - "version": "2.1.1", - "bundled": true - }, - "require-main-filename": { - "version": "1.0.1", - "bundled": true - }, - "resolve-from": { - "version": "4.0.0", - "bundled": true - }, - "right-align": { - "version": "0.1.3", - "bundled": true, - "optional": true, - "requires": { - "align-text": "^0.1.1" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "requires": { - "glob": "^7.0.5" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true - }, - "semver": { - "version": "5.5.0", - "bundled": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true - }, - "shebang-command": { - "version": "1.2.0", - "bundled": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "bundled": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true - }, - "source-map": { - "version": "0.5.7", - "bundled": true, - "optional": true - }, - "spawn-wrap": { - "version": "1.4.2", - "bundled": true, - "requires": { - "foreground-child": "^1.5.6", - "mkdirp": "^0.5.0", - "os-homedir": "^1.0.1", - "rimraf": "^2.6.2", - "signal-exit": "^3.0.2", - "which": "^1.3.0" - } - }, - "spdx-correct": { - "version": "3.0.0", - "bundled": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.1.0", - "bundled": true - }, - "spdx-expression-parse": { - "version": "3.0.0", - "bundled": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.0", - "bundled": true - }, - "string-width": { - "version": "2.1.1", - "bundled": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "bundled": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "strip-bom": { - "version": "3.0.0", - "bundled": true - }, - "strip-eof": { - "version": "1.0.0", - "bundled": true - }, - "supports-color": { - "version": "5.4.0", - "bundled": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "test-exclude": { - "version": "5.0.0", - "bundled": true, - "requires": { - "arrify": "^1.0.1", - "minimatch": "^3.0.4", - "read-pkg-up": "^4.0.0", - "require-main-filename": "^1.0.1" - } - }, - "uglify-js": { - "version": "2.8.29", - "bundled": true, - "optional": true, - "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" - }, - "dependencies": { - "yargs": { - "version": "3.10.0", - "bundled": true, - "optional": true, - "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" - } - } - } - }, - "uglify-to-browserify": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "uuid": { - "version": "3.3.2", - "bundled": true - }, - "validate-npm-package-license": { - "version": "3.0.3", - "bundled": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "bundled": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "bundled": true - }, - "window-size": { - "version": "0.1.0", - "bundled": true, - "optional": true - }, - "wordwrap": { - "version": "0.0.3", - "bundled": true - }, - "wrap-ansi": { - "version": "2.1.0", - "bundled": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "bundled": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true - }, - "write-file-atomic": { - "version": "2.3.0", - "bundled": true, - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" - } - }, - "y18n": { - "version": "3.2.1", - "bundled": true - }, - "yallist": { - "version": "2.1.2", - "bundled": true - }, - "yargs": { - "version": "11.1.0", - "bundled": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - }, - "dependencies": { - "cliui": { - "version": "4.1.0", - "bundled": true, - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, - "find-up": { - "version": "2.1.0", - "bundled": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "bundled": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "bundled": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "bundled": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "bundled": true - } - } - }, - "yargs-parser": { - "version": "9.0.2", - "bundled": true, - "requires": { - "camelcase": "^4.1.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "bundled": true - } - } - } - } - }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1" - } - }, - "optimist": { - "version": "0.6.1", - "bundled": true, - "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "path-parse": { - "version": "1.0.6", - "bundled": true - }, - "pathval": { - "version": "1.1.0", - "bundled": true - }, - "progress": { - "version": "2.0.1", - "bundled": true - }, - "rechoir": { - "version": "0.6.2", - "bundled": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "resolve": { - "version": "1.8.1", - "bundled": true, - "requires": { - "path-parse": "^1.0.5" - } - }, - "semver": { - "version": "5.6.0", - "bundled": true - }, - "shelljs": { - "version": "0.8.2", - "bundled": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, - "source-map": { - "version": "0.5.7", - "bundled": true - }, - "source-map-support": { - "version": "0.5.9", - "bundled": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "bundled": true - } - } - }, - "sprintf-js": { - "version": "1.0.3", - "bundled": true - }, - "supports-color": { - "version": "5.5.0", - "bundled": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "to-fast-properties": { - "version": "2.0.0", - "bundled": true - }, - "trim-right": { - "version": "1.0.1", - "bundled": true - }, - "ts-node": { - "version": "7.0.1", - "bundled": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true - } - } - }, - "tslib": { - "version": "1.9.3", - "bundled": true - }, - "tslint": { - "version": "5.11.0", - "bundled": true, - "requires": { - "babel-code-frame": "^6.22.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.7.0", - "minimatch": "^3.0.4", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.27.2" - } - }, - "tsutils": { - "version": "2.29.0", - "bundled": true, - "requires": { - "tslib": "^1.8.1" - } - }, - "type-detect": { - "version": "4.0.8", - "bundled": true - }, - "typedoc": { - "version": "0.13.0", - "bundled": true, - "requires": { - "@types/fs-extra": "^5.0.3", - "@types/handlebars": "^4.0.38", - "@types/highlight.js": "^9.12.3", - "@types/lodash": "^4.14.110", - "@types/marked": "^0.4.0", - "@types/minimatch": "3.0.3", - "@types/shelljs": "^0.8.0", - "fs-extra": "^7.0.0", - "handlebars": "^4.0.6", - "highlight.js": "^9.0.0", - "lodash": "^4.17.10", - "marked": "^0.4.0", - "minimatch": "^3.0.0", - "progress": "^2.0.0", - "shelljs": "^0.8.2", - "typedoc-default-themes": "^0.5.0", - "typescript": "3.1.x" - } - }, - "typedoc-default-themes": { - "version": "0.5.0", - "bundled": true - }, - "typescript": { - "version": "3.1.6", - "bundled": true - }, - "uglify-js": { - "version": "3.4.9", - "bundled": true, - "optional": true, - "requires": { - "commander": "~2.17.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "commander": { - "version": "2.17.1", - "bundled": true, - "optional": true - }, - "source-map": { - "version": "0.6.1", - "bundled": true, - "optional": true - } - } - }, - "universalify": { - "version": "0.1.2", - "bundled": true - }, - "wordwrap": { - "version": "0.0.3", - "bundled": true - }, - "wrappy": { - "version": "1.0.2", - "bundled": true - }, - "yn": { - "version": "2.0.0", - "bundled": true - } } }, "@types/bn.js": { @@ -1898,7 +148,7 @@ }, "@types/events": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", "integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==", "dev": true }, @@ -1959,9 +209,9 @@ "dev": true }, "@types/node": { - "version": "10.12.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.9.tgz", - "integrity": "sha512-eajkMXG812/w3w4a1OcBlaTwsFPO5F7fJ/amy+tieQxEMWBlbV1JGSjkFM+zkHNf81Cad+dfIRA+IBkvmvdAeA==" + "version": "10.12.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz", + "integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==" }, "@types/shelljs": { "version": "0.8.0", @@ -2285,7 +535,7 @@ }, "util": { "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "requires": { "inherits": "2.0.1" @@ -2776,7 +1026,7 @@ }, "cacache": { "version": "10.0.4", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", + "resolved": "http://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", "requires": { "bluebird": "^3.5.1", @@ -3195,7 +1445,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } @@ -3260,7 +1510,7 @@ "dependencies": { "file-type": { "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" }, "get-stream": { @@ -3274,7 +1524,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } @@ -3418,7 +1668,7 @@ }, "eccrypto": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/eccrypto/-/eccrypto-1.0.3.tgz", + "resolved": "http://registry.npmjs.org/eccrypto/-/eccrypto-1.0.3.tgz", "integrity": "sha1-pBIObOmLAHLBzqr96tFW9ruLJOM=", "requires": { "elliptic": "^6.0.2", @@ -5663,7 +3913,7 @@ }, "media-typer": { "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, "mem": { @@ -7575,7 +5825,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { @@ -8009,7 +6259,7 @@ }, "safe-regex": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "requires": { "ret": "~0.1.10" @@ -8483,7 +6733,7 @@ }, "stream-browserify": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "requires": { "inherits": "~2.0.1", @@ -8556,7 +6806,7 @@ }, "strip-eof": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-hex-prefix": { @@ -8642,7 +6892,7 @@ }, "tar": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { "block-stream": "*", @@ -9212,7 +7462,7 @@ }, "utf8": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", + "resolved": "http://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=" }, "util": { diff --git a/package.json b/package.json index 04c4781..5004e07 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "homepage": "https://github.com/oceanprotocol/squid-js#readme", "dependencies": { - "@oceanprotocol/keeper-contracts": "0.3.23", + "@oceanprotocol/keeper-contracts": "0.3.25", "@oceanprotocol/secret-store-client": "0.0.12", "bignumber.js": "^8.0.1", "eth-crypto": "^1.2.7", @@ -64,7 +64,7 @@ "devDependencies": { "@types/chai": "^4.1.7", "@types/mocha": "^5.2.5", - "@types/node": "^10.12.7", + "@types/node": "^10.12.10", "chai": "^4.2.0", "mocha": "^5.2.0", "nyc": "^13.1.0", diff --git a/src/keeper/contracts/ContractBase.ts b/src/keeper/contracts/ContractBase.ts index e3e7ecd..a916d2a 100644 --- a/src/keeper/contracts/ContractBase.ts +++ b/src/keeper/contracts/ContractBase.ts @@ -60,7 +60,7 @@ export default abstract class ContractBase { if (!this.contract.methods[name]) { throw new Error(`Method "${name}" is not part of contract "${this.contractName}"`) } - // Logger.log(name) + // Logger.log(name, args) const method = this.contract.methods[name] try { const methodInstance = method(...args) diff --git a/src/keeper/contracts/ServiceAgreement.ts b/src/keeper/contracts/ServiceAgreement.ts index 75438c8..db09194 100644 --- a/src/keeper/contracts/ServiceAgreement.ts +++ b/src/keeper/contracts/ServiceAgreement.ts @@ -16,12 +16,12 @@ export default class ServiceAgreement extends ContractBase { name: any, fulfillmentIndices: number[], fulfillmentOperator: number, - ownerAddress: string) - : Promise { + ownerAddress: string): Promise { return this.send("setupAgreementTemplate", ownerAddress, [ templateId, methodReflections.map((r) => r.address), - methodReflections.map((r) => r.signature), dependencyMatrix, name, fulfillmentIndices, fulfillmentOperator, + methodReflections.map((r) => r.signature), dependencyMatrix, name, fulfillmentIndices, + fulfillmentOperator, ]) } diff --git a/src/ocean/ServiceAgreements/ServiceAgreement.ts b/src/ocean/ServiceAgreements/ServiceAgreement.ts index 2520f7e..0f0302b 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreement.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreement.ts @@ -205,8 +205,10 @@ export default class ServiceAgreement extends OceanBase { super(serviceAgreementId) } - public async lockPayment(assetId: string, price: number, consumer: Account): Promise { - const {paymentConditions} = await Keeper.getInstance() + public async buyAsset(assetId: string, price: number, consumer: Account): Promise { + const {paymentConditions, token} = await Keeper.getInstance() + + await token.approve(paymentConditions.getAddress(), price, consumer.getId()) const lockPaymentReceipt = await paymentConditions.lockPayment(this.getId(), assetId, price, @@ -222,7 +224,7 @@ export default class ServiceAgreement extends OceanBase { await accessConditions.grantAccess(this.getId(), assetId, documentId, this.publisher.getId()) - return grantAccessReceipt.status + return !!grantAccessReceipt.events.AccessGranted } public async getStatus() { diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index 9bc4186..32317c5 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -35,15 +35,11 @@ export default class ServiceAgreementTemplate extends OceanBase { })) const fulfillmentIndices: number[] = this.template.Methods - .map((method: Method, i: number) => method.isTerminalCondition ? i : undefined) - .filter((index: number) => index !== undefined) - - Logger.log(dependencyMatrix, fulfillmentIndices, this.template.fulfillmentOperator) + .map((method: Method, i: number) => method.isTerminalCondition ? i : null) + .filter((index: number) => index !== null) const {serviceAgreement} = await Keeper.getInstance() - const methodReflections = await this.getMethodReflections() - const owner = await this.getOwner() if (owner.getId() === templateOwnerAddress) { @@ -60,7 +56,7 @@ export default class ServiceAgreementTemplate extends OceanBase { const receipt = await serviceAgreement .setupAgreementTemplate( this.template.id, - methodReflections, + await this.getMethodReflections(), dependencyMatrix, Web3Provider.getWeb3().utils.fromAscii(this.template.templateName), fulfillmentIndices, @@ -126,21 +122,20 @@ export default class ServiceAgreementTemplate extends OceanBase { throw new Error("Deps and timeouts need the same length") } - // map name to index const mappedDependencies: number[] = [] const mappedDependencyTimeoutFlags: number[] = [] this.template.Methods.forEach((m, i) => { const di = dependencies.findIndex((d) => d === m.name) mappedDependencies.push(di > -1 ? 1 : 0) - mappedDependencyTimeoutFlags.push(dependencyTimeoutFlags[i] ? 1 : 0) + mappedDependencyTimeoutFlags.push((di > -1 && dependencyTimeoutFlags[di]) ? 1 : 0) }) if (mappedDependencies.length !== mappedDependencyTimeoutFlags.length) { throw new Error("Deps and timeouts need the same length") } - Logger.log(dependencies, mappedDependencies, dependencyTimeoutFlags, mappedDependencyTimeoutFlags) + // Logger.log(dependencies, mappedDependencies, dependencyTimeoutFlags, mappedDependencyTimeoutFlags) let compressedDependencyValue: number = 0 const numBits: number = 2 // 1st for dependency, 2nd for timeout flag diff --git a/test/ocean/ServiceAgreement.test.ts b/test/ocean/ServiceAgreement.test.ts index 3b5a0c2..e944a8f 100644 --- a/test/ocean/ServiceAgreement.test.ts +++ b/test/ocean/ServiceAgreement.test.ts @@ -73,7 +73,8 @@ describe("ServiceAgreement", () => { case "assetId": return "0x" + assetId case "documentKeyId": - return "0x1234" + return "0x" + assetId + } return null @@ -118,8 +119,7 @@ describe("ServiceAgreement", () => { describe("#signServiceAgreement()", () => { it("should sign an service agreement", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService]}) const serviceAgreementId: string = IdGenerator.generateId() @@ -138,8 +138,7 @@ describe("ServiceAgreement", () => { describe("#executeServiceAgreement()", () => { it("should execute an service agreement", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService]}) const serviceAgreementId: string = IdGenerator.generateId() @@ -163,8 +162,7 @@ describe("ServiceAgreement", () => { describe("#getStatus()", () => { it("should get the status of a newly created service agreement", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService]}) const serviceAgreementId: string = IdGenerator.generateId() @@ -185,16 +183,16 @@ describe("ServiceAgreement", () => { }) }) - describe("#lockPayment()", () => { + describe("#buyAsset()", () => { it("should lock the payment in that service agreement", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService, metaDataService]}) const serviceAgreementId: string = IdGenerator.generateId() // @ts-ignore WebServiceConnectorProvider.setConnector(new WebServiceConnectorMock(ddo)) + const serviceAgreementSignature: string = await ServiceAgreement.signServiceAgreement(assetId, ddo, accessService.serviceDefinitionId, serviceAgreementId, consumerAccount) @@ -208,7 +206,7 @@ describe("ServiceAgreement", () => { // get funds await consumerAccount.requestTokens(metaDataService.metadata.base.price) - const paid: boolean = await serviceAgreement.lockPayment(assetId, metaDataService.metadata.base.price, + const paid: boolean = await serviceAgreement.buyAsset(assetId, metaDataService.metadata.base.price, consumerAccount) assert(paid) }) @@ -217,8 +215,7 @@ describe("ServiceAgreement", () => { describe("#grantAccess()", () => { it("should grant access in that service agreement", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService]}) const serviceAgreementId: string = IdGenerator.generateId() @@ -237,18 +234,18 @@ describe("ServiceAgreement", () => { // get funds await consumerAccount.requestTokens(metaDataService.metadata.base.price) - const paid: boolean = await serviceAgreement.lockPayment(assetId, metaDataService.metadata.base.price, + const paid: boolean = await serviceAgreement.buyAsset(assetId, metaDataService.metadata.base.price, consumerAccount) assert(paid) - const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, IdGenerator.generateId()) + // todo: use document id + const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, assetId) assert(accessGranted) }) - xit("should fail to grant grant access if there is no payment", async () => { + it("should fail to grant grant access if there is no payment", async () => { - const id: string = IdGenerator.generateId() - const did: string = `did:op:${id}` + const did: string = `did:op:${assetId}` const ddo = new DDO({id: did, service: [accessService]}) const serviceAgreementId: string = IdGenerator.generateId() @@ -264,7 +261,8 @@ describe("ServiceAgreement", () => { serviceAgreementId, serviceAgreementSignature, consumerAccount, publisherAccount) assert(serviceAgreement) - const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, IdGenerator.generateId()) + // todo: use document id + const accessGranted: boolean = await serviceAgreement.grantAccess(assetId, assetId) assert(!accessGranted) }) })