mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-05 00:28:27 +01:00
A wallet's balance is BTC. Its goal is not: `goal_amount` is denominated
in `goal_currency`, and the wallet form defaults that to fiat. Both
surfaces that drew the progress bar divided one straight into the other:
const progressPercent = (wallet.balance_btc / wallet.goal_amount) * 100
Measured against production today: 18 of 33 wallets carry a goal, every
one of them in fiat (CHF 11, USD 6, EUR 1), and not one in BTC. So every
savings-goal bar in the app was computed from BTC divided by francs —
including the one on the PUBLIC profile, which is the second copy of the
same expression.
It is invisible right now only because every one of those balances is
still 0.00, and zero over anything is zero. It starts lying on the first
deposit: a wallet holding 0.025 BTC toward a CHF 2 500 goal would have
read "0.001% funded" while sitting at the whole target. That case is
pinned as a test.
Both sides now meet in the goal's own currency before they meet in one
expression, via a single lib/wallet-goal.ts rather than a third inline
copy. When no rate is available the helper returns null instead of a
number: useCurrencyConversion signals a missing rate with 0 precisely so
callers do not guess, and 0 read as a percentage would tell someone they
have saved nothing when they may be fully funded.
Fixing the same line in two files is where the Never-Twice rule says to
automate, so check:currency-units joins `verify`: it fails on arithmetic
between a BTC-suffixed identifier and a bare `*_amount`. Proven by
mutation — restoring the original expression turns it red, and it caught
the naive version of its own scanner on the first run (it stripped only
`//`, and the first thing it read was a block comment describing the
bug). That is why blankNonCode moved to scripts/lib/: one tokenizer, so
a third scanner cannot reinvent the version that already cost a day.
Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Scripts Directory
This directory contains all automation scripts organized by purpose.
Directory Structure
analysis/- Bundle analysis, documentation checking, and optimization toolsauth-fix/- Scripts to fix authentication and RLS policy issuesdb/- Database operations, migrations, and schema management- Migration scripts moved from root:
apply-migration.js,apply-*-migration.js - Old schema files archived in
db/archive/
- Migration scripts moved from root:
deployment/- Deployment, production setup, and monitoring scriptsdev/- Development helpers, local setup, and debugging toolsdiagnostics/- Health checks and system diagnosticsmaintenance/- Cleanup, optimization, and maintenance scriptsmonitoring/- Performance monitoring and bundle size trackingoauth/- OAuth provider setup and configurationprofile-fix/- Scripts to fix profile-related issuesschema-fix/- Database schema fixes and migrationsstorage/- Supabase storage bucket setup and managementtest/- Testing utilities and validation scripts- Test/debug scripts moved from root:
test-*.js,check-*.js,debug-*.js
- Test/debug scripts moved from root:
Usage
Most scripts can be run with:
node scripts/{category}/script-name.js
For deployment scripts:
bash scripts/deployment/script-name.sh
Important Scripts
scripts/dev/dev-start.js- Main development server starterscripts/deployment/browser-verify.js- Post-deploy browser smoke test (deploys themselves happen on the box — see docs/deployment/DEPLOYMENT_PROCESS.md)scripts/db/apply-migrations.ts- Database migrationsscripts/maintenance/cleanup-console-logs.ts- Remove console.log statements