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

TypedDataEncoder is badly encoding domain.chainId #4649

Open
julien-devatom opened this issue Mar 15, 2024 · 0 comments
Open

TypedDataEncoder is badly encoding domain.chainId #4649

julien-devatom opened this issue Mar 15, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@julien-devatom
Copy link

julien-devatom commented Mar 15, 2024

Ethers Version

6

Search Terms

TypedData Encoder domain signing message

Describe the Problem

inside of a JsonRpcProvider, when we call the signTypedData function, the domain.chainId is always formatted as a hex number, even if the number is a safe Integer

During the encoding process, this function is used to encode chainId. However, Number.isSafeInteger(BigInt) is always returning false. So the result is transformed by using toQuantity that is writing the chainId as an hexString.

As a consequence, some browser wallets such as wallet connect & frame wallet cannot decode the chain id correctly.

Code Snippet

You should do something like that:

if(Number.isSafeInteger(+(value.toString()))) return Number(value)

return toQuantity(value)

Contract ABI

No response

Errors

No response

Environment

node.js (older than v12), Browser (Chrome, Safari, etc)

Environment (Other)

No response

@julien-devatom julien-devatom added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants