Skip to content

Commit

Permalink
fix: normalize throws an error for disallowed characters (#1866)
Browse files Browse the repository at this point in the history
* fix: normalize throws error

* chore: tweak changeset

* chore: tweak changeset

* chore: return undefined if normalize fails

* chore: small changeset tweak

---------

Co-authored-by: Magomed Khamidov <53529533+KosmosKey@users.noreply.github.com>
Co-authored-by: Daniel Sinclair <d@niel.nyc>
  • Loading branch information
3 people committed Mar 20, 2024
1 parent c837995 commit 985b80b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fair-pandas-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rainbow-me/rainbowkit": patch
---

Resolved an issue where ENS resolution would fail and throw an error for ENS names with disallowed characters.
10 changes: 9 additions & 1 deletion packages/rainbowkit/src/hooks/useMainnetEnsAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import { useIsMainnetConfigured } from './useIsMainnetConfigured';
export function useMainnetEnsAvatar(name: GetEnsNameReturnType | undefined) {
const mainnetConfigured = useIsMainnetConfigured();

const safeNormalize = (ensName: string) => {
try {
return normalize(ensName);
} catch {
/* ignore */
}
};

const { data: ensAvatar } = useEnsAvatar({
chainId: mainnet.id,
name: name ? normalize(name) : undefined,
name: name ? safeNormalize(name) : undefined,
query: {
enabled: mainnetConfigured,
},
Expand Down

0 comments on commit 985b80b

Please sign in to comment.