Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/api-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
18 changes: 2 additions & 16 deletions packages/api-format/src/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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];
};
3 changes: 1 addition & 2 deletions packages/api-jsonrpc/src/chain/newHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module.exports = ({
isSubscription: true,
inputs: [],
output: {
type: 'Header',
withHash: true
type: 'Header'
}
}: InterfaceMethodDefinition);
3 changes: 1 addition & 2 deletions packages/api-jsonrpc/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export type InterfaceInputType = {
};

export type InterfaceOutputType = {
type: FormatOutputType,
withHash?: boolean
type: FormatOutputType
};

export type InterfaceMethodDefinition$Subscribe = {
Expand Down