Remove util/jsonrpc utility functions (move to origin) (#127)

This commit is contained in:
Jaco Greeff
2018-05-17 19:44:34 +02:00
committed by GitHub
parent 73705373e7
commit 1d35c7c3ef
16 changed files with 18 additions and 194 deletions
+1 -1
View File
@@ -10,5 +10,5 @@
"packages": [
"packages/*"
],
"version": "0.20.5"
"version": "0.21.0"
}
+1 -1
View File
@@ -11,6 +11,6 @@
"test": "jest --coverage"
},
"devDependencies": {
"@polkadot/dev": "^0.19.9"
"@polkadot/dev": "^0.19.10"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-crypto",
"version": "0.20.5",
"version": "0.21.0",
"description": "A collection of useful crypto utilities for @polkadot",
"main": "index.js",
"keywords": [
@@ -30,7 +30,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/util": "^0.20.5",
"@polkadot/util": "^0.21.0",
"blakejs": "^1.1.0",
"js-sha3": "^0.7.0",
"tweetnacl": "^1.0.0",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-keyring",
"version": "0.20.5",
"version": "0.21.0",
"description": "Keyring management",
"main": "index.js",
"engines": {
@@ -32,8 +32,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/util": "^0.20.5",
"@polkadot/util-crypto": "^0.20.5",
"@polkadot/util": "^0.21.0",
"@polkadot/util-crypto": "^0.21.0",
"bs58": "^4.0.1"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-rlp",
"version": "0.20.5",
"version": "0.21.0",
"description": "RLP encoding and decoding",
"main": "index.js",
"keywords": [
@@ -30,7 +30,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/util": "^0.20.5"
"@polkadot/util": "^0.21.0"
},
"devDependencies": {
"ethereumjs-testing": "^1.0.4"
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util-triehash",
"version": "0.20.5",
"version": "0.21.0",
"description": "Creation of triehash values",
"main": "index.js",
"keywords": [
@@ -30,8 +30,8 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/util": "^0.20.5",
"@polkadot/util-crypto": "^0.20.5",
"@polkadot/util-rlp": "^0.20.5"
"@polkadot/util": "^0.21.0",
"@polkadot/util-crypto": "^0.21.0",
"@polkadot/util-rlp": "^0.21.0"
}
}
-1
View File
@@ -8,7 +8,6 @@ Utility methods for this package are split into groups
- [ext](ext.md) Extensions to basic classes
- [hex](hex.md) Internal utilities to create and test for hex values
- [is](is.md) Type checking utilities
- [jsonrpc](jsonrpc.md) Convenience functions for values from @polkadot/api-jsonrpc
- [number](number.md) Utility methods to convert to and from `number` values
- [string](string.md) Utility methods to convert to work with `string` values
- [u8a](u8a.md) Utility methods to convert to and from `Uint8Array` objects
-42
View File
@@ -1,42 +0,0 @@
# jsonrpc
Convenience functions for values from @polkadot/api-jsonrpc
- [jsonrpcParam](#jsonrpcparam) Returns a string representation of the parameter name (optional) & type.
- [jsonrpcSignature](#jsonrpcsignature) Returns a string representation of the method with inputs and outputs.
## jsonrpcParam
Returns a string representation of the parameter name (optional) & type.
```js
jsonrpcParam (param: { name?: string, type: string }): string
```
Formats the name and type into a human-readable string.
```js
import { jsonrpcParam } from '@polkadot/util';
console.log(jsonrpcParam({ name: 'dest', type: 'Address' }); // => dest: Address
```
## jsonrpcSignature
Returns a string representation of the method with inputs and outputs.
```js
jsonrpcSignature (name: string, _inputs: Array<InterfaceInputType>, _output: InterfaceOutputType): string
```
Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names, input types and output type.
```js
import { jsonrpcSignature } from '@polkadot/util';
console.log(jsonrpcSignature(
'test_method', [{ name: 'dest', type: 'Address' }], { type: 'Address' }
)); // => test_method (dest: Address): Address
```
+1 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/util",
"version": "0.20.5",
"version": "0.21.0",
"description": "A collection of useful utilities for @polkadot",
"main": "index.js",
"keywords": [
@@ -28,9 +28,6 @@
"check": "eslint src && flow check",
"test": "echo \"Tests only available from root wrapper\""
},
"devDependencies": {
"@polkadot/api-jsonrpc": "^0.11.2"
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"bn.js": "^4.11.8",
+1 -2
View File
@@ -10,7 +10,6 @@ const buffer = require('./buffer');
const ext = require('./ext');
const hex = require('./hex');
const is = require('./is');
const jsonrpc = require('./jsonrpc');
const logger = require('./logger');
const number = require('./number');
const promisify = require('./promisify');
@@ -21,5 +20,5 @@ const u8a = require('./u8a');
@summary Utility methods for this package are split into groups
*/
module.exports = Object.assign(
{}, array, { assert }, bn, buffer, ext, hex, is, jsonrpc, { logger }, number, { promisify }, string, u8a
{}, array, { assert }, bn, buffer, ext, hex, is, { logger }, number, { promisify }, string, u8a
);
-15
View File
@@ -1,15 +0,0 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
const jsonrpcParam = require('./param');
const jsonrpcSignature = require('./signature');
/**
@summary Convenience functions for values from @polkadot/api-jsonrpc
*/
module.exports = {
jsonrpcParam,
jsonrpcSignature
};
-25
View File
@@ -1,25 +0,0 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
import type { InterfaceInputType, InterfaceOutputType } from '@polkadot/api-jsonrpc/types';
/**
@name jsonrpcParam
@signature jsonrpcParam (param: { name?: string, type: string }): string
@summary Returns a string representation of the parameter name (optional) & type.
@description
Formats the name and type into a human-readable string.
@example
import { jsonrpcParam } from '@polkadot/util';
console.log(jsonrpcParam({ name: 'dest', type: 'Address' }); // => dest: Address
*/
module.exports = function jsonrpcParam (param: InterfaceInputType | InterfaceOutputType): string {
// flowlint-next-line sketchy-null-mixed:off,sketchy-null-string:off
return param.name
// $FlowFixMe InterfaceInputType found, has name
? `${param.name}: ${param.type}`
: param.type;
};
-23
View File
@@ -1,23 +0,0 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const { jsonrpcParam } = require('./index');
describe('jsonrpcParam', () => {
it('formats input parameters (name & type)', () => {
expect(
jsonrpcParam(
{ name: 'b', type: 'A' }
)
).toEqual('b: A');
});
it('formats output paramaters (type-only)', () => {
expect(
jsonrpcParam(
{ type: 'A' }
)
).toEqual('A');
});
});
-28
View File
@@ -1,28 +0,0 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
import type { InterfaceInputType, InterfaceOutputType } from '@polkadot/api-jsonrpc/types';
const formatParam = require('./param');
/**
@name jsonrpcSignature
@signature jsonrpcSignature (name: string, _inputs: Array<InterfaceInputType>, _output: InterfaceOutputType): string
@summary Returns a string representation of the method with inputs and outputs.
@description
Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names, input types and output type.
@example
import { jsonrpcSignature } from '@polkadot/util';
console.log(jsonrpcSignature(
'test_method', [{ name: 'dest', type: 'Address' }], { type: 'Address' }
)); // => test_method (dest: Address): Address
*/
module.exports = function jsonrpcSignature (name: string, _inputs: Array<InterfaceInputType>, _output: InterfaceOutputType): string {
const inputs = _inputs.map(formatParam).join(', ');
const output = formatParam(_output);
return `${name} (${inputs}): ${output}`;
};
@@ -1,32 +0,0 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const { jsonrpcSignature } = require('./index');
describe('jsonrpcSignature', () => {
it('formats the signature according to the specification', () => {
expect(
jsonrpcSignature(
'test_method',
[
{ name: 'b', type: 'A' },
{ name: 'a', type: 'B' },
{ type: 'C' },
{ type: 'D' }
],
{ type: 'A' }
)
).toEqual('test_method (b: A, a: B, C, D): A');
});
it('empty inputs format correctly', () => {
expect(
jsonrpcSignature(
'test_method',
[],
{ type: 'A' }
)
).toEqual('test_method (): A');
});
});
+3 -9
View File
@@ -664,15 +664,9 @@
lodash "^4.17.5"
to-fast-properties "^2.0.0"
"@polkadot/api-jsonrpc@^0.11.2":
version "0.11.2"
resolved "https://registry.yarnpkg.com/@polkadot/api-jsonrpc/-/api-jsonrpc-0.11.2.tgz#f2ddaab686a2da5a63a1a519d76a26d433486927"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
"@polkadot/dev@^0.19.9":
version "0.19.9"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.19.9.tgz#cc37c7364e010d96f45132d0069eda32f52e8462"
"@polkadot/dev@^0.19.10":
version "0.19.10"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.19.10.tgz#ccfbfb8632371876456a8e3e89ff26f10b27ba26"
dependencies:
"@babel/cli" "^7.0.0-beta.47"
"@babel/core" "^7.0.0-beta.47"