import { useMemo, useSyncExternalStore } from "react"; import { FormattedMessage, FormattedNumber } from "react-intl"; import AsyncButton from "@/Components/Button/AsyncButton"; import useEventPublisher from "@/Hooks/useEventPublisher"; import useLogin from "@/Hooks/useLogin"; import { ZapPoolTarget } from "@/Pages/ZapPool/ZapPoolTarget"; import { bech32ToHex, getRelayName, trackEvent, unwrap } from "@/Utils"; import { SnortPubKey } from "@/Utils/Const"; import { UploaderServices } from "@/Utils/Upload"; import { ZapPoolController, ZapPoolRecipientType } from "@/Utils/ZapPoolController"; import { useWallet } from "@/Wallet"; const DataProviders = [ { name: "nostr.band", owner: bech32ToHex("npub1sx9rnd03vs34lp39fvfv5krwlnxpl90f3dzuk8y3cuwutk2gdhdqjz6g8m"), }, ]; export function ZapPoolPageInner() { const login = useLogin(); const { system } = useEventPublisher(); const zapPool = useSyncExternalStore( c => unwrap(ZapPoolController).hook(c), () => unwrap(ZapPoolController).snapshot(), ); const { wallet } = useWallet(); const relayConnections = useMemo(() => { return [...system.pool] .map(([, a]) => { if (a.Info?.pubkey && !a.Ephemeral) { return { address: a.Address, pubkey: a.Info.pubkey, }; } }) .filter(a => a !== undefined) .map(unwrap); }, [login.relays]); const sumPending = zapPool.reduce((acc, v) => acc + v.sum, 0); return (
{wallet && (