Skip to content

Feat/add type signed data v4 with salt #400

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dawnseeker8
Copy link

This PR has added sign Typed data v4 signature with domain salt to prevent bug MetaMask/metamask-extension#30473 happen in metamask extension and mobile.

@dawnseeker8 dawnseeker8 added the enhancement New feature or request label Apr 9, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new component that implements Typed Data V4 signing with an added salt parameter to mitigate a known bug. Key changes include:

  • The addition of the signTypedDataV4WithSaltComponent in src/index.js.
  • A new UI component in src/components/signatures/signTypedDataV4-sign-with-salt.js that provides signing and verification controls.
  • Exporting the new component in src/components/signatures/index.js.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/index.js Imported and invoked the new signTypedDataV4WithSaltComponent.
src/components/signatures/signTypedDataV4-sign-with-salt.js Added a new component for signing/verification with salt.
src/components/signatures/index.js Exported the new component.

signTypedDataV4WithSalt.onclick = async () => {
const msgParams = {
domain: {
chainId: globalContext.chainIdInt.toString(),
Copy link
Preview

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chainId is converted to a string during signing, but in verification it is used as a number (line 163). Consider using the same data type for chainId in both places to prevent potential verification issues.

Suggested change
chainId: globalContext.chainIdInt.toString(),
chainId: globalContext.chainIdInt,

Copilot uses AI. Check for mistakes.

name: 'Ether Mail',
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
version: '1',
salt: 'test',
Copy link
Preview

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The salt parameter is hard-coded as 'test'. If this is only intended for development, consider adding a clear comment or mechanism to supply a proper salt value for production use.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant