diff --git a/NIP.md b/NIP.md index 300653f1..eac85ae7 100644 --- a/NIP.md +++ b/NIP.md @@ -12,7 +12,7 @@ | Kind | Name | Description | |-------|----------------------------|----------------------------------------------------------------| -| 30223 | Campaign | Fundraising campaign with a list of on-chain Bitcoin recipients | +| 33863 | Campaign | Self-authored fundraising campaign with a single Bitcoin wallet endpoint (`bc1...` or `sp1...`) | | 30385 | Community Stats Snapshot | Pre-computed per-country / global community leaderboards | | 36639 | Pledge | Donor pledge for concrete submissions, stored as sats | @@ -22,7 +22,54 @@ |--------------------------|-----------------------------------------|-----------------------------------------------------------------| | Flat Communities | 34550, 30009, 8, 1111, 1984 | One-level badge membership with explicit moderators (NIP-72 ext) | | Community Chat | 34550, 1311 | Realtime member chat scoped to a NIP-72 community | -| Campaign Moderation | 30223, 1985, 39089 | Homepage curation (approved / hidden / featured axes) via moderator-signed labels in the `agora.moderation` namespace, gated by a follow-pack moderator roster | +| Campaign Moderation | 33863, 1985, 39089 | Homepage curation (approved / hidden / featured axes) via moderator-signed labels in the `agora.moderation` namespace, gated by a follow-pack moderator roster | + +### Agora Content Marker + +Every event Agora publishes that represents a first-class Agora object carries the single-letter tag `["t", "agora"]`. This marker enables the Agora activity feed to filter strictly server-side via the relay-indexed `#t` filter (multi-letter tags like the NIP-89 `client` tag are not indexed by relays and are therefore unsuitable for this purpose). + +#### Tagged kinds + +| Kind | Object | Where tagged | +|-------|---------------------|---------------------------------------------------------------| +| 1 | Note (top-level, reply, quote) | `ComposeBox` default for top-level kind 1 publishes | +| 1111 | NIP-22 comment | `usePostComment` (all comments authored in Agora) | +| 8333 | Onchain zap | `useOnchainZap`, `useDonateCampaign`, `SendBitcoinDialog` | +| 9041 | Zap goal | `CreateGoalDialog` | +| 33863 | Campaign | `CreateCampaignPage` | +| 31922 | Date calendar event | `CreateEventPage`, `CreateCommunityEventDialog` | +| 31923 | Time calendar event | `CreateEventPage`, `CreateCommunityEventDialog` | +| 34550 | Community | `CreateCommunityPage` | +| 36639 | Pledge | `CreateActionPage` | + +The tag is added at publish time via the `withAgoraTag` helper in `src/lib/agoraNoteTags.ts`, which dedupes against any user-supplied `t:agora` tag. + +#### Untagged kinds (intentional) + +Reactions, reposts, follow lists, profile metadata, lists, settings, badges, vanish requests, encrypted DMs, and live chat are user-state or response events rather than first-class Agora content. Tagging them would pollute `#agora` hashtag surfaces without adding value to the activity feed. + +Untagged on purpose: 0, 3, 6, 7, 8, 16, 62, 1311, 30009, 10000-series, 30078, and any NIP-04 / NIP-44 encrypted kind. + +#### Querying + +The Agora activity feed combines a `t:agora`-strict layer with an intentionally cross-client world layer: + +```json +[ + { "kinds": [33863, 36639, 34550, 8333], "#t": ["agora", "Agora"] }, + { "kinds": [1111], "#t": ["agora", "Agora"], "#K": ["33863", "36639", "34550"] }, + { "kinds": [1111, 1068], "#k": ["iso3166", "geo"] }, + { "kinds": [1], "#t": ["agora", "Agora"] } +] +``` + +The first two filters surface only Agora-created content. The third surfaces all country/geo-rooted comments and polls regardless of origin — the world layer is intentionally cross-client. The fourth captures any kind 1 note carrying `#agora` (including hashtags users type themselves), which preserves viral / opt-in discovery. + +Clients filter both case variants (`agora` and `Agora`) because Nostr `t` tags are conventionally lowercase but some clients normalize hashtags to title case. + +#### Backward compatibility + +Events published before this marker was adopted do not carry `t:agora` and therefore do not appear in the Agora activity feed. They remain reachable by direct link and via kind-specific directories (e.g. the moderator-curated `/campaigns/all`). Authors who wish to surface a legacy event in the feed can republish it (any edit through the Agora UI will add the marker automatically). ### Community Chat @@ -89,26 +136,45 @@ Single-recipient zap (the common case — tipping a post or profile): } ``` -Multi-recipient zap (one transaction paying multiple recipients — campaign donations, community splits): +Multi-recipient zap (one transaction paying multiple recipients — community splits): ```json { "kind": 8333, "pubkey": "", - "content": "Great campaign!", + "content": "Great community!", "tags": [ ["i", "bitcoin:tx:"], ["p", ""], ["p", ""], ["p", ""], ["amount", ""], - ["a", "30223::"], - ["K", "30223"], + ["a", "34550::"], + ["K", "34550"], ["alt", "Donation: 75000 sats across 3 recipients"] ] } ``` +Campaign donation (one transaction paying a single campaign wallet — see Kind 33863 below): + +```json +{ + "kind": 8333, + "pubkey": "", + "content": "Keep up the good work.", + "tags": [ + ["i", "bitcoin:tx:"], + ["amount", ""], + ["a", "33863::"], + ["K", "33863"], + ["alt", "Donation to Save the Last Bookstore: 25000 sats"] + ] +} +``` + +Campaign donation receipts MUST NOT include `p` tags — campaigns no longer have Nostr-identity recipients, only a `w` wallet endpoint. Verification matches tx outputs against the campaign's declared `w` address rather than derived Taproot addresses (see *Verification* and Kind 33863 below). + ### Content The `content` field is a human-readable comment from the sender (may be empty). It is NOT a zap request JSON (unlike NIP-57 kind 9735). @@ -165,13 +231,25 @@ For addressable events, use `"#a": ["::"]` instead. For pro **Verification (REQUIRED before trusting amounts):** -Clients MUST verify a kind 8333 event on-chain before counting it toward a zap total or displaying its amount. The `amount` tag is self-reported by the sender and would otherwise be trivially spoofable. To verify: +Clients MUST verify a kind 8333 event on-chain before counting it toward a zap total or displaying its amount. The `amount` tag is self-reported by the sender and would otherwise be trivially spoofable. Verification has two modes depending on the event shape: + +*Identity-recipient mode* (the event has `p` tags — profile zaps, event zaps, community splits): 1. Extract the txid from the `i` tag. 2. Fetch the transaction from a Bitcoin data source (e.g. a mempool.space-compatible Esplora API). 3. For each `p` tag, derive the recipient's expected Taproot address. 4. Sum the values of all outputs in the transaction that pay any of the derived recipient addresses. This is the **verified amount**. Change outputs paying back to the **sender's** derived Taproot address MUST NOT be counted toward the verified amount — only outputs to listed recipients. -5. If the verified amount is 0 (no listed recipient received anything in the tx), the event SHOULD be discarded. + +*Campaign-wallet mode* (the event has an `a` tag pointing at a kind 33863 campaign and no `p` tags): + +1. Extract the txid from the `i` tag and the campaign coordinate from the `a` tag. +2. Fetch the campaign event and read its `w` tag to get the campaign's declared bech32(m) wallet address. Reject the receipt if `w` is missing, malformed, or starts with `sp1` (silent-payment campaigns do not publish receipts; see Kind 33863). +3. Fetch the transaction from a Bitcoin data source. +4. Sum the values of all outputs in the transaction that pay the campaign's `w` address. This is the **verified amount**. + +In both modes: + +5. If the verified amount is 0, the event SHOULD be discarded. 6. If the sender's `amount` tag exceeds the verified amount, clients MAY discard the event or MAY display the smaller verified amount (capping). Clients MUST NOT display or count the claimed amount when it exceeds the verified amount. 7. Unconfirmed transactions MAY be displayed as pending; clients MAY require confirmation before counting them toward public totals. Because unconfirmed transactions can be evicted (RBF, double-spend), clients SHOULD either exclude them from aggregate zap totals or clearly label them as pending. @@ -199,139 +277,202 @@ The two zap kinds are complementary. Clients SHOULD sum verified amounts from bo --- -## Kind 30223: Campaign +## Kind 33863: Campaign ### Summary -Addressable event representing a **fundraising campaign**. A campaign carries the marketing-style metadata you would expect on GoFundMe, Kickstarter, or GiveSendGo (title, summary, cover image, story, category, goal, optional deadline, and recommended country), and — most importantly — a list of recipient pubkeys (`p` tags) that share the proceeds of any donation. +Addressable event representing a **self-authored fundraising campaign**. A campaign carries marketing-style metadata (title, summary, banner image, markdown story, optional goal, optional deadline, optional country) and exactly one Bitcoin wallet endpoint declared in a `w` tag. The wallet endpoint is either a public on-chain bech32(m) address (`bc1q…`, `bc1p…`) or a silent-payment code (`sp1…`, per BIP-352). The mode is inferred from the prefix — the client renders the corresponding QR code and adjusts the donation-progress UI accordingly. -Donations are sent as a **single Bitcoin on-chain transaction** with one output per recipient. The donor's wallet derives each recipient's Taproot address from their pubkey via BIP-340/BIP-341 (the same scheme used by kind 8333 onchain zaps), so the campaign event itself does not need to carry Bitcoin addresses. After broadcasting the funding tx, the donor's client publishes one kind 8333 event referencing the `txid`, listing every campaign recipient under its own `p` tag, and tagging the campaign via `a` / `K`. The donation then shows up in the campaign's totals and in each recipient's profile zap history (the `#p` filter matches every listed recipient). +The author of the event is also the beneficiary. Campaigns are never authored on behalf of someone else; the event creator owns the wallet declared in `w` and receives the donations. To stop accepting donations, the creator publishes a NIP-09 kind 5 deletion request referencing the campaign's `a` coordinate. -The kind is addressable so the creator can edit the story, image, goal, deadline, and recipient list over the life of the campaign without minting new identifiers. The `d` tag is the campaign's slug. +The kind is addressable so the creator can edit the story, banner, goal, deadline, and wallet over the life of the campaign without minting new identifiers. The `d` tag is the campaign's slug. ### Event Structure ```json { - "kind": 30223, + "kind": 33863, "pubkey": "", "content": "", "tags": [ - ["d", "save-the-bookstore"], + ["d", "save-the-last-bookstore"], + ["title", "Save the Last Bookstore"], ["summary", "Help our 40-year-old neighborhood bookstore make rent through winter."], - ["image", "https://example.com/cover.jpg"], - ["t", "human-rights"], - ["t", "legal-defense"], - ["goal", "10000000"], + ["banner", "https://blossom.example/abc123.jpg"], + ["imeta", + "url https://blossom.example/abc123.jpg", + "m image/jpeg", + "x abc123def456...", + "dim 1600x900", + "blurhash LKO2?U%2Tw=w]~RBVZRi};RPxuwH", + "alt Storefront of the Last Bookstore at dusk" + ], + ["alt", "Fundraising campaign: Save the Last Bookstore"], + + ["w", "bc1p7w2k3xq9...xyz"], + + ["goal", "25000"], ["deadline", "1735689600"], - ["i", "iso3166:VE"], - ["k", "iso3166"], - ["p", "", "wss://relay.example", "2"], - ["p", "", "wss://relay.example", "1"], - ["p", ""], - ["alt", "Fundraising campaign: Save the Last Bookstore"] + + ["i", "iso3166-1:US"], + ["k", "iso3166-1"] ] } ``` +A silent-payment campaign is identical except the `w` tag carries an `sp1…` code: + +```json +["w", "sp1qq...verylongsilentpaymentcode..."] +``` + ### Content The `content` field is the **campaign story**, formatted as Markdown. Clients SHOULD render it with the same Markdown renderer they use for NIP-23 long-form content. Empty content is permitted (e.g. for a campaign that lives entirely in its summary). ### Tags -| Tag | Required | Description | -|------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `d` | Yes | Campaign slug, unique per author. Forms the addressable coordinate `30223::`. | -| `title` | Yes | Display title of the campaign (plain text, max ~200 chars). | -| `summary` | Recommended | Short one-paragraph tagline shown in feed cards and previews. | -| `image` | Recommended | HTTPS URL of the cover image (jpg/png/webp). Clients MUST sanitize and verify the URL before rendering. | -| `t` | Recommended | Topic tag for discovery and filtering (e.g. `human-rights`, `legal-defense`, `independent-media`). Multiple `t` tags MAY be used. Clients SHOULD normalize user-entered tag labels by removing a leading `#`, lowercasing, and replacing whitespace with hyphens. | -| `goal` | Recommended | Fundraising goal in **satoshis** (decimal integer). Omit if the campaign has no fixed goal. | -| `deadline` | Optional | Unix timestamp (seconds) at which the campaign closes. After the deadline, clients SHOULD show the campaign as ended but MAY still accept donations. | -| `i` | Recommended | NIP-73 country identifier for sorting and discovery. SHOULD be `iso3166:` with an uppercase ISO 3166-1 alpha-2 country code (e.g. `iso3166:VE`). | -| `k` | Recommended if `i` is present | NIP-73 external content kind. For country identifiers this SHOULD be `iso3166`. | -| `location` | Legacy | Human-readable location string used by older campaign events. New events SHOULD prefer `i` + `k` country tags. Clients MAY display this as a fallback only. | -| `status` | Optional | Lifecycle status. The only defined value is `archived`, which marks the campaign closed without deleting it. Other values SHOULD be ignored. See *Closing & archiving* below. | -| `p` | Yes (≥1) | Recipient pubkey. The 2nd element is the hex pubkey; the 3rd (optional) is a relay hint; the 4th (optional) is a positive decimal **weight** for split allocation. | -| `alt` | Recommended | NIP-31 human-readable fallback. | +| Tag | Required | Description | +|-----------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `d` | Yes | Campaign slug, unique per author. Forms the addressable coordinate `33863::`. | +| `title` | Yes | Display title of the campaign (plain text, max ~200 chars). | +| `w` | Yes | Bitcoin wallet endpoint. The 2nd element is a single bech32(m) string: a mainnet on-chain address starting with `bc1q` (P2WPKH/P2WSH) or `bc1p` (P2TR), **or** a silent-payment code starting with `sp1` per BIP-352. Exactly one `w` tag per campaign. | +| `summary` | Recommended | Short one-paragraph tagline shown in feed cards and previews. | +| `banner` | Recommended | HTTPS URL of the wide banner image. Clients MUST sanitize the URL (see `sanitizeUrl()` in `nostr-security`) before rendering, and SHOULD pair the URL with a NIP-92 `imeta` tag for dimensions, blurhash, MIME type, and SHA-256. | +| `imeta` | Recommended | NIP-92 media metadata for the banner. The first `url ` pair MUST match the `banner` URL; clients SHOULD ignore an `imeta` whose URL does not match. | +| `goal` | Optional | Fundraising goal in **integer US Dollars** (no unit suffix, no decimals). Clients MAY display an estimated sat-equivalent at view time using a live exchange rate. | +| `deadline`| Optional | Unix timestamp (seconds) at which the campaign closes for new donations. After the deadline, clients SHOULD show the campaign as ended but MAY still accept donations. | +| `i` | Recommended | NIP-73 country identifier. SHOULD be `iso3166-1:` with an uppercase ISO 3166-1 alpha-2 country code (e.g. `iso3166-1:VE`). | +| `k` | Recommended if `i` is present | NIP-73 external content kind. For country identifiers this SHOULD be `iso3166-1`. | +| `alt` | Recommended | NIP-31 human-readable fallback. | -### Recipient Split Rules +### Wallet Modes -When a donor sends an amount `T` in satoshis to a campaign: +The prefix of the `w` value selects one of two donation modes. Clients MUST detect the mode from the prefix; the event carries no other mode discriminator. -1. Read all `p` tags from the campaign event. -2. Parse the weight of each `p` tag from the 4th element. If absent, malformed, or non-positive, the weight defaults to **1**. -3. Compute each recipient's share as `floor(T * weight_i / sum_of_weights)` satoshis. -4. Any remainder from rounding (at most N−1 sats) MAY be appended to the largest share or kept by the donor as change — clients SHOULD prefer appending the remainder to the largest share so the full amount reaches the campaign. -5. If any computed share is below the Bitcoin dust limit (546 sats for P2TR), the donor's client MUST refuse the donation and surface a minimum-amount error. +| Prefix | Mode | Description | +|---------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------| +| `bc1q…` / `bc1p…` | On-chain | Public mainnet bech32(m) address. Donations are traceable; clients show a progress bar, total raised, and donation list. | +| `sp1…` | Silent payment | BIP-352 silent-payment code. Donations are **unlinkable by design**. Clients MUST hide all aggregate totals and progress UI (see below). | -Equal splits are the default: omit the weight on every `p` tag, and all recipients receive `floor(T / N)` sats each. +Other prefixes (`tb1…`, `bcrt1…`, `tsp1…`, lightning invoices, etc.) MUST be rejected at parse time; the campaign does not render. -### Donation Flow +Clients SHOULD validate the bech32(m) checksum of the `w` value, not just its prefix. -1. Donor opens the campaign and chooses an amount in sats (preset or custom). -2. Donor's client computes per-recipient amounts using the split rules above. -3. Donor's client builds a **single PSBT** with one output per recipient (paying each recipient's derived Taproot address) plus a change output back to the donor. -4. Donor signs the PSBT with their Nostr key (Taproot key-path spend) and broadcasts the resulting transaction. -5. Donor's client publishes **one kind 8333 event for the whole transaction**, listing every recipient under its own `p` tag. The event MUST include: +### Client Behavior by Mode + +| UI element | On-chain (`bc1`) | Silent payment (`sp1`) | +|-----------------------------|-----------------------------------------------------------------|-------------------------------------------------------| +| QR code | bech32(m) address QR (or BIP-21 `bitcoin:` URI) | SP code QR (BIP-352 / BIP-21 SP extension) | +| "Raised X" / progress bar | Shown, computed from verified kind 8333 receipts | **Hidden.** Replaced with a "Private campaign — totals are not public" notice. | +| Donor / recent-donation list| Shown | **Hidden.** | +| Goal display | Shown as USD target with optional sat-equivalent estimate | Shown as USD target; no progress computation | +| Donation receipt published | Donor's client publishes a kind 8333 receipt (see below) | **No receipt published.** Publishing one would defeat SP unlinkability and is forbidden. | + +For silent-payment campaigns, clients MUST NOT attempt to scan the chain, MUST NOT publish receipts, and MUST NOT display any aggregate that could leak donation activity. The only signal the public sees is the campaign event itself. + +### Donation Flow — On-chain (`bc1`) + +1. Donor opens the campaign and chooses an amount. +2. Donor's client constructs and broadcasts a Bitcoin transaction paying the campaign's `w` address. +3. After broadcast, the donor's client publishes a single kind 8333 receipt: ```json [ ["i", "bitcoin:tx:"], - ["p", ""], - ["p", ""], - ["p", ""], - ["amount", ""], - ["a", "30223::"], - ["K", "30223"], + ["amount", ""], + ["a", "33863::"], + ["K", "33863"], ["alt", "Donation to : sats"] ] ``` - The `amount` tag is the sum of the outputs paying the listed recipients (i.e. the full donation, excluding the donor's change). Per-recipient amounts are not encoded in the event; clients that need them recompute them from the on-chain transaction by matching each recipient's derived Taproot address against the tx outputs. + The receipt MUST NOT carry `p` tags — campaigns are not Nostr-identity recipients. The `amount` tag is the sum of tx outputs paying the campaign's `w` address (excluding the donor's change output). -This mirrors the community batch-zap pattern documented in the kind 8333 section above, with the campaign's addressable coordinate replacing the community coordinate. +4. The receipt is published **after** the tx is broadcast; the txid is already final at that point. A receipt-publish failure does not roll back the donation — the on-chain transaction stands. + +### Donation Flow — Silent Payment (`sp1`) + +1. Donor opens the campaign and chooses an amount. +2. Donor's client uses the campaign's SP code to derive a fresh, one-time Taproot output script per BIP-352. +3. Donor broadcasts a Bitcoin transaction paying that derived output. +4. **No Nostr event is published.** The campaign owner discovers the donation by scanning the chain locally with their SP private key. + +Silent-payment unlinkability is the entire point of this mode. Clients MUST NOT publish receipts, MUST NOT advertise the donation in any other Nostr event (replies, mentions, etc.) on the donor's behalf, and MUST NOT correlate the donor's pubkey with the campaign in any persisted client telemetry. ### Querying **List campaigns (newest first):** ```json -{ "kinds": [30223], "limit": 50 } -``` - -**Filter by category:** - -```json -{ "kinds": [30223], "#t": ["medical"], "limit": 50 } +{ "kinds": [33863], "limit": 50 } ``` **Fetch a specific campaign:** ```json -{ "kinds": [30223], "authors": [""], "#d": [""], "limit": 1 } +{ "kinds": [33863], "authors": [""], "#d": [""], "limit": 1 } ``` -**Aggregate donations for a campaign:** +**Aggregate donations for an on-chain campaign:** ```json -{ "kinds": [8333], "#a": ["30223::"], "limit": 500 } +{ "kinds": [8333], "#a": ["33863::"], "limit": 500 } ``` -Clients MUST verify each kind 8333 event on-chain before counting it toward the campaign total, per the verification rules in the kind 8333 section. +Clients MUST verify each kind 8333 event on-chain before counting it toward the campaign total, per the *Campaign-wallet mode* verification rules in the kind 8333 section. + +**Filter by country:** + +```json +{ "kinds": [33863], "#i": ["iso3166-1:VE"], "limit": 50 } +``` + +**Fetch pinned event comments:** + +Event owners MAY pin important comments or activity feed events with a NIP-78 app-specific data event (`kind: 30078`) authored by the root event owner. The `d` tag is scoped to the root event coordinate. Agora uses this for campaigns (`33863`), pledges (`36639`), organizations (`34550`), and calendar events (`31922` / `31923`). + +```json +{ + "kind": 30078, + "pubkey": "", + "content": "{\"pinnedEvents\":[\"\",\"\"]}", + "tags": [ + ["d", "agora-pinned-comments:::"], + ["a", "::"], + ["k", ""], + ["alt", "Pinned event comments"] + ] +} +``` + +Clients SHOULD query the pin list with: + +```json +{ "kinds": [30078], "authors": [""], "#d": ["agora-pinned-comments:::"], "limit": 1 } +``` + +The `pinnedEvents` array is ordered newest pin first. Pinning an already-pinned event removes it. Clients SHOULD ignore pin lists not authored by the root event owner. ### Client Behavior -- **Recipient validity:** clients SHOULD reject `p` tag entries whose pubkey is not 64 hex characters and SHOULD ignore weights that are not positive finite decimals. -- **Dust protection:** when a donor enters an amount that would assign any recipient less than the dust limit, the client MUST block the donation and either suggest the minimum viable total or prompt the donor to remove recipients. -- **Editability:** the creator MAY republish the same `(kind, pubkey, d)` triple to update the campaign. Clients SHOULD keep `published_at` from the first publish on subsequent edits (NIP-23 convention). -- **Closing & archiving:** the creator MAY soft-close a campaign by republishing it with a `["status", "archived"]` tag. Clients SHOULD hide archived campaigns from discovery feeds and disable the donate flow, but MUST keep them reachable by direct link so existing donors can still find them and donation history is preserved. The creator can reopen the campaign by republishing without the status tag (or with any other status value). For a hard delete, the creator MAY publish a NIP-09 kind 5 deletion request referencing the campaign's `a` coordinate; clients SHOULD continue to render past donations against the campaign even after deletion. +- **Wallet validity:** clients MUST reject events whose `w` tag is missing, present more than once, or whose value does not pass bech32(m) checksum validation for one of the supported prefixes. Invalid campaigns do not render. +- **Editability:** the creator MAY republish the same `(33863, pubkey, d)` triple to update any field, including the `w` wallet endpoint. Clients SHOULD keep `published_at` from the first publish on subsequent edits (NIP-23 convention). +- **Closing a campaign:** there is no `status` tag. To stop accepting donations, the creator publishes a NIP-09 kind 5 deletion request referencing the campaign's `a` coordinate. Clients SHOULD honor the deletion by removing the campaign from discovery feeds. Historical kind 8333 receipts MAY still be rendered against the (now-deleted) campaign coordinate so donors can find their past donations. +- **No category, no topics:** kind 33863 events MUST NOT carry `t` tags or NIP-32 category labels in any `agora.*` namespace. Campaigns are individual stories; discovery happens via search (NIP-50 against title/summary/content), country (`#i`), and moderator curation (below). +- **Migration:** kind 33863 has no relationship to any earlier campaign kind. Clients MUST NOT read, merge, or migrate events of any other kind into the kind 33863 namespace. -### Campaign Moderation Labels +### Agora Moderation Labels -Agora curates which kind 30223 campaigns appear on the homepage (`/`) and on Discover (`/discover`) via moderator-signed NIP-32 label events (kind 1985) in a dedicated label namespace. The campaign event itself is never modified — surfacing is purely a client-side rollup of label events. +Agora curates which kind 33863 campaigns appear on the homepage (`/`) and on the Support directory (`/campaigns/all`), and which kind 34550 organizations appear in the Featured shelf on `/communities`, via moderator-signed NIP-32 label events (kind 1985) in a dedicated label namespace. The labeled event itself is never modified — surfacing is purely a client-side rollup of label events. + +Campaigns and organizations share a single label namespace and a single moderator pack (Team Soapbox); the only thing distinguishing the two streams is the kind prefix on the `a` tag of each label: + +- `33863::` — campaign (kind 33863, see "Open Campaigns" above). +- `34550::` — organization (kind 34550, NIP-72 community definition). + +A client surfacing campaigns MUST filter folded labels to those whose `a` tag starts with `33863:`. A client surfacing organizations MUST filter to `34550:`. Mixing the two streams would let a moderator's `featured` label on a campaign appear to feature an unrelated organization with the same `d` tag, or vice versa. #### Namespace @@ -346,22 +487,32 @@ Each label event carries the namespace twice, per NIP-32: #### Label values -Three independent axes; the newest moderator-signed label per axis per campaign wins. +Three independent axes are defined; the newest moderator-signed label per axis per coordinate wins. **Campaigns** use all three axes (`approval`, `hide`, `featured`). **Organizations** use only two — `hide` and `featured` — because every Agora-tagged organization is publicly visible by default; there is no approval gate for orgs. Moderators MUST NOT publish `approved` or `unapproved` labels against kind 34550 coordinates, and clients MUST ignore any such labels they receive. -| Axis | Values | Meaning | -|----------|---------------------------|-------------------------------------------------------------------------| -| approval | `approved`, `unapproved` | `approved` allows the campaign on `/` and Discover. `unapproved` retracts a previous approval. | -| hide | `hidden`, `unhidden` | `hidden` suppresses the campaign everywhere it would otherwise appear. `unhidden` retracts a previous hide. | -| featured | `featured`, `unfeatured` | `featured` places the campaign in the hand-picked Featured row on `/`. `unfeatured` retracts. | +| Axis | Values | Surfaces | Meaning | +|----------|---------------------------|----------------|-------------------------------------------------------------------------| +| approval | `approved`, `unapproved` | campaigns only | `approved` allows the campaign on its discovery surfaces. `unapproved` retracts a previous approval. | +| hide | `hidden`, `unhidden` | both | `hidden` suppresses the campaign/organization everywhere it would otherwise appear. `unhidden` retracts a previous hide. | +| featured | `featured`, `unfeatured` | both | `featured` places the campaign in the hand-picked Featured row on `/`, or the organization in the Featured shelf on `/communities`. `unfeatured` retracts. | Surfacing rules (hide always wins): +**Campaigns** + - **Featured row on `/`** — iff the latest featured label is `featured` AND the latest hide label is not `hidden`. Ordered newest-`created_at`-of-`featured`-label first. Featured is independent of Approved at the protocol level; a campaign may be featured without being approved (the home page treats Featured and Approved as deduplicated bins, with Featured taking precedence). - **Community Campaigns grid on `/`** — iff approved, not hidden, and not featured (featured campaigns get their own row above). - **Discover shelf** — iff approved AND not hidden. - **Moderator-only "Pending"** — iff neither approved nor hidden. - **Moderator-only "Hidden"** — iff hidden. +**Organizations** + +- **Featured shelf on `/communities`** — iff the latest featured label is `featured` AND the latest hide label is not `hidden`. Ordered newest-`created_at`-of-`featured`-label first. +- **"My organizations" shelf on `/communities`** — intentionally ignores all moderation labels. A user's own founded, moderated, or followed organizations always render regardless of label state. +- **Moderator-only "Needs review"** — iff `t:agora` AND not featured AND not hidden. Surfaces orgs minted through Agora's create flow that haven't been triaged into Featured or Hidden yet. +- **Moderator-only "Hidden"** — iff hidden. +- **Hide enforcement on other organization discovery surfaces** — clients SHOULD suppress `hidden` organizations from any future "All organizations" / browse surface for non-moderators. Moderators MAY see hidden organizations with a "Hidden" treatment so they can unhide. + #### Event Structure ```json @@ -371,20 +522,33 @@ Surfacing rules (hide always wins): "tags": [ ["L", "agora.moderation"], ["l", "approved", "agora.moderation"], - ["a", "30223::"], + ["a", "33863::"], ["alt", "Campaign moderation: approved"] ] } ``` -A `featured` label has the same shape with `["l", "featured", "agora.moderation"]` and `["alt", "Campaign moderation: featured"]`. +An organization label has the same shape with a kind 34550 `a` tag: + +```json +{ + "kind": 1985, + "content": "", + "tags": [ + ["L", "agora.moderation"], + ["l", "featured", "agora.moderation"], + ["a", "34550::"], + ["alt", "Organization moderation: featured"] + ] +} +``` Required tags: - `L` set to `agora.moderation`. - `l` with the label value as the 2nd element and `agora.moderation` as the 3rd. -- `a` referencing the campaign coordinate `30223::`. -- `alt` (NIP-31) — clients without label support will display this string. +- `a` referencing the target coordinate (`33863::` for a campaign, `34550::` for an organization). +- `alt` (NIP-31) — clients without label support will display this string. The `alt` value SHOULD identify the surface (e.g. `Campaign moderation: featured` or `Organization moderation: featured`) so non-Agora clients can read it. #### Trust Model @@ -396,12 +560,14 @@ pubkey: 932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d d-tag: k4p5w0n22suf ``` -The pack `p` tags are the authoritative moderator list. Anyone may publish a kind 1985 event in the `agora.moderation` namespace, but events from non-pack authors are silently ignored at the relay-filter layer (`authors:` is pinned to the pack `p` tags). This means: +The pack `p` tags are the authoritative moderator list. Clients MUST pin `authors:` on their label REQ to the pack `p` tags; events from non-pack authors MUST be ignored. This means: - Self-approval is impossible unless the pack author has added you. -- A moderator removed from the pack immediately loses moderation authority — campaigns kept alive only by their labels return to "pending" until another moderator approves them. +- A moderator removed from the pack immediately loses moderation authority — campaigns/organizations kept alive only by their labels return to "pending" until another moderator approves them. - The pack author (single signer) can reset the entire moderator roster by republishing the pack. +The same moderator set governs both campaign and organization labels. Carving out per-surface moderator subsets is out of scope; clients that need that distinction would have to introduce a second follow pack and a second label namespace. + #### Querying Step 1 — fetch the pack: @@ -426,13 +592,14 @@ Step 2 — fetch label events from pack members in the namespace: } ``` -Step 3 — fold by `(campaign-coord, axis)`, latest-`created_at`-wins. Then fetch only the approved-and-not-hidden campaign coordinates with one filter per author (bundled in a single REQ). +Step 3 — fold by `(coord, axis)`, latest-`created_at`-wins, filtering to the relevant kind prefix (`33863:` for campaigns or `34550:` for organizations). Then fetch the targeted events themselves — one filter per author (bundled in a single REQ) keyed by their d-tags. #### Client Behavior -- Clients SHOULD render approve/hide controls only for users whose pubkey appears in the pack. -- Clients MAY display "Hidden" badges on hidden campaigns when viewed by a moderator, and SHOULD NOT render them at all to non-moderators. +- Clients SHOULD render approve/hide/feature controls only for users whose pubkey appears in the pack. +- Clients MAY display "Hidden" badges on hidden campaigns/organizations when viewed by a moderator, and SHOULD NOT render them at all to non-moderators. - Non-moderator authors viewing the homepage SHOULD see their own pending campaigns in a separate explained section so they understand why their campaign isn't yet on the homepage. The campaign URL remains live and donatable regardless of moderation state. +- Organization authors are not shown an equivalent "pending" surface today — organizations are visible at their NIP-19 route regardless of moderation, and the only moderation surface is the Featured shelf. --- diff --git a/index.html b/index.html index 33e4eb03..e6b45bec 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/package-lock.json b/package-lock.json index 84acbef3..a2801d22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,6 @@ "name": "agora", "version": "2.8.0", "dependencies": { - "@bitcoinerlab/secp256k1": "^1.2.0", "@breeztech/breez-sdk-spark": "^0.10.0", "@capacitor/app": "^8.0.0", "@capacitor/barcode-scanner": "^3.0.2", @@ -35,6 +34,7 @@ "@fontsource-variable/nunito": "^5.2.7", "@fontsource-variable/outfit": "^5.2.8", "@fontsource-variable/playfair-display": "^5.2.8", + "@fontsource/bebas-neue": "^5.2.7", "@fontsource/bungee-shade": "^5.2.7", "@fontsource/caveat": "^5.2.8", "@fontsource/cherry-bomb-one": "^5.2.7", @@ -96,15 +96,16 @@ "@radix-ui/react-toggle": "^1.1.0", "@radix-ui/react-toggle-group": "^1.1.0", "@radix-ui/react-tooltip": "^1.2.8", + "@scure/base": "^1.1.1", + "@scure/bip32": "^2.2.0", "@scure/bip39": "^1.6.0", + "@scure/btc-signer": "^2.2.0", "@sentry/react": "^10.42.0", "@tanstack/react-query": "^5.56.2", "@types/d3-geo": "^3.1.0", "@unhead/addons": "^2.1.13", "@unhead/react": "^2.1.13", - "bitcoinjs-lib": "^7.0.1", "blurhash": "^2.0.5", - "buffer": "^6.0.3", "capacitor-secure-storage-plugin": "^0.13.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", @@ -114,7 +115,6 @@ "d3-scale": "^4.0.2", "date-fns": "^3.6.0", "dompurify": "^3.3.3", - "ecpair": "^3.0.1", "embla-carousel-react": "^8.3.0", "emoji-mart": "^5.6.0", "fflate": "^0.8.2", @@ -360,30 +360,6 @@ "node": ">=6.9.0" } }, - "node_modules/@bitcoinerlab/secp256k1": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@bitcoinerlab/secp256k1/-/secp256k1-1.2.0.tgz", - "integrity": "sha512-jeujZSzb3JOZfmJYI0ph1PVpCRV5oaexCgy+RvCXV8XlY+XFB/2n3WOcvBsKLsOw78KYgnQrQWb2HrKE4be88Q==", - "license": "MIT", - "dependencies": { - "@noble/curves": "^1.7.0" - } - }, - "node_modules/@bitcoinerlab/secp256k1/node_modules/@noble/curves": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", - "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.8.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@breeztech/breez-sdk-spark": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/@breeztech/breez-sdk-spark/-/breez-sdk-spark-0.10.0.tgz", @@ -1486,6 +1462,15 @@ "url": "https://github.com/sponsors/ayuhito" } }, + "node_modules/@fontsource/bebas-neue": { + "version": "5.2.7", + "resolved": "https://registry.npmjs.org/@fontsource/bebas-neue/-/bebas-neue-5.2.7.tgz", + "integrity": "sha512-DsmBrmq55d9BCU0mt4DT4RZDdH8vhWRKEUOfbuNB1EEjMuwbtFvM8N+3gIlkYSFbsb10P8Q19BV5OdpMu2h0fA==", + "license": "OFL-1.1", + "funding": { + "url": "https://github.com/sponsors/ayuhito" + } + }, "node_modules/@fontsource/bungee-shade": { "version": "5.2.7", "resolved": "https://registry.npmjs.org/@fontsource/bungee-shade/-/bungee-shade-5.2.7.tgz", @@ -6213,55 +6198,40 @@ "license": "MIT" }, "node_modules/@scure/bip32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", - "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-2.2.0.tgz", + "integrity": "sha512-zFr7t2F+a9+5tB7QbarF2HQNYrgjCNaoLAupZdKkrFMYMozJf5zqH2WJCQibMzm1qQ0QogrxVGO3qXfQDYMaQg==", "license": "MIT", "dependencies": { - "@noble/curves": "~1.1.0", - "@noble/hashes": "~1.3.1", - "@scure/base": "~1.1.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/curves/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "license": "MIT", - "engines": { - "node": ">= 16" + "@noble/curves": "2.2.0", + "@noble/hashes": "2.2.0", + "@scure/base": "2.2.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32/node_modules/@noble/hashes": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", - "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz", + "integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==", "license": "MIT", "engines": { - "node": ">= 16" + "node": ">= 20.19.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, + "node_modules/@scure/bip32/node_modules/@scure/base": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-2.2.0.tgz", + "integrity": "sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@scure/bip39": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", @@ -6284,6 +6254,42 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@scure/btc-signer": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@scure/btc-signer/-/btc-signer-2.2.0.tgz", + "integrity": "sha512-ZXZ08sZqSZKEcOuEQnxTF66ouHtl6+UA6U/QfQM06K9WiOlEkXF4LviZCaSgkdiFh9cyMt9+xdup7JtEv3p0fw==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~2.2.0", + "@noble/hashes": "~2.2.0", + "@scure/base": "~2.2.0", + "micro-packed": "~0.9.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/btc-signer/node_modules/@noble/hashes": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz", + "integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/btc-signer/node_modules/@scure/base": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-2.2.0.tgz", + "integrity": "sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@sentry-internal/browser-utils": { "version": "10.42.0", "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-10.42.0.tgz", @@ -7741,16 +7747,11 @@ "dev": true, "license": "MIT" }, - "node_modules/base-x": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz", - "integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==", - "license": "MIT" - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "devOptional": true, "funding": [ { "type": "github", @@ -7767,12 +7768,6 @@ ], "license": "MIT" }, - "node_modules/bech32": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", - "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==", - "license": "MIT" - }, "node_modules/better-sqlite3": { "version": "12.9.0", "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.9.0.tgz", @@ -7821,37 +7816,6 @@ "file-uri-to-path": "1.0.0" } }, - "node_modules/bip174": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bip174/-/bip174-3.0.0.tgz", - "integrity": "sha512-N3vz3rqikLEu0d6yQL8GTrSkpYb35NQKWMR7Hlza0lOj6ZOlvQ3Xr7N9Y+JPebaCVoEUHdBeBSuLxcHr71r+Lw==", - "license": "MIT", - "dependencies": { - "uint8array-tools": "^0.0.9", - "varuint-bitcoin": "^2.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/bitcoinjs-lib": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-7.0.1.tgz", - "integrity": "sha512-vwEmpL5Tpj0I0RBdNkcDMXePoaYSTeKY6mL6/l5esbnTs+jGdPDuLp4NY1hSh6Zk5wSgePygZ4Wx5JJao30Pww==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "^1.2.0", - "bech32": "^2.0.0", - "bip174": "^3.0.0", - "bs58check": "^4.0.0", - "uint8array-tools": "^0.0.9", - "valibot": "^1.2.0", - "varuint-bitcoin": "^2.0.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -7965,49 +7929,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/bs58": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz", - "integrity": "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==", - "license": "MIT", - "dependencies": { - "base-x": "^5.0.0" - } - }, - "node_modules/bs58check": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-4.0.0.tgz", - "integrity": "sha512-FsGDOnFg9aVI9erdriULkd/JjEWONV/lQE5aYziB5PoBsXRind56lh8doIZIc9X4HoxT5x4bLjMWN1/NB8Zp5g==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "^1.2.0", - "bs58": "^6.0.0" - } - }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", @@ -8831,29 +8752,6 @@ "@types/trusted-types": "^2.0.7" } }, - "node_modules/ecpair": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ecpair/-/ecpair-3.0.1.tgz", - "integrity": "sha512-uz8wMFvtdr58TLrXnAesBsoMEyY8UudLOfApcyg40XfZjP+gt1xO4cuZSIkZ8hTMTQ8+ETgt7xSIV4eM7M6VNw==", - "license": "MIT", - "dependencies": { - "uint8array-tools": "^0.0.8", - "valibot": "^1.2.0", - "wif": "^5.0.0" - }, - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/ecpair/node_modules/uint8array-tools": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/uint8array-tools/-/uint8array-tools-0.0.8.tgz", - "integrity": "sha512-xS6+s8e0Xbx++5/0L+yyexukU7pz//Yg6IHg3BKhXotg1JcYtgxVcUctQ0HxLByiJzpAkNFawz1Nz5Xadzo82g==", - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/electron-to-chromium": { "version": "1.5.149", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.149.tgz", @@ -9766,7 +9664,8 @@ "url": "https://feross.org/support" } ], - "license": "BSD-3-Clause" + "license": "BSD-3-Clause", + "optional": true }, "node_modules/ignore": { "version": "5.3.2", @@ -11009,6 +10908,30 @@ "node": ">= 8" } }, + "node_modules/micro-packed": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/micro-packed/-/micro-packed-0.9.0.tgz", + "integrity": "sha512-gFdaWTxEXOwtSOcpxulO4AuXVtp3HWIRmB8eq8+3m1Zku0ubgva0UGpi03YhcvsTJasHngG9gTIUK5kHNKdesg==", + "license": "MIT", + "dependencies": { + "@scure/base": "~2.2.0" + }, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/micro-packed/node_modules/@scure/base": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-2.2.0.tgz", + "integrity": "sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/micromark": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", @@ -11874,6 +11797,32 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/nostr-tools/node_modules/@scure/bip32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", + "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.1.0", + "@noble/hashes": "~1.3.1", + "@scure/base": "~1.1.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/nostr-tools/node_modules/@scure/bip32/node_modules/@noble/curves": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", + "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/nostr-tools/node_modules/@scure/bip39": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", @@ -14698,15 +14647,6 @@ "integrity": "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==", "license": "MIT" }, - "node_modules/uint8array-tools": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/uint8array-tools/-/uint8array-tools-0.0.9.tgz", - "integrity": "sha512-9vqDWmoSXOoi+K14zNaf6LBV51Q8MayF0/IiQs3GlygIKUYtog603e6virExkjjFosfJUBI4LhbQK1iq8IG11A==", - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", @@ -15045,38 +14985,6 @@ "devOptional": true, "license": "MIT" }, - "node_modules/valibot": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/valibot/-/valibot-1.4.0.tgz", - "integrity": "sha512-iC/x7fVcSyOwlm/VSt7RlHnzNGLGvR9GnxdifUeWoCJo0q4ZZvrVkIHC6faTlkxG47I2Y4UrFquPuVHCrOnrLg==", - "license": "MIT", - "peerDependencies": { - "typescript": ">=5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/varuint-bitcoin": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-2.0.0.tgz", - "integrity": "sha512-6QZbU/rHO2ZQYpWFDALCDSRsXbAs1VOEmXAxtbtjLtKuMJ/FQ8YbhfxlaiKv5nklci0M6lZtlZyxo9Q+qNnyog==", - "license": "MIT", - "dependencies": { - "uint8array-tools": "^0.0.8" - } - }, - "node_modules/varuint-bitcoin/node_modules/uint8array-tools": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/uint8array-tools/-/uint8array-tools-0.0.8.tgz", - "integrity": "sha512-xS6+s8e0Xbx++5/0L+yyexukU7pz//Yg6IHg3BKhXotg1JcYtgxVcUctQ0HxLByiJzpAkNFawz1Nz5Xadzo82g==", - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/vaul": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vaul/-/vaul-1.1.2.tgz", @@ -16679,15 +16587,6 @@ "node": ">=8" } }, - "node_modules/wif": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/wif/-/wif-5.0.0.tgz", - "integrity": "sha512-iFzrC/9ne740qFbNjTZ2FciSRJlHIXoxqk/Y5EnE08QOXu1WjJyCCswwDTYbohAOEnlCtLaAAQBhyaLRFh2hMA==", - "license": "MIT", - "dependencies": { - "bs58check": "^4.0.0" - } - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/package.json b/package.json index 7bdd692f..be9929d2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "node": ">=22" }, "dependencies": { - "@bitcoinerlab/secp256k1": "^1.2.0", "@breeztech/breez-sdk-spark": "^0.10.0", "@capacitor/app": "^8.0.0", "@capacitor/barcode-scanner": "^3.0.2", @@ -42,6 +41,7 @@ "@fontsource-variable/nunito": "^5.2.7", "@fontsource-variable/outfit": "^5.2.8", "@fontsource-variable/playfair-display": "^5.2.8", + "@fontsource/bebas-neue": "^5.2.7", "@fontsource/bungee-shade": "^5.2.7", "@fontsource/caveat": "^5.2.8", "@fontsource/cherry-bomb-one": "^5.2.7", @@ -103,15 +103,16 @@ "@radix-ui/react-toggle": "^1.1.0", "@radix-ui/react-toggle-group": "^1.1.0", "@radix-ui/react-tooltip": "^1.2.8", + "@scure/base": "^1.1.1", + "@scure/bip32": "^2.2.0", "@scure/bip39": "^1.6.0", + "@scure/btc-signer": "^2.2.0", "@sentry/react": "^10.42.0", "@tanstack/react-query": "^5.56.2", "@types/d3-geo": "^3.1.0", "@unhead/addons": "^2.1.13", "@unhead/react": "^2.1.13", - "bitcoinjs-lib": "^7.0.1", "blurhash": "^2.0.5", - "buffer": "^6.0.3", "capacitor-secure-storage-plugin": "^0.13.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", @@ -121,7 +122,6 @@ "d3-scale": "^4.0.2", "date-fns": "^3.6.0", "dompurify": "^3.3.3", - "ecpair": "^3.0.1", "embla-carousel-react": "^8.3.0", "emoji-mart": "^5.6.0", "fflate": "^0.8.2", diff --git a/public/advanced-intro.png b/public/advanced-intro.png deleted file mode 100644 index e4aeb62a..00000000 Binary files a/public/advanced-intro.png and /dev/null differ diff --git a/public/community-intro.png b/public/community-intro.png deleted file mode 100644 index 2d83ff7d..00000000 Binary files a/public/community-intro.png and /dev/null differ diff --git a/public/feed-intro.png b/public/feed-intro.png deleted file mode 100644 index 474df32c..00000000 Binary files a/public/feed-intro.png and /dev/null differ diff --git a/public/lists-intro.png b/public/lists-intro.png deleted file mode 100644 index 77bab596..00000000 Binary files a/public/lists-intro.png and /dev/null differ diff --git a/public/magic-intro.png b/public/magic-intro.png deleted file mode 100644 index 72ef5931..00000000 Binary files a/public/magic-intro.png and /dev/null differ diff --git a/public/mute-intro.png b/public/mute-intro.png deleted file mode 100644 index 5fb77711..00000000 Binary files a/public/mute-intro.png and /dev/null differ diff --git a/public/notification-intro.png b/public/notification-intro.png deleted file mode 100644 index dc3d5eb9..00000000 Binary files a/public/notification-intro.png and /dev/null differ diff --git a/public/og-image.jpg b/public/og-image.jpg index 5f435436..0e8a18a4 100644 Binary files a/public/og-image.jpg and b/public/og-image.jpg differ diff --git a/public/profile-intro.png b/public/profile-intro.png deleted file mode 100644 index c9e05539..00000000 Binary files a/public/profile-intro.png and /dev/null differ diff --git a/public/relay-intro.png b/public/relay-intro.png deleted file mode 100644 index 554dcc99..00000000 Binary files a/public/relay-intro.png and /dev/null differ diff --git a/public/theme-intro.png b/public/theme-intro.png deleted file mode 100644 index 5c76c0ef..00000000 Binary files a/public/theme-intro.png and /dev/null differ diff --git a/src/App.tsx b/src/App.tsx index 1e1df42c..cb0ec2cb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -43,7 +43,6 @@ const hardcodedConfig: AppConfig = { shareOrigin: import.meta.env.VITE_SHARE_ORIGIN || undefined, homePage: "campaigns", client: "naddr1qvzqqqru7cpzq7q6z5ns2hm5c8msyv83qwzxpxe52j8c4d4q5m92wsp9sflelkh9qqzkg6t5w3hswjl4yp", - magicMouse: false, theme: "system", useAppRelays: true, useUserRelays: false, @@ -57,48 +56,48 @@ const hardcodedConfig: AppConfig = { feedIncludeReposts: true, feedIncludeGenericReposts: true, feedIncludeReactions: false, - feedIncludeZaps: false, + feedIncludeZaps: true, feedIncludeArticles: true, showArticles: true, showHighlights: true, - feedIncludeHighlights: false, + feedIncludeHighlights: true, showEvents: true, feedIncludeEvents: true, - showVines: true, + showVines: false, showPolls: true, - showTreasures: true, - showTreasureGeocaches: true, - showTreasureFoundLogs: true, - showColors: true, + showTreasures: false, + showTreasureGeocaches: false, + showTreasureFoundLogs: false, + showColors: false, showPeopleLists: true, - feedIncludeVines: true, + feedIncludeVines: false, feedIncludePolls: true, - feedIncludeTreasureGeocaches: true, - feedIncludeTreasureFoundLogs: true, - feedIncludeColors: true, + feedIncludeTreasureGeocaches: false, + feedIncludeTreasureFoundLogs: false, + feedIncludeColors: false, feedIncludePeopleLists: true, - showDecks: true, - feedIncludeDecks: true, - showWebxdc: true, - feedIncludeWebxdc: true, + showDecks: false, + feedIncludeDecks: false, + showWebxdc: false, + feedIncludeWebxdc: false, showPhotos: true, feedIncludePhotos: true, showVideos: true, feedIncludeNormalVideos: true, feedIncludeShortVideos: true, feedIncludeVoiceMessages: true, - showEmojiPacks: true, - feedIncludeEmojiPacks: true, - showCustomEmojis: true, - showUserStatuses: true, - showMusic: true, - feedIncludeMusicTracks: true, - feedIncludeMusicPlaylists: true, - showPodcasts: true, - feedIncludePodcastEpisodes: true, - feedIncludePodcastTrailers: true, - showDevelopment: true, - feedIncludeDevelopment: true, + showEmojiPacks: false, + feedIncludeEmojiPacks: false, + showCustomEmojis: false, + showUserStatuses: false, + showMusic: false, + feedIncludeMusicTracks: false, + feedIncludeMusicPlaylists: false, + showPodcasts: false, + feedIncludePodcastEpisodes: false, + feedIncludePodcastTrailers: false, + showDevelopment: false, + feedIncludeDevelopment: false, showCommunities: true, feedIncludeCommunities: true, showBadges: true, @@ -109,10 +108,10 @@ const hardcodedConfig: AppConfig = { feedIncludeProfileBadges: true, feedIncludeBadgeAwards: true, feedIncludeVanish: true, - showBirdstar: true, - feedIncludeBirdDetections: true, - feedIncludeBirdex: true, - feedIncludeConstellations: true, + showBirdstar: false, + feedIncludeBirdDetections: false, + feedIncludeBirdex: false, + feedIncludeConstellations: false, followsFeedShowReplies: true, }, sidebarOrder: [ @@ -147,7 +146,13 @@ const hardcodedConfig: AppConfig = { imageQuality: 'compressed', curatorPubkey: '932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d', sandboxDomain: 'iframe.diy', - esploraBaseUrl: 'https://mempool.space/api', + esploraApis: [ + 'https://mempool.space/api', + 'https://mempool.emzy.de/api', + 'https://blockstream.info/api', + ], + blockbookBaseUrl: 'https://btc.trezor.io', + bip352IndexerUrl: 'https://silentpayments.dev/blindbit/mainnet', sidebarWidgets: [ { id: 'trends' }, { id: 'hot-posts' }, diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 9655b07a..39d0c2e5 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -25,7 +25,7 @@ const ReplyComposeModal = lazy(() => import("@/components/ReplyComposeModal").th const EmojiPackDialog = lazy(() => import("@/components/EmojiPackDialog").then(m => ({ default: m.EmojiPackDialog }))); // Campaigns: home + create. (Campaign detail is dispatched from NIP19Page -// when an naddr resolves to kind 30223.) The campaigns list IS the homepage; +// when an naddr resolves to kind 33863.) The campaigns list IS the homepage; // the configurable HomePage delegation from the Twitter-era app is gone. const CampaignsPage = lazy(() => import("./pages/CampaignsPage").then(m => ({ default: m.CampaignsPage }))); const CreateCampaignPage = lazy(() => import("./pages/CreateCampaignPage").then(m => ({ default: m.CreateCampaignPage }))); @@ -47,10 +47,8 @@ const ChangelogPage = lazy(() => import("./pages/ChangelogPage").then(m => ({ de const CommunitiesPage = lazy(() => import("./pages/CommunitiesPage").then(m => ({ default: m.CommunitiesPage }))); const CreateCommunityPage = lazy(() => import("./pages/CreateCommunityPage").then(m => ({ default: m.CreateCommunityPage }))); const CreateEventPage = lazy(() => import("./pages/CreateEventPage").then(m => ({ default: m.CreateEventPage }))); -const ContentPage = lazy(() => import("./pages/ContentPage").then(m => ({ default: m.ContentPage }))); const ContentSettingsPage = lazy(() => import("./pages/ContentSettingsPage").then(m => ({ default: m.ContentSettingsPage }))); const CSAEPolicyPage = lazy(() => import("./pages/CSAEPolicyPage").then(m => ({ default: m.CSAEPolicyPage }))); -const DiscoverPage = lazy(() => import("./pages/DiscoverPage").then(m => ({ default: m.DiscoverPage }))); const DomainFeedPage = lazy(() => import("./pages/DomainFeedPage").then(m => ({ default: m.DomainFeedPage }))); const EventsFeedPage = lazy(() => import("./pages/EventsFeedPage").then(m => ({ default: m.EventsFeedPage }))); const ExternalContentPage = lazy(() => import("./pages/ExternalContentPage").then(m => ({ default: m.ExternalContentPage }))); @@ -63,7 +61,6 @@ const KindFeedPage = lazy(() => import("./pages/KindFeedPage").then(m => ({ defa const LetterComposePage = lazy(() => import("./pages/LetterComposePage").then(m => ({ default: m.LetterComposePage }))); const LetterPreferencesPage = lazy(() => import("./pages/LetterPreferencesPage").then(m => ({ default: m.LetterPreferencesPage }))); const LettersPage = lazy(() => import("./pages/LettersPage").then(m => ({ default: m.LettersPage }))); -const MagicSettingsPage = lazy(() => import("./pages/MagicSettingsPage").then(m => ({ default: m.MagicSettingsPage }))); const MusicPage = lazy(() => import("./pages/MusicPage").then(m => ({ default: m.MusicPage }))); const NetworkSettingsPage = lazy(() => import("./pages/NetworkSettingsPage").then(m => ({ default: m.NetworkSettingsPage }))); const NIP19Page = lazy(() => import("./pages/NIP19Page").then(m => ({ default: m.NIP19Page }))); @@ -93,7 +90,6 @@ const WorldPage = lazy(() => import("./pages/WorldPage").then(m => ({ default: m const FollowPage = lazy(() => import("./pages/FollowPage").then(m => ({ default: m.FollowPage }))); const PlanetoraPage = lazy(() => import("./pages/PlanetoraPage").then(m => ({ default: m.PlanetoraPage }))); const ReceivePage = lazy(() => import("./pages/ReceivePage").then(m => ({ default: m.ReceivePage }))); -const ClaimPage = lazy(() => import("./pages/ClaimPage").then(m => ({ default: m.ClaimPage }))); const RemoteLoginSuccessPage = lazy(() => import("./pages/RemoteLoginSuccessPage").then(m => ({ default: m.RemoteLoginSuccessPage }))); const pollsDef = getExtraKindDef("polls")!; @@ -167,13 +163,11 @@ export function AppRouter() { {/* Auto-follow deep link: fullscreen immersive (no sidebars/nav) */} } /> } /> - } /> {/* All routes share the persistent FundraiserLayout (top nav + footer) */} } /> }> } /> - } /> } /> } /> } /> @@ -190,7 +184,6 @@ export function AppRouter() { } /> } /> } /> - } /> } /> } /> - } /> } /> } /> } /> diff --git a/src/components/ArcBackground.tsx b/src/components/ArcBackground.tsx index bccb7f70..9746382b 100644 --- a/src/components/ArcBackground.tsx +++ b/src/components/ArcBackground.tsx @@ -33,6 +33,8 @@ interface ArcBackgroundProps { variant: 'down' | 'up' | 'rect'; /** Extra classes on the element. */ className?: string; + /** Extra classes on the filled background path. */ + fillClassName?: string; } /** @@ -40,7 +42,7 @@ interface ArcBackgroundProps { * MobileBottomNav. Draws a semi-transparent filled shape (rectangle + optional * curved arc) as a single path so there are no sub-pixel seams between layers. */ -export function ArcBackground({ variant, className }: ArcBackgroundProps) { +export function ArcBackground({ variant, className, fillClassName }: ArcBackgroundProps) { const path = variant === 'down' ? ARC_DOWN_PATH : variant === 'up' ? ARC_UP_PATH : RECT_PATH; const hasArc = variant !== 'rect'; @@ -57,7 +59,7 @@ export function ArcBackground({ variant, className }: ArcBackgroundProps) { preserveAspectRatio="none" style={hasArc ? (variant === 'up' ? arcUpHeightStyle : arcDownHeightStyle) : fullHeightStyle} > - + {variant === 'down' && } {variant === 'up' && } diff --git a/src/components/BanConfirmDialog.tsx b/src/components/BanConfirmDialog.tsx index aa01b5fc..f855b1a1 100644 --- a/src/components/BanConfirmDialog.tsx +++ b/src/components/BanConfirmDialog.tsx @@ -64,8 +64,25 @@ export function BanConfirmDialog({ }); // Invalidate community queries so the moderation overlay updates - // immediately (removes banned content without a page refresh). - await queryClient.invalidateQueries({ queryKey: ['community-members', communityATag] }); + // immediately (removes banned content without a page refresh). The + // activity feed's key is `['community-activity-feed', ]` + // where aTagsKey is a comma-joined list of the viewer's subscribed A + // tags. Predicate-match any feed whose aTagsKey contains this + // communityATag so the banned post disappears immediately. + await Promise.all([ + queryClient.invalidateQueries({ queryKey: ['community-members', communityATag] }), + queryClient.invalidateQueries({ + predicate: (q) => { + const [root, aTagsKey] = q.queryKey; + return root === 'community-activity-feed' + && typeof aTagsKey === 'string' + && aTagsKey.split(',').includes(communityATag); + }, + }), + // Also refresh the organization-activity feed shown on the org + // detail page (used by the pledge/campaign shelves). + queryClient.invalidateQueries({ queryKey: ['organization-activity', communityATag] }), + ]); toast({ title: 'Post removed from organization' }); setReason(''); diff --git a/src/components/BeneficiaryDonateDialog.tsx b/src/components/BeneficiaryDonateDialog.tsx deleted file mode 100644 index 77dcc680..00000000 --- a/src/components/BeneficiaryDonateDialog.tsx +++ /dev/null @@ -1,190 +0,0 @@ -import { useMemo, useState } from 'react'; -import { Link } from 'react-router-dom'; -import { AlertTriangle, Check, Copy, ExternalLink } from 'lucide-react'; - -import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; -import { BitcoinPublicDisclaimer } from '@/components/BitcoinPublicDisclaimer'; -import { Button } from '@/components/ui/button'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, -} from '@/components/ui/dialog'; -import { Label } from '@/components/ui/label'; -import { QRCodeCanvas } from '@/components/ui/qrcode'; -import { useAuthor } from '@/hooks/useAuthor'; -import { useProfileUrl } from '@/hooks/useProfileUrl'; -import { useToast } from '@/hooks/useToast'; -import { nostrPubkeyToBitcoinAddress } from '@/lib/bitcoin'; -import { genUserName } from '@/lib/genUserName'; -import { sanitizeUrl } from '@/lib/sanitizeUrl'; - -interface BeneficiaryDonatePanelProps { - /** Hex pubkey of the beneficiary. */ - pubkey: string; -} - -/** - * Inline panel rendering a beneficiary's Taproot address as a scannable - * BIP-21 QR code, a copyable string, and an "Open in wallet" button. - * - * Used both by `BeneficiaryDonateDialog` (modal context) and embedded - * directly into the campaign page when there's a single beneficiary. - * - * Always shows the beneficiary's profile preview (avatar + name) as a - * link to their Nostr profile — even when the surrounding page also - * identifies a campaign organizer, the beneficiary is a distinct party - * (the organizer may be running the campaign on someone else's behalf). - * - * Intentionally minimal: no amount input, no PSBT/in-app wallet flow — - * that's `DonateDialog`'s job. - */ -export function BeneficiaryDonatePanel({ - pubkey, -}: BeneficiaryDonatePanelProps) { - const { toast } = useToast(); - const [copied, setCopied] = useState(false); - - const author = useAuthor(pubkey); - const metadata = author.data?.metadata; - const displayName = - metadata?.display_name || metadata?.name || genUserName(pubkey); - const picture = sanitizeUrl(metadata?.picture); - const profileUrl = useProfileUrl(pubkey, metadata); - - const address = useMemo( - () => nostrPubkeyToBitcoinAddress(pubkey), - [pubkey], - ); - // BIP-21 URI: most wallets recognize the `bitcoin:` scheme when scanning. - // No amount field — donor picks one in their wallet. - const bip21 = address ? `bitcoin:${address}` : ''; - - const copyAddress = async () => { - if (!address) return; - try { - await navigator.clipboard.writeText(address); - setCopied(true); - setTimeout(() => setCopied(false), 1500); - toast({ title: 'Address copied' }); - } catch { - toast({ - title: 'Copy failed', - description: 'Select and copy the address manually.', - variant: 'destructive', - }); - } - }; - - if (!address) { - return ( -
- - We couldn't derive a Bitcoin address for this beneficiary. -
- ); - } - - return ( -
- - - {picture && } - - {displayName.slice(0, 2).toUpperCase()} - - -
-
{displayName}
-
- - - {/* QR code */} -
-
- -
-
- - {/* Copyable address */} -
- - -
- - {/* Privacy notice — informational only. Bitcoin is a public - ledger, so the donation can be traced back to the donor's - wallet. */} - - - {/* Open in wallet — relies on the `bitcoin:` URI handler. */} - -
- ); -} - -interface BeneficiaryDonateDialogProps { - /** Hex pubkey of the beneficiary. */ - pubkey: string; - open: boolean; - onOpenChange: (open: boolean) => void; -} - -/** - * Modal wrapper around `BeneficiaryDonatePanel` for places that still want - * the dialog UX (e.g. multi-beneficiary campaigns, where each row's - * "Donate" button opens this dialog). - */ -export function BeneficiaryDonateDialog({ - pubkey, - open, - onOpenChange, -}: BeneficiaryDonateDialogProps) { - const author = useAuthor(pubkey); - const metadata = author.data?.metadata; - const displayName = - metadata?.display_name || metadata?.name || genUserName(pubkey); - - return ( - - - - Donate to {displayName} - - Scan the QR code or copy the Bitcoin address below to donate. - - - - - - - ); -} diff --git a/src/components/BitcoinPrivateDisclaimer.tsx b/src/components/BitcoinPrivateDisclaimer.tsx new file mode 100644 index 00000000..38388848 --- /dev/null +++ b/src/components/BitcoinPrivateDisclaimer.tsx @@ -0,0 +1,51 @@ +import { Alert, AlertDescription } from '@/components/ui/alert'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover'; + +/** + * Informational notice for BIP-352 silent-payment receive endpoints + * (sp1…). Surfaces the "private but experimental" trade-off the user + * accepts when they choose silent payments instead of a regular + * on-chain address. + * + * Visual treatment mirrors `BitcoinPublicDisclaimer` with `tone="soft"`: + * `role="note"`, amber tint, no icon, no checkbox. The lead sentence + * carries the headline, and "Learn more" opens a popover with the full + * explanation. + */ +export function BitcoinPrivateDisclaimer() { + return ( + + {/* No icon — the shadcn Alert reserves left padding for an icon via + `[&>svg~*]:pl-7`, so omitting it reclaims the indent. */} + +

