Skip to content

refactor: parse signTypedData logic #14378

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 32 commits into
base: main
Choose a base branch
from

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Apr 2, 2025

Description

Cleanup signTypedData parse and sanitize logic:

  • add related unit tests
  • move sanitizeMessage from util/string to utils/signature
  • memoized parseAndSanitizeSignTypedData
  • renamed methods
    • typedSignData → signTypedData to be consistent with EIP signTypedData
    • TypedDataMessage → signTypedData to avoid confusion as these methods are handling signTypedData request messageParams.data. That is message data, not data message
    • sanitizeString → escapeSpecialUnicode
  • reduce methods by 1. Combined parseSanitizeTypedDataMessage from util/string with the method from utils/signature
  • parseSignTypedDataFromSignatureRequest now returns {} with nullish values to be consistent with other parse methods

Related issues

Fixes: #14377

Manual testing steps

Test signTypedData confirmations v1 & v3/v4

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@digiwand digiwand requested review from a team as code owners April 2, 2025 15:54
Copy link
Contributor

github-actions bot commented Apr 2, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Apr 2, 2025
@digiwand digiwand added the No QA Needed Apply this label when your PR does not need any QA effort. label Apr 3, 2025
@digiwand digiwand changed the title Refactor parse sign typed data logic refactor: parse signTypedData logic Apr 4, 2025
@digiwand digiwand added the Run Smoke E2E Triggers smoke e2e on Bitrise label Apr 4, 2025
Copy link
Contributor

github-actions bot commented Apr 4, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 4c77a09
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/9de82e77-36ff-49ad-a64a-d1a49ae094dd

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

Copy link

@al-sultani al-sultani left a comment

Choose a reason for hiding this comment

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

LGTM.

@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Apr 16, 2025
Copy link
Contributor

github-actions bot commented Apr 16, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 29b738d
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/6f5c8ad7-2411-4566-bd5e-75e1123eb39e

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Apr 17, 2025
Copy link
Contributor

github-actions bot commented Apr 17, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 36c1972
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d9b9560d-7cb9-45c3-aa7a-6114436a7b9b

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Apr 17, 2025
Copy link
Contributor

github-actions bot commented Apr 17, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 86d0114
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/9ccd7205-3650-4c6c-b158-1097b3aa9f47

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 86.36364% with 9 lines in your changes missing coverage. Please review.

Project coverage is 67.53%. Comparing base (7d87b6c) to head (e9aae1c).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../components/Views/confirmations/utils/signature.ts 89.13% 2 Missing and 3 partials ⚠️
...nts/Views/confirmations/components/title/title.tsx 33.33% 0 Missing and 2 partials ⚠️
...confirmations/legacy/components/TypedSign/index.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14378      +/-   ##
==========================================
- Coverage   67.53%   67.53%   -0.01%     
==========================================
  Files        2307     2307              
  Lines       49598    49598              
  Branches     7191     7190       -1     
==========================================
- Hits        33497    33495       -2     
- Misses      13983    13984       +1     
- Partials     2118     2119       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@digiwand digiwand added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Apr 22, 2025
Copy link
Contributor

github-actions bot commented Apr 22, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: e9aae1c
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/7fcbf687-f1c8-406a-b8d8-2265f5c4f408

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@digiwand digiwand added the no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Apr 23, 2025
OGPoyraz
OGPoyraz previously approved these changes Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No QA Needed Apply this label when your PR does not need any QA effort. no-changelog Indicates no external facing user changes, therefore no changelog documentation needed Run Smoke E2E Triggers smoke e2e on Bitrise team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring signTypedData parse methods
5 participants