From 854e31ddfd9003719de1dfcfac440fb218048de5 Mon Sep 17 00:00:00 2001
From: peripheralist <79433522+peripheralist@users.noreply.github.com>
Date: Tue, 12 Sep 2023 17:34:56 -0400
Subject: [PATCH] [DO NOT MERGE] Compatibility for subgraph nft collections
(#4053)
---
.../NftRewardsPanel/RedeemNftsSection/RedeemNftTiles.tsx | 6 +++---
.../RedeemNftsSection/RedeemNftsSection.tsx | 2 +-
.../hooks/useJB721DelegateTokenToNftReward.ts | 4 ++--
.../V2V3Project/ManageNftsSection/ManageNftsSection.tsx | 2 +-
.../RedeemNftsModal/RedeemNftsModal.tsx | 6 +++---
.../jb721DelegateTokens/jb721DelegateTokens.graphql | 7 -------
src/graphql/nfts/nfts.graphql | 9 +++++++++
src/hooks/JB721Delegate/useNftAccountBalance.ts | 8 +++++---
8 files changed, 24 insertions(+), 20 deletions(-)
delete mode 100644 src/graphql/jb721DelegateTokens/jb721DelegateTokens.graphql
create mode 100644 src/graphql/nfts/nfts.graphql
diff --git a/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftTiles.tsx b/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftTiles.tsx
index 3732237b54..c0636439f6 100644
--- a/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftTiles.tsx
+++ b/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftTiles.tsx
@@ -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 (
- {nftAccountBalance?.jb721DelegateTokens.map((nft, i) => {
+ {nftAccountBalance?.nfts.map((nft, i) => {
const tokenId = nft.tokenId.toHexString()
const _nft = {
...nft,
diff --git a/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx b/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx
index cc42262bee..027709e2db 100644
--- a/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx
+++ b/src/components/ProjectDashboard/components/NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx
@@ -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
diff --git a/src/components/ProjectDashboard/components/NftRewardsPanel/hooks/useJB721DelegateTokenToNftReward.ts b/src/components/ProjectDashboard/components/NftRewardsPanel/hooks/useJB721DelegateTokenToNftReward.ts
index 3ab9895864..6562375e53 100644
--- a/src/components/ProjectDashboard/components/NftRewardsPanel/hooks/useJB721DelegateTokenToNftReward.ts
+++ b/src/components/ProjectDashboard/components/NftRewardsPanel/hooks/useJB721DelegateTokenToNftReward.ts
@@ -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 & {
+export type RedeemingNft = Pick & {
tokenId: string
}
diff --git a/src/components/v2v3/V2V3Project/ManageNftsSection/ManageNftsSection.tsx b/src/components/v2v3/V2V3Project/ManageNftsSection/ManageNftsSection.tsx
index b3a803deec..dfbcb1e540 100644
--- a/src/components/v2v3/V2V3Project/ManageNftsSection/ManageNftsSection.tsx
+++ b/src/components/v2v3/V2V3Project/ManageNftsSection/ManageNftsSection.tsx
@@ -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
diff --git a/src/components/v2v3/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftsModal.tsx b/src/components/v2v3/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftsModal.tsx
index 7245119d90..06d76bc534 100644
--- a/src/components/v2v3/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftsModal.tsx
+++ b/src/components/v2v3/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftsModal.tsx
@@ -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
@@ -213,7 +213,7 @@ export function RedeemNftsModal({
- {jb721DelegateTokens?.map(nft => {
+ {nfts?.map(nft => {
const isSelected = tokenIdsToRedeem.includes(nft.tokenId)
return (
diff --git a/src/graphql/jb721DelegateTokens/jb721DelegateTokens.graphql b/src/graphql/jb721DelegateTokens/jb721DelegateTokens.graphql
deleted file mode 100644
index f1ba8e59b5..0000000000
--- a/src/graphql/jb721DelegateTokens/jb721DelegateTokens.graphql
+++ /dev/null
@@ -1,7 +0,0 @@
-query JB721DelegateTokens($where: JB721DelegateToken_filter) {
- jb721DelegateTokens(where: $where) {
- tokenId
- address
- tokenUri
- }
-}
diff --git a/src/graphql/nfts/nfts.graphql b/src/graphql/nfts/nfts.graphql
new file mode 100644
index 0000000000..0045d652fa
--- /dev/null
+++ b/src/graphql/nfts/nfts.graphql
@@ -0,0 +1,9 @@
+query NFTs($where: NFT_filter) {
+ nfts(where: $where) {
+ tokenId
+ collection {
+ address
+ }
+ tokenUri
+ }
+}
diff --git a/src/hooks/JB721Delegate/useNftAccountBalance.ts b/src/hooks/JB721Delegate/useNftAccountBalance.ts
index 2757ca11cf..7dce0ce200 100644
--- a/src/hooks/JB721Delegate/useNftAccountBalance.ts
+++ b/src/hooks/JB721Delegate/useNftAccountBalance.ts
@@ -1,4 +1,4 @@
-import { useJb721DelegateTokensQuery } from 'generated/graphql'
+import { useNfTsQuery } from 'generated/graphql'
import { client } from 'lib/apollo/client'
/**
@@ -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 } } : {}),
},
},