+ Experimental. Donations are private, but bugs may occur.{' '} + + + + + + Your private wallet hides the real address of your wallet + and your donors on the Bitcoin network. Funds are always + fully recoverable, but bugs in the wallet may cause it to + show an incorrect balance, and it may require long wait + times to synchronize. + + +

+
+
+ ); +} diff --git a/src/components/BitcoinPublicDisclaimer.tsx b/src/components/BitcoinPublicDisclaimer.tsx index b354072b..d60c1275 100644 --- a/src/components/BitcoinPublicDisclaimer.tsx +++ b/src/components/BitcoinPublicDisclaimer.tsx @@ -1,3 +1,4 @@ +import type { ReactNode } from 'react'; import { AlertTriangle } from 'lucide-react'; import { Alert, AlertDescription } from '@/components/ui/alert'; @@ -41,6 +42,14 @@ interface BitcoinPublicDisclaimerProps { * Defaults to `true` for backwards compatibility. */ includeCashOutAdvice?: boolean; + /** + * Override the popover body. When set, replaces the entire "Bitcoin + * is a public ledger…" paragraph (including the cash-out advice). Use + * when the calling surface has a meaningfully different audience — + * e.g. a campaign *creator* configuring a receive address, vs. the + * sender flow this component was originally written for. + */ + popoverText?: ReactNode; } /** @@ -56,6 +65,7 @@ export function BitcoinPublicDisclaimer({ leadText = 'Money you send is public and can be traced back to you.', tone = 'destructive', includeCashOutAdvice = true, + popoverText, }: BitcoinPublicDisclaimerProps) { const showCheckbox = onAcknowledgedChange !== undefined; const isSoft = tone === 'soft'; @@ -67,7 +77,12 @@ export function BitcoinPublicDisclaimer({ role={isSoft ? 'note' : 'alert'} className={cn( isSoft - ? 'border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100' + // Use the project's foreground token (not raw amber-900) so + // the text always contrasts against the page in both light + // and dark themes. The faint amber tint keeps the + // "informational notice" cue without leaning on hard-coded + // amber text that disappears on the wrong backdrop. + ? 'border-amber-500/30 bg-amber-500/10 text-foreground' : 'border-destructive/50 bg-destructive/5 text-destructive dark:border-destructive', )} > @@ -88,11 +103,15 @@ export function BitcoinPublicDisclaimer({ - Bitcoin is a public ledger. Transactions you send can - be traced back to you forever, even after being - exchanged by multiple people. Send it only to those - you wish to support publicly - {includeCashOutAdvice ? ', or cash out at an exchange.' : '.'} + {popoverText ?? ( + <> + Bitcoin is a public ledger. Transactions you send can + be traced back to you forever, even after being + exchanged by multiple people. Send it only to those + you wish to support publicly + {includeCashOutAdvice ? ', or cash out at an exchange.' : '.'} + + )}

diff --git a/src/components/CalendarEventDetailPage.tsx b/src/components/CalendarEventDetailPage.tsx index 9512a197..370b54b0 100644 --- a/src/components/CalendarEventDetailPage.tsx +++ b/src/components/CalendarEventDetailPage.tsx @@ -1,8 +1,8 @@ import { useMemo, useCallback, useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { - ArrowLeft, CalendarDays, + ChevronLeft, MapPin, Clock, Users, @@ -18,10 +18,12 @@ import type { NostrEvent, NostrMetadata } from '@nostrify/nostrify'; import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; -import { Separator } from '@/components/ui/separator'; +import { Card, CardContent } from '@/components/ui/card'; +import { DetailCommentComposer } from '@/components/DetailCommentComposer'; import { NoteContent } from '@/components/NoteContent'; import { NoteMoreMenu } from '@/components/NoteMoreMenu'; import { PostActionBar } from '@/components/PostActionBar'; +import { PinnedCommentHeader } from '@/components/PinnedCommentHeader'; import { ReplyComposeModal } from '@/components/ReplyComposeModal'; import { CreateCommunityEventDialog } from '@/components/CreateCommunityEventDialog'; import { RSVPAvatars } from '@/components/RSVPAvatars'; @@ -33,9 +35,11 @@ import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useEventRSVPs } from '@/hooks/useEventRSVPs'; import { useMyRSVP } from '@/hooks/useMyRSVP'; import { usePublishRSVP } from '@/hooks/usePublishRSVP'; +import { usePinnedEventComments } from '@/hooks/usePinnedEventComments'; import { useProfileUrl } from '@/hooks/useProfileUrl'; import { useToast } from '@/hooks/useToast'; import { genUserName } from '@/lib/genUserName'; +import { openUrl } from '@/lib/downloadFile'; import { sanitizeUrl } from '@/lib/sanitizeUrl'; import { cn } from '@/lib/utils'; @@ -126,6 +130,26 @@ function formatDetailDate(event: NostrEvent): string { return startStr; } +function formatCalendarHeroDate(event: NostrEvent): string | null { + const startRaw = getTag(event.tags, 'start'); + if (!startRaw) return null; + + if (event.kind === 31922) { + const [year, month, day] = startRaw.split('-').map(Number); + const date = new Date(year, month - 1, day); + if (isNaN(date.getTime())) return startRaw; + return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); + } + + const timestamp = Number(startRaw); + if (!Number.isFinite(timestamp)) return startRaw; + const startTzid = getTag(event.tags, 'start_tzid'); + return new Date(timestamp * 1000).toLocaleDateString('en-US', { + month: 'short', day: 'numeric', year: 'numeric', + ...(startTzid ? { timeZone: startTzid } : {}), + }); +} + const ROLE_ORDER = ['host', 'speaker', 'moderator', 'participant']; function roleSort(a: string, b: string): number { const ai = ROLE_ORDER.indexOf(a.toLowerCase()); @@ -162,6 +186,15 @@ function PersonRow({ pubkey, label, size = 'md' }: { pubkey: string; label?: str ); } +function EventDetailRow({ icon, children }: { icon: React.ReactNode; children: React.ReactNode }) { + return ( +
+
{icon}
+
{children}
+
+ ); +} + // --- Main Component --- export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { @@ -170,7 +203,7 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { const { toast } = useToast(); const title = getTag(event.tags, 'title') ?? 'Untitled Event'; - const image = getTag(event.tags, 'image'); + const image = sanitizeUrl(getTag(event.tags, 'image')); const locationRaw = getTag(event.tags, 'location'); const location = locationRaw ? parseLocation(locationRaw) : undefined; const summary = getTag(event.tags, 'summary'); @@ -179,6 +212,7 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { const eventCoord = useMemo(() => getEventCoord(event), [event]); const dateStr = useMemo(() => formatDetailDate(event), [event]); + const heroDate = useMemo(() => formatCalendarHeroDate(event), [event]); // Participants grouped by role const participantsByRole = useMemo(() => { @@ -200,6 +234,12 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { const myRsvp = useMyRSVP(eventCoord); const publishRSVP = usePublishRSVP(); const { data: commentsData, isLoading: commentsLoading } = useComments(event, 500); + const { + pinnedEvents, + isPinned, + canManagePins, + togglePin, + } = usePinnedEventComments(eventCoord, event.pubkey); const [replyOpen, setReplyOpen] = useState(false); const [moreMenuOpen, setMoreMenuOpen] = useState(false); const [editOpen, setEditOpen] = useState(false); @@ -225,6 +265,11 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { .map((comment) => buildNode(comment)); }, [commentsData]); + const pinnedNodes = useMemo( + () => pinnedEvents.map((event): ReplyNode => ({ event, children: [] })), + [pinnedEvents], + ); + const handleRSVP = useCallback(async (status: 'accepted' | 'declined' | 'tentative') => { if (status === myRsvp.status) return; try { @@ -240,202 +285,339 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { }, [eventCoord, event.pubkey, myRsvp.status, publishRSVP, toast]); const showRSVP = !!user; + const attendingCount = rsvps.accepted.length; + const interestedCount = rsvps.tentative.length; + const rsvpStatusLabel = myRsvp.status === 'accepted' + ? 'You are going' + : myRsvp.status === 'tentative' + ? 'You are interested' + : myRsvp.status === 'declined' + ? "You can't go" + : 'Choose your RSVP'; - return ( -
- {/* ── Standard top bar ── */} -
- -

