Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

encode_eip712 doesn't work correctly when int256 is used #2785

Open
fvictorio opened this issue May 2, 2024 · 0 comments
Open

encode_eip712 doesn't work correctly when int256 is used #2785

fvictorio opened this issue May 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@fvictorio
Copy link

Version

ethers-core v2.0.14 (https://github.com/gakonst/ethers-rs#51fe937f)

Platform
GNU/Linux x86_64

Description

TypedData::encode_eip712 doesn't work correctly when an int256 is used. This is easier explained with some tests, so I opened a WIP PR with a couple of tests: #2784

Both tests use almost the same EIP712 data, except one uses uint256 and the other one uses int256.

I'm pretty sure the int256 hash used in the test is correct because I verified it both with viem and ethers.js:

const viem = require("viem")
const ethers = require("ethers")

const typedData = {
  "domain": {
    "name": "TestName",
    "version": "1",
    "chainId": 31337,
    "verifyingContract": "0x1111111111111111111111111111111111111111",
  },
  "types": {
    "Test": [{ "name": "amount", "type": "int256" }],
  },
  "message": {
    "amount": "1234",
  },
  "primaryType": "Test",
};

console.log("viem", viem.hashTypedData(typedData))
console.log("ethers", ethers.TypedDataEncoder.hash(typedData.domain, typedData.types, typedData.message))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant