Skip to content

Commit

Permalink
fix: filter expired ens names (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
marthendalnunes authored Apr 15, 2024
1 parent f66cfc4 commit dc587fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/website/lib/hooks/web3/use-nfts-for-owner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ENS_CONTRACT_ADDRESS } from "@/data/constants"
import { env } from "@/env.mjs"
import { useQuery } from "@tanstack/react-query"
import { type Address } from "viem"
Expand All @@ -9,7 +10,7 @@ export interface Nft {
imageUrl?: string | null
contract: {
address: Address
name: string
name: string | null
symbol: string
totalSupply: number | null
tokenType: "ERC721" | "ERC1155" | "UNKNOWN"
Expand Down Expand Up @@ -116,6 +117,13 @@ export function useNftsForOwner({ owner, contractAddresses, chainId }: Params) {
)
const allNfts = responses
.flatMap((response) => response)
// Filters out ENS names that doesn't have a `name` property,
// Meaning they have expired
.filter(
({ name, contract }) =>
contract?.address !== ENS_CONTRACT_ADDRESS ||
(contract?.address === ENS_CONTRACT_ADDRESS && name !== null)
)
.map((nft) => ({
...nft,
// Adds a convenience property that gets fallback image from the NFT metadata
Expand Down

0 comments on commit dc587fd

Please sign in to comment.