Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #238 from reservoirprotocol/ofir/platf-2304-refres…
Browse files Browse the repository at this point in the history
…h-collection-timeout

feat: updated os api flow
  • Loading branch information
nofir authored Sep 21, 2023
2 parents ce87476 + 6c75a62 commit feab054
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/fetchers/opensea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit feab054

Please sign in to comment.