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

Commit

Permalink
feat: added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nofir committed Aug 11, 2023
1 parent 9ab0b00 commit 2397a58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
43 changes: 13 additions & 30 deletions src/fetchers/opensea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/shared/utils.js
Original file line number Diff line number Diff line change
@@ -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);
};

Expand Down

0 comments on commit 2397a58

Please sign in to comment.