From 15b1bf846eb5a32f25f3d174e5a52281d8a4e135 Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 29 May 2019 12:09:23 +0200 Subject: [PATCH 1/4] detect agreements and reuse --- client/src/components/templates/Asset/AssetFile.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/templates/Asset/AssetFile.tsx b/client/src/components/templates/Asset/AssetFile.tsx index a26c4cd..5fd7ca7 100644 --- a/client/src/components/templates/Asset/AssetFile.tsx +++ b/client/src/components/templates/Asset/AssetFile.tsx @@ -59,9 +59,17 @@ export default class AssetFile extends PureComponent< const accounts = await ocean.accounts.list() const service = ddo.findServiceByType('Access') - const agreementId = await ocean.assets + const agreements = await ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer(accounts[0].id) + const agreement = agreements.find((element: any) => {return element.did === ddo.id}) + + let agreementId + if (agreement) { + agreementId = agreement.agreementId + } else { + agreementId = await ocean.assets .order(ddo.id, service.serviceDefinitionId, accounts[0]) .next((step: number) => this.setState({ step })) + } // manually add another step here for better UX this.setState({ step: 4 }) From 6e0ffe43674cc714f0f87a50f59984bf9727d61a Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 29 May 2019 16:34:21 +0200 Subject: [PATCH 2/4] update squid-js --- client/package-lock.json | 90 ++++++++++++---------------------------- client/package.json | 2 +- 2 files changed, 27 insertions(+), 65 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index c52039f..f3465bb 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1296,9 +1296,9 @@ "integrity": "sha512-nOpbSE/BG+tQBfLXZ/EqSOvUPzOuot84vHxjAfEU8K3v4eOnqFJVo+oyB7KlcF87wBJXDmi/Ir9qHY4c0Saipg==" }, "@oceanprotocol/squid": { - "version": "0.5.11", - "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.11.tgz", - "integrity": "sha512-vgwu0ibLPAi97+i9hWCRdBOG+RChm1dkvHNdLE6T0dA3Xw6gEbdAmOZ/iWYoBxYiYr8DXyjgOdChU6kb7jAepQ==", + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.12.tgz", + "integrity": "sha512-RhP0wK4nA9ro/HQl3SohJ21XknxD1PtOCY+gQS3iUyyAabcGKVgMrpcuKKPi7SJLMBpUlV5O1V+4qPozCQZbWg==", "requires": { "@oceanprotocol/keeper-contracts": "^0.9.7", "bignumber.js": "^8.1.1", @@ -3487,8 +3487,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3512,15 +3511,13 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3537,22 +3534,19 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3683,8 +3677,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3698,7 +3691,6 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3715,7 +3707,6 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3724,15 +3715,13 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3753,7 +3742,6 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3842,8 +3830,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3857,7 +3844,6 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3953,8 +3939,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3996,7 +3981,6 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4018,7 +4002,6 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4067,15 +4050,13 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true, - "optional": true + "dev": true } } }, @@ -8764,8 +8745,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -8789,15 +8769,13 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8814,22 +8792,19 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -8960,8 +8935,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -8975,7 +8949,6 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -8992,7 +8965,6 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -9001,15 +8973,13 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9030,7 +9000,6 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -9119,8 +9088,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -9134,7 +9102,6 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -9230,8 +9197,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -9273,7 +9239,6 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9295,7 +9260,6 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9344,15 +9308,13 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true, - "optional": true + "dev": true } } } @@ -16545,7 +16507,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": { diff --git a/client/package.json b/client/package.json index f26fc90..b911d70 100644 --- a/client/package.json +++ b/client/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@oceanprotocol/art": "^2.2.0", - "@oceanprotocol/squid": "^0.5.11", + "@oceanprotocol/squid": "^0.5.12", "@oceanprotocol/typographies": "^0.1.0", "@sindresorhus/slugify": "^0.9.1", "classnames": "^2.2.6", From 1e6b334cdca79e93a585d8c23f6551142d7bf1c0 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 31 May 2019 12:56:13 +0200 Subject: [PATCH 3/4] formatting and test tweaks --- client/__mocks__/ocean-mock.ts | 25 ++++++ client/__mocks__/user-mock.ts | 14 +--- client/package-lock.json | 84 ++++++++++++++----- client/src/App.test.tsx | 8 +- client/src/Routes.test.tsx | 10 ++- .../organisms/AssetsLatest.test.tsx | 12 ++- .../organisms/ChannelTeaser.test.tsx | 10 ++- .../templates/Asset/AssetFile.test.tsx | 20 +---- .../components/templates/Asset/AssetFile.tsx | 17 ++-- .../src/components/templates/Channel.test.tsx | 28 +------ client/src/routes/Channels.test.tsx | 10 ++- client/src/routes/Search.test.tsx | 28 +------ server/src/routes/UrlCheckRouter.ts | 2 +- 13 files changed, 144 insertions(+), 124 deletions(-) create mode 100644 client/__mocks__/ocean-mock.ts diff --git a/client/__mocks__/ocean-mock.ts b/client/__mocks__/ocean-mock.ts new file mode 100644 index 0000000..af44f70 --- /dev/null +++ b/client/__mocks__/ocean-mock.ts @@ -0,0 +1,25 @@ +const oceanMock = { + ocean: { + accounts: { + list: () => ['xxx', 'xxx'] + }, + aquarius: { + queryMetadata: () => { + return { + results: [], + totalResults: 1, + totalPages: 1 + } + } + }, + keeper: { + conditions: { + accessSecretStoreCondition: { + getGrantedDidByConsumer: jest.fn() + } + } + } + } +} + +export default oceanMock diff --git a/client/__mocks__/user-mock.ts b/client/__mocks__/user-mock.ts index 5cda7ea..eabdfd5 100644 --- a/client/__mocks__/user-mock.ts +++ b/client/__mocks__/user-mock.ts @@ -1,3 +1,5 @@ +import oceanMock from './ocean-mock' + const userMock = { isLogged: false, isLoading: false, @@ -5,11 +7,7 @@ const userMock = { isOceanNetwork: false, account: '', web3: {}, - ocean: { - aquarius: { - queryMetadata: jest.fn() - } - }, + ...oceanMock, balance: { eth: 0, ocn: 0 }, network: '', requestFromFaucet: jest.fn(), @@ -24,11 +22,7 @@ const userMockConnected = { isOceanNetwork: true, account: '0xxxxxx', web3: {}, - ocean: { - aquarius: { - queryMetadata: jest.fn() - } - }, + ...oceanMock, balance: { eth: 0, ocn: 0 }, network: '', requestFromFaucet: jest.fn(), diff --git a/client/package-lock.json b/client/package-lock.json index f3465bb..5e20e97 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -3487,7 +3487,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3511,13 +3512,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3534,19 +3537,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3677,7 +3683,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3691,6 +3698,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3707,6 +3715,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3715,13 +3724,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3742,6 +3753,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3830,7 +3842,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3844,6 +3857,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3939,7 +3953,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3981,6 +3996,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4002,6 +4018,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4050,13 +4067,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -8745,7 +8764,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -8769,13 +8789,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8792,19 +8814,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -8935,7 +8960,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -8949,6 +8975,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -8965,6 +8992,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -8973,13 +9001,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9000,6 +9030,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -9088,7 +9119,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -9102,6 +9134,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -9197,7 +9230,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -9239,6 +9273,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9260,6 +9295,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9308,13 +9344,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } } @@ -16507,7 +16545,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" } }, "web3-shh": { diff --git a/client/src/App.test.tsx b/client/src/App.test.tsx index 8c85a79..0f22fcd 100644 --- a/client/src/App.test.tsx +++ b/client/src/App.test.tsx @@ -2,7 +2,7 @@ import React from 'react' import { render } from 'react-testing-library' import App from './App' import { User } from './context' -import { userMock } from '../__mocks__/user-mock' +import { userMock, userMockConnected } from '../__mocks__/user-mock' describe('App', () => { it('should be able to run tests', () => { @@ -10,7 +10,11 @@ describe('App', () => { }) it('renders without crashing', () => { - const { container } = render() + const { container } = render( + + + + ) expect(container.firstChild).toBeInTheDocument() }) diff --git a/client/src/Routes.test.tsx b/client/src/Routes.test.tsx index 5ae671b..43c63e8 100644 --- a/client/src/Routes.test.tsx +++ b/client/src/Routes.test.tsx @@ -2,13 +2,17 @@ import React from 'react' import { BrowserRouter as Router } from 'react-router-dom' import { render } from 'react-testing-library' import Routes from './Routes' +import { User } from './context' +import { userMockConnected } from '../__mocks__/user-mock' describe('Routes', () => { it('renders without crashing', () => { const { container } = render( - - - + + + + + ) expect(container.firstChild).toBeInTheDocument() }) diff --git a/client/src/components/organisms/AssetsLatest.test.tsx b/client/src/components/organisms/AssetsLatest.test.tsx index 978045b..69aacd7 100644 --- a/client/src/components/organisms/AssetsLatest.test.tsx +++ b/client/src/components/organisms/AssetsLatest.test.tsx @@ -1,14 +1,18 @@ import React from 'react' +import { BrowserRouter } from 'react-router-dom' import { render } from 'react-testing-library' import AssetsLatest from './AssetsLatest' -import { BrowserRouter } from 'react-router-dom' +import { User } from '../../context' +import { userMockConnected } from '../../../__mocks__/user-mock' describe('AssetsLatest', () => { it('renders without crashing', () => { const { container } = render( - - - + + + + + ) expect(container.firstChild).toBeInTheDocument() }) diff --git a/client/src/components/organisms/ChannelTeaser.test.tsx b/client/src/components/organisms/ChannelTeaser.test.tsx index c270a41..c92dce3 100644 --- a/client/src/components/organisms/ChannelTeaser.test.tsx +++ b/client/src/components/organisms/ChannelTeaser.test.tsx @@ -2,13 +2,17 @@ import React from 'react' import { render } from 'react-testing-library' import ChannelTeaser from './ChannelTeaser' import { BrowserRouter } from 'react-router-dom' +import { User } from '../../context' +import { userMockConnected } from '../../../__mocks__/user-mock' describe('ChannelTeaser', () => { it('renders without crashing', () => { const { container } = render( - - - + + + + + ) expect(container.firstChild).toBeInTheDocument() }) diff --git a/client/src/components/templates/Asset/AssetFile.test.tsx b/client/src/components/templates/Asset/AssetFile.test.tsx index c34abc4..a4e2307 100644 --- a/client/src/components/templates/Asset/AssetFile.test.tsx +++ b/client/src/components/templates/Asset/AssetFile.test.tsx @@ -7,6 +7,7 @@ import { StateMock } from '@react-mock/state' import ReactGA from 'react-ga' import { User } from '../../../context' import AssetFile, { messages } from './AssetFile' +import { userMockConnected } from '../../../../__mocks__/user-mock' const file = { index: 0, @@ -15,22 +16,7 @@ const file = { contentLength: 100 } -const ddo = ({ id: 'xxx' } as any) as DDO - -const contextConnectedMock = { - isLogged: true, - isLoading: false, - isWeb3: true, - isOceanNetwork: true, - account: '', - web3: {}, - ocean: {}, - balance: { eth: 0, ocn: 0 }, - network: '', - requestFromFaucet: () => {}, - unlockAccounts: () => {}, - message: '' -} +const ddo = ({ id: 'xxx', findServiceByType: jest.fn() } as any) as DDO ReactGA.initialize('foo', { testMode: true }) @@ -47,7 +33,7 @@ describe('AssetFile', () => { it('button to be enabled when connected', async () => { const { getByText } = render( - + ) diff --git a/client/src/components/templates/Asset/AssetFile.tsx b/client/src/components/templates/Asset/AssetFile.tsx index 5fd7ca7..263f274 100644 --- a/client/src/components/templates/Asset/AssetFile.tsx +++ b/client/src/components/templates/Asset/AssetFile.tsx @@ -59,16 +59,21 @@ export default class AssetFile extends PureComponent< const accounts = await ocean.accounts.list() const service = ddo.findServiceByType('Access') - const agreements = await ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer(accounts[0].id) - const agreement = agreements.find((element: any) => {return element.did === ddo.id}) + const agreements = await ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer( + accounts[0].id + ) + const agreement = agreements.find((element: any) => { + return element.did === ddo.id + }) let agreementId + if (agreement) { - agreementId = agreement.agreementId + ;({ agreementId } = agreement) } else { agreementId = await ocean.assets - .order(ddo.id, service.serviceDefinitionId, accounts[0]) - .next((step: number) => this.setState({ step })) + .order(ddo.id, service.serviceDefinitionId, accounts[0]) + .next((step: number) => this.setState({ step })) } // manually add another step here for better UX @@ -89,7 +94,7 @@ export default class AssetFile extends PureComponent< }) this.setState({ isLoading: false }) } catch (error) { - Logger.log('error', error.message) + Logger.error('error', error.message) this.setState({ isLoading: false, error: `${error.message}. Sorry about that, can you try again?` diff --git a/client/src/components/templates/Channel.test.tsx b/client/src/components/templates/Channel.test.tsx index c16c84b..cad7808 100644 --- a/client/src/components/templates/Channel.test.tsx +++ b/client/src/components/templates/Channel.test.tsx @@ -3,38 +3,14 @@ import { render } from 'react-testing-library' import Channel from './Channel' import { User } from '../../context' import { createMemoryHistory } from 'history' +import { userMockConnected } from '../../../__mocks__/user-mock' describe('Channel', () => { it('renders without crashing', () => { const history = createMemoryHistory() const { container } = render( - { - return { - results: [], - totalResults: 1, - totalPages: 1 - } - } - } - }, - balance: { eth: 0, ocn: 0 }, - network: '', - requestFromFaucet: () => {}, - unlockAccounts: () => {}, - message: '' - }} - > + { it('renders without crashing', () => { const { container } = render( - - - + + + + + ) expect(container.firstChild).toBeInTheDocument() }) diff --git a/client/src/routes/Search.test.tsx b/client/src/routes/Search.test.tsx index cf2819c..584ab94 100644 --- a/client/src/routes/Search.test.tsx +++ b/client/src/routes/Search.test.tsx @@ -4,38 +4,14 @@ import Search from './Search' import { User } from '../context' import { createMemoryHistory } from 'history' import { BrowserRouter as Router } from 'react-router-dom' +import { userMockConnected } from '../../__mocks__/user-mock' describe('Search', () => { it('renders without crashing', () => { const history = createMemoryHistory() const { container } = render( - { - return { - results: [], - totalResults: 1, - totalPages: 1 - } - } - } - }, - balance: { eth: 0, ocn: 0 }, - network: '', - requestFromFaucet: () => {}, - unlockAccounts: () => {}, - message: '' - }} - > + Date: Fri, 31 May 2019 13:23:13 +0200 Subject: [PATCH 4/4] update required squid-js version in library.json --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 577346e..72db0b2 100644 --- a/library.json +++ b/library.json @@ -19,7 +19,7 @@ }, { "name": "squid-js", - "version": "~0.5.11" + "version": "~0.5.12" }, { "name": "faucet",