Commit Graph
3 Commits
Author SHA1 Message Date
CatoandClaude 4187188712 feat(events): buy a paid ticket without an account; listing pages open again on phones (#1313)
A paid event sent every signed-out visitor to sign up. For Bitcoin the
account-free rail already existed (public support, tips), so a guest now
gives a name and pays the organizer's own wallet directly:

- guestTicketPurchase: publication gate, sold-out refusal before payment,
  server-side price, an intent carrying guest_name and a bearer status token.
- Settlement issues the ticket to that name (issue_paid_guest_ticket,
  idempotent on the payment); the public status poll returns the ticket page.
- usePublicPayment + PublicPaymentProgress: the poll/acknowledge/resume loop
  once, shared by the support panel and the ticket purchase.
- A paid ticket can't be given back from its page; the organizer refunds a
  guest "another way" (no wallet on record), recorded with a null recipient.
- Migration 20261011220000: payment_intents.guest_name, the issue function,
  guest_ticket returns payment_status, claim_guest_ticket points at the
  purchase, event_payouts.recipient_user_id nullable.

Also fixes a crash from #1311: MobileStickyCTA (a server component) called
the client hook useMobileActionBar, so public listing pages with a sticky
buy bar switched to "Something went wrong" after loading. The bar is now its
own client component.

Verified: every migration replayed on Supabase Postgres 15 and the new
functions exercised as anon/service_role/organizer; the purchase driven in
Chromium at 390px from name to QR to ticket page.


Claude-Session: https://claude.ai/code/session_01MFTqYKVJNY7ddWNQqsc7yM

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 15:56:05 -07:00
CatoandClaude Opus 5.5 b3b33f3d74 feat(money): decide where money paid to you goes, in order (#1300)
* feat(money): decide where money paid to you goes, in order

A person lists their wallets in the order money should cover them: a
share of everything that comes in (taxes first), then amounts to fill —
once (a debt) or every calendar month (rent, insurance). When someone pays
them, the WHOLE payment goes to the first line still behind; over many
payments the totals converge on the rule. OrangeCat never holds or splits
money: the payer's wallet pays the chosen wallet directly.

- money_routes (owner-only RLS; the row AND the wallet it names must be
  the caller's; nothing for anon). Keyed by profile_id like the personal
  wallets it routes between.
- domain/money-routes/routing.ts: pure decision. Shares compare in BTC
  (no rate needed); fills compare at each payment's price on arrival
  (rates_at_paid, #1295), today's rate if none, and never count money
  nobody can value as filling a line.
- resolveUserWallet asks the rule first. No rule, a satisfied rule, an
  unreadable rule or an unpayable destination all fall through to the
  usual choice — a rule can never make a person unpayable.
- GET/PUT /api/money-routes; saving keeps each kept line's start, so
  reordering or correcting an amount never resets its progress.
- "Where your money goes" on Your money: the order, each line's progress,
  the line the next payment lands in, "Covered" markers, and an editor.
  Screenshotted at 390px and 1280px (no horizontal overflow).

Tests: routing as a table (incl. convergence: a 25% share of 200 equal
payments lands 50 ±1), resolution end to end on the fake DB (gains a real
`gte`), saving and validation. Proved by mutation: disabling the hook (3
red) and the date window (2 red); the DB date filter is a redundant
optimisation and mutating it alone is correctly not caught.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor(money): split the waterfall screen and the address minting under the size limits

CI's check:sizes refused two files (no new exceptions allowed):
- MoneyRoutes.tsx (407 > 300): the editor is its own component
  (MoneyRoutesEditor owns the draft and the save, hands back the server's
  answer) and the shared shapes/formatting live in moneyRoutesFormat.ts.
- walletResolutionService.ts (516 > 500): materializeOnchainAddress — the
  one step that WRITES (claims a derivation index at invoice creation) —
  moves to onchainAddressMaterialization.ts, apart from resolution, which
  only decides. Its importers point at the new module; no re-export, so
  there is one path to it.

And the changelog's {#money-routes} anchor is declared on the roadmap, with
the Solon-suggested tax line as the open next step.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 09:05:47 -07:00
e99115c3bd feat(money): amount entry people can use, and payment logic the tests actually constrain (#615)
* test(payments): constrain who gets paid and when money counts as settled

Mutation testing showed the payment tests executed this code without
checking it: 65% of mutants in wallet resolution and 60% in settlement
survived the whole suite. Two shapes of hole.

First, the query WAS the logic. Deciding who receives money is mostly
filters and orderings — is_active, profile_id, group_id, primary-first —
and the old doubles returned a fixed row for any query, so every filter
could be deleted with the suite still green. Tests now run against a fake
that applies the query (test-utils/fakeSupabase), with a deactivated
wallet and a stranger's wallet present in the fixtures so a missing
filter changes who gets paid.

Second, two exported functions had no tests at all: the address the owner
is SHOWN as their receiving address, and who gets credited when money
arrives. Same for the token-authenticated path a payer with no account
uses to poll and to report "I've paid" — so nothing checked that a wrong
token reveals nothing, or that a payer's word is refused on rails that
answer for themselves.

Also pins settlement dispatch: each method asks its own authority and no
other, no rail is asked without the field it needs, mempool is not money,
and expiry is only the truth after the rail has said nothing arrived.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(money): enter the amount like a person, and know you can send before you type

Two problems, both found by using the screens rather than reading them.

The amount input had the priority backwards: a row of preset pills in BTC
decimals, with typing your own amount hidden behind a "Custom" button that
only committed on blur. Every money app people already use opens on an
amount you type first, in the currency you think in. AmountField does
that — big tap-to-type value in your display currency, the BTC figure
always visible underneath because Bitcoin is what actually moves, and
presets demoted to suggestions.

Three rules it will not break: a missing exchange rate switches to BTC
entry rather than silently converting your "20" into 0 BTC; an
out-of-range amount says so instead of being quietly clamped to
something you did not type; and `inputMode="decimal"` gives phones the
plain number pad and accepts the comma half of Europe types.

Driving the real page found two more. The suggestions were round in the
wrong unit — a CHF user saw "CHF 0.52 · CHF 2.59 · CHF 5.18", arithmetic
noise — so the ladder is now round in whichever unit is being typed. And
the field arrives pre-filled with a suggestion, so typing APPENDED to it:
"27.50" over a suggested "5.18" became "27.51850", an amount the payer
never chose. It now selects on focus.

Second problem: /send let you fill in a recipient, an amount and a note
before telling you, on the final tap, that you have no wallet to send
from — the worst moment to say it, and knowable before a keystroke. It
now asks the same resolution the payment runs (GET /api/send) and shows
the connect-wallet state instead of a form that ends in a refusal.
Requests got the matching fix: the payer is resolved while you type, so
asking someone who does not exist fails visibly rather than on submit.

Also: the committing button sticks to the bottom on phones, where these
forms are taller than the viewport.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(payments): pin which group wallet receives when several could

group_wallets has no is_primary, so creation order is the entire
tie-break — and nothing constrained it. Two equally capable treasury
wallets would receive in whatever order Postgres happened to return.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 10:05:30 +00:00