Event Details

- {canEdit && ( - + const eventDetailsCard = ( + + +
+
Hosted by
+ +
+ + {(event.content || summary) && ( +
+
Description
+ {event.content ? ( + + ) : ( +

{summary}

+ )} +
)} -
- {/* ── Cover image ── */} - {image ? ( -
- {title} -
- ) : ( -
- -
- )} - - {/* ── Content ── */} -
- {/* Title */} -

{title}

- {/* Organizer row */} -
-
- -
-
- - {/* Date & Location — sidebar-style pills */} -
-
- - {dateStr} -
+
+ }> + {dateStr} + {location && ( -
- - {location} -
+ }> + {location} + )}
- {/* Hashtags */} - {hashtags.length > 0 && ( -
- {hashtags.map((tag) => ( - - - #{tag} - - - ))} + {showRSVP && ( +
+
+
RSVP
+ {rsvpStatusLabel} +
+
+ + + +
)} - {/* Description */} - {(event.content || summary) && ( - <> - -
-

About

- {event.content ? ( - - ) : ( -

{summary}

+ {rsvps.total > 0 && ( +
+
Attendees
+
+ {([ + ['Going', rsvps.accepted, 'border-green-500/50 bg-green-500/5 text-green-600'], + ['Interested', rsvps.tentative, 'border-amber-500/50 bg-amber-500/5 text-amber-600'], + ["Can't Go", rsvps.declined, 'border-muted-foreground/30 bg-muted/30 text-muted-foreground'], + ] as const).map(([label, pks, cls]) => pks.length > 0 && ( +
+ {label} ({pks.length}) + +
+ ))} +
+
+ )} + + {links.length > 0 && ( +
+
Links
+
+ {links.map((url) => ( + + ))} +
+
+ )} + + + ); + + const participantsCard = participantsByRole.length > 0 ? ( + + +
Participants
+
+ {participantsByRole.map(([role, pubkeys]) => + pubkeys.map((pk) => ), + )} +
+
+
+ ) : null; + + return ( +
+
+
+ {image ? ( + + ) : ( +
+ +
+ )} +
+ +
+ + {canEdit && ( + + )} +
+ +
+
+

+ {title} +

+
+
+ {heroDate && ( + + + {heroDate} + + )} + {location && ( + + + {location} + + )} + {attendingCount > 0 && ( + + + {attendingCount} attending + + )} + {interestedCount > 0 && ( + + + {interestedCount} interested + + )} +
+ {summary && ( +

+ {summary} +

+ )} +
+
+
+ +
+
+ setReplyOpen(true)} + onMore={() => setMoreMenuOpen(true)} + /> +
+
+ + {pinnedNodes.length > 0 && ( +
+
+ ( + handleTogglePin(event)} + /> + )} + /> +
+
+ )} + +
+
+ {eventDetailsCard} + {participantsCard} +
+ +
+
+
+ {hashtags.length > 0 && ( +
+ {hashtags.map((tag) => ( + + + #{tag} + + + ))} +
+ )} + + {(event.content || summary) && ( +
+ {event.content ? ( + + ) : ( +

{summary}

+ )} +
)}
- - )} - {/* External links */} - {links.length > 0 && ( -
- {links.map((url) => ( - - - {url.replace(/^https?:\/\//, '')} - - - ))} +
+
+

Comments

+ {replyTree.length > 0 ? ( + + {replyTree.length.toLocaleString()} {replyTree.length === 1 ? 'comment' : 'comments'} + + ) : null} +
+ + + + {commentsLoading ? ( +
+ {Array.from({ length: 3 }).map((_, i) => ( +
+
+ +
+ + + +
+
+
+ ))} +
+ ) : replyTree.length > 0 ? ( +
+ ( + handleTogglePin(event)} + /> + )} + /> +
+ ) : ( + + )} +
- )} - {/* Participants */} - {participantsByRole.length > 0 && ( - <> - -
-

- Participants -

-
- {participantsByRole.map(([role, pubkeys]) => - pubkeys.map((pk) => ), - )} -
-
- - )} - - {/* Attendees */} - {rsvps.total > 0 && ( - <> - -
-

- Attendees -

-
- {([ - ['Going', rsvps.accepted, 'border-green-500/50 bg-green-500/5 text-green-600'], - ['Interested', rsvps.tentative, 'border-amber-500/50 bg-amber-500/5 text-amber-600'], - ["Can't Go", rsvps.declined, 'border-muted-foreground/30 bg-muted/30 text-muted-foreground'], - ] as const).map(([label, pks, cls]) => pks.length > 0 && ( -
- {label} ({pks.length}) - -
- ))} -
-
- - )} - - {/* RSVP section */} - {showRSVP && ( - <> - -
-

- RSVP -

-
- - - -
-
- - )} - - setReplyOpen(true)} - onMore={() => setMoreMenuOpen(true)} - className="-mx-5 px-5" - /> + +
@@ -446,32 +628,40 @@ export function CalendarEventDetailPage({ event }: { event: NostrEvent }) { event={event} /> )} - -
- {commentsLoading ? ( -
- {Array.from({ length: 3 }).map((_, i) => ( -
- -
- - - -
-
- ))} -
- ) : replyTree.length > 0 ? ( -
- -
- ) : ( -
- No comments yet. Be the first to comment! -
- )} -
-
+
+ ); + + function handleTogglePin(event: NostrEvent) { + const wasPinned = isPinned(event.id); + togglePin.mutate(event.id, { + onSuccess: () => { + toast({ title: wasPinned ? 'Unpinned from event' : 'Pinned to event' }); + }, + onError: () => { + toast({ title: 'Failed to update event pins', variant: 'destructive' }); + }, + }); + } +} + +function EventPinHeader({ + isPinned, + canManagePins, + pinPending, + onTogglePin, +}: { + isPinned: boolean; + canManagePins: boolean; + pinPending: boolean; + onTogglePin: () => void; +}) { + return ( + ); } diff --git a/src/components/CampaignCard.tsx b/src/components/CampaignCard.tsx index e3feb639..ae6ece7f 100644 --- a/src/components/CampaignCard.tsx +++ b/src/components/CampaignCard.tsx @@ -1,6 +1,7 @@ import { useMemo } from 'react'; +import type { ReactNode } from 'react'; import { Link } from 'react-router-dom'; -import { CalendarClock, HandHeart, MapPin, Target, Users, Archive } from 'lucide-react'; +import { CalendarClock, EyeOff, HandHeart, MapPin, ShieldCheck, Target } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Card } from '@/components/ui/card'; @@ -15,9 +16,8 @@ import { type ParsedCampaign, encodeCampaignNaddr, getCampaignCountryLabel, - getCampaignPrimaryTagLabel, } from '@/lib/campaign'; -import { formatCampaignAmount } from '@/lib/formatCampaignAmount'; +import { formatCampaignAmount, formatUsdGoal, satsToUsd } from '@/lib/formatCampaignAmount'; import { genUserName } from '@/lib/genUserName'; import { sanitizeUrl } from '@/lib/sanitizeUrl'; import { cn } from '@/lib/utils'; @@ -33,20 +33,32 @@ function formatDeadline(unixSeconds: number): { label: string; isPast: boolean } return { label: `${months} mo left`, isPast: false }; } -/** Short helper rendered both inline (cards) and in the detail page. */ +/** + * Short helper rendered both inline (cards) and in the detail page. + * + * Per NIP.md Kind 33863, the campaign **goal** is integer USD and the + * **raised** total is the sum of verified sats. We render both in the + * goal's unit (USD) for consistency, converting the sats total at view + * time using the live BTC price. While the price is loading the raised + * amount falls back to sats. + */ export function CampaignProgress({ raisedSats, - goalSats, + goalUsd, btcPrice, className, }: { raisedSats: number; - goalSats?: number; + goalUsd?: number; btcPrice?: number; className?: string; }) { - const hasGoal = !!goalSats && goalSats > 0; - const pct = hasGoal ? Math.min(100, Math.round((raisedSats / goalSats!) * 100)) : 0; + const hasGoal = !!goalUsd && goalUsd > 0; + const raisedUsd = satsToUsd(raisedSats, btcPrice); + const pct = hasGoal && raisedUsd !== undefined + ? Math.min(100, Math.round((raisedUsd / goalUsd!) * 100)) + : 0; + return (
{hasGoal && } @@ -56,32 +68,59 @@ export function CampaignProgress({ {!hasGoal && raised} {hasGoal && ( - of {formatCampaignAmount(goalSats!, btcPrice)} goal + of {formatUsdGoal(goalUsd!)} goal )}
); } +/** + * Replaces {@link CampaignProgress} for silent-payment campaigns, where + * on-chain totals are unobservable by design. Shows the goal as a target + * (if set) but no progress bar or raised amount. + */ +export function CampaignPrivateNotice({ + goalUsd, + className, +}: { + goalUsd?: number; + className?: string; +}) { + return ( +
+
+ + Private campaign — totals are not public +
+ {goalUsd && goalUsd > 0 && ( +
Target: {formatUsdGoal(goalUsd)}
+ )} +
+ ); +} + interface CampaignCardProps { campaign: ParsedCampaign; /** Visual variant: `compact` for grid items, `featured` for hero placement. */ variant?: 'compact' | 'featured'; className?: string; + /** Optional footer affordance rendered opposite the author line. */ + footerBadge?: ReactNode; } /** * Renders a single campaign as a clickable card. The whole card is a * `` to the campaign's naddr-based detail route. */ -export function CampaignCard({ campaign, variant = 'compact', className }: CampaignCardProps) { +export function CampaignCard({ campaign, variant = 'compact', className, footerBadge }: CampaignCardProps) { const author = useAuthor(campaign.pubkey); - const { data: stats } = useCampaignDonations(campaign.aTag); + const { data: stats } = useCampaignDonations(campaign); const { data: btcPrice } = useBtcPrice(); const { data: moderation } = useCampaignModeration(); const naddr = useMemo(() => encodeCampaignNaddr(campaign), [campaign]); - const cover = sanitizeUrl(campaign.image); + const cover = sanitizeUrl(campaign.banner); const creatorName = author.data?.metadata?.display_name || author.data?.metadata?.name || @@ -89,7 +128,7 @@ export function CampaignCard({ campaign, variant = 'compact', className }: Campa const deadline = campaign.deadline ? formatDeadline(campaign.deadline) : null; const raisedSats = stats?.totalSats ?? 0; const countryLabel = getCampaignCountryLabel(campaign); - const tagLabel = getCampaignPrimaryTagLabel(campaign); + const isSilentPayment = campaign.wallet.mode === 'sp'; const isFeaturedVariant = variant === 'featured'; const isApproved = moderation.approvedCoords.has(campaign.aTag); @@ -129,29 +168,22 @@ export function CampaignCard({ campaign, variant = 'compact', className }: Campa
)} - {tagLabel && ( + {isSilentPayment && ( - {tagLabel} + + Private )}
- {campaign.archived && ( - - - Archived - - )} {isHidden && ( + Hidden )} @@ -190,16 +222,15 @@ export function CampaignCard({ campaign, variant = 'compact', className }: Campa
- + {isSilentPayment ? ( + + ) : ( + + )} {/* Meta row */}
- - - {campaign.recipients.length}{' '} - {campaign.recipients.length === 1 ? 'recipient' : 'recipients'} - - {stats && stats.donorCount > 0 && ( + {!isSilentPayment && stats && stats.donorCount > 0 && ( {stats.donorCount} {stats.donorCount === 1 ? 'donor' : 'donors'} @@ -224,8 +255,11 @@ export function CampaignCard({ campaign, variant = 'compact', className }: Campa )}
-
- by {creatorName} +
+
+ by {creatorName} +
+ {footerBadge &&
{footerBadge}
}
diff --git a/src/components/CampaignHeroBackground.tsx b/src/components/CampaignHeroBackground.tsx deleted file mode 100644 index e72d98b5..00000000 --- a/src/components/CampaignHeroBackground.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import { useEffect, useRef, useState } from 'react'; - -import { sanitizeUrl } from '@/lib/sanitizeUrl'; -import { cn } from '@/lib/utils'; -interface CampaignHeroBackgroundProps { - /** - * Image URL for the active campaign. Each new URL crossfades over the - * previous one — we keep up to two layers mounted at a time so the - * transition is smooth even when the source changes mid-fade. - */ - imageUrl: string | undefined; - /** Optional className for the outer wrapper. */ - className?: string; -} - -interface Layer { - /** Stable key so React doesn't tear down the layer mid-transition. */ - id: number; - /** Sanitized URL (or `null` for the gradient-only fallback). */ - url: string | null; -} - -const FADE_MS = 1500; - -/** - * Full-bleed crossfading background built from the active campaign's banner - * image. Modelled after Treasures' HeroGallery: each image gets its own - * stacked layer and we toggle opacity to crossfade. The previous layer - * unmounts after the fade completes, so we never accumulate more than a - * couple of layers in the DOM. - * - * A warm tint + subtle film-grain SVG sit on top so headlines stay readable - * over any photo. - */ -export function CampaignHeroBackground({ imageUrl, className }: CampaignHeroBackgroundProps) { - const idRef = useRef(0); - const [layers, setLayers] = useState([]); - const lastUrlRef = useRef(null); - - useEffect(() => { - const safe = sanitizeUrl(imageUrl) ?? null; - if (safe === lastUrlRef.current) return; - lastUrlRef.current = safe; - - const id = ++idRef.current; - // Add the new layer; existing layers stay mounted so the crossfade has - // something to fade from. - setLayers((prev) => [...prev, { id, url: safe }]); - - // After the fade completes, drop everything except the most recent - // layer to keep the DOM tidy. - const timeout = window.setTimeout(() => { - setLayers((prev) => prev.filter((l) => l.id === id)); - }, FADE_MS + 50); - return () => window.clearTimeout(timeout); - }, [imageUrl]); - - return ( -