From 39944c4b1291690897004b6cff874d4f3bea104b Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 27 Jun 2024 08:58:27 -0700 Subject: [PATCH] feat(lens): throw error if apikey is not found --- packages/lens/src/validate.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/lens/src/validate.ts b/packages/lens/src/validate.ts index 5acd1dc6d..ae89be967 100644 --- a/packages/lens/src/validate.ts +++ b/packages/lens/src/validate.ts @@ -5,11 +5,8 @@ import { production, } from '@lens-protocol/client' import axios from 'axios' -import dotenv from 'dotenv' import { Address } from 'viem' -dotenv.config() - const lensClient = new LensClient({ environment: production, }) @@ -56,7 +53,10 @@ export async function checkAddressMintedCollect( ) { try { return await checkMintedUsingBlockspan(actor, collectAddress) - } catch { + } catch (err) { + if (err instanceof Error) { + console.error(err.message) + } return await checkMintedUsingReservoir(actor, collectAddress) } } @@ -65,6 +65,11 @@ async function checkMintedUsingBlockspan( actor: Address, collectAddress: Address, ) { + + if (!process.env.BLOCKSPAN_API_KEY) { + throw new Error('Blockspan API key not found') + } + const baseUrl = 'https://api.blockspan.com/v1/transfers/contract' const params = new URLSearchParams({ chain: 'poly-main',