From 796311dd0112e11492ee0e6a2e761dce1bfde15a Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Mon, 25 Mar 2019 00:46:58 +0700 Subject: [PATCH 1/9] update marketplace service api --- systemservices/marketplace/mesg.yml | 27 +- systemservices/marketplace/package-lock.json | 829 +++++++++++++++++- systemservices/marketplace/package.json | 1 + .../marketplace/src/contracts/version.ts | 6 +- .../src/events/serviceVersionCreated.ts | 7 +- .../marketplace/src/tasks/isAuthorized.ts | 6 +- .../src/tasks/publishServiceVersion.ts | 22 +- .../marketplace/src/types/version.ts | 4 +- 8 files changed, 843 insertions(+), 59 deletions(-) diff --git a/systemservices/marketplace/mesg.yml b/systemservices/marketplace/mesg.yml index 752cc7d1c..636aeeefb 100644 --- a/systemservices/marketplace/mesg.yml +++ b/systemservices/marketplace/mesg.yml @@ -49,18 +49,24 @@ tasks: description: "" type: String manifest: &manifest - name: "" - description: "" - type: String - manifestProtocol: &manifestProtocol - name: "" - description: "" - type: String - manifestData: &manifestData name: "" description: "" type: Object optional: true + object: + version: { type: String } + service: &serviceInformation + type: Object + object: + hash: { type: String } + hashVersion: { type: String } + deployment: + type: Object + object: + type: { type: String } + source: { type: String } + definition: { type: Object } + readme: { type: String } createTime: *createTime offers: &offers name: "" @@ -130,9 +136,7 @@ tasks: name: "" description: "" inputs: - sid: *sid - manifest: *manifest - manifestProtocol: *manifestProtocol + service: *serviceInformation from: &inputFrom name: "" description: "" @@ -292,7 +296,6 @@ events: sid: *sid versionHash: *versionHash manifest: *manifest - manifestProtocol: *manifestProtocol serviceOfferCreated: name: "" description: "" diff --git a/systemservices/marketplace/package-lock.json b/systemservices/marketplace/package-lock.json index 1e0243c2b..253a9c8ef 100644 --- a/systemservices/marketplace/package-lock.json +++ b/systemservices/marketplace/package-lock.json @@ -282,6 +282,11 @@ "optjs": "~3.2.2" } }, + "asmcrypto.js": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/asmcrypto.js/-/asmcrypto.js-2.3.2.tgz", + "integrity": "sha512-3FgFARf7RupsZETQ1nHnhLUUvpcttcCq1iZCaVAbJZbCZ5VNRrNyvpDyHTOb0KC3llFcsyOT/a99NZcCbeiEsA==" + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -311,6 +316,14 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + }, "async-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", @@ -435,6 +448,22 @@ "integrity": "sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "bl": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", @@ -444,6 +473,11 @@ "safe-buffer": "^5.1.1" } }, + "blakejs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", + "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=" + }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -489,6 +523,25 @@ } } }, + "borc": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/borc/-/borc-2.1.0.tgz", + "integrity": "sha512-hKTxeYt3AIzIG45epJHv8xJYSF0ktp7nZgFsqi5cPzoL3T8qKMPeUlqydORy6j3NWZvRDANx30PjpTmGho69Gw==", + "requires": { + "bignumber.js": "^8.0.1", + "commander": "^2.15.0", + "ieee754": "^1.1.8", + "iso-url": "~0.4.4", + "json-text-sequence": "~0.1.0" + }, + "dependencies": { + "commander": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + } + } + }, "boxen": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", @@ -613,6 +666,14 @@ "parse-asn1": "^5.0.0" } }, + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", + "requires": { + "base-x": "^3.0.2" + } + }, "buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", @@ -661,6 +722,11 @@ "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" + }, "bytebuffer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", @@ -752,6 +818,17 @@ "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", "dev": true }, + "cids": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/cids/-/cids-0.5.8.tgz", + "integrity": "sha512-Ye8TZP3YQfy0j+i5k+LPHdTY3JOvTwN1pxds44p6BRUv8PTMOAF/Vt4Bc+oiIQ0Sktn0iftkUHgqKNHIMwhshA==", + "requires": { + "class-is": "^1.1.0", + "multibase": "~0.6.0", + "multicodec": "~0.5.0", + "multihashes": "~0.4.14" + } + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -761,6 +838,11 @@ "safe-buffer": "^5.0.1" } }, + "class-is": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", + "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -900,6 +982,26 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "concat-stream": { + "version": "github:hugomrdias/concat-stream#057bc7b5d6d8df26c8cf00a3f151b6721a0a8034", + "from": "github:hugomrdias/concat-stream#feat/smaller", + "requires": { + "inherits": "^2.0.3", + "readable-stream": "^3.0.2" + }, + "dependencies": { + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "configstore": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", @@ -1225,6 +1327,11 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "delimit-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/delimit-stream/-/delimit-stream-0.1.0.tgz", + "integrity": "sha1-m4MZR3wOX4rrPONXrjBfwl6hzSs=" + }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -1244,6 +1351,11 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "detect-node": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz", + "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==" + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -1273,6 +1385,16 @@ "is-obj": "^1.0.0" } }, + "drbg.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", + "integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", + "requires": { + "browserify-aes": "^1.0.6", + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4" + } + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -1319,6 +1441,11 @@ "once": "^1.4.0" } }, + "err-code": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz", + "integrity": "sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=" + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -1684,6 +1811,11 @@ "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=" }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -1736,6 +1868,11 @@ } } }, + "flatmap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/flatmap/-/flatmap-0.0.3.tgz", + "integrity": "sha1-Hxik2TgVLUlZZfnJWNkjqy3WabQ=" + }, "for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -1834,8 +1971,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -1856,14 +1992,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1878,20 +2012,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2008,8 +2139,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2021,7 +2151,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2036,7 +2165,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2044,14 +2172,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2070,7 +2196,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2151,8 +2276,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2164,7 +2288,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2250,8 +2373,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2287,7 +2409,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2307,7 +2428,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2351,14 +2471,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -3091,11 +3209,167 @@ "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "ip-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", + "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=" + }, "ipaddr.js": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" }, + "ipfs-block": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/ipfs-block/-/ipfs-block-0.8.0.tgz", + "integrity": "sha512-znNtFRxXlJYP1/Q4u0tGFJUceH9pNww8WA+zair6T3y7d28m+vtUDJGn96M7ZlFFSkByQyQsAiq2ssNhKtMzxw==", + "requires": { + "cids": "~0.5.5", + "class-is": "^1.1.0" + } + }, + "ipfs-http-client": { + "version": "30.1.0", + "resolved": "https://registry.npmjs.org/ipfs-http-client/-/ipfs-http-client-30.1.0.tgz", + "integrity": "sha512-yon0JgvXDXxy90x6R+Ut7nBoXEgSQI4cSmlV3KOhzMO9cIdUSDBflEWBGBSVciDBu9xxPASOh7umYV6XPz8Xlw==", + "requires": { + "async": "^2.6.1", + "bignumber.js": "^8.0.2", + "bl": "^3.0.0", + "bs58": "^4.0.1", + "cids": "~0.5.5", + "concat-stream": "github:hugomrdias/concat-stream#057bc7b5d6d8df26c8cf00a3f151b6721a0a8034", + "debug": "^4.1.0", + "detect-node": "^2.0.4", + "end-of-stream": "^1.4.1", + "err-code": "^1.1.2", + "flatmap": "0.0.3", + "glob": "^7.1.3", + "ipfs-block": "~0.8.0", + "ipld-dag-cbor": "~0.13.1", + "ipld-dag-pb": "~0.15.3", + "is-ipfs": "~0.6.0", + "is-pull-stream": "0.0.0", + "is-stream": "^1.1.0", + "iso-stream-http": "~0.1.1", + "iso-url": "~0.4.6", + "just-kebab-case": "^1.1.0", + "just-map-keys": "^1.1.0", + "lru-cache": "^5.1.1", + "multiaddr": "^6.0.6", + "multibase": "~0.6.0", + "multicodec": "~0.5.0", + "multihashes": "~0.4.14", + "ndjson": "github:hugomrdias/ndjson#4db16da6b42e5b39bf300c3a7cde62abb3fa3a11", + "once": "^1.4.0", + "peer-id": "~0.12.2", + "peer-info": "~0.15.1", + "promisify-es6": "^1.0.3", + "pull-defer": "~0.2.3", + "pull-stream": "^3.6.9", + "pull-to-stream": "~0.1.0", + "pump": "^3.0.0", + "qs": "^6.5.2", + "readable-stream": "^3.1.1", + "stream-to-pull-stream": "^1.7.2", + "tar-stream": "^2.0.1", + "through2": "^3.0.1" + }, + "dependencies": { + "bl": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", + "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", + "requires": { + "readable-stream": "^3.0.1" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "tar-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.0.1.tgz", + "integrity": "sha512-I6OJF7wE62BC6zNPdHDtseK0D0187PBjbKSLYY4ffvVkBM6tyBn2O9plDvVM2229/mozfEL/X3++qSvYYQE2xw==", + "requires": { + "bl": "^3.0.0", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } + }, + "ipld-dag-cbor": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/ipld-dag-cbor/-/ipld-dag-cbor-0.13.1.tgz", + "integrity": "sha512-96KKh5XUq9LrWE/TQ/BOJ5FcQx7UZ892N76ufDdovq+fIwZ4/YpPRTAVssLUuN3crATHoGu80TVZMgevsuTCdQ==", + "requires": { + "borc": "^2.1.0", + "bs58": "^4.0.1", + "cids": "~0.5.5", + "is-circular": "^1.0.2", + "multihashes": "~0.4.14", + "multihashing-async": "~0.5.1", + "traverse": "~0.6.6" + } + }, + "ipld-dag-pb": { + "version": "0.15.3", + "resolved": "https://registry.npmjs.org/ipld-dag-pb/-/ipld-dag-pb-0.15.3.tgz", + "integrity": "sha512-J1RJzSVCaOpxPmSzXbwVNsAZPHctjY4OjqG1dMIG86Z37CKvuy1QwCFkDhNccUTcQpF3sXfj5e0ZUyMM035vzg==", + "requires": { + "async": "^2.6.1", + "bs58": "^4.0.1", + "cids": "~0.5.4", + "class-is": "^1.1.0", + "is-ipfs": "~0.6.0", + "multihashing-async": "~0.5.1", + "protons": "^1.0.1", + "pull-stream": "^3.6.9", + "pull-traverse": "^1.0.3", + "stable": "~0.1.8" + } + }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -3145,6 +3419,11 @@ "ci-info": "^1.5.0" } }, + "is-circular": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-circular/-/is-circular-1.0.2.tgz", + "integrity": "sha512-YttjnrswnUYRVJvxCvu8z+PGMUSzC2JttP0OEXezlAEdp3EXzhf7IZ3j0gRAybJBQupedIZFhY61Tga6E0qASA==" + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -3231,6 +3510,27 @@ "is-path-inside": "^1.0.0" } }, + "is-ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ip/-/is-ip-2.0.0.tgz", + "integrity": "sha1-aO6gfooKCpTC0IDdZ0xzGrKkYas=", + "requires": { + "ip-regex": "^2.0.0" + } + }, + "is-ipfs": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.6.0.tgz", + "integrity": "sha512-q/CO69rN+vbw9eGXGQOAa15zXq+pSyhdKvE7mqvuplDu67LyT3H9t3RyYQvKpueN7dL4f6fbyjEMPp9J3rJ4qA==", + "requires": { + "bs58": "^4.0.1", + "cids": "~0.5.6", + "mafmt": "^v6.0.7", + "multiaddr": "^6.0.4", + "multibase": "~0.6.0", + "multihashes": "~0.4.13" + } + }, "is-natural-number": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", @@ -3296,6 +3596,16 @@ "isobject": "^3.0.1" } }, + "is-promise": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz", + "integrity": "sha1-MVc3YcBX4zwukaq56W2gjO++duU=" + }, + "is-pull-stream": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/is-pull-stream/-/is-pull-stream-0.0.0.tgz", + "integrity": "sha1-o7w9HG0wVRUcRr3m85nv7SFEDKk=" + }, "is-redirect": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", @@ -3334,6 +3644,38 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "iso-random-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/iso-random-stream/-/iso-random-stream-1.1.0.tgz", + "integrity": "sha512-ywSWt0KrWcsaK0jVoVJIR30rLyjg9Rw3k2Sm/qp+3tdtSV0SNH7L7KilKnENcENOSoJxDFvpt2idvuMMQohdCQ==" + }, + "iso-stream-http": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/iso-stream-http/-/iso-stream-http-0.1.1.tgz", + "integrity": "sha512-uYveJvqcH+TecR1ittHG+vSfq8fwQRNiqWYlFkpZu1RpwLcXU9zSgN29CQ66M/ZOykbcXm3igDiHrs+G+bLd6A==", + "requires": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "iso-url": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/iso-url/-/iso-url-0.4.6.tgz", + "integrity": "sha512-YQO7+aIe6l1aSJUKOx+Vrv08DlhZeLFIVfehG2L29KLSEb9RszqPXilxJRVpp57px36BddKR5ZsebacO5qG0tg==" + }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -3388,6 +3730,14 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "json-text-sequence": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/json-text-sequence/-/json-text-sequence-0.1.1.tgz", + "integrity": "sha1-py8hfcSvxGKf/1/rME3BvVGi89I=", + "requires": { + "delimit-stream": "0.1.0" + } + }, "jsonfile": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", @@ -3407,6 +3757,16 @@ "verror": "1.10.0" } }, + "just-kebab-case": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/just-kebab-case/-/just-kebab-case-1.1.0.tgz", + "integrity": "sha512-QkuwuBMQ9BQHMUEkAtIA4INLrkmnnveqlFB1oFi09gbU0wBdZo6tTnyxNWMR84zHxBuwK7GLAwqN8nrvVxOLTA==" + }, + "just-map-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/just-map-keys/-/just-map-keys-1.1.0.tgz", + "integrity": "sha512-oNKi+4y7fr8lXnhKYpBbCkiwHRVkAnx0VDkCeTDtKKMzGr1Lz1Yym+RSieKUTKim68emC5Yxrb4YmiF9STDO+g==" + }, "keccakjs": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/keccakjs/-/keccakjs-0.2.3.tgz", @@ -3416,6 +3776,11 @@ "sha3": "^1.2.2" } }, + "keypair": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/keypair/-/keypair-1.0.1.tgz", + "integrity": "sha1-dgNxknCvtlZO04oiCHoG/Jqk6hs=" + }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -3439,6 +3804,59 @@ "invert-kv": "^1.0.0" } }, + "libp2p-crypto": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.16.1.tgz", + "integrity": "sha512-+fxqy+cDjwOKK4KTj44WQmjPE5ep2eR5uAIQWHl/+RKvRSor3+RAY53VWkAecgAEvjX2AswxBsoCIJK1Qk5aIQ==", + "requires": { + "asmcrypto.js": "^2.3.2", + "asn1.js": "^5.0.1", + "async": "^2.6.1", + "bn.js": "^4.11.8", + "browserify-aes": "^1.2.0", + "bs58": "^4.0.1", + "iso-random-stream": "^1.1.0", + "keypair": "^1.0.1", + "libp2p-crypto-secp256k1": "~0.3.0", + "multihashing-async": "~0.5.1", + "node-forge": "~0.7.6", + "pem-jwk": "^2.0.0", + "protons": "^1.0.1", + "rsa-pem-to-jwk": "^1.1.3", + "tweetnacl": "^1.0.0", + "ursa-optional": "~0.9.10" + }, + "dependencies": { + "asn1.js": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.0.1.tgz", + "integrity": "sha512-aO8EaEgbgqq77IEw+1jfx5c9zTbzvkfuRBuZsSsPnTHMkmd5AI4J6OtITLZFa381jReeaQL67J0GBTUu0+ZTVw==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "tweetnacl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", + "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" + } + } + }, + "libp2p-crypto-secp256k1": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/libp2p-crypto-secp256k1/-/libp2p-crypto-secp256k1-0.3.0.tgz", + "integrity": "sha512-+rF3S5p2pzS4JLDwVE6gLWZeaKkpl4NkYwG+0knV6ot29UcRSb73OyCWl07r1h5+g9E3KZC3wpsu+RIK5w8zQA==", + "requires": { + "async": "^2.6.1", + "bs58": "^4.0.1", + "multihashing-async": "~0.5.1", + "nodeify": "^1.0.1", + "safe-buffer": "^5.1.2", + "secp256k1": "^3.6.1" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -3459,6 +3877,11 @@ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, + "looper": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/looper/-/looper-3.0.0.tgz", + "integrity": "sha1-LvpUw7HLq6m5Su4uWRSwvlf7t0k=" + }, "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -3474,6 +3897,14 @@ "yallist": "^2.1.2" } }, + "mafmt": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-6.0.7.tgz", + "integrity": "sha512-2OG/EGAJZmpZBl7YRT1hD83sZa2gKsUEdegRuURreIOe7B4VeHU1rYYmhgk7BkLzknGL3xGYsDx3bbSgEEzE7g==", + "requires": { + "multiaddr": "^6.0.4" + } + }, "make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -3682,6 +4113,77 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "multiaddr": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.6.tgz", + "integrity": "sha512-nR4s91mi7IKed1jrqUj/4OhZ1VKdAjUG79IuVB5PS6b+qxOZLKPW8nsskHhrfGn4o1Rn1NJWl7znidF/NVQpEA==", + "requires": { + "bs58": "^4.0.1", + "class-is": "^1.1.0", + "ip": "^1.1.5", + "is-ip": "^2.0.0", + "varint": "^5.0.0" + } + }, + "multibase": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-0.6.0.tgz", + "integrity": "sha512-R9bNLQhbD7MsitPm1NeY7w9sDgu6d7cuj25snAWH7k5PSNPSwIQQBpcpj8jx1W96dLbdigZqmUWOdQRMnAmgjA==", + "requires": { + "base-x": "3.0.4" + }, + "dependencies": { + "base-x": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.4.tgz", + "integrity": "sha512-UYOadoSIkEI/VrRGSG6qp93rp2WdokiAiNYDfGW5qURAY8GiAQkvMbwNNSDYiVJopqv4gCna7xqf4rrNGp+5AA==", + "requires": { + "safe-buffer": "^5.0.1" + } + } + } + }, + "multicodec": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-0.5.0.tgz", + "integrity": "sha512-lKsJeT4cKeSq0rVEWhO3oSBgDN4sMY1sNZKlvl68g/ZAahjPS1KIVyF4IqhuYmCdtOyKs4Q4hQ6M0C3iqRnuqQ==", + "requires": { + "varint": "^5.0.0" + } + }, + "multihashes": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.14.tgz", + "integrity": "sha512-V/g/EIN6nALXfS/xHUAgtfPP3mn3sPIF/i9beuGKf25QXS2QZYCpeVJbDPEannkz32B2fihzCe2D/KMrbcmefg==", + "requires": { + "bs58": "^4.0.1", + "varint": "^5.0.0" + } + }, + "multihashing-async": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.5.2.tgz", + "integrity": "sha512-mmyG6M/FKxrpBh9xQDUvuJ7BbqT93ZeEeH5X6LeMYKoYshYLr9BDdCsvDtZvn+Egf+/Xi+aOznrWL4vp3s+p0Q==", + "requires": { + "blakejs": "^1.1.0", + "js-sha3": "~0.8.0", + "multihashes": "~0.4.13", + "murmurhash3js": "^3.0.1", + "nodeify": "^1.0.1" + }, + "dependencies": { + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + } + } + }, + "murmurhash3js": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/murmurhash3js/-/murmurhash3js-3.0.1.tgz", + "integrity": "sha1-Ppg+W0fCoG9DpxMXTn5DXKBEuZg=" + }, "mz": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", @@ -3721,11 +4223,35 @@ "to-regex": "^3.0.1" } }, + "ndjson": { + "version": "github:hugomrdias/ndjson#4db16da6b42e5b39bf300c3a7cde62abb3fa3a11", + "from": "github:hugomrdias/ndjson#feat/readable-stream3", + "requires": { + "json-stringify-safe": "^5.0.1", + "minimist": "^1.2.0", + "split2": "^3.1.0", + "through2": "^3.0.0" + } + }, "negotiator": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, + "node-forge": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.6.tgz", + "integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==" + }, + "nodeify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz", + "integrity": "sha1-ZKtpp7268DzhB7TwM1yHwLnpGx0=", + "requires": { + "is-promise": "~1.0.0", + "promise": "~1.3.0" + } + }, "nodemon": { "version": "1.18.10", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.18.10.tgz", @@ -3872,6 +4398,14 @@ "wrappy": "1" } }, + "optimist": { + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz", + "integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=", + "requires": { + "wordwrap": "~0.0.2" + } + }, "optjs": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", @@ -3988,6 +4522,48 @@ "sha.js": "^2.4.8" } }, + "peer-id": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/peer-id/-/peer-id-0.12.2.tgz", + "integrity": "sha512-pked3yPLcOcprH21OnYbJAzk9OgI/TDEqjJ0IfRJSVB/61ZyqU5VKO7cw7hul+YD8nTD79wM79xFRWN3f6otNg==", + "requires": { + "async": "^2.6.1", + "class-is": "^1.1.0", + "libp2p-crypto": "~0.16.0", + "multihashes": "~0.4.13" + } + }, + "peer-info": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/peer-info/-/peer-info-0.15.1.tgz", + "integrity": "sha512-Y91Q2tZRC0CpSTPd1UebhGqniOrOAk/aj60uYUcWJXCoLTAnGu+4LJGoiay8ayudS6ice7l3SKhgL/cS62QacA==", + "requires": { + "mafmt": "^6.0.2", + "multiaddr": "^6.0.3", + "peer-id": "~0.12.2", + "unique-by": "^1.0.0" + } + }, + "pem-jwk": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pem-jwk/-/pem-jwk-2.0.0.tgz", + "integrity": "sha512-rFxu7rVoHgQ5H9YsP50dDWf0rHjreVA2z0yPiWr5WdH/UHb29hKtF7h6l8vNd1cbYR1t0QL+JKhW55a2ZV4KtA==", + "requires": { + "asn1.js": "^5.0.1" + }, + "dependencies": { + "asn1.js": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.0.1.tgz", + "integrity": "sha512-aO8EaEgbgqq77IEw+1jfx5c9zTbzvkfuRBuZsSsPnTHMkmd5AI4J6OtITLZFa381jReeaQL67J0GBTUu0+ZTVw==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + } + } + }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -4037,6 +4613,19 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, + "promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-1.3.0.tgz", + "integrity": "sha1-5cyaTIJ45GZP/twBx9qEhCsEAXU=", + "requires": { + "is-promise": "~1" + } + }, + "promisify-es6": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/promisify-es6/-/promisify-es6-1.0.3.tgz", + "integrity": "sha512-N9iVG+CGJsI4b4ZGazjwLnxErD2d9Pe4DPvvXSxYA9tFNu8ymXME4Qs5HIQ0LMJpNM7zj+m0NlNnNeqFpKzqnA==" + }, "protobufjs": { "version": "6.8.8", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz", @@ -4057,6 +4646,22 @@ "long": "^4.0.0" } }, + "protocol-buffers-schema": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.3.2.tgz", + "integrity": "sha512-Xdayp8sB/mU+sUV4G7ws8xtYMGdQnxbeIfLjyO9TZZRJdztBGhlmbI5x1qcY4TG5hBkIKGnc28i7nXxaugu88w==" + }, + "protons": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/protons/-/protons-1.0.1.tgz", + "integrity": "sha512-+0ZKnfVs+4c43tbAQ5j0Mck8wPcLnlxUYzKQoB4iDW4ocdXGnN4P+0dDbgX1FTpoY9+7P2Tn2scJyHHqj+S/lQ==", + "requires": { + "protocol-buffers-schema": "^3.3.1", + "safe-buffer": "^5.1.1", + "signed-varint": "^2.0.1", + "varint": "^5.0.0" + } + }, "proxy-addr": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", @@ -4096,6 +4701,50 @@ "safe-buffer": "^5.1.2" } }, + "pull-defer": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/pull-defer/-/pull-defer-0.2.3.tgz", + "integrity": "sha512-/An3KE7mVjZCqNhZsr22k1Tx8MACnUnHZZNPSJ0S62td8JtYr/AiRG42Vz7Syu31SoTLUzVIe61jtT/pNdjVYA==" + }, + "pull-stream": { + "version": "3.6.9", + "resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.6.9.tgz", + "integrity": "sha512-hJn4POeBrkttshdNl0AoSCVjMVSuBwuHocMerUdoZ2+oIUzrWHFTwJMlbHND7OiKLVgvz6TFj8ZUVywUMXccbw==" + }, + "pull-to-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/pull-to-stream/-/pull-to-stream-0.1.0.tgz", + "integrity": "sha512-LMvdE0JwT7XQZMFjc7JDl/G9gmoZ8Zo8e86SG4ZZUcjuwvod803KxpAK8WrmdxzHsMRK9DETlIzuA0tbEVv6jg==", + "requires": { + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "pull-traverse": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pull-traverse/-/pull-traverse-1.0.3.tgz", + "integrity": "sha1-dPtde+f6a9enjpeTPhmbeUWGaTg=" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -4312,6 +4961,30 @@ "inherits": "^2.0.1" } }, + "rsa-pem-to-jwk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/rsa-pem-to-jwk/-/rsa-pem-to-jwk-1.1.3.tgz", + "integrity": "sha1-JF52vbfnI0z+58oDLTG1TDj6uY4=", + "requires": { + "object-assign": "^2.0.0", + "rsa-unpack": "0.0.6" + }, + "dependencies": { + "object-assign": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", + "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=" + } + } + }, + "rsa-unpack": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/rsa-unpack/-/rsa-unpack-0.0.6.tgz", + "integrity": "sha1-9Q69VqYoN45jHylxYQJs6atO3bo=", + "requires": { + "optimist": "~0.3.5" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -4361,6 +5034,21 @@ "pbkdf2": "^3.0.3" } }, + "secp256k1": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.6.2.tgz", + "integrity": "sha512-90nYt7yb0LmI4A2jJs1grglkTAXrBwxYAjP9bpeKjvJKOjG2fOeH/YI/lchDMIvjrOasd5QXwvV2jwN168xNng==", + "requires": { + "bindings": "^1.2.1", + "bip66": "^1.1.3", + "bn.js": "^4.11.3", + "create-hash": "^1.1.2", + "drbg.js": "^1.0.1", + "elliptic": "^6.2.3", + "nan": "^2.2.1", + "safe-buffer": "^5.1.0" + } + }, "seek-bzip": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz", @@ -4520,6 +5208,14 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "signed-varint": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/signed-varint/-/signed-varint-2.0.1.tgz", + "integrity": "sha1-UKmYnafJjCxh2tEZvJdHDvhSgSk=", + "requires": { + "varint": "~5.0.0" + } + }, "simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", @@ -4699,6 +5395,26 @@ "extend-shallow": "^3.0.0" } }, + "split2": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.1.1.tgz", + "integrity": "sha512-emNzr1s7ruq4N+1993yht631/JH+jaj0NYBosuKmLcq+JkGQ9MmTw1RB1fGaTCzUuseRIClrlSLHRNYGwWQ58Q==", + "requires": { + "readable-stream": "^3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -4720,6 +5436,11 @@ "tweetnacl": "~0.14.0" } }, + "stable": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", + "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==" + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -4751,6 +5472,15 @@ "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" }, + "stream-to-pull-stream": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz", + "integrity": "sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==", + "requires": { + "looper": "^3.0.0", + "pull-stream": "^3.2.3" + } + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -4936,6 +5666,14 @@ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, + "through2": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", + "requires": { + "readable-stream": "2 || 3" + } + }, "timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", @@ -5013,6 +5751,11 @@ } } }, + "traverse": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz", + "integrity": "sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc=" + }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", @@ -5148,6 +5891,11 @@ } } }, + "unique-by": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-by/-/unique-by-1.0.0.tgz", + "integrity": "sha1-UiDIa6e8Vy+3E610ZRRwy2RCEr0=" + }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -5264,6 +6012,15 @@ "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=" }, + "ursa-optional": { + "version": "0.9.10", + "resolved": "https://registry.npmjs.org/ursa-optional/-/ursa-optional-0.9.10.tgz", + "integrity": "sha512-RvEbhnxlggX4MXon7KQulTFiJQtLJZpSb9ZSa7ZTkOW0AzqiVTaLjI4vxaSzJBDH9dwZ3ltZadFiBaZslp6haA==", + "requires": { + "bindings": "^1.3.0", + "nan": "^2.11.1" + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -5290,6 +6047,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, + "varint": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.0.tgz", + "integrity": "sha1-2Ca4n3SQcy+rwMDtaT7Uddyynr8=" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -5574,7 +6336,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" } }, "web3-shh": { @@ -5652,6 +6414,11 @@ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", diff --git a/systemservices/marketplace/package.json b/systemservices/marketplace/package.json index 4992f5c89..2ac9bfe61 100644 --- a/systemservices/marketplace/package.json +++ b/systemservices/marketplace/package.json @@ -10,6 +10,7 @@ "@types/web3": "^1.0.18", "base-x": "^3.0.5", "bignumber.js": "^8.1.1", + "ipfs-http-client": "^30.1.0", "mesg-js": "^2.0.1", "request": "^2.88.0", "request-promise-native": "^1.0.7", diff --git a/systemservices/marketplace/src/contracts/version.ts b/systemservices/marketplace/src/contracts/version.ts index fe9cd453c..605610910 100644 --- a/systemservices/marketplace/src/contracts/version.ts +++ b/systemservices/marketplace/src/contracts/version.ts @@ -29,12 +29,10 @@ const getServiceVersion = async (contract: Marketplace, versionHash: string): Pr return } const version = await contract.methods.serviceVersion(versionHashHex).call() - const manifestData = await getManifest(hexToAscii(version.manifestProtocol), hexToAscii(version.manifest)) + const manifest = await getManifest(hexToAscii(version.manifestProtocol), hexToAscii(version.manifest)) return { versionHash: versionHash, - manifest: hexToAscii(version.manifest), - manifestProtocol: hexToAscii(version.manifestProtocol), - manifestData: manifestData, + manifest: manifest, createTime: parseTimestamp(version.createTime), } } diff --git a/systemservices/marketplace/src/events/serviceVersionCreated.ts b/systemservices/marketplace/src/events/serviceVersionCreated.ts index 6f7c331fa..5ddf432af 100644 --- a/systemservices/marketplace/src/events/serviceVersionCreated.ts +++ b/systemservices/marketplace/src/events/serviceVersionCreated.ts @@ -1,12 +1,13 @@ import Service, { EmitEventReply } from "mesg-js/lib/service/service" import { EventLog } from "web3/types"; import { hexToAscii } from "../contracts/utils"; +import { getManifest } from "../contracts/manifest"; -export = (mesg: Service, event: EventLog): Promise => { +export = async (mesg: Service, event: EventLog): Promise => { + const manifest = await getManifest(hexToAscii(event.returnValues.manifestProtocol), hexToAscii(event.returnValues.manifest)) return mesg.emitEvent('serviceVersionCreated', { sid: hexToAscii(event.returnValues.sid), versionHash: event.returnValues.versionHash, - manifest: hexToAscii(event.returnValues.manifest), - manifestProtocol: hexToAscii(event.returnValues.manifestProtocol), + manifest: manifest }) } diff --git a/systemservices/marketplace/src/tasks/isAuthorized.ts b/systemservices/marketplace/src/tasks/isAuthorized.ts index 1b5e48f21..d140bff8a 100644 --- a/systemservices/marketplace/src/tasks/isAuthorized.ts +++ b/systemservices/marketplace/src/tasks/isAuthorized.ts @@ -54,15 +54,15 @@ export default ( if (version === undefined) { throw new Error('service with versionHash ' + versionHash + ' does not exist') } - if (version.manifestData === undefined) { + if (version.manifest === undefined) { throw new Error('could not download manifest of version with hash ' + versionHash) } return outputs.success({ authorized: authorized, sid: sid, - type: version.manifestData.service.deployment.type, - source: version.manifestData.service.deployment.source, + type: version.manifest.service.deployment.type, + source: version.manifest.service.deployment.source, }) } catch (error) { diff --git a/systemservices/marketplace/src/tasks/publishServiceVersion.ts b/systemservices/marketplace/src/tasks/publishServiceVersion.ts index 3ee14c72e..597260802 100644 --- a/systemservices/marketplace/src/tasks/publishServiceVersion.ts +++ b/systemservices/marketplace/src/tasks/publishServiceVersion.ts @@ -1,16 +1,21 @@ import { TaskInputs, TaskOutputs } from "mesg-js/lib/service" import { Marketplace } from "../contracts/Marketplace" import { asciiToHex, CreateTransaction, hashToHex } from "../contracts/utils"; +import { Manifest } from "../types/manifest"; export default ( marketplace: Marketplace, createTransaction: CreateTransaction ) => async (inputs: TaskInputs, outputs: TaskOutputs): Promise => { try { + const manifestHash = await uploadManifest({ + version: '1', + service: inputs.service + }) const transactionData = marketplace.methods.publishServiceVersion( - asciiToHex(inputs.sid), - asciiToHex(inputs.manifest), - asciiToHex(inputs.manifestProtocol) + asciiToHex(inputs.service.definition.sid), + asciiToHex(manifestHash), + asciiToHex('ipfs') ).encodeABI() return outputs.success(await createTransaction(marketplace, inputs, transactionData)) } @@ -19,3 +24,14 @@ export default ( return outputs.error({ message: error.toString() }) } } + +const uploadManifest = async (manifest: Manifest): Promise => { + const ipfsClient = require('ipfs-http-client') + const IPFS = ipfsClient('ipfs.infura.io', '5001', {protocol: 'https'}) + const buffer = Buffer.from(JSON.stringify(manifest)) + const res = await IPFS.add(buffer, {pin: false}) + if (!res.length) { + throw new Error('Error while uploading manifest') + } + return res[0].hash +} \ No newline at end of file diff --git a/systemservices/marketplace/src/types/version.ts b/systemservices/marketplace/src/types/version.ts index 0a0727200..0cf5a83ba 100644 --- a/systemservices/marketplace/src/types/version.ts +++ b/systemservices/marketplace/src/types/version.ts @@ -2,8 +2,6 @@ import { Manifest } from "./manifest"; export interface Version { versionHash: string; - manifest: string; - manifestProtocol: string; - manifestData: Manifest|undefined; + manifest: Manifest|undefined; createTime: Date; } From 1c471933cae84a98361e518e515bf4848b5998a6 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Mon, 25 Mar 2019 23:29:07 +0700 Subject: [PATCH 2/9] add readme optional --- systemservices/marketplace/mesg.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/systemservices/marketplace/mesg.yml b/systemservices/marketplace/mesg.yml index 636aeeefb..4ced64839 100644 --- a/systemservices/marketplace/mesg.yml +++ b/systemservices/marketplace/mesg.yml @@ -66,7 +66,9 @@ tasks: type: { type: String } source: { type: String } definition: { type: Object } - readme: { type: String } + readme: + type: String + optional: true createTime: *createTime offers: &offers name: "" From 8abb1c7c0a2790ef4104c077fa0fdb03b3fd37e2 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Tue, 26 Mar 2019 00:05:37 +0700 Subject: [PATCH 3/9] update commands for marketplace --- commands/commands.go | 5 +- commands/marketplace_publish.go | 70 +++++++-------- commands/mocks/Executor.go | 102 ++++------------------ commands/provider/marketplace_provider.go | 61 ++++--------- commands/provider/marketplace_types.go | 38 ++++---- 5 files changed, 84 insertions(+), 192 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 591593c9d..c6dc01151 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -40,9 +40,8 @@ type ServiceExecutor interface { // MarketplaceExecutor is an interface that handles marketplace commands. type MarketplaceExecutor interface { - CreateManifest(path string, hash string) (provider.MarketplaceManifestData, error) - UploadServiceFiles(path string, manifest provider.MarketplaceManifestData) (protocol string, source string, err error) - PublishServiceVersion(sid, manifest, manifestProtocol, from string) (provider.Transaction, error) + UploadSources(path string) (deployment provider.SourceDeployment, err error) + PublishServiceVersion(service provider.MarketplaceServiceData, from string) (provider.Transaction, error) CreateServiceOffer(sid string, price string, duration string, from string) (provider.Transaction, error) Purchase(sid, offerIndex, from string) ([]provider.Transaction, error) SendSignedTransaction(signedTransaction string) (provider.TransactionReceipt, error) diff --git a/commands/marketplace_publish.go b/commands/marketplace_publish.go index f6d201c95..65c334de9 100644 --- a/commands/marketplace_publish.go +++ b/commands/marketplace_publish.go @@ -2,20 +2,26 @@ package commands import ( "fmt" - "strings" "github.com/mesg-foundation/core/commands/provider" + "github.com/mesg-foundation/core/service/importer" "github.com/mesg-foundation/core/utils/pretty" + "github.com/mesg-foundation/core/utils/readme" "github.com/spf13/cobra" survey "gopkg.in/AlecAivazis/survey.v1" ) +const ( + // marketplaceServiceHashVersion is the version of the service hash used by the core. + marketplaceServiceHashVersion = "1" +) + type marketplacePublishCmd struct { baseMarketplaceCmd - path string - manifest provider.MarketplaceManifestData - service provider.MarketplaceService + path string + sid string + hash string e Executor } @@ -35,11 +41,6 @@ func newMarketplacePublishCmd(e Executor) *marketplacePublishCmd { } func (c *marketplacePublishCmd) preRunE(cmd *cobra.Command, args []string) error { - var ( - err error - question = "a new service" - ) - if err := c.askAccountAndPassphrase(); err != nil { return err } @@ -52,28 +53,9 @@ func (c *marketplacePublishCmd) preRunE(cmd *cobra.Command, args []string) error } fmt.Printf("%s Service deployed with sid %s and hash %s\n", pretty.SuccessSign, pretty.Success(sid), pretty.Success(hash)) - c.manifest, err = c.e.CreateManifest(c.path, hash) - if err != nil { - return err - } - - pretty.Progress("Getting service data...", func() { - c.service, err = c.e.GetService(c.manifest.Service.Definition.Sid) - }) - outputError, isMarketplaceError := err.(provider.MarketplaceErrorOutput) - if err != nil && !isMarketplaceError { - return err - } - if outputError.Code != "notFound" { - question = "a new version of service" - if !strings.EqualFold(c.service.Owner, c.account) { - return fmt.Errorf("the service's owner %q is different than the specified account", c.service.Owner) - } - } - var confirmed bool if err := survey.AskOne(&survey.Confirm{ - Message: fmt.Sprintf("Are you sure to publish %s %q from path %q using account %q?", question, c.manifest.Service.Definition.Sid, c.path, c.account), + Message: fmt.Sprintf("Are you sure to publish a new version of service %q from path %q using account %q?", sid, c.path, c.account), }, &confirmed, nil); err != nil { return err } @@ -86,21 +68,35 @@ func (c *marketplacePublishCmd) preRunE(cmd *cobra.Command, args []string) error func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error { var ( - tx provider.Transaction - err error - manifestProtocol string - manifestSource string + tx provider.Transaction + err error + deployment provider.SourceDeployment ) pretty.Progress("Uploading service source code on the marketplace...", func() { // TODO: add a progress for the upload - manifestProtocol, manifestSource, err = c.e.UploadServiceFiles(c.path, c.manifest) + deployment, err = c.e.UploadSources(c.path) }) if err != nil { return err } + definition, err := importer.From(c.path) + if err != nil { + return err + } + readme, err := readme.Lookup(c.path) + if err != nil { + return err + } + fmt.Println("readme", readme) pretty.Progress("Publishing service on the marketplace...", func() { - tx, err = c.e.PublishServiceVersion(c.manifest.Service.Definition.Sid, manifestSource, manifestProtocol, c.account) + tx, err = c.e.PublishServiceVersion(provider.MarketplaceServiceData{ + Definition: *definition, + Hash: c.hash, + HashVersion: marketplaceServiceHashVersion, + Readme: readme, + Deployment: deployment, + }, c.account) if err != nil { return } @@ -110,9 +106,9 @@ func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error { return err } fmt.Printf("%s Service published with success\n", pretty.SuccessSign) - fmt.Printf("%s See it on the marketplace: https://marketplace.mesg.com/services/%s\n", pretty.SuccessSign, c.manifest.Service.Definition.Sid) + fmt.Printf("%s See it on the marketplace: https://marketplace.mesg.com/services/%s\n", pretty.SuccessSign, c.sid) - fmt.Printf("%s To create a service offer, execute the command:\n\tmesg-core marketplace create-offer %s\n", pretty.SuccessSign, c.manifest.Service.Definition.Sid) + fmt.Printf("%s To create a service offer, execute the command:\n\tmesg-core marketplace create-offer %s\n", pretty.SuccessSign, c.sid) return nil } diff --git a/commands/mocks/Executor.go b/commands/mocks/Executor.go index 19fe2163d..8b619675e 100644 --- a/commands/mocks/Executor.go +++ b/commands/mocks/Executor.go @@ -35,27 +35,6 @@ func (_m *Executor) Create(passphrase string) (string, error) { return r0, r1 } -// CreateManifest provides a mock function with given fields: path, hash -func (_m *Executor) CreateManifest(path string, hash string) (provider.MarketplaceManifestData, error) { - ret := _m.Called(path, hash) - - var r0 provider.MarketplaceManifestData - if rf, ok := ret.Get(0).(func(string, string) provider.MarketplaceManifestData); ok { - r0 = rf(path, hash) - } else { - r0 = ret.Get(0).(provider.MarketplaceManifestData) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(path, hash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // CreateServiceOffer provides a mock function with given fields: sid, price, duration, from func (_m *Executor) CreateServiceOffer(sid string, price string, duration string, from string) (provider.Transaction, error) { ret := _m.Called(sid, price, duration, from) @@ -98,27 +77,6 @@ func (_m *Executor) Delete(address string, passphrase string) (string, error) { return r0, r1 } -// DisableServiceOffer provides a mock function with given fields: sid, offerIndex, from -func (_m *Executor) DisableServiceOffer(sid string, offerIndex string, from string) (provider.Transaction, error) { - ret := _m.Called(sid, offerIndex, from) - - var r0 provider.Transaction - if rf, ok := ret.Get(0).(func(string, string, string) provider.Transaction); ok { - r0 = rf(sid, offerIndex, from) - } else { - r0 = ret.Get(0).(provider.Transaction) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string, string) error); ok { - r1 = rf(sid, offerIndex, from) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // Export provides a mock function with given fields: address, passphrase func (_m *Executor) Export(address string, passphrase string) (provider.WalletEncryptedKeyJSONV3, error) { ret := _m.Called(address, passphrase) @@ -249,20 +207,20 @@ func (_m *Executor) Logs() (io.ReadCloser, error) { return r0, r1 } -// PublishServiceVersion provides a mock function with given fields: sid, manifest, manifestProtocol, from -func (_m *Executor) PublishServiceVersion(sid string, manifest string, manifestProtocol string, from string) (provider.Transaction, error) { - ret := _m.Called(sid, manifest, manifestProtocol, from) +// PublishServiceVersion provides a mock function with given fields: service, from +func (_m *Executor) PublishServiceVersion(service provider.MarketplaceServiceData, from string) (provider.Transaction, error) { + ret := _m.Called(service, from) var r0 provider.Transaction - if rf, ok := ret.Get(0).(func(string, string, string, string) provider.Transaction); ok { - r0 = rf(sid, manifest, manifestProtocol, from) + if rf, ok := ret.Get(0).(func(provider.MarketplaceServiceData, string) provider.Transaction); ok { + r0 = rf(service, from) } else { r0 = ret.Get(0).(provider.Transaction) } var r1 error - if rf, ok := ret.Get(1).(func(string, string, string, string) error); ok { - r1 = rf(sid, manifest, manifestProtocol, from) + if rf, ok := ret.Get(1).(func(provider.MarketplaceServiceData, string) error); ok { + r1 = rf(service, from) } else { r1 = ret.Error(1) } @@ -733,51 +691,23 @@ func (_m *Executor) Stop() error { return r0 } -// TransferServiceOwnership provides a mock function with given fields: sid, newOwner, from -func (_m *Executor) TransferServiceOwnership(sid string, newOwner string, from string) (provider.Transaction, error) { - ret := _m.Called(sid, newOwner, from) +// UploadSources provides a mock function with given fields: path +func (_m *Executor) UploadSources(path string) (provider.SourceDeployment, error) { + ret := _m.Called(path) - var r0 provider.Transaction - if rf, ok := ret.Get(0).(func(string, string, string) provider.Transaction); ok { - r0 = rf(sid, newOwner, from) + var r0 provider.SourceDeployment + if rf, ok := ret.Get(0).(func(string) provider.SourceDeployment); ok { + r0 = rf(path) } else { - r0 = ret.Get(0).(provider.Transaction) + r0 = ret.Get(0).(provider.SourceDeployment) } var r1 error - if rf, ok := ret.Get(1).(func(string, string, string) error); ok { - r1 = rf(sid, newOwner, from) + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(path) } else { r1 = ret.Error(1) } return r0, r1 } - -// UploadServiceFiles provides a mock function with given fields: path, manifest -func (_m *Executor) UploadServiceFiles(path string, manifest provider.MarketplaceManifestData) (string, string, error) { - ret := _m.Called(path, manifest) - - var r0 string - if rf, ok := ret.Get(0).(func(string, provider.MarketplaceManifestData) string); ok { - r0 = rf(path, manifest) - } else { - r0 = ret.Get(0).(string) - } - - var r1 string - if rf, ok := ret.Get(1).(func(string, provider.MarketplaceManifestData) string); ok { - r1 = rf(path, manifest) - } else { - r1 = ret.Get(1).(string) - } - - var r2 error - if rf, ok := ret.Get(2).(func(string, provider.MarketplaceManifestData) error); ok { - r2 = rf(path, manifest) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} diff --git a/commands/provider/marketplace_provider.go b/commands/provider/marketplace_provider.go index 0cf3bc300..bbc71cb2d 100644 --- a/commands/provider/marketplace_provider.go +++ b/commands/provider/marketplace_provider.go @@ -1,14 +1,11 @@ package provider import ( - "bytes" "encoding/json" "github.com/docker/docker/pkg/archive" "github.com/mesg-foundation/core/ipfs" "github.com/mesg-foundation/core/protobuf/coreapi" - "github.com/mesg-foundation/core/service/importer" - "github.com/mesg-foundation/core/utils/readme" ) // MarketplaceProvider is a struct that provides all methods required by service command. @@ -22,12 +19,10 @@ func NewMarketplaceProvider(c coreapi.CoreClient) *MarketplaceProvider { } // PublishServiceVersion executes the create service version task -func (p *MarketplaceProvider) PublishServiceVersion(sid, manifest, manifestProtocol, from string) (Transaction, error) { +func (p *MarketplaceProvider) PublishServiceVersion(service MarketplaceServiceData, from string) (Transaction, error) { input := marketplacePublishServiceVersionTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Sid: sid, - Manifest: manifest, - ManifestProtocol: manifestProtocol, + Service: service, } var output Transaction return output, p.call("publishServiceVersion", input, &output) @@ -37,9 +32,9 @@ func (p *MarketplaceProvider) PublishServiceVersion(sid, manifest, manifestProto func (p *MarketplaceProvider) CreateServiceOffer(sid string, price string, duration string, from string) (Transaction, error) { input := marketplaceCreateServiceOfferTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Sid: sid, - Price: price, - Duration: duration, + Sid: sid, + Price: price, + Duration: duration, } var output Transaction return output, p.call("createServiceOffer", input, &output) @@ -49,8 +44,8 @@ func (p *MarketplaceProvider) CreateServiceOffer(sid string, price string, durat func (p *MarketplaceProvider) Purchase(sid, offerIndex, from string) ([]Transaction, error) { input := marketplacePurchaseTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Sid: sid, - OfferIndex: offerIndex, + Sid: sid, + OfferIndex: offerIndex, } var output marketplacePurchaseTaskOutputs return output.Transactions, p.call("purchase", input, &output) @@ -85,49 +80,23 @@ func (p *MarketplaceProvider) IsAuthorized(sid string, versionHash string, addre return output.Authorized, output.Sid, output.Source, output.Type, p.call("isAuthorized", input, &output) } -// UploadServiceFiles upload the tarball and the definition file, and returns the address of the definition file -func (p *MarketplaceProvider) UploadServiceFiles(path string, manifest MarketplaceManifestData) (protocol string, source string, err error) { +// UploadSources upload the tarball, and returns the address of the uploaded sources +func (p *MarketplaceProvider) UploadSources(path string) (SourceDeployment, error) { // upload service source to IPFS tar, err := archive.TarWithOptions(path, &archive.TarOptions{ Compression: archive.Gzip, }) if err != nil { - return "", "", err + return SourceDeployment{}, err } tarballResponse, err := ipfs.Add("tarball", tar) if err != nil { - return "", "", err + return SourceDeployment{}, err } - - manifest.Service.Deployment.Type = marketplaceDeploymentType - manifest.Service.Deployment.Source = tarballResponse.Hash - - // upload manifest - manifestData, err := json.Marshal(manifest) - if err != nil { - return "", "", err - } - definitionResponse, err := ipfs.Add("manifest", bytes.NewReader(manifestData)) - if err != nil { - return "", "", err - } - - return marketplaceDeploymentType, definitionResponse.Hash, nil -} - -// CreateManifest creates the manifest file for the service in path. -func (p *MarketplaceProvider) CreateManifest(path string, hash string) (MarketplaceManifestData, error) { - var data MarketplaceManifestData - definition, err := importer.From(path) - if err != nil { - return data, err - } - data.Version = marketplacePublishVersion - data.Service.Hash = hash - data.Service.HashVersion = marketplaceServiceHashVersion - data.Service.Definition = *definition - data.Service.Readme, err = readme.Lookup(path) - return data, err + return SourceDeployment{ + Type: marketplaceDeploymentType, + Source: tarballResponse.Hash, + }, nil } func (p *MarketplaceProvider) call(task string, inputs interface{}, output interface{}) error { diff --git a/commands/provider/marketplace_types.go b/commands/provider/marketplace_types.go index a77efe981..30313e72f 100644 --- a/commands/provider/marketplace_types.go +++ b/commands/provider/marketplace_types.go @@ -7,12 +7,6 @@ import ( ) const ( - // marketplacePublishVersion is the version used to publish the services to the marketplace. - marketplacePublishVersion = "1" - - // marketplaceServiceHashVersion is the version of the service hash used by the core. - marketplaceServiceHashVersion = "1" - // marketplaceDeploymentType is the type of deployment used for the service. marketplaceDeploymentType = "ipfs" @@ -52,19 +46,25 @@ type MarketplaceService struct { } `json:"purchases"` } +// SourceDeployment is the information related to a deployment +type SourceDeployment struct { + Type string `json:"type"` + Source string `json:"source"` +} + +// MarketplaceServiceData is the data present to the manifest and sent to create a new service's version +type MarketplaceServiceData struct { + Definition importer.ServiceDefinition `json:"definition"` + Readme string `json:"readme,omitempty"` + Hash string `json:"hash"` + HashVersion string `json:"hashVersion"` + Deployment SourceDeployment `json:"deployment"` +} + // MarketplaceManifestData struct { type MarketplaceManifestData struct { - Version string `json:"version"` - Service struct { - Definition importer.ServiceDefinition `json:"definition"` - Readme string `json:"readme,omitempty"` - Hash string `json:"hash"` - HashVersion string `json:"hashVersion"` - Deployment struct { - Type string `json:"type"` - Source string `json:"source"` - } `json:"deployment"` - } `json:"service"` + Version string `json:"version"` + Service MarketplaceServiceData `json:"service"` } // UnmarshalJSON overrides the default one to allow parsing malformed manifest data without returning error to user. @@ -85,9 +85,7 @@ type marketplaceTransactionTaskInputs struct { type marketplacePublishServiceVersionTaskInputs struct { marketplaceTransactionTaskInputs - Sid string `json:"sid"` - Manifest string `json:"manifest"` - ManifestProtocol string `json:"manifestProtocol"` + Service MarketplaceServiceData `json:"service"` } type marketplaceCreateServiceOfferTaskInputs struct { From 6f721d568c8ea9a2633cd3a0af31e9e376ca5035 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Tue, 26 Mar 2019 12:40:56 +0700 Subject: [PATCH 4/9] make version and manifest stricter --- .../marketplace/src/contracts/manifest.ts | 22 +++----- .../marketplace/src/contracts/version.ts | 53 ++++++++++++++++--- .../marketplace/src/tasks/isAuthorized.ts | 2 +- .../marketplace/src/types/version.ts | 2 +- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/systemservices/marketplace/src/contracts/manifest.ts b/systemservices/marketplace/src/contracts/manifest.ts index 926f6d28d..740721d6d 100644 --- a/systemservices/marketplace/src/contracts/manifest.ts +++ b/systemservices/marketplace/src/contracts/manifest.ts @@ -15,23 +15,15 @@ const get: {[key: string]: (source: string) => Promise} = { 'http': getHttp, } -const getManifest = async (protocol: string, source: string): Promise => { - try { - if (!get[protocol]) { - console.warn('protocol', protocol, 'is not compatible with this service') - return - } - const manifest = await get[protocol](source) - if (typeof manifest === 'object') { - return manifest as Manifest - } - console.warn('manifest ', protocol, '::', source, 'is not a valid manifest') - return +const getManifest = async (protocol: string, source: string): Promise => { + if (!get[protocol]) { + throw new Error(`protocol ${protocol} is not compatible with this service`) } - catch (error) { - console.warn('error while downloading manifest', protocol, '::', source, error.toString()) - return + const manifest = await get[protocol](source) + if (typeof manifest !== 'object') { + throw new Error(`manifest ${protocol} :: ${source} is not a valid manifest`) } + return manifest as Manifest } export { getManifest } diff --git a/systemservices/marketplace/src/contracts/version.ts b/systemservices/marketplace/src/contracts/version.ts index 605610910..8d4f1c1c1 100644 --- a/systemservices/marketplace/src/contracts/version.ts +++ b/systemservices/marketplace/src/contracts/version.ts @@ -10,26 +10,35 @@ const getServiceVersions = async (contract: Marketplace, sid: string): Promise[] = [] + const versions: Version[] = [] for (let j = new BigNumber(0); versionsLength.isGreaterThan(j); j = j.plus(1)) { - versionsPromise.push(getServiceVersionWithIndex(contract, sid, j)) + try { + const version = normalizeVersion(await getServiceVersionWithIndex(contract, sid, j)) + if (validVersion(version)) { + versions.push(version) + } + } catch(e) { + console.warn(e.toString()) + } } - const versions = await Promise.all(versionsPromise) - return versions.filter(version => version !== undefined) as Version[] + return versions } -const getServiceVersionWithIndex = async (contract: Marketplace, sid: string, versionIndex: BigNumber): Promise => { +const getServiceVersionWithIndex = async (contract: Marketplace, sid: string, versionIndex: BigNumber): Promise => { const versionHash = hexToHash(await contract.methods.serviceVersionHash(asciiToHex(sid), versionIndex.toString()).call()) return getServiceVersion(contract, versionHash) } -const getServiceVersion = async (contract: Marketplace, versionHash: string): Promise => { +const getServiceVersion = async (contract: Marketplace, versionHash: string): Promise => { const versionHashHex = hashToHex(versionHash) if (!await contract.methods.isServiceVersionExist(versionHashHex).call()) { - return + throw new Error('Service does not exists') } const version = await contract.methods.serviceVersion(versionHashHex).call() const manifest = await getManifest(hexToAscii(version.manifestProtocol), hexToAscii(version.manifest)) + if (!manifest) { + throw new Error('Unable to get the manifest') + } return { versionHash: versionHash, manifest: manifest, @@ -37,4 +46,34 @@ const getServiceVersion = async (contract: Marketplace, versionHash: string): Pr } } +const validVersion = (version: Version): boolean => { + return version.versionHash != '' && + !!version.manifest && + !!version.manifest.service && + !!version.manifest.service.hash && + !!version.manifest.service.hashVersion && + !!version.manifest.service.definition && + !!version.manifest.service.deployment +} + +const normalizeVersion = (version: any): Version => { + return { + createTime: version.createTime, + versionHash: version.versionHash, + manifest: { + version: version.manifest.version.toString(), + service: { + definition: version.manifest.service.definition, + deployment: { + type: version.manifest.service.deployment.type || 'ipfs', + source: version.manifest.service.deployment.source, + }, + hash: version.manifest.service.hash, + hashVersion: version.manifest.service.hashVersion, + readme: version.manifest.service.readme || '', + } + } + } +} + export { getServiceVersions, getServiceVersion } diff --git a/systemservices/marketplace/src/tasks/isAuthorized.ts b/systemservices/marketplace/src/tasks/isAuthorized.ts index d140bff8a..1c12fc32d 100644 --- a/systemservices/marketplace/src/tasks/isAuthorized.ts +++ b/systemservices/marketplace/src/tasks/isAuthorized.ts @@ -51,7 +51,7 @@ export default ( // get version's manifest data const version = await getServiceVersion(contract, versionHash) - if (version === undefined) { + if (!version) { throw new Error('service with versionHash ' + versionHash + ' does not exist') } if (version.manifest === undefined) { diff --git a/systemservices/marketplace/src/types/version.ts b/systemservices/marketplace/src/types/version.ts index 0cf5a83ba..754a8e07a 100644 --- a/systemservices/marketplace/src/types/version.ts +++ b/systemservices/marketplace/src/types/version.ts @@ -2,6 +2,6 @@ import { Manifest } from "./manifest"; export interface Version { versionHash: string; - manifest: Manifest|undefined; + manifest: Manifest; createTime: Date; } From 950a0f3d797a8da937d97e561595c9fd72ac2e5b Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Tue, 26 Mar 2019 14:29:23 +0700 Subject: [PATCH 5/9] fix lint --- commands/provider/marketplace_provider.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/provider/marketplace_provider.go b/commands/provider/marketplace_provider.go index bbc71cb2d..247b4c357 100644 --- a/commands/provider/marketplace_provider.go +++ b/commands/provider/marketplace_provider.go @@ -22,7 +22,7 @@ func NewMarketplaceProvider(c coreapi.CoreClient) *MarketplaceProvider { func (p *MarketplaceProvider) PublishServiceVersion(service MarketplaceServiceData, from string) (Transaction, error) { input := marketplacePublishServiceVersionTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Service: service, + Service: service, } var output Transaction return output, p.call("publishServiceVersion", input, &output) @@ -32,9 +32,9 @@ func (p *MarketplaceProvider) PublishServiceVersion(service MarketplaceServiceDa func (p *MarketplaceProvider) CreateServiceOffer(sid string, price string, duration string, from string) (Transaction, error) { input := marketplaceCreateServiceOfferTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Sid: sid, - Price: price, - Duration: duration, + Sid: sid, + Price: price, + Duration: duration, } var output Transaction return output, p.call("createServiceOffer", input, &output) @@ -44,8 +44,8 @@ func (p *MarketplaceProvider) CreateServiceOffer(sid string, price string, durat func (p *MarketplaceProvider) Purchase(sid, offerIndex, from string) ([]Transaction, error) { input := marketplacePurchaseTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, - Sid: sid, - OfferIndex: offerIndex, + Sid: sid, + OfferIndex: offerIndex, } var output marketplacePurchaseTaskOutputs return output.Transactions, p.call("purchase", input, &output) From 28021d21e45d4421f6a6de1a1bfa63be75ffcada Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 27 Mar 2019 18:31:54 +0700 Subject: [PATCH 6/9] renaming --- commands/commands.go | 4 ++-- commands/marketplace_publish.go | 6 +++--- commands/mocks/Executor.go | 16 ++++++++-------- commands/provider/marketplace_provider.go | 12 ++++++------ commands/provider/marketplace_types.go | 16 ++++++++-------- systemservices/marketplace/mesg.yml | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index c6dc01151..56f9773e9 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -40,8 +40,8 @@ type ServiceExecutor interface { // MarketplaceExecutor is an interface that handles marketplace commands. type MarketplaceExecutor interface { - UploadSources(path string) (deployment provider.SourceDeployment, err error) - PublishServiceVersion(service provider.MarketplaceServiceData, from string) (provider.Transaction, error) + UploadSource(path string) (deployment provider.MarketplaceDeployedSource, err error) + PublishServiceVersion(service provider.MarketplaceManifestServiceData, from string) (provider.Transaction, error) CreateServiceOffer(sid string, price string, duration string, from string) (provider.Transaction, error) Purchase(sid, offerIndex, from string) ([]provider.Transaction, error) SendSignedTransaction(signedTransaction string) (provider.TransactionReceipt, error) diff --git a/commands/marketplace_publish.go b/commands/marketplace_publish.go index 65c334de9..592e3efde 100644 --- a/commands/marketplace_publish.go +++ b/commands/marketplace_publish.go @@ -70,12 +70,12 @@ func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error { var ( tx provider.Transaction err error - deployment provider.SourceDeployment + deployment provider.MarketplaceDeployedSource ) pretty.Progress("Uploading service source code on the marketplace...", func() { // TODO: add a progress for the upload - deployment, err = c.e.UploadSources(c.path) + deployment, err = c.e.UploadSource(c.path) }) if err != nil { return err @@ -90,7 +90,7 @@ func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error { } fmt.Println("readme", readme) pretty.Progress("Publishing service on the marketplace...", func() { - tx, err = c.e.PublishServiceVersion(provider.MarketplaceServiceData{ + tx, err = c.e.PublishServiceVersion(provider.MarketplaceManifestServiceData{ Definition: *definition, Hash: c.hash, HashVersion: marketplaceServiceHashVersion, diff --git a/commands/mocks/Executor.go b/commands/mocks/Executor.go index 8b619675e..ca67141ba 100644 --- a/commands/mocks/Executor.go +++ b/commands/mocks/Executor.go @@ -208,18 +208,18 @@ func (_m *Executor) Logs() (io.ReadCloser, error) { } // PublishServiceVersion provides a mock function with given fields: service, from -func (_m *Executor) PublishServiceVersion(service provider.MarketplaceServiceData, from string) (provider.Transaction, error) { +func (_m *Executor) PublishServiceVersion(service provider.MarketplaceManifestServiceData, from string) (provider.Transaction, error) { ret := _m.Called(service, from) var r0 provider.Transaction - if rf, ok := ret.Get(0).(func(provider.MarketplaceServiceData, string) provider.Transaction); ok { + if rf, ok := ret.Get(0).(func(provider.MarketplaceManifestServiceData, string) provider.Transaction); ok { r0 = rf(service, from) } else { r0 = ret.Get(0).(provider.Transaction) } var r1 error - if rf, ok := ret.Get(1).(func(provider.MarketplaceServiceData, string) error); ok { + if rf, ok := ret.Get(1).(func(provider.MarketplaceManifestServiceData, string) error); ok { r1 = rf(service, from) } else { r1 = ret.Error(1) @@ -691,15 +691,15 @@ func (_m *Executor) Stop() error { return r0 } -// UploadSources provides a mock function with given fields: path -func (_m *Executor) UploadSources(path string) (provider.SourceDeployment, error) { +// UploadSource provides a mock function with given fields: path +func (_m *Executor) UploadSource(path string) (provider.MarketplaceDeployedSource, error) { ret := _m.Called(path) - var r0 provider.SourceDeployment - if rf, ok := ret.Get(0).(func(string) provider.SourceDeployment); ok { + var r0 provider.MarketplaceDeployedSource + if rf, ok := ret.Get(0).(func(string) provider.MarketplaceDeployedSource); ok { r0 = rf(path) } else { - r0 = ret.Get(0).(provider.SourceDeployment) + r0 = ret.Get(0).(provider.MarketplaceDeployedSource) } var r1 error diff --git a/commands/provider/marketplace_provider.go b/commands/provider/marketplace_provider.go index 247b4c357..eead6bb4d 100644 --- a/commands/provider/marketplace_provider.go +++ b/commands/provider/marketplace_provider.go @@ -19,7 +19,7 @@ func NewMarketplaceProvider(c coreapi.CoreClient) *MarketplaceProvider { } // PublishServiceVersion executes the create service version task -func (p *MarketplaceProvider) PublishServiceVersion(service MarketplaceServiceData, from string) (Transaction, error) { +func (p *MarketplaceProvider) PublishServiceVersion(service MarketplaceManifestServiceData, from string) (Transaction, error) { input := marketplacePublishServiceVersionTaskInputs{ marketplaceTransactionTaskInputs: marketplaceTransactionTaskInputs{From: from}, Service: service, @@ -80,20 +80,20 @@ func (p *MarketplaceProvider) IsAuthorized(sid string, versionHash string, addre return output.Authorized, output.Sid, output.Source, output.Type, p.call("isAuthorized", input, &output) } -// UploadSources upload the tarball, and returns the address of the uploaded sources -func (p *MarketplaceProvider) UploadSources(path string) (SourceDeployment, error) { +// UploadSource upload the tarball, and returns the address of the uploaded sources +func (p *MarketplaceProvider) UploadSource(path string) (MarketplaceDeployedSource, error) { // upload service source to IPFS tar, err := archive.TarWithOptions(path, &archive.TarOptions{ Compression: archive.Gzip, }) if err != nil { - return SourceDeployment{}, err + return MarketplaceDeployedSource{}, err } tarballResponse, err := ipfs.Add("tarball", tar) if err != nil { - return SourceDeployment{}, err + return MarketplaceDeployedSource{}, err } - return SourceDeployment{ + return MarketplaceDeployedSource{ Type: marketplaceDeploymentType, Source: tarballResponse.Hash, }, nil diff --git a/commands/provider/marketplace_types.go b/commands/provider/marketplace_types.go index 30313e72f..c34f00994 100644 --- a/commands/provider/marketplace_types.go +++ b/commands/provider/marketplace_types.go @@ -46,25 +46,25 @@ type MarketplaceService struct { } `json:"purchases"` } -// SourceDeployment is the information related to a deployment -type SourceDeployment struct { +// MarketplaceDeployedSource is the information related to a deployment +type MarketplaceDeployedSource struct { Type string `json:"type"` Source string `json:"source"` } -// MarketplaceServiceData is the data present to the manifest and sent to create a new service's version -type MarketplaceServiceData struct { +// MarketplaceManifestServiceData is the data present to the manifest and sent to create a new service's version +type MarketplaceManifestServiceData struct { Definition importer.ServiceDefinition `json:"definition"` Readme string `json:"readme,omitempty"` Hash string `json:"hash"` HashVersion string `json:"hashVersion"` - Deployment SourceDeployment `json:"deployment"` + Deployment MarketplaceDeployedSource `json:"deployment"` } // MarketplaceManifestData struct { type MarketplaceManifestData struct { - Version string `json:"version"` - Service MarketplaceServiceData `json:"service"` + Version string `json:"version"` + Service MarketplaceManifestServiceData `json:"service"` } // UnmarshalJSON overrides the default one to allow parsing malformed manifest data without returning error to user. @@ -85,7 +85,7 @@ type marketplaceTransactionTaskInputs struct { type marketplacePublishServiceVersionTaskInputs struct { marketplaceTransactionTaskInputs - Service MarketplaceServiceData `json:"service"` + Service MarketplaceManifestServiceData `json:"service"` } type marketplaceCreateServiceOfferTaskInputs struct { diff --git a/systemservices/marketplace/mesg.yml b/systemservices/marketplace/mesg.yml index 4ced64839..203d3ec59 100644 --- a/systemservices/marketplace/mesg.yml +++ b/systemservices/marketplace/mesg.yml @@ -55,7 +55,7 @@ tasks: optional: true object: version: { type: String } - service: &serviceInformation + service: &manifestServiceData type: Object object: hash: { type: String } @@ -138,7 +138,7 @@ tasks: name: "" description: "" inputs: - service: *serviceInformation + service: *manifestServiceData from: &inputFrom name: "" description: "" From c8e7e751f44a55fa8a9b8432bd2f0cce7836e2de Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 27 Mar 2019 18:35:37 +0700 Subject: [PATCH 7/9] mesg.yml formatting --- systemservices/marketplace/mesg.yml | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/systemservices/marketplace/mesg.yml b/systemservices/marketplace/mesg.yml index 203d3ec59..162717055 100644 --- a/systemservices/marketplace/mesg.yml +++ b/systemservices/marketplace/mesg.yml @@ -54,18 +54,36 @@ tasks: type: Object optional: true object: - version: { type: String } + version: + name: "" + description: "" + type: String service: &manifestServiceData type: Object object: - hash: { type: String } - hashVersion: { type: String } + hash: + name: "" + description: "" + type: String + hashVersion: + name: "" + description: "" + type: String deployment: type: Object object: - type: { type: String } - source: { type: String } - definition: { type: Object } + type: + name: "" + description: "" + type: String + source: + name: "" + description: "" + type: String + definition: + name: "" + description: "" + type: Object readme: type: String optional: true From 7f3e8e7af1ccf56dc1e3307f9caa59b7113880a1 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Wed, 27 Mar 2019 19:08:15 +0700 Subject: [PATCH 8/9] revert modifications --- commands/marketplace_publish.go | 1 - systemservices/marketplace/mesg.yml | 63 +++++++++---------- .../marketplace/src/contracts/manifest.ts | 22 ++++--- .../marketplace/src/contracts/version.ts | 59 ++++------------- .../src/events/serviceVersionCreated.ts | 7 +-- .../marketplace/src/tasks/isAuthorized.ts | 8 +-- .../marketplace/src/types/version.ts | 4 +- 7 files changed, 64 insertions(+), 100 deletions(-) diff --git a/commands/marketplace_publish.go b/commands/marketplace_publish.go index 592e3efde..5dc54b2ce 100644 --- a/commands/marketplace_publish.go +++ b/commands/marketplace_publish.go @@ -88,7 +88,6 @@ func (c *marketplacePublishCmd) runE(cmd *cobra.Command, args []string) error { if err != nil { return err } - fmt.Println("readme", readme) pretty.Progress("Publishing service on the marketplace...", func() { tx, err = c.e.PublishServiceVersion(provider.MarketplaceManifestServiceData{ Definition: *definition, diff --git a/systemservices/marketplace/mesg.yml b/systemservices/marketplace/mesg.yml index 162717055..a22a7a322 100644 --- a/systemservices/marketplace/mesg.yml +++ b/systemservices/marketplace/mesg.yml @@ -49,44 +49,18 @@ tasks: description: "" type: String manifest: &manifest + name: "" + description: "" + type: String + manifestProtocol: &manifestProtocol + name: "" + description: "" + type: String + manifestData: &manifestData name: "" description: "" type: Object optional: true - object: - version: - name: "" - description: "" - type: String - service: &manifestServiceData - type: Object - object: - hash: - name: "" - description: "" - type: String - hashVersion: - name: "" - description: "" - type: String - deployment: - type: Object - object: - type: - name: "" - description: "" - type: String - source: - name: "" - description: "" - type: String - definition: - name: "" - description: "" - type: Object - readme: - type: String - optional: true createTime: *createTime offers: &offers name: "" @@ -156,7 +130,25 @@ tasks: name: "" description: "" inputs: - service: *manifestServiceData + service: + type: Object + object: + hash: + type: String + hashVersion: + type: String + deployment: + type: Object + object: + type: + type: String + source: + type: String + definition: + type: Object + readme: + type: String + optional: true from: &inputFrom name: "" description: "" @@ -316,6 +308,7 @@ events: sid: *sid versionHash: *versionHash manifest: *manifest + manifestProtocol: *manifestProtocol serviceOfferCreated: name: "" description: "" diff --git a/systemservices/marketplace/src/contracts/manifest.ts b/systemservices/marketplace/src/contracts/manifest.ts index 740721d6d..926f6d28d 100644 --- a/systemservices/marketplace/src/contracts/manifest.ts +++ b/systemservices/marketplace/src/contracts/manifest.ts @@ -15,15 +15,23 @@ const get: {[key: string]: (source: string) => Promise} = { 'http': getHttp, } -const getManifest = async (protocol: string, source: string): Promise => { - if (!get[protocol]) { - throw new Error(`protocol ${protocol} is not compatible with this service`) +const getManifest = async (protocol: string, source: string): Promise => { + try { + if (!get[protocol]) { + console.warn('protocol', protocol, 'is not compatible with this service') + return + } + const manifest = await get[protocol](source) + if (typeof manifest === 'object') { + return manifest as Manifest + } + console.warn('manifest ', protocol, '::', source, 'is not a valid manifest') + return } - const manifest = await get[protocol](source) - if (typeof manifest !== 'object') { - throw new Error(`manifest ${protocol} :: ${source} is not a valid manifest`) + catch (error) { + console.warn('error while downloading manifest', protocol, '::', source, error.toString()) + return } - return manifest as Manifest } export { getManifest } diff --git a/systemservices/marketplace/src/contracts/version.ts b/systemservices/marketplace/src/contracts/version.ts index 8d4f1c1c1..fe9cd453c 100644 --- a/systemservices/marketplace/src/contracts/version.ts +++ b/systemservices/marketplace/src/contracts/version.ts @@ -10,70 +10,33 @@ const getServiceVersions = async (contract: Marketplace, sid: string): Promise[] = [] for (let j = new BigNumber(0); versionsLength.isGreaterThan(j); j = j.plus(1)) { - try { - const version = normalizeVersion(await getServiceVersionWithIndex(contract, sid, j)) - if (validVersion(version)) { - versions.push(version) - } - } catch(e) { - console.warn(e.toString()) - } + versionsPromise.push(getServiceVersionWithIndex(contract, sid, j)) } - return versions + const versions = await Promise.all(versionsPromise) + return versions.filter(version => version !== undefined) as Version[] } -const getServiceVersionWithIndex = async (contract: Marketplace, sid: string, versionIndex: BigNumber): Promise => { +const getServiceVersionWithIndex = async (contract: Marketplace, sid: string, versionIndex: BigNumber): Promise => { const versionHash = hexToHash(await contract.methods.serviceVersionHash(asciiToHex(sid), versionIndex.toString()).call()) return getServiceVersion(contract, versionHash) } -const getServiceVersion = async (contract: Marketplace, versionHash: string): Promise => { +const getServiceVersion = async (contract: Marketplace, versionHash: string): Promise => { const versionHashHex = hashToHex(versionHash) if (!await contract.methods.isServiceVersionExist(versionHashHex).call()) { - throw new Error('Service does not exists') + return } const version = await contract.methods.serviceVersion(versionHashHex).call() - const manifest = await getManifest(hexToAscii(version.manifestProtocol), hexToAscii(version.manifest)) - if (!manifest) { - throw new Error('Unable to get the manifest') - } + const manifestData = await getManifest(hexToAscii(version.manifestProtocol), hexToAscii(version.manifest)) return { versionHash: versionHash, - manifest: manifest, + manifest: hexToAscii(version.manifest), + manifestProtocol: hexToAscii(version.manifestProtocol), + manifestData: manifestData, createTime: parseTimestamp(version.createTime), } } -const validVersion = (version: Version): boolean => { - return version.versionHash != '' && - !!version.manifest && - !!version.manifest.service && - !!version.manifest.service.hash && - !!version.manifest.service.hashVersion && - !!version.manifest.service.definition && - !!version.manifest.service.deployment -} - -const normalizeVersion = (version: any): Version => { - return { - createTime: version.createTime, - versionHash: version.versionHash, - manifest: { - version: version.manifest.version.toString(), - service: { - definition: version.manifest.service.definition, - deployment: { - type: version.manifest.service.deployment.type || 'ipfs', - source: version.manifest.service.deployment.source, - }, - hash: version.manifest.service.hash, - hashVersion: version.manifest.service.hashVersion, - readme: version.manifest.service.readme || '', - } - } - } -} - export { getServiceVersions, getServiceVersion } diff --git a/systemservices/marketplace/src/events/serviceVersionCreated.ts b/systemservices/marketplace/src/events/serviceVersionCreated.ts index 5ddf432af..6f7c331fa 100644 --- a/systemservices/marketplace/src/events/serviceVersionCreated.ts +++ b/systemservices/marketplace/src/events/serviceVersionCreated.ts @@ -1,13 +1,12 @@ import Service, { EmitEventReply } from "mesg-js/lib/service/service" import { EventLog } from "web3/types"; import { hexToAscii } from "../contracts/utils"; -import { getManifest } from "../contracts/manifest"; -export = async (mesg: Service, event: EventLog): Promise => { - const manifest = await getManifest(hexToAscii(event.returnValues.manifestProtocol), hexToAscii(event.returnValues.manifest)) +export = (mesg: Service, event: EventLog): Promise => { return mesg.emitEvent('serviceVersionCreated', { sid: hexToAscii(event.returnValues.sid), versionHash: event.returnValues.versionHash, - manifest: manifest + manifest: hexToAscii(event.returnValues.manifest), + manifestProtocol: hexToAscii(event.returnValues.manifestProtocol), }) } diff --git a/systemservices/marketplace/src/tasks/isAuthorized.ts b/systemservices/marketplace/src/tasks/isAuthorized.ts index 1c12fc32d..1b5e48f21 100644 --- a/systemservices/marketplace/src/tasks/isAuthorized.ts +++ b/systemservices/marketplace/src/tasks/isAuthorized.ts @@ -51,18 +51,18 @@ export default ( // get version's manifest data const version = await getServiceVersion(contract, versionHash) - if (!version) { + if (version === undefined) { throw new Error('service with versionHash ' + versionHash + ' does not exist') } - if (version.manifest === undefined) { + if (version.manifestData === undefined) { throw new Error('could not download manifest of version with hash ' + versionHash) } return outputs.success({ authorized: authorized, sid: sid, - type: version.manifest.service.deployment.type, - source: version.manifest.service.deployment.source, + type: version.manifestData.service.deployment.type, + source: version.manifestData.service.deployment.source, }) } catch (error) { diff --git a/systemservices/marketplace/src/types/version.ts b/systemservices/marketplace/src/types/version.ts index 754a8e07a..0a0727200 100644 --- a/systemservices/marketplace/src/types/version.ts +++ b/systemservices/marketplace/src/types/version.ts @@ -2,6 +2,8 @@ import { Manifest } from "./manifest"; export interface Version { versionHash: string; - manifest: Manifest; + manifest: string; + manifestProtocol: string; + manifestData: Manifest|undefined; createTime: Date; } From 833052f1ba2594cf228df66026d6b59aa476f8f5 Mon Sep 17 00:00:00 2001 From: Anthony ESTEBE Date: Thu, 28 Mar 2019 18:43:07 +0700 Subject: [PATCH 9/9] fix issue with empty sid/hash --- commands/marketplace_publish.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/marketplace_publish.go b/commands/marketplace_publish.go index 5dc54b2ce..9eec25206 100644 --- a/commands/marketplace_publish.go +++ b/commands/marketplace_publish.go @@ -47,15 +47,16 @@ func (c *marketplacePublishCmd) preRunE(cmd *cobra.Command, args []string) error c.path = getFirstOrCurrentPath(args) - sid, hash, err := deployService(c.e, c.path, map[string]string{}) + var err error + c.sid, c.hash, err = deployService(c.e, c.path, map[string]string{}) if err != nil { return err } - fmt.Printf("%s Service deployed with sid %s and hash %s\n", pretty.SuccessSign, pretty.Success(sid), pretty.Success(hash)) + fmt.Printf("%s Service deployed with sid %s and hash %s\n", pretty.SuccessSign, pretty.Success(c.sid), pretty.Success(c.hash)) var confirmed bool if err := survey.AskOne(&survey.Confirm{ - Message: fmt.Sprintf("Are you sure to publish a new version of service %q from path %q using account %q?", sid, c.path, c.account), + Message: fmt.Sprintf("Are you sure to publish a new version of service %q from path %q using account %q?", c.sid, c.path, c.account), }, &confirmed, nil); err != nil { return err }