Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
1 change: 1 addition & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { NextConfig } from "next";

const nextConfig: NextConfig = {
output: "standalone",
transpilePackages: ["@base-ui/react"],
};

export default nextConfig;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
18 changes: 18 additions & 0 deletions src/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client"

export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
return (
<html>
<body>
<h2>Something went wrong!</h2>
<button onClick={() => reset()}>Try again</button>
</body>
</html>
)
}
4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -40,7 +40,7 @@ export default function RootLayout({
className={`${rajdhani.variable} ${jakarta.variable} ${firaCode.variable} h-full antialiased dark`}
>
<body className="h-full overflow-hidden">
<TooltipProvider>{children}</TooltipProvider>
<Providers>{children}</Providers>
</body>
</html>
)
Expand Down
42 changes: 6 additions & 36 deletions src/components/boost/boost-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
<button
Expand Down
7 changes: 7 additions & 0 deletions src/components/providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use client"

import { TooltipProvider } from "@/components/ui/tooltip"

export function Providers({ children }: { children: React.ReactNode }) {
return <TooltipProvider>{children}</TooltipProvider>
}
Loading