diff --git a/packages/util/package.json b/packages/util/package.json index 270458409..b6849d19c 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -29,7 +29,7 @@ "test": "echo \"Tests only available from root wrapper\"" }, "devDependencies": { - "@polkadot/api-jsonrpc": "^0.8.11" + "@polkadot/api-jsonrpc": "^0.8.13" }, "dependencies": { "babel-runtime": "^6.26.0", diff --git a/packages/util/src/u8a/concat.js b/packages/util/src/u8a/concat.js index 3e9802eba..af914e8a7 100644 --- a/packages/util/src/u8a/concat.js +++ b/packages/util/src/u8a/concat.js @@ -19,13 +19,14 @@ const u8aToU8a = require('./toU8a'); new Uint8Array([4, 5, 6]) ); // [1, 2, 3, 4, 5, 6] */ -module.exports = function u8aConcat (...list: Array): Uint8Array { +module.exports = function u8aConcat (..._list: Array): Uint8Array { + const list: Array = _list.map(u8aToU8a); const length = list.reduce((total, item) => total + item.length, 0); const result = new Uint8Array(length); let offset = 0; return list.reduce((result, item) => { - result.set(u8aToU8a(item), offset); + result.set(item, offset); offset += item.length; return result; diff --git a/packages/util/src/u8a/concat.spec.js b/packages/util/src/u8a/concat.spec.js index 5980348ec..abeddf614 100644 --- a/packages/util/src/u8a/concat.spec.js +++ b/packages/util/src/u8a/concat.spec.js @@ -16,4 +16,16 @@ describe('u8aConcat', () => { new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]) ); }); + + it('concatenates arrays & hex values', () => { + expect( + u8aConcat( + new Uint8Array([1, 2, 3, 4]), + '0x0506', + '0x070809' + ) + ).toEqual( + new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]) + ); + }); }); diff --git a/yarn.lock b/yarn.lock index 198e6eb2e..8756c15a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -79,9 +79,9 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" -"@polkadot/api-jsonrpc@^0.8.11": - version "0.8.11" - resolved "https://registry.yarnpkg.com/@polkadot/api-jsonrpc/-/api-jsonrpc-0.8.11.tgz#9ff8dc38f026bac0bb8274836f4f68ba93aa090e" +"@polkadot/api-jsonrpc@^0.8.13": + version "0.8.13" + resolved "https://registry.yarnpkg.com/@polkadot/api-jsonrpc/-/api-jsonrpc-0.8.13.tgz#60a0241204cef405936b21e009970c5a7295d909" dependencies: babel-runtime "^6.26.0"