Skip to content

Commit

Permalink
fix validateNftChain
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Sep 17, 2024
1 parent 9f837c7 commit 1ceebb8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pages/api/nft/collectors/[chain]/[address].ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CONTRACT_CALL_SUPPORTED_CHAINS } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft"
import { env } from "env"
import { NextApiHandler } from "next"
import { topCollectorsSupportedChains } from "pages/[guild]/collect/[chain]/[address]"
Expand Down Expand Up @@ -34,9 +35,11 @@ export const alchemyApiUrl: Record<
SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`,
}

// TODO: just use Zod.
export const validateNftChain = (value: string | string[]): Chain => {
const valueAsString = value?.toString()?.toUpperCase()
if (!value || !Object.keys(alchemyApiUrl).includes(valueAsString)) return null
if (!value || !CONTRACT_CALL_SUPPORTED_CHAINS.includes(valueAsString as any))
return null
return valueAsString as Chain
}
export const validateNftAddress = (value: string | string[]): `0x${string}` => {
Expand Down

0 comments on commit 1ceebb8

Please sign in to comment.