Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant