Skip to content

Commit

Permalink
fix: Use toUnicode function to normalize ens domains in the UI (#29231
Browse files Browse the repository at this point in the history
)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
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 use `toASCII`. This
function is typically used to convert a domain name from its Unicode
representation to ASCII, specifically using the `Punycode` 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.


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29231?quickstart=1)

## **Related issues**

Fixes: #28610

## **Manual testing steps**

See #28610 for
repro steps

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

![Screenshot 2024-12-16 at 13 37
04](https://github.com/user-attachments/assets/62163ce0-007a-404b-8f2e-7a49eaa7b927)


### **After**

![Screenshot 2024-12-16 at 13 36
32](https://github.com/user-attachments/assets/cd287cb0-aa81-49da-aafb-1e753d8544e7)


## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.
  • Loading branch information
OGPoyraz authored Dec 20, 2024
1 parent 367769b commit fd6e755
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/selectors/selectors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { toUnicode } from 'punycode/punycode.js';
import { SubjectType } from '@metamask/permission-controller';
import { ApprovalType } from '@metamask/controller-utils';
import {
Expand Down Expand Up @@ -729,7 +730,10 @@ export function getAddressBook(state) {

export function getEnsResolutionByAddress(state, address) {
if (state.metamask.ensResolutionsByAddress[address]) {
return state.metamask.ensResolutionsByAddress[address];
const ensResolution = state.metamask.ensResolutionsByAddress[address];
// ensResolution is a punycode encoded string hence toUnicode is used to decode it from same package
const normalizedEnsResolution = toUnicode(ensResolution);
return normalizedEnsResolution;
}

const entry =
Expand Down

0 comments on commit fd6e755

Please sign in to comment.