From c5a53d6911d7c41dd03a290b550e80f2919e9379 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 25 Feb 2021 00:46:10 -0500 Subject: [PATCH] Force TypedData numbers to be in decimal (#1193). --- packages/hash/src.ts/typed-data.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/hash/src.ts/typed-data.ts b/packages/hash/src.ts/typed-data.ts index 5612647959..a1758ec287 100644 --- a/packages/hash/src.ts/typed-data.ts +++ b/packages/hash/src.ts/typed-data.ts @@ -1,7 +1,7 @@ import { TypedDataDomain, TypedDataField } from "@ethersproject/abstract-signer"; import { getAddress } from "@ethersproject/address"; import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; -import { arrayify, BytesLike, hexConcat, hexlify, hexValue, hexZeroPad, isHexString } from "@ethersproject/bytes"; +import { arrayify, BytesLike, hexConcat, hexlify, hexZeroPad, isHexString } from "@ethersproject/bytes"; import { keccak256 } from "@ethersproject/keccak256"; import { deepCopy, defineReadOnly, shallowCopy } from "@ethersproject/properties"; @@ -484,13 +484,7 @@ export class TypedDataEncoder { // uint or int if (type.match(/^u?int/)) { - let prefix = ""; - let v = BigNumber.from(value); - if (v.isNegative()) { - prefix = "-"; - v = v.mul(-1); - } - return prefix + hexValue(v.toHexString()); + return BigNumber.from(value).toString(); } switch (type) {