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

refactor: clean up Trade component by removing commented code and simplifying error handling

yoginth.com 4ceadbd7 b1b31eea

verified
Changed files
+3 -8
apps
web
src
components
Account
CreatorCoin
+3 -6
apps/web/src/components/Account/CreatorCoin/Trade.tsx
··· 44 44 const [tokenBalance, setTokenBalance] = useState<bigint>(0n); 45 45 const [estimatedOut, setEstimatedOut] = useState<string>(""); 46 46 47 - // balances 48 47 useEffect(() => { 49 48 (async () => { 50 49 if (!address) return; ··· 60 59 ]); 61 60 setEthBalance(eth); 62 61 setTokenBalance(token as bigint); 63 - } catch { 64 - // ignore 65 - } 62 + } catch {} 66 63 })(); 67 64 }, [address, coin.address, publicClient]); 68 65 69 - const tokenDecimals = 18; // ZORA20 tokens have 18 decimals 66 + const tokenDecimals = 18; 70 67 71 68 const setPercentAmount = (pct: number) => { 72 69 const decimals = 6; 73 70 if (mode === "buy") { 74 71 const available = Number(formatEther(ethBalance)); 75 - const gasReserve = 0.0002; // leave a tiny bit for gas on Base 72 + const gasReserve = 0.0002; 76 73 const baseAmt = (available * pct) / 100; 77 74 const amt = pct === 100 ? Math.max(baseAmt - gasReserve, 0) : baseAmt; 78 75 setAmount(amt.toFixed(decimals));
-2
apps/web/vite.config.mjs
··· 72 72 tsconfigPaths(), 73 73 react(), 74 74 tailwindcss(), 75 - // Expose env vars to client-side code (process.env.*) 76 - // Provide a safe default for HEY_API_URL to avoid build-time errors. 77 75 EnvironmentPlugin({ 78 76 HEY_API_URL: "https://api.hey.xyz", 79 77 LENS_NETWORK: undefined