Move to lerna repo (#19)

* Pull api-* packages into lerna repo

* Bootstrap with hoist

* Update jest alias config

* Add api-jsonrpc

* Pull in jsonrpc

* Update badges

* Don't hoist, use workspaces

* .eslintrc to root

* Cleanups, build from root

* Shorthand commands

* Update to @polkadot/dev 0.9.1

* Update description
This commit is contained in:
Jaco Greeff
2017-11-28 18:03:48 +01:00
committed by GitHub
parent bf6880d5b0
commit e8ccc9aa79
64 changed files with 2378 additions and 136 deletions
+33
View File
@@ -0,0 +1,33 @@
// ISC, Copyright 2017 Jaco Greeff
// @flow
const { hexAddPrefix, hexHasPrefix, hexStripPrefix } = require('@polkadot/util/hex');
const H64_ZERO: string = '00000000000000000000000000000000';
const H128_ZERO: string = `${H64_ZERO}${H64_ZERO}`;
const H256_ZERO: string = `${H128_ZERO}${H128_ZERO}`;
// const H512_ZERO: string = `${H256_ZERO}${H256_ZERO}`;
function leftHexPad (value: ?string, bitLength: number): string {
const length = 2 * bitLength / 8;
if (hexHasPrefix(value)) {
value = hexStripPrefix(value);
}
return hexAddPrefix(`${H256_ZERO}${value || ''}`.slice(-length));
}
function formatH160 (value: ?string): string {
return leftHexPad(value, 160);
}
function formatH256 (value: ?string): string {
return leftHexPad(value, 256);
}
module.exports = {
leftHexPad,
formatH160,
formatH256
};