Skip to content

Commit dc587fd

Browse files
authoredApr 15, 2024
fix: filter expired ens names (#15)
1 parent f66cfc4 commit dc587fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎apps/website/lib/hooks/web3/use-nfts-for-owner.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ENS_CONTRACT_ADDRESS } from "@/data/constants"
12
import { env } from "@/env.mjs"
23
import { useQuery } from "@tanstack/react-query"
34
import { type Address } from "viem"
@@ -9,7 +10,7 @@ export interface Nft {
910
imageUrl?: string | null
1011
contract: {
1112
address: Address
12-
name: string
13+
name: string | null
1314
symbol: string
1415
totalSupply: number | null
1516
tokenType: "ERC721" | "ERC1155" | "UNKNOWN"
@@ -116,6 +117,13 @@ export function useNftsForOwner({ owner, contractAddresses, chainId }: Params) {
116117
)
117118
const allNfts = responses
118119
.flatMap((response) => response)
120+
// Filters out ENS names that doesn't have a `name` property,
121+
// Meaning they have expired
122+
.filter(
123+
({ name, contract }) =>
124+
contract?.address !== ENS_CONTRACT_ADDRESS ||
125+
(contract?.address === ENS_CONTRACT_ADDRESS && name !== null)
126+
)
119127
.map((nft) => ({
120128
...nft,
121129
// Adds a convenience property that gets fallback image from the NFT metadata

0 commit comments

Comments
 (0)