diff --git a/src/sign-typed-data-gggg.test.ts b/src/sign-typed-data-gggg.test.ts index 8ab076ee..ea6da1f3 100644 --- a/src/sign-typed-data-gggg.test.ts +++ b/src/sign-typed-data-gggg.test.ts @@ -240,11 +240,11 @@ function validateTypedMessageSchema( const encodeDataExamples = { // dynamic types supported by EIP-712: bytes: [ - 10, - '10', - '0x10', // even + // 10, + // '10', + // '0x10', // even '0x101', // odd - Buffer.from('10', 'utf8'), + // Buffer.from('10', 'utf8'), '0xa22cb465000000000000000000000000a9079d872d10185b54c5db2c36cc978cbd3f72b70000000000000000000000000000000000000000000000000000000000000001', ], // string: [ diff --git a/src/sign-typed-data.ts b/src/sign-typed-data.ts index 604ddbf9..7945e7a2 100644 --- a/src/sign-typed-data.ts +++ b/src/sign-typed-data.ts @@ -1,4 +1,4 @@ -import { isHexString } from 'ethjs-util'; +import { isHexString, stripHexPrefix } from 'ethjs-util'; import { arrToBufArr, bufferToHex, @@ -8,7 +8,7 @@ import { } from '@ethereumjs/util'; import { keccak256 } from 'ethereum-cryptography/keccak'; import { rawEncode, solidityPack } from './ethereumjs-abi-utils'; - +import BN from 'bn.js'; import { concatSig, isNullish, @@ -174,9 +174,15 @@ function encodeField( if (typeof value === 'number') { value = numberToBuffer(value); } else if (isHexString(value)) { + const original = value; + // const bnValue = new BN(stripHexPrefix(value), 16) + const bigIntValue = BigInt(value) + if(bigIntValue > Number.MAX_SAFE_INTEGER){ + console.log("HMMM?", original, 'bigIntValue:', bigIntValue) + } value = Buffer.from(value.slice(2), 'hex'); + console.log("original:", original, "after:", value, 'keccakd', arrToBufArr(keccak256(numberToBuffer(parseInt(original, 16))))) } else { - console.log("value:", value) value = Buffer.from(value, 'utf8'); } return ['bytes32', arrToBufArr(keccak256(value))];