Align fromHex in AbstractInt with toHex (and with actual BE JSON) (#571)

* Align fromHex in AbstractInt with toHex (and with actual BE JSON)

* Update test (hex input in BE)
This commit is contained in:
Jaco Greeff
2019-01-11 14:16:49 +01:00
committed by GitHub
parent ee513f783c
commit 132a8dd4ed
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ export default abstract class AbstractInt extends BN implements Codec {
// constructor. It would be ideal to actually return a BN, but there's a
// bug: https://github.com/indutny/bn.js/issues/206.
if (isHex(value)) {
return hexToBn(value, { isLe: true, isNegative }).toString();
return hexToBn(value, { isLe: false, isNegative }).toString();
} else if (isU8a(value)) {
try {
// NOTE When passing u8a in (typically from decoded data), it is always LE
+1 -1
View File
@@ -63,7 +63,7 @@ describe('Compact', () => {
it('encondes a large balance', () => {
expect(
Compact.encodeU8a(new Balance('0x00407a10f35a'))
Compact.encodeU8a(new Balance('0x5af3107a4000'))
).toEqual(
new Uint8Array([
3 + ((6 - 4) << 2),