diff --git a/src/components/AddressInputPanel/index.js b/src/components/AddressInputPanel/index.js index 85016d308c..f1561638da 100644 --- a/src/components/AddressInputPanel/index.js +++ b/src/components/AddressInputPanel/index.js @@ -93,9 +93,8 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = let stale = false if (isAddress(debouncedInput)) { - library - .lookupAddress(debouncedInput) - .then(name => { + try { + library.lookupAddress(debouncedInput).then(name => { if (!stale) { // if an ENS name exists, set it as the destination if (name) { @@ -106,15 +105,14 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = } } }) - .catch(() => { - setData({ address: debouncedInput, name: '' }) - setError(null) - }) + } catch { + setData({ address: debouncedInput, name: '' }) + setError(null) + } } else { if (debouncedInput !== '') { - library - .resolveName(debouncedInput) - .then(address => { + try { + library.resolveName(debouncedInput).then(address => { if (!stale) { // if the debounced input name resolves to an address if (address) { @@ -125,9 +123,9 @@ export default function AddressInputPanel({ title, initialInput = '', onChange = } } }) - .catch(() => { - setError(true) - }) + } catch { + setError(true) + } } } diff --git a/src/hooks/index.js b/src/hooks/index.js index 7ba2fb6a21..06f6c42e82 100644 --- a/src/hooks/index.js +++ b/src/hooks/index.js @@ -58,9 +58,8 @@ export function useENSName(address) { useEffect(() => { if (isAddress(address)) { let stale = false - library - .lookupAddress(address) - .then(name => { + try { + library.lookupAddress(address).then(name => { if (!stale) { if (name) { setENSNname(name) @@ -69,11 +68,11 @@ export function useENSName(address) { } } }) - .catch(() => { - if (!stale) { - setENSNname(null) - } - }) + } catch { + if (!stale) { + setENSNname(null) + } + } return () => { stale = true