Skip to content

Commit

Permalink
Look for UNS name before ENS
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Nov 21, 2023
1 parent 4296b46 commit 7e2103b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/hooks/useAddressInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
throttledFetchEnsAvatar,
throttledFetchEnsName,
throttledFetchUnsAddress,
throttledFetchUnsName,
} from "../helpers";
import { useXmtpStore } from "../store/xmtp";

Expand Down Expand Up @@ -43,11 +44,17 @@ export const useAddressInput = () => {
// no name
if (!recipientName) {
setRecipientState("loading");
// check for name
const name = await throttledFetchEnsName({
address: recipientAddress,
});
setRecipientName(name);
// check for UNS name
const unsName = await throttledFetchUnsName(recipientAddress);
if (unsName) {
setRecipientName(unsName);
} else {
// check for ENS name
const ensName = await throttledFetchEnsName({
address: recipientAddress,
});
setRecipientName(ensName);
}
}
} catch (e) {
console.error(e);
Expand Down

0 comments on commit 7e2103b

Please sign in to comment.