Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Oct 13, 2022
1 parent 35a387e commit 38b7c72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/sign-typed-data-gggg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
12 changes: 9 additions & 3 deletions src/sign-typed-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isHexString } from 'ethjs-util';
import { isHexString, stripHexPrefix } from 'ethjs-util';
import {
arrToBufArr,
bufferToHex,
Expand All @@ -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,
Expand Down Expand Up @@ -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))];
Expand Down

0 comments on commit 38b7c72

Please sign in to comment.