we did this at rainbow. take a look here https://github.com/rainbow-me/rainbow/blob/develop/src/helpers/ens.ts
I did not realize Rainbow made this Open Source, damn appreciate you linking this, I was actually inspired by Rainbow so cool to see the source now