Skip to content

Commit

Permalink
compatibility for nft collections
Browse files Browse the repository at this point in the history
  • Loading branch information
peripheralist committed Sep 5, 2023
1 parent 00fe140 commit 13e5465
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Loading from 'components/Loading'
import { Jb721DelegateTokensQuery } from 'generated/graphql'
import { NfTsQuery } from 'generated/graphql'
import { useJB721DelegateTokenToNftReward } from '../hooks/useJB721DelegateTokenToNftReward'
import { RedeemNftTile } from './RedeemNftTile'

export function RedeemNftTiles({
nftAccountBalance,
}: {
nftAccountBalance: Jb721DelegateTokensQuery | undefined
nftAccountBalance: NfTsQuery | undefined
}) {
return (
<div className="flex space-x-2.5 overflow-x-scroll">
{nftAccountBalance?.jb721DelegateTokens.map((nft, i) => {
{nftAccountBalance?.nfts.map((nft, i) => {
const tokenId = nft.tokenId.toHexString()
const _nft = {
...nft,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function RedeemNftsSection() {
accountAddress: userAddress,
dataSourceAddress: fundingCycleMetadata?.dataSource,
})
const hasRedeemableNfts = (data?.jb721DelegateTokens?.length ?? 0) > 0
const hasRedeemableNfts = (data?.nfts?.length ?? 0) > 0

if (loading || !hasRedeemableNfts || !userAddress) return null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {
NFT_METADATA_CONTRIBUTION_FLOOR_ATTRIBUTES_INDEX,
useJB721DelegateTokenMetadata,
} from 'components/v2v3/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftCard'
import { Jb721DelegateToken } from 'generated/graphql'
import { Nft } from 'generated/graphql'
import { NftRewardTier } from 'models/nftRewards'
import { UseQueryResult } from 'react-query'

export type RedeemingNft = Pick<Jb721DelegateToken, 'address' | 'tokenUri'> & {
export type RedeemingNft = Pick<Nft, 'tokenUri'> & {
tokenId: string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function ManageNftsSection() {
dataSourceAddress: fundingCycleMetadata?.dataSource,
})

const nftBalanceFormatted = data?.jb721DelegateTokens.length ?? 0
const nftBalanceFormatted = data?.nfts.length ?? 0
const nftRedeemAllowed =
fundingCycleMetadata?.useDataSourceForRedeem && nftBalanceFormatted > 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ export function RedeemNftsModal({
}
}

const jb721DelegateTokens = data?.jb721DelegateTokens.map(t => ({
const nfts = data?.nfts.map(t => ({
...t,
tokenId: t.tokenId.toHexString(),
}))
const nftBalanceFormatted = jb721DelegateTokens?.length ?? 0
const nftBalanceFormatted = nfts?.length ?? 0
const hasOverflow = primaryTerminalCurrentOverflow?.gt(0)
const hasRedemptionRate = fundingCycleMetadata.redemptionRate.gt(0)
const canRedeem = hasOverflow && hasRedemptionRate
Expand Down Expand Up @@ -213,7 +213,7 @@ export function RedeemNftsModal({
<Form form={form} layout="vertical">
<Form.Item label={t`Select NFTs to redeem`}>
<Row gutter={[20, 20]}>
{jb721DelegateTokens?.map(nft => {
{nfts?.map(nft => {
const isSelected = tokenIdsToRedeem.includes(nft.tokenId)
return (
<Col span={8} key={nft.tokenId}>
Expand Down
7 changes: 0 additions & 7 deletions src/graphql/jb721DelegateTokens/jb721DelegateTokens.graphql

This file was deleted.

9 changes: 9 additions & 0 deletions src/graphql/nfts/nfts.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
query NFTs($where: NFT_filter) {
nfts(where: $where) {
tokenId
collection {
address
}
tokenUri
}
}
8 changes: 5 additions & 3 deletions src/hooks/JB721Delegate/useNftAccountBalance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useJb721DelegateTokensQuery } from 'generated/graphql'
import { useNfTsQuery } from 'generated/graphql'
import { client } from 'lib/apollo/client'

/**
Expand All @@ -11,11 +11,13 @@ export function useNftAccountBalance({
dataSourceAddress: string | undefined
accountAddress: string | undefined
}) {
return useJb721DelegateTokensQuery({
return useNfTsQuery({
client,
variables: {
where: {
...(dataSourceAddress ? { address: dataSourceAddress } : {}),
...(dataSourceAddress
? { collection_: { address: dataSourceAddress } }
: {}),
...(accountAddress ? { owner_: { wallet: accountAddress } } : {}),
},
},
Expand Down

0 comments on commit 13e5465

Please sign in to comment.