fix: add more null checks for trending collections gql query (#6164)

add more null checks for trending collections gql query

Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
This commit is contained in:
Charles Bachmeier 2023-03-15 17:30:01 -07:00 committed by GitHub
parent 5f64149f39
commit 0f8d3fa506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -68,20 +68,20 @@ export function useTrendingCollections(size: number, timePeriod: HistoryDuration
const collection = edge?.node
return {
name: collection.name,
address: collection.nftContracts?.[0].address,
address: collection.nftContracts?.[0]?.address,
imageUrl: collection.image?.url,
bannerImageUrl: collection.bannerImage?.url,
isVerified: collection.isVerified,
volume: collection.markets?.[0].volume?.value,
volumeChange: collection.markets?.[0].volumePercentChange?.value,
floor: collection.markets?.[0].floorPrice?.value,
floorChange: collection.markets?.[0].floorPricePercentChange?.value,
marketCap: collection.markets?.[0].totalVolume?.value,
volume: collection.markets?.[0]?.volume?.value,
volumeChange: collection.markets?.[0]?.volumePercentChange?.value,
floor: collection.markets?.[0]?.floorPrice?.value,
floorChange: collection.markets?.[0]?.floorPricePercentChange?.value,
marketCap: collection.markets?.[0]?.totalVolume?.value,
percentListed:
(collection.markets?.[0].listings?.value ?? 0) / (collection.nftContracts?.[0].totalSupply ?? 1),
owners: collection.markets?.[0].owners,
sales: collection.markets?.[0].sales?.value,
totalSupply: collection.nftContracts?.[0].totalSupply,
(collection.markets?.[0]?.listings?.value ?? 0) / (collection.nftContracts?.[0]?.totalSupply ?? 1),
owners: collection.markets?.[0]?.owners,
sales: collection.markets?.[0]?.sales?.value,
totalSupply: collection.nftContracts?.[0]?.totalSupply,
}
}),
[data?.topCollections?.edges]