Skip to content

feat: add useFirstPartyContractName hook and use it in useDisplayName#23092

Merged
dbrans merged 3 commits intodevelopfrom
dbrans/useContractName
Feb 22, 2024
Merged

feat: add useFirstPartyContractName hook and use it in useDisplayName#23092
dbrans merged 3 commits intodevelopfrom
dbrans/useContractName

Conversation

@dbrans
Copy link
Copy Markdown
Contributor

@dbrans dbrans commented Feb 21, 2024

Open in GitHub Codespaces

Description

Add useFirstPartyContractName hook to find names for our first-party contracts based on their address and chainID.

Integrated with useDisplayName to ensure Petnames recognize these contracts correctly.

Why It Matters:
Prior to Petnames, MetaMask displayed first-party contracts like the MetaMask Bridge as cryptic hex addresses. This wasn't very user-friendly. However, with the introduction of Petnames in version 11.11, these addresses will start appearing even more alarming due to the new color scheme and icons. Our update aims to make these contracts easily recognizable and less intimidating.

Before Petnames:

With Petnames, before this PR:

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2136

Manual testing steps

  1. Set the current chain to mainnet
  2. Start a send transaction from the extension wallet
  3. Put 0x0439e60F02a8900a951603950d8D4527f400C3f1 as the recipient
  4. Click "Next"
  5. On the confirmation screen, the recipient should be labelled as "MetaMask Bridge"

If you want to test other addresses and names on other chains, you can refer to first-party-contracts.ts in this PR for a full list.

Screenshots/Recordings

Before

See description

After

image

image

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@github-actions
Copy link
Copy Markdown
Contributor

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.

@dbrans dbrans changed the title feat: add useFirstPartyContractName hook feat: add useFirstPartyContractName hook and use it in useDisplayName Feb 21, 2024
@dbrans dbrans added the team-confirmations-system-deprecated DEPRECATED: please use "team-confirmations" instead label Feb 21, 2024
@dbrans dbrans marked this pull request as ready for review February 21, 2024 19:44
@dbrans dbrans requested a review from a team as a code owner February 21, 2024 19:44
@dbrans dbrans force-pushed the dbrans/useContractName branch from 2bdcc15 to fc6e93f Compare February 21, 2024 20:40
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [c0efa11]
Page Load Metrics (1869 ± 89 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint944351768340
domContentLoaded108025178
load16502269186918589
domInteractive98025178
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 3.14 KiB (0.04%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.49%. Comparing base (afb1b66) to head (c0efa11).
Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #23092      +/-   ##
===========================================
+ Coverage    68.49%   68.49%   +0.01%     
===========================================
  Files         1090     1092       +2     
  Lines        43133    43142       +9     
  Branches     11501    11504       +3     
===========================================
+ Hits         29541    29550       +9     
  Misses       13592    13592              

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

@dbrans dbrans merged commit c9ccde4 into develop Feb 22, 2024
@dbrans dbrans deleted the dbrans/useContractName branch February 22, 2024 22:11
@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2024
@metamaskbot metamaskbot added release-11.13.0 Issue or pull request that will be included in release 11.13.0 release-11.11.0 Issue or pull request that will be included in release 11.11.0 and removed release-11.13.0 Issue or pull request that will be included in release 11.13.0 labels Feb 22, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Missing release label release-11.11.0 on PR. Adding release label release-11.11.0 on PR and removing other release labels(release-11.13.0), as PR was cherry-picked in branch 11.11.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

QA Passed release-11.11.0 Issue or pull request that will be included in release 11.11.0 team-confirmations-system-deprecated DEPRECATED: please use "team-confirmations" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants