Update sign-typed-data.js file to support signTypedData_v4

Open
#257 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
cryptography

Research direction

Start in sign-typed-data.js at sanitizeData and trace how signTypedData_v4 input reaches it. Confirm the data is parsed before schema filtering and that the EIP712Domain error is avoided; done means v4 data is sanitized without the reported TypeError.

Written by the indexing model from the issue text.

Description

Update the sanitizeData function to parse data properly using JSON.parse and avoid error: TypeError: Cannot read properties of undefined (reading 'EIP712Domain')

function sanitizeData(unparsedData) {
    const data=JSON.parse(unparsedData)
    const sanitizedData = {};
    for (const key in exports.TYPED_MESSAGE_SCHEMA.properties) {
        if (data[key]) {
            sanitizedData[key] = data[key];
        }
    }
    if ('types' in sanitizedData) {
        sanitizedData.types = Object.assign({ EIP712Domain: [] }, sanitizedData.types);
    }
    return sanitizedData;
}
Dominant language
TypeScript
Stars
586
Forks
231
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MetaMask/eth-sig-util

All issues in MetaMask/eth-sig-util

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.