Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

feat: add Zora API key to constants for integration with Zora services

yoginth.com dff4bb3c d16dc17a

verified
+35 -11
+18 -4
apps/web/src/components/Account/CreatorCoin/Trade.tsx
··· 35 35 () => createPublicClient({ chain: base, transport: http() }), 36 36 [] 37 37 ); 38 - const handleWrongNetwork = useHandleWrongNetwork({ chainId: base.id }); 38 + const handleWrongNetwork = useHandleWrongNetwork(); 39 39 40 40 const [mode, setMode] = useState<Mode>("buy"); 41 41 const [amount, setAmount] = useState(""); ··· 107 107 }; 108 108 109 109 const handleSubmit = async () => { 110 - if (!publicClient || !address) { 110 + console.log(publicClient); 111 + if (!address) { 111 112 return toast.error("Connect a wallet to trade"); 112 113 } 113 114 ··· 116 117 117 118 try { 118 119 setLoading(true); 119 - await handleWrongNetwork(); 120 + await handleWrongNetwork({ chainId: base.id }); 120 121 121 122 if (!walletClient) { 122 123 setLoading(false); ··· 142 143 143 144 useEffect(() => { 144 145 let cancelled = false; 146 + let intervalId: ReturnType<typeof setInterval> | undefined; 147 + let timeoutId: ReturnType<typeof setTimeout> | undefined; 148 + 145 149 const run = async () => { 146 150 const sender = (address as Address) || undefined; 147 151 if (!sender || !amount) { ··· 176 180 if (!cancelled) setEstimatedOut(""); 177 181 } 178 182 }; 179 - run(); 183 + 184 + timeoutId = setTimeout(() => { 185 + void run(); 186 + }, 300); 187 + 188 + intervalId = setInterval(() => { 189 + void run(); 190 + }, 8000); 191 + 180 192 return () => { 181 193 cancelled = true; 194 + if (intervalId) clearInterval(intervalId); 195 + if (timeoutId) clearTimeout(timeoutId); 182 196 }; 183 197 }, [address, amount, coin.address, mode]); 184 198
+4 -1
apps/web/src/components/Account/CreatorCoin/index.tsx
··· 1 + import { ZORA_API_KEY } from "@hey/data/constants"; 1 2 import type { AccountFragment } from "@hey/indexer"; 2 3 import { useQuery } from "@tanstack/react-query"; 3 - import { type GetCoinResponse, getCoin } from "@zoralabs/coins-sdk"; 4 + import { type GetCoinResponse, getCoin, setApiKey } from "@zoralabs/coins-sdk"; 4 5 import { useState } from "react"; 5 6 import type { Address } from "viem"; 6 7 import { base } from "viem/chains"; 7 8 import { Image, Modal } from "../../Shared/UI"; 8 9 import MetaDetails from "../MetaDetails"; 9 10 import CreatorCoinDetails from "./CreatorCoinDetails"; 11 + 12 + setApiKey(ZORA_API_KEY); 10 13 11 14 interface CreatorCoinProps { 12 15 account: AccountFragment;
+11 -6
apps/web/src/hooks/useHandleWrongNetwork.tsx
··· 2 2 import logger from "@hey/helpers/logger"; 3 3 import { useConnections, useSwitchChain } from "wagmi"; 4 4 5 - const useHandleWrongNetwork = (props?: { chainId?: number }) => { 6 - const { chainId = CHAIN.id } = props ?? {}; 5 + interface HandleWrongNetworkParams { 6 + chainId?: number; 7 + } 8 + 9 + const useHandleWrongNetwork = () => { 7 10 const activeConnection = useConnections(); 8 11 const { switchChainAsync } = useSwitchChain(); 12 + const isConnected = () => activeConnection[0] !== undefined; 9 13 10 - const isConnected = () => activeConnection[0] !== undefined; 11 - const isWrongNetwork = () => activeConnection[0]?.chainId !== chainId; 14 + const handleWrongNetwork = async (params?: HandleWrongNetworkParams) => { 15 + const chainId = params?.chainId ?? CHAIN.id; 12 16 13 - const handleWrongNetwork = async () => { 17 + const isWrongNetwork = () => activeConnection[0]?.chainId !== chainId; 18 + 14 19 if (!isConnected()) { 15 20 logger.warn("No active connection found."); 16 21 return; ··· 18 23 19 24 if (isWrongNetwork()) { 20 25 try { 21 - await switchChainAsync({ chainId: CHAIN.id }); 26 + await switchChainAsync({ chainId }); 22 27 } catch (error) { 23 28 logger.error("Failed to switch chains:", error); 24 29 }
+2
packages/data/constants.ts
··· 41 41 // Tokens / Keys 42 42 export const WALLETCONNECT_PROJECT_ID = "cd542acc70c2b548030f9901a52e70c8"; 43 43 export const GIPHY_KEY = "yNwCXMKkiBrxyyFduF56xCbSuJJM8cMd"; // Read only safe key 44 + export const ZORA_API_KEY = 45 + "zora_api_2b019182fe376a45b4495c89bbb18393d6d529ef9e9d0c799321116a8bfb8f47"; 44 46 45 47 export const LENS_NAMESPACE = "lens/"; 46 48 export const NATIVE_TOKEN_SYMBOL = IS_MAINNET ? "GHO" : "GRASS";