Skip to content

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

@0R61

Description

@0R61

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions