Commit 8d0b8e32 authored by Noah Zinsmeister's avatar Noah Zinsmeister Committed by GitHub

fix ens name typing bug (#378)

* fix ens typing error handling
parent 66604cf4
...@@ -93,9 +93,8 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = ...@@ -93,9 +93,8 @@ export default function AddressInputPanel({ title, initialInput = '', onChange =
let stale = false let stale = false
if (isAddress(debouncedInput)) { if (isAddress(debouncedInput)) {
library try {
.lookupAddress(debouncedInput) library.lookupAddress(debouncedInput).then(name => {
.then(name => {
if (!stale) { if (!stale) {
// if an ENS name exists, set it as the destination // if an ENS name exists, set it as the destination
if (name) { if (name) {
...@@ -106,15 +105,14 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = ...@@ -106,15 +105,14 @@ export default function AddressInputPanel({ title, initialInput = '', onChange =
} }
} }
}) })
.catch(() => { } catch {
setData({ address: debouncedInput, name: '' }) setData({ address: debouncedInput, name: '' })
setError(null) setError(null)
}) }
} else { } else {
if (debouncedInput !== '') { if (debouncedInput !== '') {
library try {
.resolveName(debouncedInput) library.resolveName(debouncedInput).then(address => {
.then(address => {
if (!stale) { if (!stale) {
// if the debounced input name resolves to an address // if the debounced input name resolves to an address
if (address) { if (address) {
...@@ -125,9 +123,9 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = ...@@ -125,9 +123,9 @@ export default function AddressInputPanel({ title, initialInput = '', onChange =
} }
} }
}) })
.catch(() => { } catch {
setError(true) setError(true)
}) }
} }
} }
......
...@@ -58,9 +58,8 @@ export function useENSName(address) { ...@@ -58,9 +58,8 @@ export function useENSName(address) {
useEffect(() => { useEffect(() => {
if (isAddress(address)) { if (isAddress(address)) {
let stale = false let stale = false
library try {
.lookupAddress(address) library.lookupAddress(address).then(name => {
.then(name => {
if (!stale) { if (!stale) {
if (name) { if (name) {
setENSNname(name) setENSNname(name)
...@@ -69,11 +68,11 @@ export function useENSName(address) { ...@@ -69,11 +68,11 @@ export function useENSName(address) {
} }
} }
}) })
.catch(() => { } catch {
if (!stale) { if (!stale) {
setENSNname(null) setENSNname(null)
} }
}) }
return () => { return () => {
stale = true stale = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment