Page MenuHomePhabricator

[lib] Introduce ENSCache with getNameForAddress function
ClosedPublic

Authored by ashoat on Jan 13 2023, 1:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 15, 2:53 AM
Unknown Object (File)
Thu, Jun 13, 2:25 AM
Unknown Object (File)
Thu, Jun 13, 12:46 AM
Unknown Object (File)
Wed, Jun 12, 5:14 AM
Unknown Object (File)
Sat, Jun 1, 6:36 PM
Unknown Object (File)
Sat, Jun 1, 6:36 PM
Unknown Object (File)
Sat, Jun 1, 8:38 AM
Unknown Object (File)
Sat, Jun 1, 8:38 AM
Subscribers

Details

Summary

This is the beginning of addressing this Linear task: ENG-2588

We'll also need a way to query for forward resolution, but that will come in a separate diff.

Depends on D6263

Test Plan
ALCHEMY_API_KEY=alchemykeygoeshere yarn test utils/ens-cache.test.js

Two notes on the test plan:

  1. I originally wanted test cases for an ETH name that wasn't normalized and for a reverse resolution that didn't have a matching forward resolution, but I couldn't find anything in the wild. I found non-normalized ETH names but none of them had a reverse resolution set, and I didn't find any reverse resolutions without matching forward resolutions. I could construct these myself but it would probably require hitting some APIs directly or something, since I'm guessing ENS doesn't want you doing these things. Probably not worth it.
  2. The tests require ALCHEMY_API_KEY, otherwise they are silently ignored. This diff adds that environmental to GitHub Actions, but the tests will get ignored when run in precommit hooks and in Buildkite. Discussing with Atul about potentially making it work on Buildkite, but my impression is that it might not be worth the time.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Add ALCHEMY_API_KEY to GitHub Actions CI

Note: after landing, I should confirm GitHub Actions CI is actually running my test by checking the log

lib/utils/ens-cache.js
12–22 ↗(On Diff #20956)

Nit: I should move these types above the comment

Looks good. Both comments are super minor, feel free to ignore/land as-is.

lib/utils/ens-cache.js
12–13 ↗(On Diff #20960)

Wonder if lowercasedETHAddress would be clearer for future readers instead of having to jump here to figure out what "normalized" means in this context?

But also normalized prefix is symmetrical with normalizedENSName below?

Don't feel strongly, whatever you prefer

lib/utils/ens-cache.test.js
20–49 ↗(On Diff #20960)

Might be missing something, but could we move the log inside the describe block and also early return before the it blocks?

This revision is now accepted and ready to land.Jan 18 2023, 7:18 PM
lib/utils/ens-cache.js
12–13 ↗(On Diff #20960)

Yeah was prioritizing consistency, figure the comment clarifies it

lib/utils/ens-cache.test.js
20–49 ↗(On Diff #20960)

Tried this, it doesn't work because Jest fails if no tests are defined:

Your test suite must contain at least one test.