diff --git a/src/utils/hex.test.ts b/src/utils/hex.test.ts index 07a145e..83714eb 100644 --- a/src/utils/hex.test.ts +++ b/src/utils/hex.test.ts @@ -11,13 +11,13 @@ describe('Utils hex', () => { it('converts a string to a hex string', () => { const stringInput = '456'; - const expectedHex = '0x01c8'; + const expectedHex = '0x1c8'; expect(toHex(stringInput)).toBe(expectedHex); }); it('converts a BigNumber to a hex string', () => { const bigNumberInput = BigNumber.from(789); - const expectedHex = '0x0315'; + const expectedHex = '0x315'; expect(toHex(bigNumberInput)).toBe(expectedHex); }); }); diff --git a/src/utils/hex.ts b/src/utils/hex.ts index a8a86e4..30737a6 100644 --- a/src/utils/hex.ts +++ b/src/utils/hex.ts @@ -1,4 +1,6 @@ import { BigNumber } from '@ethersproject/bignumber'; +import { hexValue } from '@ethersproject/bytes'; -export const toHex = (stringToConvert: string | number | BigNumber): string => - BigNumber.from(stringToConvert).toHexString(); +export const toHex = (stringToConvert: string | number | BigNumber): string => { + return hexValue(BigNumber.from(stringToConvert).toHexString()); +};