-
Notifications
You must be signed in to change notification settings - Fork 5k
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
fix: Use toUnicode
function to normalize ens domains in the UI
#29231
fix: Use toUnicode
function to normalize ens domains in the UI
#29231
Conversation
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; | |||
import classnames from 'classnames'; | |||
import copyToClipboard from 'copy-to-clipboard'; | |||
import { NameType } from '@metamask/name-controller'; | |||
import { toUnicode } from 'punycode'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
punycode
lib I think is deprecated, we should avoid using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should rely on any other package before removing the toASCII
util from ENSController
- these utils match each other since both using same encoding from punycode
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, will be nice to mention that as a comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, added a comment.
const displayName = | ||
(recipientName || | ||
recipientNickname || | ||
recipientMetadataName || | ||
recipientEns || | ||
normalizedEnsRecipientName || | ||
shortenAddress(checksummedRecipientAddress)) ?? | ||
(!addressOnly && t('newContract')); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be useful to also test cover this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's moved in to selector and we are not adding any test on them, I will skip and won't add it.
const displayName = | ||
(recipientName || | ||
recipientNickname || | ||
recipientMetadataName || | ||
recipientEns || | ||
normalizedEnsRecipientName || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we have this issue rendering ENS proposed names in petnames, and anywhere the ENS controller state is used?
Could we fix this deeper in the getEnsResolutionByAddress
selector perhaps so we don't have to manually do this for each usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to do that casting on deeper, done.
19536a7
to
c2bc8b5
Compare
…handling-of-emojis-ens-domains
Builds ready [143deb9]
Page Load Metrics (1589 ± 32 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…handling-of-emojis-ens-domains
…handling-of-emojis-ens-domains
…handling-of-emojis-ens-domains
Builds ready [d01b223]
Page Load Metrics (1731 ± 66 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
In
ENSController
(https://github.com/MetaMask/core/blob/main/packages/ens-controller/src/EnsController.ts#L375) right before saving the ens domain in the state we usetoASCII
. This function is typically used to convert a domain name from its Unicode representation to ASCII, specifically using thePunycode
package encoding. This is necessary because the Domain Name System (DNS) operates with ASCII characters, and internationalized domain names (IDNs) need to be converted to a format that DNS can understand.On the other side, in the client, we are not converting/normalizing this domain value. That is causing that unwanted ASCII coded domain in the UI when using smileys in the ENS domain.
Related issues
Fixes: #28610
Manual testing steps
See #28610 for repro steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist