Skip to content

Commit

Permalink
Force TypedData numbers to be in decimal (#1193).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Feb 25, 2021
1 parent bcda16d commit c5a53d6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/hash/src.ts/typed-data.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c5a53d6

Please sign in to comment.