Compare commits
138 Commits
Author | SHA1 | Date |
---|---|---|
Matthias Kretschmann | da3b1fe3a6 | |
dependabot[bot] | 72e2637ac4 | |
Ahmed Ali | 8831fd7a77 | |
dependabot[bot] | dc37448d63 | |
Matthias Kretschmann | bfe9b228d8 | |
dependabot[bot] | 25e07a61c8 | |
Matthias Kretschmann | 942b9ce813 | |
dependabot[bot] | ad10c580e6 | |
Matthias Kretschmann | a13a3a3652 | |
dependabot[bot] | ecdfec41cc | |
Matthias Kretschmann | 088e8d9ab6 | |
dependabot[bot] | 9c8dc7c16e | |
Matthias Kretschmann | 57bc1c10a3 | |
dependabot[bot] | e424b737f8 | |
Matthias Kretschmann | 765aa6831f | |
Matthias Kretschmann | 63e3f2ab90 | |
dependabot[bot] | dad24646c9 | |
dependabot[bot] | ad988df63f | |
Matthias Kretschmann | cb8b41a6aa | |
Matthias Kretschmann | 982c65ae7b | |
dependabot[bot] | b03fe9dd9e | |
dependabot[bot] | 3cc297be56 | |
Matthias Kretschmann | 5c38bc228d | |
Matthias Kretschmann | 0b0ca0c99a | |
dependabot[bot] | 46f4c658ed | |
dependabot[bot] | c250e10c0b | |
Matthias Kretschmann | 25b329bdda | |
Matthias Kretschmann | 945a2243ce | |
Matthias Kretschmann | 2aaca21ea3 | |
dependabot[bot] | 39a034173a | |
dependabot[bot] | 9175f50ece | |
dependabot[bot] | 94edfda748 | |
Matthias Kretschmann | 392b4d19f7 | |
Ahmed Ali | 8717c7832a | |
dependabot[bot] | c8e00182d6 | |
dependabot[bot] | f4771d77e1 | |
Matthias Kretschmann | c033f666cd | |
dependabot-preview[bot] | 0c6e298545 | |
dependabot-preview[bot] | edc457bae8 | |
dependabot-preview[bot] | dbee539a95 | |
dependabot-preview[bot] | a22e59ebc8 | |
dependabot-preview[bot] | fa2485ee2e | |
dependabot-preview[bot] | 02434725ac | |
dependabot-preview[bot] | 256b36e005 | |
dependabot-preview[bot] | 111fb2c3f6 | |
dependabot-preview[bot] | 2d75530af9 | |
Matthias Kretschmann | 9b03c9da6c | |
Matthias Kretschmann | 8e3a03d4c7 | |
Matthias Kretschmann | 480d6cd48d | |
Matthias Kretschmann | cc980b2f28 | |
Matthias Kretschmann | ce4ee6fb5d | |
Matthias Kretschmann | 9ef30c1cfd | |
dependabot-preview[bot] | d0e655b7c2 | |
dependabot-preview[bot] | e157479faa | |
dependabot-preview[bot] | af3cdf3f8f | |
dependabot-preview[bot] | 83334607d5 | |
dependabot-preview[bot] | fae9741db7 | |
dependabot-preview[bot] | 455f122b85 | |
dependabot-preview[bot] | ec8fe0c310 | |
dependabot-preview[bot] | dacf31cea7 | |
dependabot-preview[bot] | c99f7043ac | |
dependabot-preview[bot] | b8b1d334eb | |
dependabot-preview[bot] | 8015260b6c | |
dependabot-preview[bot] | 9d350065ec | |
dependabot-preview[bot] | 36377dbc35 | |
Matthias Kretschmann | 9b34c00835 | |
dependabot-preview[bot] | a54e2af319 | |
dependabot-preview[bot] | a5a9350e90 | |
dependabot-preview[bot] | ae3a460ec9 | |
dependabot-preview[bot] | 26e79665a7 | |
dependabot-preview[bot] | 18804e8d07 | |
dependabot-preview[bot] | c3c1b94d5e | |
dependabot-preview[bot] | 9ac9c39fda | |
dependabot-preview[bot] | 44c25f4882 | |
dependabot-preview[bot] | e669392e39 | |
dependabot-preview[bot] | 6509912fda | |
dependabot-preview[bot] | f488024ea3 | |
dependabot-preview[bot] | e32501482a | |
dependabot-preview[bot] | 33811daba0 | |
dependabot-preview[bot] | e00cb82435 | |
dependabot-preview[bot] | 4994403a03 | |
dependabot-preview[bot] | 1435fd8d81 | |
dependabot-preview[bot] | 8ce5ba9eb4 | |
Matthias Kretschmann | 8ece01d9fa | |
dependabot-preview[bot] | 1c884bcf09 | |
Matthias Kretschmann | d5d27678f0 | |
Matthias Kretschmann | cd02ed79d2 | |
alexcos20 | df95801ca8 | |
Alex Coseru | 3e9e809860 | |
Matthias Kretschmann | 7ddaf794a9 | |
Matthias Kretschmann | 57ed8681c1 | |
Matthias Kretschmann | b4dfd22e3b | |
dependabot-preview[bot] | 5d3bc949de | |
Matthias Kretschmann | 15dec9bcad | |
dependabot-preview[bot] | dad78048ba | |
dependabot-preview[bot] | 1e3c2105bb | |
dependabot-preview[bot] | c0bd722872 | |
dependabot-preview[bot] | 435b76358c | |
dependabot-preview[bot] | 5ad044daae | |
Matthias Kretschmann | 32b671e2a4 | |
dependabot-preview[bot] | 27a8a37729 | |
dependabot-preview[bot] | c618c9c2a7 | |
dependabot-preview[bot] | c386136ecb | |
dependabot-preview[bot] | 52b4afe012 | |
dependabot-preview[bot] | c333fc0f49 | |
dependabot-preview[bot] | 242c97317b | |
dependabot-preview[bot] | 0edb5f9171 | |
dependabot-preview[bot] | ac375919cd | |
dependabot-preview[bot] | d87eea5f99 | |
dependabot-preview[bot] | 99e6ca6679 | |
Matthias Kretschmann | 5a15d3dc59 | |
Matthias Kretschmann | d8ff20fe81 | |
Matthias Kretschmann | 8cba5fb637 | |
Matthias Kretschmann | 0c13406e2f | |
Matthias Kretschmann | 6988767a27 | |
Matthias Kretschmann | bce6c4302f | |
Matthias Kretschmann | 4c97da9856 | |
Matthias Kretschmann | c3bdb10617 | |
dependabot-preview[bot] | f34b0e0fed | |
dependabot-preview[bot] | 9c954675ed | |
dependabot-preview[bot] | e922d49beb | |
dependabot-preview[bot] | ca51b5ec7f | |
dependabot-preview[bot] | f708487f41 | |
dependabot-preview[bot] | 1d0f1d4bb9 | |
alexcos20 | 62e2dd640a | |
alexcos20 | 4e5eb1bf1c | |
alexcos20 | 46e3de63f1 | |
alexcos20 | cee861cffd | |
greenkeeper[bot] | 52d5a4c359 | |
greenkeeper[bot] | 6690399045 | |
alexcos20 | 3f1d595331 | |
alexcos20 | 9a722d8686 | |
alexcos20 | 25413b05c7 | |
alexcos20 | c4921d129b | |
alexcos20 | 59e2accf68 | |
0x3bfc | 49b61b5590 | |
greenkeeper[bot] | f7a61a811b | |
greenkeeper[bot] | 2f2c0bb3c7 |
|
@ -0,0 +1,8 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
time: '03:00'
|
||||
timezone: Europe/Berlin
|
|
@ -14,17 +14,16 @@ matrix:
|
|||
|
||||
before_install:
|
||||
- npm install -g npm
|
||||
- npm install -g codacy-coverage release-it greenkeeper-lockfile ganache-cli@~6.5.1
|
||||
- npm install -g ganache-cli@~6.5.1
|
||||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
||||
- chmod +x ./cc-test-reporter
|
||||
|
||||
before_script:
|
||||
- greenkeeper-lockfile-update
|
||||
- ganache-cli --port 18545 > ganache-cli.log &
|
||||
- git clone https://github.com/oceanprotocol/barge
|
||||
- cd barge
|
||||
- export AQUARIUS_VERSION=unstable
|
||||
- export BRIZO_VERSION=v0.9.5
|
||||
- export AQUARIUS_VERSION=v1.1.0
|
||||
- export BRIZO_VERSION=v0.9.7
|
||||
- export KEEPER_VERSION=v0.13.2
|
||||
- export EVENTS_HANDLER_VERSION=v0.4.7
|
||||
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
|
||||
|
@ -41,12 +40,10 @@ script:
|
|||
- npm run test:integration:cover
|
||||
|
||||
after_script:
|
||||
- npm run report-codacy
|
||||
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.unit.json coverage/unit/lcov.info # Format unit test coverage
|
||||
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.integration.json coverage/integration/lcov.info # Format integration test coverage
|
||||
- ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json
|
||||
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json
|
||||
- greenkeeper-lockfile-upload
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
|
40
CHANGELOG.md
40
CHANGELOG.md
|
@ -4,6 +4,42 @@ All notable changes to this project will be documented in this file. Dates are d
|
|||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
#### [v2.2.0](https://github.com/oceanprotocol/squid-js/compare/v2.1.3...v2.2.0)
|
||||
|
||||
> 19 May 2020
|
||||
|
||||
- add trusted algo [`#410`](https://github.com/oceanprotocol/squid-js/pull/410)
|
||||
- add checks before order & tests [`9a722d8`](https://github.com/oceanprotocol/squid-js/commit/9a722d8686796ec993782d21173b406971876b5b)
|
||||
- fix lint [`c4921d1`](https://github.com/oceanprotocol/squid-js/commit/c4921d129bc5edf87151e6ad72108e62495a30eb)
|
||||
- fix tests broken due to master merge [`df95801`](https://github.com/oceanprotocol/squid-js/commit/df95801ca8e0d142629a38d6f566b7e2fbc6c7b0)
|
||||
|
||||
#### [v2.1.3](https://github.com/oceanprotocol/squid-js/compare/v2.1.2...v2.1.3)
|
||||
|
||||
> 19 May 2020
|
||||
|
||||
- Bump @types/node from 14.0.0 to 14.0.1 [`#429`](https://github.com/oceanprotocol/squid-js/pull/429)
|
||||
- Bump mocha from 7.1.0 to 7.1.2 [`#426`](https://github.com/oceanprotocol/squid-js/pull/426)
|
||||
- security fixes [`57ed868`](https://github.com/oceanprotocol/squid-js/commit/57ed8681c167c191ffdb6fd7385e3a2f8a7cb70b)
|
||||
- Release 2.1.3 [`7ddaf79`](https://github.com/oceanprotocol/squid-js/commit/7ddaf794a9924d5d8d41227bafc7a139f4b1ee26)
|
||||
- Merge pull request #428 from oceanprotocol/dependabot/npm_and_yarn/ethereum-navigator/navigator-0.5.2 [`5d3bc94`](https://github.com/oceanprotocol/squid-js/commit/5d3bc949de1306f01fde21f97d4dd0255aa1c78b)
|
||||
|
||||
#### [v2.1.2](https://github.com/oceanprotocol/squid-js/compare/v2.1.1...v2.1.2)
|
||||
|
||||
> 18 May 2020
|
||||
|
||||
- fix timeouts [`#413`](https://github.com/oceanprotocol/squid-js/pull/413)
|
||||
- Bump @typescript-eslint/parser from 2.23.0 to 2.33.0 [`#419`](https://github.com/oceanprotocol/squid-js/pull/419)
|
||||
- Bump nyc from 15.0.0 to 15.0.1 [`#418`](https://github.com/oceanprotocol/squid-js/pull/418)
|
||||
- Bump eslint-config-prettier from 6.10.0 to 6.11.0 [`#417`](https://github.com/oceanprotocol/squid-js/pull/417)
|
||||
- Bump whatwg-url from 8.0.0 to 8.1.0 [`#416`](https://github.com/oceanprotocol/squid-js/pull/416)
|
||||
- Bump eslint-plugin-prettier from 3.1.2 to 3.1.3 [`#414`](https://github.com/oceanprotocol/squid-js/pull/414)
|
||||
- Update @types/node to the latest version 🚀 [`#412`](https://github.com/oceanprotocol/squid-js/pull/412)
|
||||
- [Security] Bump jquery from 3.4.1 to 3.5.1 [`#415`](https://github.com/oceanprotocol/squid-js/pull/415)
|
||||
- Update uuid to the latest version 🚀 [`#407`](https://github.com/oceanprotocol/squid-js/pull/407)
|
||||
- Release 2.1.2 [`32b671e`](https://github.com/oceanprotocol/squid-js/commit/32b671e2a4d48e05acab36fdd5fff8c2c83a3c48)
|
||||
- Merge pull request #424 from oceanprotocol/dependabot/npm_and_yarn/types/node-fetch-2.5.7 [`27a8a37`](https://github.com/oceanprotocol/squid-js/commit/27a8a37729bb01735c3023f6aa6fc23302f08d98)
|
||||
- Merge pull request #423 from oceanprotocol/dependabot/npm_and_yarn/types/sinon-9.0.1 [`c618c9c`](https://github.com/oceanprotocol/squid-js/commit/c618c9c2a752c02ba7f40051c6d7cd8fa8a20c08)
|
||||
|
||||
#### [v2.1.1](https://github.com/oceanprotocol/squid-js/compare/v2.1.0...v2.1.1)
|
||||
|
||||
> 14 April 2020
|
||||
|
@ -11,9 +47,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|||
- fix Brizo auth for compute [`#400`](https://github.com/oceanprotocol/squid-js/pull/400)
|
||||
- Update @ethereum-navigator/navigator to the latest version 🚀 [`#398`](https://github.com/oceanprotocol/squid-js/pull/398)
|
||||
- Update auto-changelog to the latest version 🚀 [`#404`](https://github.com/oceanprotocol/squid-js/pull/404)
|
||||
- Release 2.1.1 [`a2f1985`](https://github.com/oceanprotocol/squid-js/commit/a2f19850790bcc77e04a085301094fb8ccc21e65)
|
||||
- chore(package): update lockfile package-lock.json [`96bd22d`](https://github.com/oceanprotocol/squid-js/commit/96bd22d83581ecc4d25eadd4f17f9c9a68c636a0)
|
||||
- fix signing [`795f849`](https://github.com/oceanprotocol/squid-js/commit/795f8494f99c4e771e70a8a33458f85ef89f36e4)
|
||||
- fix auth & tests [`7de1b11`](https://github.com/oceanprotocol/squid-js/commit/7de1b110b0c1c3cd46de153b87db911e677be599)
|
||||
|
||||
#### [v2.1.0](https://github.com/oceanprotocol/squid-js/compare/v2.0.0...v2.1.0)
|
||||
|
||||
|
@ -864,7 +900,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|||
|
||||
#### [v0.1.1](https://github.com/oceanprotocol/squid-js/compare/v0.1.0...v0.1.1)
|
||||
|
||||
> 14 April 2020
|
||||
> 19 May 2020
|
||||
|
||||
#### [v0.1.0](https://github.com/oceanprotocol/squid-js/compare/v0.1.0-beta.20...v0.1.0)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
[![Maintainability](https://api.codeclimate.com/v1/badges/ff173cf1c7adc6b21ae5/maintainability)](https://codeclimate.com/github/oceanprotocol/squid-js/maintainability)
|
||||
[![Test Coverage](https://api.codeclimate.com/v1/badges/ff173cf1c7adc6b21ae5/test_coverage)](https://codeclimate.com/github/oceanprotocol/squid-js/test_coverage)
|
||||
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
|
||||
[![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/squid-js.svg)](https://greenkeeper.io/)
|
||||
[![Dependabot enabled](https://badgen.net/dependabot/thepracticaldev/dev.to?icon=dependabot)](https://dependabot.com/)
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
},
|
||||
{
|
||||
"name": "brizo",
|
||||
"version": "~0.9.0"
|
||||
"version": "~0.9.7"
|
||||
},
|
||||
{
|
||||
"name": "aquarius",
|
||||
"version": "~1.0.7"
|
||||
"version": "~1.1.0"
|
||||
},
|
||||
{
|
||||
"name": "events-handler",
|
||||
"version": "~0.4.4"
|
||||
"version": "~0.4.7"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@oceanprotocol/squid",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "JavaScript client library for Ocean Protocol",
|
||||
"main": "./dist/node/squid.js",
|
||||
"typings": "./dist/node/squid.d.ts",
|
||||
|
@ -26,9 +26,6 @@
|
|||
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
|
||||
"doc": "typedoc --mode modules --out ./doc/ ./src/",
|
||||
"doc:json": "./scripts/typedoc.js",
|
||||
"report-codacy": "npm run report-coverage:unit && npm run report-coverage:integration",
|
||||
"report-codacy:unit": "cat coverage/unit/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a",
|
||||
"report-codacy:integration": "cat coverage/integration/lcov.info | codacy-coverage --token 71ef0d15f6f04ac29b31d704b28f866a",
|
||||
"run": "ts-node",
|
||||
"release": "release-it --non-interactive",
|
||||
"changelog": "auto-changelog -p",
|
||||
|
@ -58,7 +55,7 @@
|
|||
"deprecated-decorator": "^0.1.6",
|
||||
"node-fetch": "^2.6.0",
|
||||
"save-file": "^2.3.1",
|
||||
"uuid": "^7.0.2",
|
||||
"uuid": "^8.0.0",
|
||||
"web3": "^1.2.6",
|
||||
"whatwg-url": "^8.0.0"
|
||||
},
|
||||
|
@ -67,8 +64,8 @@
|
|||
"@truffle/hdwallet-provider": "^1.0.33",
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/chai-spies": "^1.0.1",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^13.9.1",
|
||||
"@types/mocha": "^8.0.0",
|
||||
"@types/node": "^14.0.0",
|
||||
"@types/node-fetch": "^2.5.5",
|
||||
"@types/sinon": "^9.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.23.0",
|
||||
|
@ -86,7 +83,7 @@
|
|||
"mock-local-storage": "^1.1.11",
|
||||
"nyc": "^15.0.0",
|
||||
"ora": "^4.0.2",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier": "^2.0.5",
|
||||
"sinon": "^9.0.1",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-node": "^8.6.2",
|
||||
|
|
|
@ -9,9 +9,7 @@ process.stdout.write(
|
|||
JSON.stringify(
|
||||
{
|
||||
version: require('../package.json').version,
|
||||
commit: execSync(`git rev-parse HEAD`)
|
||||
.toString()
|
||||
.trim()
|
||||
commit: execSync(`git rev-parse HEAD`).toString().trim()
|
||||
},
|
||||
null,
|
||||
' '
|
||||
|
|
|
@ -64,7 +64,7 @@ export class Aquarius {
|
|||
this.logger.error('Success accessing consume endpoint: ', consumptionUrl)
|
||||
return consumptionUrl
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error(
|
||||
'Error fetching the data asset consumption url: ',
|
||||
error
|
||||
|
@ -94,10 +94,10 @@ export class Aquarius {
|
|||
)
|
||||
return this.transformResult()
|
||||
})
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
return this.transformResult(results)
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return this.transformResult()
|
||||
})
|
||||
|
@ -133,10 +133,10 @@ export class Aquarius {
|
|||
)
|
||||
return this.transformResult()
|
||||
})
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
return this.transformResult(results)
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata by text: ', error)
|
||||
return this.transformResult()
|
||||
})
|
||||
|
@ -168,7 +168,7 @@ export class Aquarius {
|
|||
.then((response: DDO) => {
|
||||
return new DDO(response) as DDO
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return null as DDO
|
||||
})
|
||||
|
@ -204,7 +204,7 @@ export class Aquarius {
|
|||
.then((response: DDO) => {
|
||||
return new DDO(response) as DDO
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return null as DDO
|
||||
})
|
||||
|
@ -253,7 +253,7 @@ export class Aquarius {
|
|||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
|
@ -261,6 +261,60 @@ export class Aquarius {
|
|||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Compute Privacy
|
||||
* @param {DID | string} did DID of the asset to update.
|
||||
* @param {number } serviceIndex Service index
|
||||
* @param {boolean} allowRawAlgorithm Allow Raw Algorithms
|
||||
* @param {boolean} allowNetworkAccess Allow Raw Algorithms
|
||||
* @param {String[]} trustedAlgorithms Allow Raw Algorithms
|
||||
* @param {String} updated Updated field of the DDO
|
||||
* @param {String} signature Signature using updated field to verify that the consumer has rights
|
||||
* @return {Promise<String>} Result.
|
||||
*/
|
||||
public async updateComputePrivacy(
|
||||
did: DID | string,
|
||||
serviceIndex: number,
|
||||
allowRawAlgorithm: boolean,
|
||||
allowNetworkAccess: boolean,
|
||||
trustedAlgorithms: string[],
|
||||
updated: string,
|
||||
signature: string
|
||||
): Promise<string> {
|
||||
did = did && DID.parse(did)
|
||||
const fullUrl = `${this.url}${apiPath}/computePrivacy/update/${did.getDid()}`
|
||||
const result = await this.fetch
|
||||
.put(
|
||||
fullUrl,
|
||||
JSON.stringify({
|
||||
signature: signature,
|
||||
updated: updated,
|
||||
serviceIndex: serviceIndex,
|
||||
allowRawAlgorithm: allowRawAlgorithm,
|
||||
allowNetworkAccess: allowNetworkAccess,
|
||||
trustedAlgorithms: trustedAlgorithms
|
||||
})
|
||||
)
|
||||
.then((response: any) => {
|
||||
if (response.ok) {
|
||||
return response.text
|
||||
}
|
||||
this.logger.log(
|
||||
'update compute privacy failed:',
|
||||
response.status,
|
||||
response.statusText
|
||||
)
|
||||
return null
|
||||
})
|
||||
|
||||
.catch((error) => {
|
||||
this.logger.error('Error updating compute privacy: ', error)
|
||||
return null
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Metadata for a DDO.
|
||||
* @param {did} string DID.
|
||||
|
@ -299,7 +353,7 @@ export class Aquarius {
|
|||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
|
@ -337,7 +391,7 @@ export class Aquarius {
|
|||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
|
@ -358,7 +412,7 @@ export class Aquarius {
|
|||
}
|
||||
): QueryResult {
|
||||
return {
|
||||
results: (results || []).map(ddo => new DDO(ddo as DDO)),
|
||||
results: (results || []).map((ddo) => new DDO(ddo as DDO)),
|
||||
page,
|
||||
totalPages,
|
||||
totalResults
|
||||
|
|
|
@ -71,7 +71,7 @@ export class DDO {
|
|||
throw new Error('index is not set')
|
||||
}
|
||||
|
||||
const service = this.service.find(s => s.index === index)
|
||||
const service = this.service.find((s) => s.index === index)
|
||||
|
||||
return service as Service<T>
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ export class DDO {
|
|||
throw new Error('serviceType not set')
|
||||
}
|
||||
|
||||
return this.service.find(s => s.type === serviceType) as Service<T>
|
||||
return this.service.find((s) => s.type === serviceType) as Service<T>
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ export class DDO {
|
|||
const { files, name, author, license } = attributes.main
|
||||
|
||||
const values = [
|
||||
...(files || []).map(({ checksum }) => checksum).filter(_ => !!_),
|
||||
...(files || []).map(({ checksum }) => checksum).filter((_) => !!_),
|
||||
name,
|
||||
author,
|
||||
license,
|
||||
|
|
|
@ -25,6 +25,11 @@ export interface ServiceAccessAttributes extends ServiceCommonAttributes {
|
|||
timeout: number
|
||||
}
|
||||
}
|
||||
export interface ServiceComputePrivacy {
|
||||
allowRawAlgorithm: boolean
|
||||
allowNetworkAccess: boolean
|
||||
trustedAlgorithms: string[]
|
||||
}
|
||||
|
||||
export interface ServiceComputeAttributes extends ServiceCommonAttributes {
|
||||
main: {
|
||||
|
@ -34,6 +39,7 @@ export interface ServiceComputeAttributes extends ServiceCommonAttributes {
|
|||
timeout: number
|
||||
provider?: ServiceComputeProvider
|
||||
name: string
|
||||
privacy?: ServiceComputePrivacy
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ export class ContractEvent {
|
|||
}
|
||||
|
||||
public once(callback?: (events: any[]) => void) {
|
||||
return new Promise(resolve => {
|
||||
const subscription = this.subscribe(events => {
|
||||
return new Promise((resolve) => {
|
||||
const subscription = this.subscribe((events) => {
|
||||
subscription.unsubscribe()
|
||||
if (callback) {
|
||||
callback(events)
|
||||
|
|
|
@ -62,7 +62,7 @@ export class EventHandler extends Instantiable {
|
|||
}
|
||||
|
||||
if (this.lastBlock !== blockNumber) {
|
||||
this.events.forEach(fn => fn(this.lastBlock + 1))
|
||||
this.events.forEach((fn) => fn(this.lastBlock + 1))
|
||||
this.lastBlock = blockNumber
|
||||
}
|
||||
this.lastTimeout = global.setTimeout(
|
||||
|
|
|
@ -192,7 +192,7 @@ export class Keeper extends Instantiable {
|
|||
*/
|
||||
public getConditionByAddress(address: string): Condition {
|
||||
return Object.values(this.conditions).find(
|
||||
condition => condition.getAddress() === address
|
||||
(condition) => condition.getAddress() === address
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ export class Keeper extends Instantiable {
|
|||
*/
|
||||
public getTemplateByName(name: string): AgreementTemplateBase {
|
||||
return Object.values(this.templates).find(
|
||||
template => template.templateName === name
|
||||
(template) => template.templateName === name
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ export class Keeper extends Instantiable {
|
|||
*/
|
||||
public getTemplateById(templateId: string): AgreementTemplateBase {
|
||||
return Object.values(this.templates).find(
|
||||
template => template.getId() === templateId
|
||||
(template) => template.getId() === templateId
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ export abstract class ContractBase extends Instantiable {
|
|||
|
||||
private searchMethod(methodName: string, args: any[] = []) {
|
||||
const methods = this.contract.options.jsonInterface
|
||||
.map(method => ({
|
||||
.map((method) => ({
|
||||
...method,
|
||||
signature: (method as any).signature
|
||||
}))
|
||||
|
|
|
@ -80,7 +80,7 @@ export class TemplateStoreManager extends ContractBase {
|
|||
}
|
||||
|
||||
public getConditions(conditionTypes: string[]) {
|
||||
return conditionTypes.map(address =>
|
||||
return conditionTypes.map((address) =>
|
||||
this.ocean.keeper.getConditionByAddress(address)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ export class AgreementTemplateBase {
|
|||
({ name: conditionRef }) => conditionRef === ref
|
||||
).contractName
|
||||
return (await this.getConditions()).find(
|
||||
condition => condition.contractName === name
|
||||
(condition) => condition.contractName === name
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -237,8 +237,8 @@ export class AgreementTemplateBase {
|
|||
|
||||
return states.reduce((acc, { contractName, ref, state }) => {
|
||||
const blockers = dependencies[ref]
|
||||
.map(dependency => states.find(_ => _.ref === dependency))
|
||||
.filter(condition => condition.state !== ConditionState.Fulfilled)
|
||||
.map((dependency) => states.find((_) => _.ref === dependency))
|
||||
.filter((condition) => condition.state !== ConditionState.Fulfilled)
|
||||
return {
|
||||
...acc,
|
||||
[ref]: {
|
||||
|
@ -246,7 +246,7 @@ export class AgreementTemplateBase {
|
|||
contractName,
|
||||
state,
|
||||
blocked: !!blockers.length,
|
||||
blockedBy: blockers.map(_ => _.ref)
|
||||
blockedBy: blockers.map((_) => _.ref)
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
|
@ -309,6 +309,8 @@ export class AgreementTemplateBase {
|
|||
*/
|
||||
public async getActorTypes() {
|
||||
const actorTypeIds = await this.getActorTypeIds()
|
||||
return actorTypeIds.map(typeId => this.templateManager.getActorTypeValue(typeId))
|
||||
return actorTypeIds.map((typeId) =>
|
||||
this.templateManager.getActorTypeValue(typeId)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export class OceanAccounts extends Instantiable {
|
|||
const ethAccounts: string[] = await this.web3.eth.getAccounts()
|
||||
|
||||
const accountPromises = ethAccounts.map(
|
||||
address => new Account(address, this.instanceConfig)
|
||||
(address) => new Account(address, this.instanceConfig)
|
||||
)
|
||||
return Promise.all(accountPromises)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { TransactionReceipt } from 'web3-core'
|
|||
import { SearchQuery } from '../aquarius/Aquarius'
|
||||
import { DDO } from '../ddo/DDO'
|
||||
import { MetaData, EditableMetaData } from '../ddo/MetaData'
|
||||
import { Service, ServiceAccess } from '../ddo/Service'
|
||||
import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/Service'
|
||||
import Account from './Account'
|
||||
import DID from './DID'
|
||||
import { fillConditionsWithDDO, SubscribablePromise, didZeroX } from '../utils'
|
||||
|
@ -60,7 +60,7 @@ export class OceanAssets extends Instantiable {
|
|||
services: Service[] = []
|
||||
): SubscribablePromise<CreateProgressStep, DDO> {
|
||||
this.logger.log('Creating asset')
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { secretStoreUri } = this.config
|
||||
const { didRegistry, templates } = this.ocean.keeper
|
||||
|
||||
|
@ -147,7 +147,7 @@ export class OceanAssets extends Instantiable {
|
|||
)
|
||||
.reverse()
|
||||
// Adding index
|
||||
.map(_ => ({
|
||||
.map((_) => ({
|
||||
..._,
|
||||
index: indexCount++
|
||||
})) as Service[]
|
||||
|
@ -287,7 +287,7 @@ export class OceanAssets extends Instantiable {
|
|||
consumerAccount: Account,
|
||||
provider?: string
|
||||
): SubscribablePromise<OrderProgressStep, string> {
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { keeper, utils } = this.ocean
|
||||
const ddo: DDO = await this.resolve(did)
|
||||
const condition = keeper.conditions.accessSecretStoreCondition
|
||||
|
@ -414,6 +414,41 @@ export class OceanAssets extends Instantiable {
|
|||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Compute Privacy
|
||||
* @param {did} string DID.
|
||||
* @param {number} serviceIndex Index of the compute service in the DDO
|
||||
* @param {ServiceComputePrivacy} computePrivacy ComputePrivacy fields & new values.
|
||||
* @param {Account} account Ethereum account of owner to sign and prove the ownership.
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
public async updateComputePrivacy(
|
||||
did: string,
|
||||
serviceIndex: number,
|
||||
computePrivacy: ServiceComputePrivacy,
|
||||
account: Account
|
||||
): Promise<string> {
|
||||
const oldDdo = await this.ocean.aquarius.retrieveDDO(did)
|
||||
// get a signature
|
||||
const signature = await this.ocean.utils.signature.signForAquarius(
|
||||
oldDdo.updated,
|
||||
account
|
||||
)
|
||||
let result = null
|
||||
if (signature != null)
|
||||
result = await this.ocean.aquarius.updateComputePrivacy(
|
||||
did,
|
||||
serviceIndex,
|
||||
computePrivacy.allowRawAlgorithm,
|
||||
computePrivacy.allowNetworkAccess,
|
||||
computePrivacy.trustedAlgorithms,
|
||||
oldDdo.updated,
|
||||
signature
|
||||
)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Retire a DDO (Delete)
|
||||
* @param {did} string DID.
|
||||
|
@ -477,7 +512,8 @@ export class OceanAssets extends Instantiable {
|
|||
public async createAccessServiceAttributes(
|
||||
consumerAccount: Account,
|
||||
price: string,
|
||||
datePublished: string
|
||||
datePublished: string,
|
||||
timeout: number = 0
|
||||
): Promise<ServiceAccess> {
|
||||
const { templates } = this.ocean.keeper
|
||||
const serviceAgreementTemplate = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplate()
|
||||
|
@ -491,7 +527,7 @@ export class OceanAssets extends Instantiable {
|
|||
creator: consumerAccount.getId(),
|
||||
datePublished,
|
||||
price,
|
||||
timeout: 3600,
|
||||
timeout: timeout,
|
||||
name: 'dataAssetAccessServiceAgreement'
|
||||
},
|
||||
serviceAgreementTemplate
|
||||
|
|
|
@ -5,7 +5,7 @@ import { DDO } from '../ddo/DDO'
|
|||
import { SubscribablePromise } from '../utils'
|
||||
import { OrderProgressStep } from './utils/ServiceUtils'
|
||||
import { DID } from '../squid'
|
||||
import { ServiceCompute } from '../ddo/Service'
|
||||
import { Service, ServiceCompute, ServiceComputePrivacy } from '../ddo/Service'
|
||||
|
||||
export const ComputeJobStatus = Object.freeze({
|
||||
Started: 10,
|
||||
|
@ -66,16 +66,43 @@ export class OceanCompute extends Instantiable {
|
|||
* Starts an order of a compute service that is defined in an asset's services.
|
||||
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||
* @param {string} datasetDid The DID of the dataset asset (of type `dataset`) to run the algorithm on.
|
||||
* @param {string} algorithmDid The DID of the algorithm asset (of type `algorithm`) to run on the asset.
|
||||
* @param {MetaData} algorithmMeta Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.
|
||||
* @return {Promise<string>} Returns the Service Agreement ID, representation of `bytes32` ID.
|
||||
*
|
||||
* Note: algorithmDid and algorithmMeta are optional, but if they are not passed,
|
||||
* you can end up in the situation that you are ordering and paying for your agreement,
|
||||
* but brizo will not allow the compute, due to privacy settings of the ddo
|
||||
*/
|
||||
public order(
|
||||
consumerAccount: Account,
|
||||
datasetDid: string,
|
||||
algorithmDid?: string,
|
||||
algorithmMeta?: MetaDataAlgorithm,
|
||||
provider?: string
|
||||
): SubscribablePromise<OrderProgressStep, string> {
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { assets, keeper, utils } = this.ocean
|
||||
const ddo: DDO = await assets.resolve(datasetDid)
|
||||
const service: Service = ddo.findServiceByType('compute')
|
||||
if (!service) return null
|
||||
if (algorithmMeta) {
|
||||
// check if raw algo is allowed
|
||||
if (service.attributes.main.privacy)
|
||||
if (!service.attributes.main.privacy.allowRawAlgorithm) return null
|
||||
}
|
||||
if (algorithmDid) {
|
||||
// check if did is in trusted list
|
||||
if (service.attributes.main.privacy)
|
||||
if (service.attributes.main.privacy.trustedAlgorithms)
|
||||
if (service.attributes.main.privacy.trustedAlgorithms.length > 0)
|
||||
if (
|
||||
!service.attributes.main.privacy.trustedAlgorithms.includes(
|
||||
algorithmDid
|
||||
)
|
||||
)
|
||||
return null
|
||||
}
|
||||
const condition = keeper.conditions.computeExecutionCondition
|
||||
|
||||
const agreementId = await utils.services.order(
|
||||
|
@ -137,17 +164,18 @@ export class OceanCompute extends Instantiable {
|
|||
output?: Output
|
||||
): Promise<ComputeJob> {
|
||||
output = this.checkOutput(consumerAccount, output)
|
||||
const computeJobsList = await this.ocean.brizo.compute(
|
||||
'post',
|
||||
agreementId,
|
||||
consumerAccount,
|
||||
algorithmDid,
|
||||
algorithmMeta,
|
||||
undefined,
|
||||
output
|
||||
)
|
||||
|
||||
return computeJobsList[0] as ComputeJob
|
||||
if (agreementId) {
|
||||
const computeJobsList = await this.ocean.brizo.compute(
|
||||
'post',
|
||||
agreementId,
|
||||
consumerAccount,
|
||||
algorithmDid,
|
||||
algorithmMeta,
|
||||
undefined,
|
||||
output
|
||||
)
|
||||
return computeJobsList[0] as ComputeJob
|
||||
} else return null
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,12 +294,15 @@ export class OceanCompute extends Instantiable {
|
|||
public async createComputeServiceAttributes(
|
||||
consumerAccount: Account,
|
||||
price: string,
|
||||
datePublished: string
|
||||
datePublished: string,
|
||||
computePrivacy?: ServiceComputePrivacy,
|
||||
timeout?: number
|
||||
): Promise<ServiceCompute> {
|
||||
const { templates } = this.ocean.keeper
|
||||
const serviceAgreementTemplate = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplate()
|
||||
const name = 'dataAssetComputingServiceAgreement'
|
||||
return {
|
||||
if (!timeout) timeout = 3600
|
||||
const service = {
|
||||
type: 'compute',
|
||||
index: 3,
|
||||
serviceEndpoint: this.ocean.brizo.getComputeEndpoint(),
|
||||
|
@ -281,11 +312,14 @@ export class OceanCompute extends Instantiable {
|
|||
creator: consumerAccount.getId(),
|
||||
datePublished,
|
||||
price,
|
||||
timeout: 3600,
|
||||
privacy: {},
|
||||
timeout: timeout,
|
||||
name
|
||||
},
|
||||
serviceAgreementTemplate
|
||||
}
|
||||
}
|
||||
if (computePrivacy) service.attributes.main.privacy = computePrivacy
|
||||
return service as ServiceCompute
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ export class OceanVersions extends Instantiable {
|
|||
network: (await this.ocean.keeper.getNetworkName()).toLowerCase(),
|
||||
keeperVersion: keeperPackageJson.version,
|
||||
contracts: Object.values(await this.ocean.keeper.getAllInstances())
|
||||
.filter(_ => !!_)
|
||||
.filter((_) => !!_)
|
||||
.reduce(
|
||||
(acc, { contractName, address }) => ({
|
||||
...acc,
|
||||
|
@ -115,19 +115,19 @@ export class OceanVersions extends Instantiable {
|
|||
|
||||
const networks = techs
|
||||
.map(({ network }) => network)
|
||||
.filter(_ => !!_)
|
||||
.filter((_) => !!_)
|
||||
.reduce((acc, network) => ({ ...acc, [network]: true }), {})
|
||||
|
||||
let contractStatus = true
|
||||
const contractList = techs.map(({ contracts }) => contracts).filter(_ => !!_)
|
||||
const contractList = techs.map(({ contracts }) => contracts).filter((_) => !!_)
|
||||
Array.from(contractList.map(Object.keys))
|
||||
.reduce((acc, _) => [...acc, ..._], [])
|
||||
.filter((_, i, list) => list.indexOf(_) === i)
|
||||
.forEach(name => {
|
||||
.forEach((name) => {
|
||||
let address
|
||||
contractList
|
||||
.map(_ => _[name])
|
||||
.forEach(_ => {
|
||||
.map((_) => _[name])
|
||||
.forEach((_) => {
|
||||
if (!address) {
|
||||
address = _
|
||||
return
|
||||
|
|
|
@ -8,7 +8,7 @@ function fillParameterWithDDO(
|
|||
parameter: ServiceAgreementTemplateParameter,
|
||||
ddo: DDO
|
||||
): ServiceAgreementTemplateParameter {
|
||||
const getValue = name => {
|
||||
const getValue = (name) => {
|
||||
switch (name) {
|
||||
case 'amount':
|
||||
case 'price':
|
||||
|
@ -38,9 +38,9 @@ export function fillConditionsWithDDO(
|
|||
conditions: ServiceAgreementTemplateCondition[],
|
||||
ddo: DDO
|
||||
): ServiceAgreementTemplateCondition[] {
|
||||
return conditions.map(condition => ({
|
||||
return conditions.map((condition) => ({
|
||||
...condition,
|
||||
parameters: condition.parameters.map(parameter => ({
|
||||
parameters: condition.parameters.map((parameter) => ({
|
||||
...fillParameterWithDDO(parameter, ddo)
|
||||
}))
|
||||
}))
|
||||
|
|
|
@ -39,7 +39,7 @@ export class SubscribableObserver<T, P> {
|
|||
|
||||
private emit(type: 'onNext' | 'onComplete' | 'onError', value: any) {
|
||||
Array.from(this.subscriptions)
|
||||
.map(subscription => subscription[type])
|
||||
.map((subscription) => subscription[type])
|
||||
.filter((callback: any) => callback && typeof callback === 'function')
|
||||
.forEach((callback: any) => callback(value))
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ export class SubscribablePromise<T extends any, P extends any> {
|
|||
const execution = executor(this.observer)
|
||||
|
||||
Promise.resolve(execution as any)
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
if (typeof (execution as any).then === 'function') {
|
||||
this.observer.complete(result)
|
||||
}
|
||||
})
|
||||
.catch(result => {
|
||||
.catch((result) => {
|
||||
if (typeof (execution as any).then === 'function') {
|
||||
this.observer.error(result)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { assert } from 'chai'
|
|||
import { config } from '../config'
|
||||
import { getMetadata } from '../utils'
|
||||
import { Ocean, Account, EditableMetaData } from '../../../src' // @oceanprotocol/squid
|
||||
import { ServiceComputePrivacy } from '../../../src/ddo/Service'
|
||||
|
||||
describe('Asset Owners', () => {
|
||||
let ocean: Ocean
|
||||
|
@ -202,4 +203,56 @@ describe('Asset Owners', () => {
|
|||
assert.equal(-1, remList.indexOf(consumer1.getId()))
|
||||
assert.notEqual(-1, remList.indexOf(consumer2.getId()))
|
||||
})
|
||||
|
||||
it('should be able to update computePrivacy', async () => {
|
||||
const origComputePrivacy = {
|
||||
allowRawAlgorithm: true,
|
||||
allowNetworkAccess: true,
|
||||
trustedAlgorithms: []
|
||||
}
|
||||
|
||||
const newComputePrivacy = {
|
||||
allowRawAlgorithm: false,
|
||||
allowNetworkAccess: false,
|
||||
trustedAlgorithms: ['did:op:123', 'did:op:1234']
|
||||
}
|
||||
const computeService = await ocean.compute.createComputeServiceAttributes(
|
||||
account1,
|
||||
'0',
|
||||
'2020-03-10T10:00:00Z',
|
||||
origComputePrivacy as ServiceComputePrivacy
|
||||
)
|
||||
const { id } = await ocean.assets.create(metadata as any, account1, [
|
||||
computeService
|
||||
])
|
||||
|
||||
const oldDDO = await ocean.assets.resolve(id)
|
||||
let serviceIndex = null
|
||||
|
||||
for (let index = 0; index < oldDDO.service.length; index++) {
|
||||
if (oldDDO.service[index].type === 'compute') serviceIndex = index
|
||||
}
|
||||
|
||||
await ocean.assets.updateComputePrivacy(
|
||||
id,
|
||||
serviceIndex,
|
||||
newComputePrivacy as ServiceComputePrivacy,
|
||||
account1
|
||||
)
|
||||
|
||||
const newDDO = await ocean.assets.resolve(id)
|
||||
|
||||
assert.equal(
|
||||
newDDO.service[serviceIndex].attributes.main.privacy.allowRawAlgorithm,
|
||||
newComputePrivacy.allowRawAlgorithm
|
||||
)
|
||||
assert.equal(
|
||||
newDDO.service[serviceIndex].attributes.main.privacy.allowNetworkAccess,
|
||||
newComputePrivacy.allowNetworkAccess
|
||||
)
|
||||
assert.deepEqual(
|
||||
newDDO.service[serviceIndex].attributes.main.privacy.trustedAlgorithms,
|
||||
newComputePrivacy.trustedAlgorithms
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
MetaDataAlgorithm
|
||||
} from '../../../src'
|
||||
import { getMetadata } from '../utils'
|
||||
import { ServiceCompute } from '../../../src/ddo/Service'
|
||||
import { ServiceCompute, ServiceComputePrivacy } from '../../../src/ddo/Service'
|
||||
|
||||
const metadataAsset = getMetadata()
|
||||
const metadataAlgorithm = getMetadata(0, 'algorithm')
|
||||
|
@ -26,11 +26,24 @@ const customConfig: Config = {
|
|||
verbose: true
|
||||
}
|
||||
|
||||
export const rawAlgoMeta = {
|
||||
rawcode: `console.log('Hello world'!)`,
|
||||
format: 'docker-image',
|
||||
version: '0.1',
|
||||
container: {
|
||||
entrypoint: 'node $ALGO',
|
||||
image: 'node',
|
||||
tag: '10'
|
||||
}
|
||||
}
|
||||
|
||||
describe('Compute', () => {
|
||||
let ocean: Ocean
|
||||
let account: Account
|
||||
let agreementId: string
|
||||
let dataset: DDO
|
||||
let datasetNoRawAlgo: DDO
|
||||
let datasetWithTrustedAlgo: DDO
|
||||
let algorithm: DDO
|
||||
let computeService: ServiceCompute
|
||||
let jobId: string
|
||||
|
@ -53,7 +66,7 @@ describe('Compute', () => {
|
|||
)
|
||||
dataset = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next(step => stepsAsset.push(step))
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(dataset, DDO)
|
||||
assert.isDefined(
|
||||
|
@ -63,16 +76,88 @@ describe('Compute', () => {
|
|||
assert.deepEqual(stepsAsset, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
})
|
||||
|
||||
it('should publish a dataset with a compute service object that does not allow rawAlgo', async () => {
|
||||
const stepsAsset = []
|
||||
const origComputePrivacy = {
|
||||
allowRawAlgorithm: false,
|
||||
allowNetworkAccess: false,
|
||||
trustedAlgorithms: []
|
||||
}
|
||||
|
||||
computeService = await ocean.compute.createComputeServiceAttributes(
|
||||
account,
|
||||
'1000',
|
||||
metadataAsset.main.datePublished,
|
||||
origComputePrivacy as ServiceComputePrivacy
|
||||
)
|
||||
datasetNoRawAlgo = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(datasetNoRawAlgo, DDO)
|
||||
assert.isDefined(
|
||||
dataset.findServiceByType('compute'),
|
||||
`DDO compute service doesn't exist`
|
||||
)
|
||||
assert.deepEqual(stepsAsset, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
})
|
||||
|
||||
it('should publish a dataset with a compute service object that allows only algo with did:op:1234', async () => {
|
||||
const stepsAsset = []
|
||||
const origComputePrivacy = {
|
||||
allowRawAlgorithm: false,
|
||||
allowNetworkAccess: false,
|
||||
trustedAlgorithms: ['did:op:1234']
|
||||
}
|
||||
|
||||
computeService = await ocean.compute.createComputeServiceAttributes(
|
||||
account,
|
||||
'1000',
|
||||
metadataAsset.main.datePublished,
|
||||
origComputePrivacy as ServiceComputePrivacy
|
||||
)
|
||||
datasetWithTrustedAlgo = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(datasetWithTrustedAlgo, DDO)
|
||||
assert.isDefined(
|
||||
dataset.findServiceByType('compute'),
|
||||
`DDO compute service doesn't exist`
|
||||
)
|
||||
assert.deepEqual(stepsAsset, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
})
|
||||
|
||||
it('should publish an algorithm', async () => {
|
||||
const stepsAlgorithm = []
|
||||
algorithm = await ocean.assets
|
||||
.create(metadataAlgorithm as MetaData, account)
|
||||
.next(step => stepsAlgorithm.push(step))
|
||||
.next((step) => stepsAlgorithm.push(step))
|
||||
|
||||
assert.instanceOf(algorithm, DDO)
|
||||
assert.deepEqual(stepsAlgorithm, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
})
|
||||
|
||||
it('should not allow order the compute service with raw algo for dataset that does not allow raw algo', async () => {
|
||||
const steps = []
|
||||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, datasetNoRawAlgo.id, null, rawAlgoMeta)
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.equal(agreementId, null)
|
||||
})
|
||||
|
||||
it('should not allow order the compute service with did != did:op:1234 for dataset that allows only did:op:1234 as algo', async () => {
|
||||
const steps = []
|
||||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, datasetWithTrustedAlgo.id, 'did:op:233454', null)
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.equal(agreementId, null)
|
||||
})
|
||||
|
||||
it('should order the compute service of the dataset', async () => {
|
||||
const steps = []
|
||||
try {
|
||||
|
@ -87,7 +172,7 @@ describe('Compute', () => {
|
|||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, dataset.id)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
console.log(agreementId)
|
||||
assert.isDefined(agreementId)
|
||||
|
|
|
@ -170,7 +170,7 @@ describe('Consume Asset', () => {
|
|||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
@ -195,7 +195,7 @@ describe('Consume Asset', () => {
|
|||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('Consume Asset (Brizo)', () => {
|
|||
const steps = []
|
||||
ddo = await ocean.assets
|
||||
.create(metadata as any, publisher)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.instanceOf(ddo, DDO)
|
||||
assert.deepEqual(steps, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
|
@ -64,7 +64,7 @@ describe('Consume Asset (Brizo)', () => {
|
|||
|
||||
agreementId = await ocean.assets
|
||||
.order(ddo.id, consumer)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
} catch {}
|
||||
|
||||
assert.isDefined(agreementId)
|
||||
|
@ -77,7 +77,7 @@ describe('Consume Asset (Brizo)', () => {
|
|||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
|
|
@ -72,7 +72,7 @@ xdescribe('Consume Asset (Large size)', () => {
|
|||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
|
|
@ -53,7 +53,7 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
|
||||
it('should approve the template', async () => {
|
||||
|
@ -63,7 +63,7 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -122,9 +122,9 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||
})
|
||||
|
||||
it('should have condition instances asociated', async () => {
|
||||
const conditionInstances = (await template.getConditionTypes()).map(address =>
|
||||
keeper.getConditionByAddress(address)
|
||||
)
|
||||
const conditionInstances = (
|
||||
await template.getConditionTypes()
|
||||
).map((address) => keeper.getConditionByAddress(address))
|
||||
|
||||
assert.equal(conditionInstances.length, 3, 'Expected 3 conditions.')
|
||||
|
||||
|
@ -133,10 +133,10 @@ describe('Register Escrow Access Secret Store Template', () => {
|
|||
EscrowReward,
|
||||
LockRewardCondition
|
||||
]
|
||||
conditionClasses.forEach(conditionClass => {
|
||||
conditionClasses.forEach((conditionClass) => {
|
||||
if (
|
||||
!conditionInstances.find(
|
||||
condition => condition instanceof conditionClass
|
||||
(condition) => condition instanceof conditionClass
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('Register Escrow Compute Execution Template', () => {
|
|||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
|
||||
it('should approve the template', async () => {
|
||||
|
@ -65,7 +65,7 @@ describe('Register Escrow Compute Execution Template', () => {
|
|||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -133,10 +133,10 @@ describe('Register Escrow Compute Execution Template', () => {
|
|||
EscrowReward,
|
||||
LockRewardCondition
|
||||
]
|
||||
conditionClasses.forEach(conditionClass => {
|
||||
conditionClasses.forEach((conditionClass) => {
|
||||
if (
|
||||
!conditionInstances.find(
|
||||
condition => condition instanceof conditionClass
|
||||
(condition) => condition instanceof conditionClass
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
|
|
|
@ -11,9 +11,7 @@ describe('Search Asset', () => {
|
|||
|
||||
let publisher: Account
|
||||
|
||||
const testHash = Math.random()
|
||||
.toString(36)
|
||||
.substr(2)
|
||||
const testHash = Math.random().toString(36).substr(2)
|
||||
let price
|
||||
const metadataGenerator = (name: string) =>
|
||||
generateMetadata(`${name}${testHash}`, price)
|
||||
|
@ -83,7 +81,7 @@ describe('Search Asset', () => {
|
|||
1,
|
||||
'Something was wrong searching the assets'
|
||||
)
|
||||
ddos.map(ddo =>
|
||||
ddos.map((ddo) =>
|
||||
assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO')
|
||||
)
|
||||
})
|
||||
|
@ -101,7 +99,7 @@ describe('Search Asset', () => {
|
|||
})
|
||||
|
||||
assert.equal(ddos.length, 1, 'Something was wrong searching the assets')
|
||||
ddos.map(ddo =>
|
||||
ddos.map((ddo) =>
|
||||
assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO')
|
||||
)
|
||||
})
|
||||
|
|
|
@ -9,7 +9,7 @@ import { LoggerInstance } from '../../../src/utils'
|
|||
|
||||
use(spies)
|
||||
|
||||
const reponsify = async data => ({
|
||||
const reponsify = async (data) => ({
|
||||
ok: true,
|
||||
json: () => Promise.resolve(data)
|
||||
})
|
||||
|
|
|
@ -17,25 +17,25 @@ describe('ContractWrapperBase', () => {
|
|||
})
|
||||
|
||||
describe('#call()', () => {
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.callMock('balanceOfxxx', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an contract function with wrong set of parameters', done => {
|
||||
it('should fail to call on an contract function with wrong set of parameters', (done) => {
|
||||
wrappedContract.callMock('balanceOf', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.sendMock('balanceOfxxx', '0x00', ['0x00']).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an contract function with wrong set of parameters', done => {
|
||||
it('should fail to call on an contract function with wrong set of parameters', (done) => {
|
||||
wrappedContract.sendMock('approve', '0x000', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ describe('ContractWrapperBase', () => {
|
|||
})
|
||||
|
||||
describe('#send()', () => {
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.sendMock('transferxxx', accounts[0].getId(), []).catch(() => {
|
||||
done()
|
||||
})
|
||||
|
@ -60,7 +60,7 @@ describe('ContractWrapperBase', () => {
|
|||
})
|
||||
|
||||
describe('#getEventData()', () => {
|
||||
it('should fail on unknown event', done => {
|
||||
it('should fail on unknown event', (done) => {
|
||||
wrappedContract.getEventData('crazyevent', {}).catch(() => {
|
||||
done()
|
||||
})
|
||||
|
|
|
@ -28,8 +28,8 @@ describe('ContractEvent', () => {
|
|||
let validResolve = false
|
||||
let subscription: ContractEventSubscription
|
||||
|
||||
const waitUntilEvent = new Promise(resolve => {
|
||||
subscription = event.subscribe(events => {
|
||||
const waitUntilEvent = new Promise((resolve) => {
|
||||
subscription = event.subscribe((events) => {
|
||||
assert.isDefined(events)
|
||||
assert.lengthOf(events, 2)
|
||||
if (validResolve) {
|
||||
|
@ -40,7 +40,7 @@ describe('ContractEvent', () => {
|
|||
|
||||
await Promise.all([executeTransaction(), executeTransaction()])
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
validResolve = true
|
||||
|
||||
await Promise.all([executeTransaction(), executeTransaction()])
|
||||
|
@ -68,7 +68,7 @@ describe('ContractEvent', () => {
|
|||
|
||||
await executeTransaction()
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
canBeRejected = true
|
||||
|
||||
await executeTransaction()
|
||||
|
@ -82,7 +82,7 @@ describe('ContractEvent', () => {
|
|||
|
||||
const waitUntilEvent = event.once()
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 400))
|
||||
await new Promise((resolve) => setTimeout(resolve, 400))
|
||||
|
||||
await executeTransaction()
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('ContractHandler', () => {
|
|||
assert(await contractHandler.get('OceanToken'))
|
||||
})
|
||||
|
||||
it('should fail to load an unknown contract', done => {
|
||||
it('should fail to load an unknown contract', (done) => {
|
||||
contractHandler.get('OceanXXX').catch(() => {
|
||||
done()
|
||||
})
|
||||
|
|
|
@ -67,12 +67,12 @@ describe('EventHandler', () => {
|
|||
|
||||
const subscription = eventHandler.subscribe(callbackSpy)
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 300))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
|
||||
expect(callbackSpy).not.to.has.been.called()
|
||||
blockNumber++
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 300))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
|
||||
expect(callbackSpy).to.has.been.called.with(blockNumber)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('DID', () => {
|
|||
assert(did.getId() === id, did.getId())
|
||||
})
|
||||
|
||||
it('should throw if prefix does not match', done => {
|
||||
it('should throw if prefix does not match', (done) => {
|
||||
const id = '1234'
|
||||
try {
|
||||
const did: DID = DID.parse(`did:xxx:${id}`)
|
||||
|
@ -28,7 +28,7 @@ describe('DID', () => {
|
|||
}
|
||||
})
|
||||
|
||||
it('should throw if id does not match', done => {
|
||||
it('should throw if id does not match', (done) => {
|
||||
const id = 'xyz'
|
||||
try {
|
||||
const did: DID = DID.parse(`did:op:${id}`)
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('OceanAccounts', () => {
|
|||
it('should return the list of accounts', async () => {
|
||||
const accounts = await oceanAccounts.list()
|
||||
|
||||
accounts.map(account => assert.instanceOf(account, Account))
|
||||
accounts.map((account) => assert.instanceOf(account, Account))
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ describe('SubscribablePromise', () => {
|
|||
assert.typeOf(subscription.unsubscribe, 'function')
|
||||
})
|
||||
|
||||
it('should listen the next values', done => {
|
||||
it('should listen the next values', (done) => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.next('test'), 20)
|
||||
})
|
||||
|
@ -39,10 +39,10 @@ describe('SubscribablePromise', () => {
|
|||
})
|
||||
|
||||
describe('#then()', () => {
|
||||
it('should resolve', done => {
|
||||
it('should resolve', (done) => {
|
||||
const onCompleteSpy = spy()
|
||||
const onFinallySpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.complete('test'), 20)
|
||||
})
|
||||
|
@ -59,10 +59,10 @@ describe('SubscribablePromise', () => {
|
|||
})
|
||||
|
||||
describe('#error()', () => {
|
||||
it('should catch the error', done => {
|
||||
it('should catch the error', (done) => {
|
||||
const onErrorSpy = spy()
|
||||
const onFinallySpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.error('test'), 20)
|
||||
})
|
||||
|
@ -80,7 +80,7 @@ describe('SubscribablePromise', () => {
|
|||
|
||||
it('should be able to subscribe and wait for a promise', async () => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.next('test'), 20)
|
||||
setTimeout(() => observer.complete('completed'), 30)
|
||||
|
@ -96,12 +96,12 @@ describe('SubscribablePromise', () => {
|
|||
|
||||
it('should use the result of a the promise as executor to complete the observer', async () => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(async observer => {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
const subscribable = new SubscribablePromise(async (observer) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
observer.next('test')
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
observer.next('test')
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
return 'completed'
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue