diff --git a/src/app/dashboard/writer/page.tsx b/src/app/dashboard/writer/page.tsx index 52a5134f..dd624c40 100644 --- a/src/app/dashboard/writer/page.tsx +++ b/src/app/dashboard/writer/page.tsx @@ -139,14 +139,14 @@ function StorylineDetail({ storyline, writerAddress }: { storyline: Storyline; w )} {storyline.token_address && ( - <> +
- +
)} ); diff --git a/src/components/ClaimRoyalties.tsx b/src/components/ClaimRoyalties.tsx index 729adbda..61db4379 100644 --- a/src/components/ClaimRoyalties.tsx +++ b/src/components/ClaimRoyalties.tsx @@ -8,6 +8,14 @@ import { publicClient } from "../../lib/rpc"; import { mcv2BondAbi, getTokenTVL } from "../../lib/price"; import { MCV2_BOND, IS_TESTNET, EXPLORER_URL } from "../../lib/contracts/constants"; +function formatTruncated(value: bigint, decimals: number, digits = 10): string { + const raw = formatUnits(value, decimals); + const dot = raw.indexOf("."); + if (dot === -1 || raw.length - dot - 1 <= digits) return raw; + const truncated = raw.slice(0, dot + 1 + digits).replace(/0+$/, "").replace(/\.$/, ""); + return truncated === "0" && value > BigInt(0) ? raw.slice(0, dot + 1 + digits) : truncated; +} + type TxState = "idle" | "confirming" | "pending" | "done" | "error"; interface ClaimRoyaltiesProps { @@ -84,8 +92,8 @@ export function ClaimRoyalties({ tokenAddress, plotCount, beneficiary }: ClaimRo }, []); return ( -
-
+
+
Royalties @@ -114,30 +122,30 @@ export function ClaimRoyalties({ tokenAddress, plotCount, beneficiary }: ClaimRo Chain at least 2 plots ({plotCount}/2)
  • - Unclaimed > 0 ({formatUnits(unclaimed, decimals)} {reserveLabel}) + Unclaimed > 0 ({formatTruncated(unclaimed, decimals)} {reserveLabel})
  • )}
    - - {formatUnits(unclaimed, decimals)} {reserveLabel} + BigInt(0) ? "text-accent" : "text-foreground"}`}> + {formatTruncated(unclaimed, decimals)} {reserveLabel} +
    -
    {!eligible && txState === "idle" && (

    diff --git a/src/components/WriterTradingStats.tsx b/src/components/WriterTradingStats.tsx index 9d50fc8e..b87ba34e 100644 --- a/src/components/WriterTradingStats.tsx +++ b/src/components/WriterTradingStats.tsx @@ -6,14 +6,6 @@ import { publicClient } from "../../lib/rpc"; import { mcv2BondAbi, getTokenTVL } from "../../lib/price"; import { MCV2_BOND, IS_TESTNET } from "../../lib/contracts/constants"; import type { Storyline } from "../../lib/supabase"; -import { supabase } from "../../lib/supabase"; - -function formatTruncated(value: bigint, decimals: number, digits = 6): string { - const raw = formatUnits(value, decimals); - const dot = raw.indexOf("."); - if (dot === -1 || raw.length - dot - 1 <= digits) return raw; - return raw.slice(0, dot + 1 + digits).replace(/0+$/, "").replace(/\.$/, ""); -} interface WriterTradingStatsProps { storyline: Storyline; @@ -45,34 +37,10 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { enabled: !!tokenAddress, }); - // Fetch total donations for this storyline - const { data: donationsTotal } = useQuery({ - queryKey: ["writer-donations", storyline.storyline_id], - queryFn: async () => { - if (!supabase) return BigInt(0); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const { data } = await (supabase.from("donations") as any) - .select("amount") - .eq("storyline_id", storyline.storyline_id); - if (!data) return BigInt(0); - return (data as { amount: string }[]).reduce((sum, d) => sum + BigInt(d.amount), BigInt(0)); - }, - }); - const decimals = tvlData?.decimals; return ( -

    -
    - - Donations - - - {donationsTotal !== undefined && decimals !== undefined - ? `${formatTruncated(donationsTotal, decimals)} ${reserveLabel}` - : "—"} - -
    +
    Token Price