From 132a8dd4ed50544e75481a2b1b5b5091a5fe5a28 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 11 Jan 2019 14:16:49 +0100 Subject: [PATCH] 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) --- packages/types/src/codec/AbstractInt.ts | 2 +- packages/types/src/codec/Compact.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/types/src/codec/AbstractInt.ts b/packages/types/src/codec/AbstractInt.ts index e4a274bec0..c3cad8ea17 100644 --- a/packages/types/src/codec/AbstractInt.ts +++ b/packages/types/src/codec/AbstractInt.ts @@ -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 diff --git a/packages/types/src/codec/Compact.spec.ts b/packages/types/src/codec/Compact.spec.ts index 92f4bd495c..f27364dd7d 100644 --- a/packages/types/src/codec/Compact.spec.ts +++ b/packages/types/src/codec/Compact.spec.ts @@ -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),