diff --git a/src/fetchers/opensea.js b/src/fetchers/opensea.js index b030373..d8fbc39 100644 --- a/src/fetchers/opensea.js +++ b/src/fetchers/opensea.js @@ -170,31 +170,27 @@ const getOSData = async (api, chainId, contract, tokenId, slug) => { export const fetchCollection = async (chainId, { contract, tokenId }) => { try { - let data; - let creatorAddress; + let data = await getOSData("nft", chainId, contract, tokenId); + let creatorAddress = data?.creator; - if (chainId === 1) { - data = await getOSData("asset", chainId, contract, tokenId); - creatorAddress = data?.creator?.address; + if (data?.collection) { + data = await getOSData("collection", chainId, contract, tokenId, data.collection); + creatorAddress = creatorAddress ?? data?.creator?.address; } else { - data = await getOSData("nft", chainId, contract, tokenId); - creatorAddress = data?.creator; - - if (data?.collection) { - data = await getOSData("collection", chainId, contract, tokenId, data.collection); - creatorAddress = creatorAddress ?? data?.creator?.address; + if (chainId === 1) { + data = await getOSData("asset", chainId, contract, tokenId); } else { data = (await getOSData("events", chainId, contract, tokenId)) ?? (await getOSData("asset", chainId, contract, tokenId)); + } - // Get payment tokens if we have the collection slug - if (data?.collection?.slug && !data?.collection?.payment_tokens) { - data = await getOSData("collection", chainId, contract, tokenId, data.collection.slug); - } - - creatorAddress = data?.creator?.address; + // Get payment tokens if we have the collection slug + if (data?.collection?.slug && !data?.collection?.payment_tokens) { + data = await getOSData("collection", chainId, contract, tokenId, data.collection.slug); } + + creatorAddress = data?.creator?.address; } if (!data?.collection) {