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

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

Open
0R61 opened this issue Jun 23, 2022 · 0 comments
Open

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

0R61 opened this issue Jun 23, 2022 · 0 comments

Comments

@0R61
Copy link

0R61 commented Jun 23, 2022

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant