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

hashTypedData does not check domain type at runtime #2999

Closed
1 task done
freemanzMrojo opened this issue Nov 12, 2024 · 1 comment
Closed
1 task done

hashTypedData does not check domain type at runtime #2999

freemanzMrojo opened this issue Nov 12, 2024 · 1 comment

Comments

@freemanzMrojo
Copy link

Check existing issues

Viem Version

2.21.44

Current Behavior

Good afternoon!

I can pass any value as domain to the hashTypedData function and it will be hashed regardless without checking its type at runtime.

    hashTypedData({
      ...typedData.complex,
      domain: 'wrong' as unknown as Record<string, unknown>,
      primaryType: 'Mail',
    }),

The equivalent in ethers does check the value at runtime.

Expected Behavior

I get an error since I am trying to fool the function and the hash that I get as a result does not take the domain into account (might be just an error on my side).

Steps To Reproduce

Run pnpm vitest run src/utils/signature/hashTypedData.test.ts -t 'wrong domain value' on this forked branch: https://github.com/freemanzMrojo/viem/tree/test-hash-typed-data (it uses the code above).

Link to Minimal Reproducible Example

No response

Anything else?

No response

Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant