Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update : fetch nft using symbol #154

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions components/UserNFTs.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Connection, PublicKey } from '@solana/web3.js';
import { Metaplex } from '@metaplex-foundation/js';

const COLLECTION_IDS = {
DL_NFT: '5FusHaKEKjfKsmQwXNrhFcFABGGxu7iYCdbvyVSRe3Ri',
SOLANA_MONKEY_BUSINESS_GEN2: 'SMBtHCCC6RYRutFEPb4gZqeBLUZbMNhRKaMKZZLHi7W',
SOLANA_MONKEY_BUSINESS_GEN3: '8Rt3Ayqth4DAiPnW9MDFi63TiQJHmohfTWLMQFHi4KZH',
SHARKX: '5f2PvbmKd9pRLjKdMr8nrK8fNisLi7irjB6X5gopnKpB',
Superteam_Member_NFT :'5sDBuHZ7zDzZ2Px1YQS3ELxoFja5J66vpKKcW84ndRk7'
};
const ALLOWED_SYMBOLS = ['SMB', 'sharx', '$TEAM','DEAN', 'SMB Gen3', "EVPN"];

const fetchUserNFTs = async (userAddress: string, chainSymbol: string) => {
if (!userAddress) {
Expand Down Expand Up @@ -38,11 +32,7 @@ const fetchUserNFTs = async (userAddress: string, chainSymbol: string) => {
console.log('All user NFTs:', userNFTs);

const filteredNFTs = userNFTs.filter(nft =>
nft.collection?.address.toString() === COLLECTION_IDS.DL_NFT ||
nft.collection?.address.toString() === COLLECTION_IDS.SOLANA_MONKEY_BUSINESS_GEN2 ||
nft.collection?.address.toString() === COLLECTION_IDS.SOLANA_MONKEY_BUSINESS_GEN3 ||
nft.collection?.address.toString() === COLLECTION_IDS.SHARKX ||
nft.collection?.address.toString() === COLLECTION_IDS.Superteam_Member_NFT
ALLOWED_SYMBOLS.includes(nft.symbol)
).map(nft => ({
amount: 1,
current_token_data: {
Expand All @@ -54,10 +44,11 @@ const fetchUserNFTs = async (userAddress: string, chainSymbol: string) => {
cdn_image_uri: nft.json?.image || '',
},
collection: nft.collection?.address.toString(),
symbol: nft.symbol,
},
}));

console.log('Filtered NFTs from specified collections:', filteredNFTs);
console.log('Filtered NFTs with specified symbols:', filteredNFTs);

return filteredNFTs;
} else {
Expand Down