Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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](https://user-images.githubusercontent.com/81330305/124678076-2161a080-dec2-11eb-8b98-d2382ef11a89.png)
![memefactory_02](https://user-images.githubusercontent.com/81330305/124678067-1d358300-dec2-11eb-9c5c-b4f847bcc38d.png)
![memefactory_03](https://user-images.githubusercontent.com/81330305/124678072-1f97dd00-dec2-11eb-9569-84b9a601d9af.png)
![memefactory_04](https://user-images.githubusercontent.com/81330305/124678070-1dce1980-dec2-11eb-81d6-a5521ddaa63c.png)
![memefactory_05](https://user-images.githubusercontent.com/81330305/124678074-20307380-dec2-11eb-844b-588229c9c16b.png)
![memefactory_06](https://user-images.githubusercontent.com/81330305/124678069-1dce1980-dec2-11eb-9e06-895bc2d48366.png)
![memefactory_07](https://user-images.githubusercontent.com/81330305/124678064-1c9cec80-dec2-11eb-94db-d4ced420eb43.png)
![memefactory_08](https://user-images.githubusercontent.com/81330305/124678063-1b6bbf80-dec2-11eb-8582-4a44dac7bafe.png)