Skip to content
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

ENS reverse resolution support #7177

Merged
merged 9 commits into from
Nov 1, 2019

Conversation

whymarrh
Copy link
Contributor

@whymarrh whymarrh commented Sep 17, 2019

Closes #5525

This PR adds ENS Reverse Resolution support to the UI, showing ENS names in a few places where addresses are currently used (the confirm screen & tx activity log). This represents a step towards "level two" of ENS integration, as outlined in the ENS docs:[1]

The second level of ENS integration involves displaying ENS names wherever your app currently displays addresses.

[...]

If a user entered an address, or the address was obtained from elsewhere, you may still be able to show an ENS name, by doing Reverse Resolution. This permits you to find the canonical name for an address and display that when possible. If no canonical name is provided, your application can fall back to displaying the address as it did previously.

By supporting reverse resolution, you make it easier for your users to identify accounts they interact with, associating them with a short human-readable name instead of a long opaque Ethereum address.

And, further, from Resolving Names § Reverse Resolution:[2]

ENS does not enforce the accuracy of reverse records - for instance, anyone may claim that the name for their address is 'alice.eth'. To be certain that the claim is accurate, you must always perform a forward resolution for the returned name and check it matches the original address.

IDN homograph attack[3]

As we're showing user-generated domain names in sensitive places in the UI, we need to prevent malicious users from tricking users by registering domains that use Unicode characters to look visually similar to other registered names (see also #1913).

This PR converts ENS domain names to Punycode via punycode.toASCII.

Tasks

  • Add tests for the ENS controller's reverse resolving functionality
  • Save punycode for ENS domains with Unicode characters (see also RFC 3492 and RFC 5891)
  • Update the confirm screen (screenshots below)
  • Update the transaction list details (screenshots below)

Confirm Screen Screenshots (SenderToRecipient)

Before, after, & tooltip

Transaction List Item Details (TransactionListItemDetails)

Before, after, & tooltip

Test addresses

I've registered peaksignal.eth for test purposes and have correctly configured it to enable reverse resolution.[4]

> const ENS = require('ethjs-ens')
undefined
> const HttpProvider = require('ethjs-provider-http')
undefined
> const provider = new HttpProvider('https://ropsten.infura.io')
undefined
> const ens = new ENS({ provider, network: '3' })
undefined
> await ens.lookup('peaksignal.eth')
'0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
undefined
> await ens.reverse('0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5')
'peaksignal.eth'

@whymarrh whymarrh force-pushed the ens-support-reverse-resolution branch 4 times, most recently from 74055a9 to 20b351e Compare September 18, 2019 23:14
@whymarrh whymarrh force-pushed the ens-support-reverse-resolution branch 5 times, most recently from bb7a388 to 1b094a5 Compare October 28, 2019 13:37
@whymarrh whymarrh marked this pull request as ready for review October 28, 2019 16:13
@whymarrh
Copy link
Contributor Author

This PR should be good to review now 😅

@whymarrh whymarrh force-pushed the ens-support-reverse-resolution branch 3 times, most recently from 09d32a0 to 8f5db5c Compare October 30, 2019 17:53
danjm
danjm previously approved these changes Oct 31, 2019
Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

QA'd and reviewed code. Tentatively approving in case the two comments I left don't require action. But if they require action, I'll approve again after they are addressed.

I think there are other place that we can show ENS names (on the send screen), but it may require design consideration. So we can handle those in another issue.

You may want to record a video of a demo of the feature implemented here for Bobby to review.

@danjm
Copy link
Contributor

danjm commented Oct 31, 2019

Recorded a video demo here: https://streamable.com/pevp4

app/scripts/controllers/ens/ens.js Outdated Show resolved Hide resolved
app/scripts/controllers/ens/index.js Outdated Show resolved Hide resolved
@@ -116,8 +142,8 @@ export default class SenderToRecipient extends PureComponent {
<span>{ addressOnly ? `${t('to')}: ` : '' }</span>
{
addressOnly
? checksummedRecipientAddress
: (recipientNickname || recipientName || this.context.t('newContract'))
? (recipientNickname || recipientEns || checksummedRecipientAddress)
Copy link
Member

Choose a reason for hiding this comment

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

Interesting; what is addressOnly supposed to do anyway? Using a nickname seems contrary to asking for the address to be used, but maybe I'm misunderstanding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressOnly is the flag passed to the component when this is rendered in the tx details

Copy link
Member

Choose a reason for hiding this comment

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

Right, but semantically what does it mean? "address only" implies to me that nicknames shouldn't be used, and you've just updated this to show the nickname in that case. If nicknames are desired, maybe the prop should be renamed? Or perhaps I'm misunderstanding the meaning.

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe the intended meaning was "no icons", in which case this is fine 🤔

@whymarrh
Copy link
Contributor Author

I think this is ready for another round of 👀

const domain = await this._ens.reverse(address)
const registeredAddress = await this._ens.lookup(domain)
if (registeredAddress === ZERO_ADDRESS || registeredAddress === ZERO_X_ERROR_ADDRESS) {
return undefined
Copy link
Member

@Gudahtt Gudahtt Oct 31, 2019

Choose a reason for hiding this comment

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

Nit: it would be nice to know what happened in these cases though - e.g. whether the address didn't resolve, or whether it did but it couldn't be verified, etc.

Maybe a log.debug statement would be appropriate in each of these cases? With something like the error messages you had before.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Looks good!

@whymarrh whymarrh merged commit eed4a9e into MetaMask:develop Nov 1, 2019
@whymarrh whymarrh deleted the ens-support-reverse-resolution branch November 1, 2019 17:54
tmashuang pushed a commit that referenced this pull request Nov 4, 2019
* ENS Reverse Resolution support
* Save punycode for ENS domains with Unicode characters
* Update SenderToRecipient recipientEns tooltip
* Use cached results when reverse-resolving ENS names
* Display ENS names in tx activity log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show ENS reverse-resolved names where addresses are used
3 participants