fix: Adds some null checks to Asset gql query (#5058)
* add some null checks * undo susflag change * fix not for sale logic * fix rarity * fix rarity format * remove logging Co-authored-by: Charles Bachmeier <charlie@genie.xyz>
This commit is contained in:
parent
d3cbcc769c
commit
734a15e350
@ -1,6 +1,6 @@
|
||||
import graphql from 'babel-plugin-relay/macro'
|
||||
import { parseEther } from 'ethers/lib/utils'
|
||||
import { GenieAsset } from 'nft/types'
|
||||
import { GenieAsset, Rarity } from 'nft/types'
|
||||
import { loadQuery, usePaginationFragment, usePreloadedQuery } from 'react-relay'
|
||||
|
||||
import RelayEnvironment from '../RelayEnvironment'
|
||||
@ -135,16 +135,16 @@ export function useAssetsQuery(
|
||||
|
||||
const assets: GenieAsset[] = data.nftAssets?.edges?.map((queryAsset: { node: any }) => {
|
||||
const asset = queryAsset.node
|
||||
const ethPrice = parseEther(asset.listings?.edges[0].node.price.value?.toString() ?? '0').toString()
|
||||
const ethPrice = parseEther(asset.listings?.edges[0]?.node.price.value?.toString() ?? '0').toString()
|
||||
return {
|
||||
id: asset.id,
|
||||
address: asset.collection.nftContracts[0].address,
|
||||
notForSale: asset.listings === null,
|
||||
address: asset.collection.nftContracts[0]?.address,
|
||||
notForSale: asset.listings?.edges.length === 0,
|
||||
collectionName: asset.collection?.name,
|
||||
collectionSymbol: asset.collection?.image?.url,
|
||||
imageUrl: asset.image?.url,
|
||||
animationUrl: asset.animationUrl,
|
||||
marketplace: asset.listings?.edges[0].node.marketplace.toLowerCase(),
|
||||
marketplace: asset.listings?.edges[0]?.node.marketplace.toLowerCase(),
|
||||
name: asset.name,
|
||||
priceInfo: asset.listings
|
||||
? {
|
||||
@ -158,12 +158,17 @@ export function useAssetsQuery(
|
||||
sellorders: asset.listings?.edges,
|
||||
smallImageUrl: asset.smallImage?.url,
|
||||
tokenId: asset.tokenId,
|
||||
tokenType: asset.collection.nftContracts[0].standard,
|
||||
tokenType: asset.collection.nftContracts[0]?.standard,
|
||||
// totalCount?: number, // TODO waiting for BE changes
|
||||
collectionIsVerified: asset.collection?.isVerified,
|
||||
rarity: {
|
||||
primaryProvider: 'Rarity Sniper', // TODO update when backend adds more providers
|
||||
providers: asset.rarities,
|
||||
providers: asset.rarities.map((rarity: Rarity) => {
|
||||
return {
|
||||
...rarity,
|
||||
provider: 'Rarity Sniper',
|
||||
}
|
||||
}),
|
||||
},
|
||||
owner: asset.ownerAddress,
|
||||
creator: {
|
||||
|
Loading…
Reference in New Issue
Block a user