From 2397a587e6b0cde57432ef5f613425fd4d6a6038 Mon Sep 17 00:00:00 2001 From: nofir Date: Fri, 11 Aug 2023 13:26:56 -0400 Subject: [PATCH] feat: added logs --- src/fetchers/opensea.js | 43 +++++++++++++---------------------------- src/shared/utils.js | 6 ++++++ 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/fetchers/opensea.js b/src/fetchers/opensea.js index 20c1f052..995e17af 100644 --- a/src/fetchers/opensea.js +++ b/src/fetchers/opensea.js @@ -148,6 +148,19 @@ 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; @@ -269,36 +282,6 @@ export const fetchCollection = async (chainId, { contract, tokenId }) => { }) ); - if (chainId === 43114) { - try { - const tokens = await fetchTokensOnChain(chainId, [{ contract, tokenId }]); - - logger.info( - "opensea-fetcher", - JSON.stringify({ - topic: "fetchTokensOnChainDebug", - message: `fetchTokensOnChain debug. chainId=${chainId}, contract=${contract}, tokenId=${tokenId}`, - chainId, - contract, - tokenId, - tokens, - }) - ); - } catch (error) { - logger.error( - "opensea-fetcher", - JSON.stringify({ - topic: "fetchTokensOnChainError", - message: `fetchTokensOnChain error. chainId=${chainId}, contract=${contract}, tokenId=${tokenId}, error=${error.message}`, - chainId, - contract, - tokenId, - error, - }) - ); - } - } - let name = contract; try { name = await new Contract( diff --git a/src/shared/utils.js b/src/shared/utils.js index f1bbe4ad..9dc4cad1 100644 --- a/src/shared/utils.js +++ b/src/shared/utils.js @@ -1,6 +1,12 @@ import { providers } from "ethers"; +import _ from "lodash"; export const getProvider = (chainId) => { + if (chainId === 43114) { + const network = _.upperCase(supportedChains[chainId]).replace(" ", "_"); + return new providers.JsonRpcProvider(process.env[`RPC_URL_${network}`]); + } + return new providers.AlchemyProvider(chainId, process.env.ALCHEMY_API_KEY); };