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 integration #707

Merged
merged 1 commit into from
Jul 8, 2021
Merged

ENS integration #707

merged 1 commit into from
Jul 8, 2021

Conversation

ginesdt
Copy link
Contributor

@ginesdt ginesdt commented Jul 6, 2021

Summary

ENS integration as described in #700
This implementation allows ENS reverse resolution from addresses to names.
The implementation has been done entirely in ClojureScript, and it does not require or depend on any external JS libraries.
To do a reverse look-up, we firstly query the ENS Registry to fetch the Resolver associated to the given address. Then, query the obtained Resolver to get the name associated to the address. Additionally, we need to perform a forward lookup with the obtained name to validate the name is actually matching the address. We use re-frame subscriptions to trigger the look-up and update the UI once the name has been resolved.

Design decisions
Addresses are shown in a variety of places (titles, tooltips, links, etc.), so the idea was to create the component as generic as possible to be reusable everywhere. Even though the challenge suggests to use the lifecycle method :component-did-mount to dispatch the re-frame event to fetch ENS name, this is discouraged from the official re-frame documentation for similar use cases. (https://github.com/day8/re-frame/blob/master/docs/Subscribing-To-External-Data.md)
Thus, I triggering the dispatch inside the subscription handler using reg-sub-raw instead, which allow more flexibility to be integrated in the different places.

Usage would be as simple as:
@(subscribe [::ens/ens-name my-address])
to get the domain name of my-address. This both triggers the resolution event and gets updated with the domain name once resolved.
Or even more simple, you can use the short way:
(ens/reverse-resolve my-address)
which will show the original address until the name is resolved, and automatically updated if succedded.

Review notes

Testing notes

Screenshots of the integration in required places
memefactory_01
memefactory_02
memefactory_03
memefactory_04
memefactory_05
memefactory_06
memefactory_07
memefactory_08

@madvas madvas merged commit d69ed1a into district0x:master Jul 8, 2021
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.

2 participants