From eb156a2378f89c0a0e826195621ef1ebe4ef1317 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 20 Apr 2018 16:22:01 +0200 Subject: [PATCH] Revert "Calculate hash on pass-through" (#71) * Revert "[CI Skip] 0.8.15" This reverts commit c1b03eaf2c369625ad100edbeb1361d747ae23db. * Revert "Calculate hash on pass-through (#70)" This reverts commit 7074036064199a1d3fc36bb2c9b2838de1fcff02. * Update package.json * Update package.json * Update package.json * yarn --- packages/api-format/package.json | 1 - packages/api-format/src/output.js | 18 ++---------------- packages/api-jsonrpc/src/chain/newHead.js | 3 +-- packages/api-jsonrpc/src/types.js | 3 +-- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/packages/api-format/package.json b/packages/api-format/package.json index e9499ad368..84a0067771 100644 --- a/packages/api-format/package.json +++ b/packages/api-format/package.json @@ -35,7 +35,6 @@ "dependencies": { "@polkadot/primitives-json": "^0.10.1", "@polkadot/util": "^0.19.1", - "@polkadot/util-crypto": "^0.19.1", "babel-runtime": "^6.26.0" } } diff --git a/packages/api-format/src/output.js b/packages/api-format/src/output.js index db3d7dbe28..35b443fa5e 100644 --- a/packages/api-format/src/output.js +++ b/packages/api-format/src/output.js @@ -10,7 +10,6 @@ const bytesDecode = require('@polkadot/primitives-json/bytes/decode'); const headerDecode = require('@polkadot/primitives-json/header/decode'); const isNull = require('@polkadot/util/is/null'); const isUndefined = require('@polkadot/util/is/undefined'); -const blake2Asu8a256 = require('@polkadot/util-crypto/blake2/asU8a256'); const format = require('./format'); @@ -21,23 +20,10 @@ const formatters = { 'U64': bnDecode }; -module.exports = function formatOutput ({ type, withHash }: InterfaceOutputType, value?: mixed): ?mixed { +module.exports = function formatOutput (output: InterfaceOutputType, value?: mixed): ?mixed { if (isUndefined(value) || isNull(value)) { return value; } - const decoded = format(formatters, [type], [value])[0]; - - // flowlint-next-line sketchy-null-bool:off - if (!withHash) { - return decoded; - } - - // flowlint-next-line unclear-type:off - const hash = blake2Asu8a256(((value: any): Uint8Array)); - - return { - [type.toLowerCase()]: decoded, - hash - }; + return format(formatters, [output.type], [value])[0]; }; diff --git a/packages/api-jsonrpc/src/chain/newHead.js b/packages/api-jsonrpc/src/chain/newHead.js index f3fbaf67ab..3612566906 100644 --- a/packages/api-jsonrpc/src/chain/newHead.js +++ b/packages/api-jsonrpc/src/chain/newHead.js @@ -16,7 +16,6 @@ module.exports = ({ isSubscription: true, inputs: [], output: { - type: 'Header', - withHash: true + type: 'Header' } }: InterfaceMethodDefinition); diff --git a/packages/api-jsonrpc/src/types.js b/packages/api-jsonrpc/src/types.js index 726031b4a5..ae057f7903 100644 --- a/packages/api-jsonrpc/src/types.js +++ b/packages/api-jsonrpc/src/types.js @@ -16,8 +16,7 @@ export type InterfaceInputType = { }; export type InterfaceOutputType = { - type: FormatOutputType, - withHash?: boolean + type: FormatOutputType }; export type InterfaceMethodDefinition$Subscribe = {