diff --git a/lerna.json b/lerna.json index 36010f4dd..97d9b36d8 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "packages": [ "packages/*" ], - "version": "0.16.6" + "version": "0.17.0" } diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index b8fe149dd..00c92da5a 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "0.16.6", + "version": "0.17.0", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", "keywords": [ diff --git a/packages/util-keyring/package.json b/packages/util-keyring/package.json index 9e95e9ce8..7725c16cb 100644 --- a/packages/util-keyring/package.json +++ b/packages/util-keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-keyring", - "version": "0.16.6", + "version": "0.17.0", "description": "Keyring management", "main": "index.js", "engines": { @@ -31,8 +31,8 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.16.6", - "@polkadot/util-crypto": "^0.16.6", + "@polkadot/util": "^0.17.0", + "@polkadot/util-crypto": "^0.17.0", "babel-runtime": "^6.26.0" } } diff --git a/packages/util-keyring/src/testing.js b/packages/util-keyring/src/testing.js index e245a8d01..65d83dc5d 100644 --- a/packages/util-keyring/src/testing.js +++ b/packages/util-keyring/src/testing.js @@ -11,19 +11,25 @@ type TestKeyring = { const createKeyring = require('./index'); +function padSeed (seed: string): string { + return seed.length < 32 + ? padSeed(`${seed} `) + : seed; +} + const SEEDS = { alice: - 'Alice ', + padSeed('Alice'), bob: - 'Bob ', + padSeed('Bob'), charlie: - 'Charlie ', + padSeed('Charlie'), dave: - 'Dave ', + padSeed('Dave'), eve: - 'Eve ', + padSeed('Eve'), ferdie: - 'Ferdie ', + padSeed('Ferdie'), one: '12345678901234567890123456789012', two: diff --git a/packages/util-keyring/src/testing.spec.js b/packages/util-keyring/src/testing.spec.js new file mode 100644 index 000000000..49b0a014f --- /dev/null +++ b/packages/util-keyring/src/testing.spec.js @@ -0,0 +1,11 @@ +// 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. + +describe('testing', () => { + it('creates without failing', () => { + expect( + require('./testing') + ).toBeDefined(); + }); +}); diff --git a/packages/util-rlp/package.json b/packages/util-rlp/package.json index 0e5046152..394e9b22c 100644 --- a/packages/util-rlp/package.json +++ b/packages/util-rlp/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-rlp", - "version": "0.16.6", + "version": "0.17.0", "description": "RLP encoding and decoding", "main": "index.js", "keywords": [ @@ -29,7 +29,7 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.16.6", + "@polkadot/util": "^0.17.0", "babel-runtime": "^6.26.0" }, "devDependencies": { diff --git a/packages/util-rlp/src/encoder/array.js b/packages/util-rlp/src/encoder/array.js index 4c76d2f68..d6cf2030e 100644 --- a/packages/util-rlp/src/encoder/array.js +++ b/packages/util-rlp/src/encoder/array.js @@ -11,18 +11,10 @@ const encodeLength = require('./length'); // flowlint-next-line unclear-type:off module.exports = function encodeArray (encoder: EncodeFunc, input: any): Uint8Array { - const output = []; + const encoded = u8aConcat.apply(null, input.map(encoder)); - for (let i = 0; i < input.length; i++) { - output.push( - encoder(input[i]) - ); - } - - const encoded = u8aConcat(output); - - return u8aConcat([ + return u8aConcat( encodeLength(encoded.length, 192), encoded - ]); + ); }; diff --git a/packages/util-rlp/src/encoder/u8a.js b/packages/util-rlp/src/encoder/u8a.js index 981836007..dfa20c99b 100644 --- a/packages/util-rlp/src/encoder/u8a.js +++ b/packages/util-rlp/src/encoder/u8a.js @@ -14,8 +14,8 @@ module.exports = function encodeU8a (encoder: EncodeFunc, input: Uint8Array): Ui return input; } - return u8aConcat([ + return u8aConcat( encodeLength(input.length, 128), input - ]); + ); }; diff --git a/packages/util-triehash/package.json b/packages/util-triehash/package.json index ddb20493c..ecd262783 100644 --- a/packages/util-triehash/package.json +++ b/packages/util-triehash/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-triehash", - "version": "0.16.6", + "version": "0.17.0", "description": "Creation of triehash values", "main": "index.js", "keywords": [ @@ -29,9 +29,9 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.16.6", - "@polkadot/util-crypto": "^0.16.6", - "@polkadot/util-rlp": "^0.16.6", + "@polkadot/util": "^0.17.0", + "@polkadot/util-crypto": "^0.17.0", + "@polkadot/util-rlp": "^0.17.0", "babel-runtime": "^6.26.0" } } diff --git a/packages/util/package.json b/packages/util/package.json index 5af220542..08198dd7a 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "0.16.6", + "version": "0.17.0", "description": "A collection of useful utilities for @polkadot", "main": "index.js", "keywords": [ diff --git a/packages/util/src/u8a/concat.js b/packages/util/src/u8a/concat.js index 5f9400c7c..319cec9b0 100644 --- a/packages/util/src/u8a/concat.js +++ b/packages/util/src/u8a/concat.js @@ -5,20 +5,21 @@ /** @name u8aConcat - @signature u8aConcat (values: Array): Uint8Array + @signature u8aConcat (...values: Array): Uint8Array @summary Creates a concatenated Uint8Array from the inputs. @description Concatenates the input arrays into a single `UInt8Array`. @example import { u8aConcat } from '@polkadot/util'; - u8aConcat([ + u8aConcat( new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]) - ]); // [1, 2, 3, 4, 5, 6] + ); // [1, 2, 3, 4, 5, 6] */ -module.exports = function u8aConcat (list: Array): Uint8Array { +module.exports = function u8aConcat (...list: Array): Uint8Array { const length = list.reduce((total, item) => total + item.length, 0); + const result = new Uint8Array(length); let offset = 0; return list.reduce((result, item) => { @@ -26,5 +27,5 @@ module.exports = function u8aConcat (list: Array): Uint8Array { offset += item.length; return result; - }, new Uint8Array(length)); + }, result); }; diff --git a/packages/util/src/u8a/concat.spec.js b/packages/util/src/u8a/concat.spec.js index 569351979..5980348ec 100644 --- a/packages/util/src/u8a/concat.spec.js +++ b/packages/util/src/u8a/concat.spec.js @@ -7,11 +7,11 @@ const { u8aConcat } = require('./index'); describe('u8aConcat', () => { it('concatenates arrays', () => { expect( - u8aConcat([ + u8aConcat( new Uint8Array([1, 2, 3, 4]), new Uint8Array([5, 6]), new Uint8Array([7, 8, 9]) - ]) + ) ).toEqual( new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]) );