"use client"; import Link from "next/link"; import { useCallback, useEffect, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button, buttonVariants } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { EmptyState } from "@/components/ui/empty-state"; import { clearActivityForWallet, formatActivityTime, readActivityForWallet, shortHash, type MaviActivityItem, } from "@/lib/mavi/activity"; import { shortAddress } from "@/lib/mavi/storage"; import { cn } from "@/lib/utils"; // Re-export for callers that imported from this module earlier export { notifyActivityChanged } from "@/lib/mavi/activity"; export function ActivityList({ walletAddress, /** Compact strip on home (fewer rows) */ compact = false, className, }: { walletAddress: string; compact?: boolean; className?: string; }) { const [items, setItems] = useState([]); const [mounted, setMounted] = useState(false); const refresh = useCallback(() => { setItems(readActivityForWallet(walletAddress, compact ? 5 : 30)); }, [compact, walletAddress]); useEffect(() => { setMounted(true); refresh(); const onStorage = (e: StorageEvent) => { if (e.key === "mavi_activity_v1" || e.key === null) refresh(); }; window.addEventListener("storage", onStorage); window.addEventListener("mavi-activity", refresh); return () => { window.removeEventListener("storage", onStorage); window.removeEventListener("mavi-activity", refresh); }; }, [refresh]); if (!mounted) { return ( Loading activity… ); } return (
Activity Recent mavi actions in this browser (not a full chain explorer).
{items.length > 0 && !compact ? ( ) : null}
{items.length === 0 ? ( Send } /> ) : (
    {items.map((item) => (
  • {kindLabel(item.kind)} {item.amountEth ? ( {item.kind === "send" ? "−" : "+"} {trimEth(item.amountEth)} ETH ) : null}

    {item.kind === "send" && item.to ? `To ${shortAddress(item.to)}` : item.kind === "fund" ? "From local test bank" : item.note ?? ""} {item.hash ? ( <> {" · "} {shortHash(item.hash)} ) : null}

  • ))}
)} {compact && items.length > 0 ? ( Full activity → ) : null}
); } function kindLabel(kind: MaviActivityItem["kind"]): string { switch (kind) { case "send": return "Sent"; case "fund": return "Test ETH"; case "receive_note": return "Received"; default: return kind; } } function trimEth(eth: string): string { const n = Number(eth); if (!Number.isFinite(n)) return eth; if (n === 0) return "0"; if (n >= 1) return n.toFixed(4).replace(/\.?0+$/, ""); return n.toFixed(6).replace(/\.?0+$/, ""); }