From 78aa7698234f8c5a96a331efef72bb40ce79f07d Mon Sep 17 00:00:00 2001 From: tomsmith8 Date: Fri, 10 Apr 2026 18:06:10 +0000 Subject: [PATCH] Generated with Hive: Simplify BoostButton and remove NEXT_PUBLIC_BOOST_PUBKEY from environment --- .env.local.example | 2 -- next.config.ts | 1 + package.json | 2 +- src/app/global-error.tsx | 18 ++++++++++++ src/app/layout.tsx | 4 +-- src/components/boost/boost-button.tsx | 42 ++++----------------------- src/components/providers.tsx | 7 +++++ 7 files changed, 35 insertions(+), 41 deletions(-) create mode 100644 src/app/global-error.tsx create mode 100644 src/components/providers.tsx diff --git a/.env.local.example b/.env.local.example index 7952651..25717bc 100644 --- a/.env.local.example +++ b/.env.local.example @@ -5,5 +5,3 @@ NEXT_PUBLIC_API_URL= # Mock mode for local development (skip real API calls) NEXT_PUBLIC_USE_MOCKS=true -# Pubkey for Lightning boost keysends -NEXT_PUBLIC_BOOST_PUBKEY= diff --git a/next.config.ts b/next.config.ts index 68a6c64..433efbb 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: "standalone", + transpilePackages: ["@base-ui/react"], }; export default nextConfig; diff --git a/package.json b/package.json index f93fcda..a44998f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 next dev", - "build": "next build", + "build": "NODE_ENV=production next build", "start": "next start", "lint": "eslint" }, diff --git a/src/app/global-error.tsx b/src/app/global-error.tsx new file mode 100644 index 0000000..8d797a7 --- /dev/null +++ b/src/app/global-error.tsx @@ -0,0 +1,18 @@ +"use client" + +export default function GlobalError({ + error, + reset, +}: { + error: Error & { digest?: string } + reset: () => void +}) { + return ( + + +

Something went wrong!

+ + + + ) +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e01299f..0ea5f52 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,6 +1,6 @@ import type { Metadata } from "next" import { Rajdhani, Plus_Jakarta_Sans, Fira_Code } from "next/font/google" -import { TooltipProvider } from "@/components/ui/tooltip" +import { Providers } from "@/components/providers" import "./globals.css" const rajdhani = Rajdhani({ @@ -40,7 +40,7 @@ export default function RootLayout({ className={`${rajdhani.variable} ${jakarta.variable} ${firaCode.variable} h-full antialiased dark`} > - {children} + {children} ) diff --git a/src/components/boost/boost-button.tsx b/src/components/boost/boost-button.tsx index bd04253..8b5f75c 100644 --- a/src/components/boost/boost-button.tsx +++ b/src/components/boost/boost-button.tsx @@ -3,16 +3,10 @@ import { useCallback, useState } from "react" import { Zap } from "lucide-react" import { cn } from "@/lib/utils" -import { isSphinx } from "@/lib/sphinx/detect" import { api } from "@/lib/api" import { useMocks } from "@/lib/mock-data" -// eslint-disable-next-line @typescript-eslint/no-require-imports -const sphinx = require("sphinx-bridge") - -const SPHINX_PUBKEY = process.env.NEXT_PUBLIC_BOOST_PUBKEY ?? "" - -const DEFAULT_BOOST_AMOUNT = 5 +const DEFAULT_BOOST_AMOUNT = 10 interface BoostButtonProps { refId: string @@ -24,48 +18,24 @@ export function BoostButton({ refId, boostCount = 0, className }: BoostButtonPro const [count, setCount] = useState(boostCount) const [boosting, setBoosting] = useState(false) const [flash, setFlash] = useState(false) + const mocks = useMocks() const handleBoost = useCallback(async () => { if (boosting) return setBoosting(true) - try { - if (isSphinx()) { - // Lightning keysend via Sphinx - let res = await sphinx.enable(true) - if (!res) throw new Error("Sphinx enable failed") - - res = await sphinx.keysend(SPHINX_PUBKEY, DEFAULT_BOOST_AMOUNT) - - if (!res?.success) { - // Ask for topup then retry - res = await sphinx.topup() - if (!res) res = await sphinx.authorize() - if (!res?.budget || res.budget < DEFAULT_BOOST_AMOUNT) { - throw new Error("Insufficient budget") - } - res = await sphinx.keysend(SPHINX_PUBKEY, DEFAULT_BOOST_AMOUNT) - if (!res?.success) throw new Error("Keysend failed") - } - } - - // Record boost on backend - if (!useMocks()) { - await api.post("/boost", { - amount: DEFAULT_BOOST_AMOUNT, - refid: refId, - }) + if (!mocks) { + await api.post('/boost', { refid: refId, amount: DEFAULT_BOOST_AMOUNT }) } - setCount((c) => c + DEFAULT_BOOST_AMOUNT) setFlash(true) setTimeout(() => setFlash(false), 600) } catch (err) { - console.error("Boost failed:", err) + console.error('Boost failed:', err) } finally { setBoosting(false) } - }, [refId, boosting]) + }, [refId, boosting, mocks]) return (