From 8cf97ca031b14baa20b7765aa2791ad54bae83d4 Mon Sep 17 00:00:00 2001 From: d3or Date: Thu, 31 Aug 2023 12:41:18 -0400 Subject: [PATCH 1/2] feat: remove console logs --- src/shared/utils.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/utils.js b/src/shared/utils.js index 7360aa5..186c948 100644 --- a/src/shared/utils.js +++ b/src/shared/utils.js @@ -121,7 +121,6 @@ export const normalizeMetadata = (collection) => { let metadata = {}; if (collection?.social_urls) { Object.keys(collection.social_urls).forEach((key) => { - console.log(key, map); if (key in map) { if (map[key].normalize) { metadata[map[key].key] = map[key].normalize(collection.social_urls[key]); @@ -134,7 +133,6 @@ export const normalizeMetadata = (collection) => { // do the above via the map Object.keys(map).forEach((key) => { - console.log(key, map, collection); if (key in collection) { if (map[key].normalize) { metadata[map[key].key] = map[key].normalize(collection[key]); From 4741f0bb46ae9987b131bd28a5363db60e5d5f71 Mon Sep 17 00:00:00 2001 From: nofir Date: Thu, 31 Aug 2023 19:36:13 -0400 Subject: [PATCH 2/2] feat: added test nets --- src/fetchers/opensea.js | 48 ++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/fetchers/opensea.js b/src/fetchers/opensea.js index dcba2f9..7080664 100644 --- a/src/fetchers/opensea.js +++ b/src/fetchers/opensea.js @@ -37,12 +37,28 @@ const getOSNetworkName = (chainId) => { return "base"; case 7777777: return "zora"; + case 11155111: + return "sepolia"; + case 80001: + return "mumbai"; + case 84531: + return "base_goerli"; + case 999: + return "zora_testnet"; + case 324: + return "zksync"; } }; +const getOSTestNetsChainIds = () => { + return [4, 5, 11155111, 80001, 84531, 999]; +}; + const getUrlForApi = (api, chainId, contract, tokenId, network, slug) => { const baseUrl = `${ - ![4, 5].includes(chainId) ? "https://api.opensea.io" : "https://testnets-api.opensea.io" + !getOSTestNetsChainIds().includes(chainId) + ? "https://api.opensea.io" + : "https://testnets-api.opensea.io" }`; switch (api) { @@ -64,7 +80,7 @@ const getUrlForApi = (api, chainId, contract, tokenId, network, slug) => { const getOSData = async (api, chainId, contract, tokenId, slug) => { const network = getOSNetworkName(chainId); const url = getUrlForApi(api, chainId, contract, tokenId, network, slug); - const headers = ![4, 5].includes(chainId) + const headers = !getOSTestNetsChainIds().includes(chainId) ? { url, "X-API-KEY": apiKey, @@ -76,7 +92,7 @@ const getOSData = async (api, chainId, contract, tokenId, slug) => { try { const osResponse = await axios.get( - ![4, 5].includes(chainId) ? process.env.OPENSEA_BASE_URL_ALT || url : url, + !getOSTestNetsChainIds().includes(chainId) ? process.env.OPENSEA_BASE_URL_ALT || url : url, { headers } ); @@ -148,19 +164,6 @@ export const fetchCollection = async (chainId, { contract, tokenId }) => { let data; let creatorAddress; - if (chainId === 43114) { - logger.info( - "opensea-fetcher", - JSON.stringify({ - topic: "fetchCollectionDebug", - message: `Collection metadata start. contract=${contract}, tokenId=${tokenId}`, - contract, - tokenId, - data, - }) - ); - } - if (chainId === 1) { data = await getOSData("asset", chainId, contract, tokenId); creatorAddress = data?.creator?.address; @@ -185,19 +188,6 @@ export const fetchCollection = async (chainId, { contract, tokenId }) => { } } - if (chainId === 43114) { - logger.info( - "opensea-fetcher", - JSON.stringify({ - topic: "fetchCollectionDebug", - message: `Collection metadata debug. contract=${contract}, tokenId=${tokenId}`, - contract, - tokenId, - data, - }) - ); - } - if (!data?.collection) { throw new Error("Missing collection"); }