Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { loadAppSettings, saveAppSettings } from './src/storage/appSettings';
import { VaultKeyInvalidatedError } from './modules/mojito-core';
import { walletVault, type VaultMeta, type WalletVaultHandle } from './src/storage/walletVault';
import { pinStore } from './src/storage/pinStore';
import { getBlobStore } from './src/storage/blobStore';
import { STORAGE_KEYS } from './src/storage/keys';
import { detectBio } from './src/onboarding/ui/useBioScan';
import { C, alpha } from './src/theme';
import { AppBackground, Chip, Icon, IconName, Txt } from './src/ui';
Expand Down Expand Up @@ -117,7 +119,7 @@ type AppSession = {
};

function Shell({ network, onNetworkChange }: { network: NetworkFlag; onNetworkChange: (testnet: boolean) => void }) {
const { mode, pricesAreMock } = useProviders();
const { mode, pricesAreMock, waitlist } = useProviders();
const insets = useSafeAreaInsets();
const [splashDone, setSplashDone] = useState(false);
/** Whether the vault-existence check finished; drives onboarding vs lock. */
Expand Down Expand Up @@ -316,15 +318,23 @@ function Shell({ network, onNetworkChange }: { network: NetworkFlag; onNetworkCh
setLocked(true);
};

/** Settings sign-out: the device forgets the keys, per its own copy. A
* failed wipe must not drop the session state: the vault is re-verified
* gone before the app returns to onboarding, and the error surfaces. */
/** Settings sign-out: the device forgets the keys, per its own copy. The
* waitlist email is personal data, so its sealed store joins the same
* destructive boundary (decision R4): it wipes together with the vault
* and the PIN. A failed wipe must not drop the session state: the vault
* is re-verified gone and the waitlist blob verified absent before the
* app returns to onboarding, and the error surfaces. */
const signOut = () => {
void (async () => {
let gone = false;
try {
await Promise.all([walletVault.wipe(), pinStore.wipe()]);
gone = !(await walletVault.exists());
await Promise.all([walletVault.wipe(), pinStore.wipe(), waitlist.leave()]);
// Same verification pattern as the vault: probe the storage seam
// directly instead of trusting the provider (the HTTP provider has
// no member-status route to ask, and the local store's blob is the
// persistence that must be gone).
const leftover = await (await getBlobStore()).store.get(STORAGE_KEYS.waitlistEmail);
gone = !(await walletVault.exists()) && leftover === null;
} catch {
gone = false;
}
Expand Down
95 changes: 69 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ mobile app, rebuilt in React Native.

---

## ⚠️ Project status · M4 (trade)
## ⚠️ Project status · M5 (card)

**This repository is the trade milestone: everything M3 shipped (keys, vault, live chain data, the send pipeline) plus the three trade surfaces wired to real infrastructure where it exists - the DEX runs the live on-chain order book with order create/fill/conclude flows, the swap screen drives the ML-side HTLC session machine with persisted sessions, and the bridge reads the bridge_v2 api-server (M2E quotes, fees, status; the treasury deposit address). Signing still rides the device-pending bindings seam and ML broadcasting waits on infrastructure, so every trade action lands in an honest state instead of a fabricated success.**
**This repository is the card milestone: everything M4 shipped (keys, vault, live chain data, the send pipeline, the trade surfaces) plus the card screen with its early-access waitlist. The join flow runs on a validated, normalized email through a sealed device-local store (one slot per install), the confirmation view masks the address, duplicates, transport failures and retries land in honest states, and both Leave and wallet sign-out wipe the sealed email from the device.**

Real in M5:

- **Card waitlist**: the form machine (RFC-validated input, no double submits, submit-time address freeze so a mid-flight edit cannot rename the confirmation), the masked confirmation and duplicate callouts, the provider-state counter, the Settings membership row with Leave, and the sign-out wipe. **R4 ship blocker (decision R4, 2026-11-17): the waitlist backend does not exist; v1 persistence is device-local only, and a production build must never ship it. `createWaitlistProvider` refuses release construction without a configured `waitlistBase` (plans/mojito-neo/decisions.md, missing-architecture gap 4).**

Real in M4:

Expand Down Expand Up @@ -241,7 +245,7 @@ npm run lint # eslint only
npx tsx src/theme.test.ts
```

`npm run check` runs thirty-seven things:
`npm run check` runs forty things:

1. **`src/theme.test.ts`**: asserts the oklch→sRGB conversion against the known sRGB primaries.
Every colour in the app flows through it, so it's the one piece of non-trivial logic with a
Expand Down Expand Up @@ -278,61 +282,76 @@ npx tsx src/theme.test.ts
17. **`src/data/providers/bridge.test.ts`**: the bridge_v2 api provider: quote and fee parsing
per direction, the treasury deposit address, status mapping and the E2M and initiation
typed gates, all over a scripted transport.
18. **`src/trade/orderBookService.test.ts`**: the live depth aggregation: cursor-paginated
18. **`src/data/providers/WaitlistProvider.test.ts`**: the gap 4 waitlist contract over a
scripted transport: the 201 join and the idempotent 200 duplicate, the
invalid/unavailable mappings, transport failures and non-JSON bodies, the typed
member-status refusal, factory selection and the R4 ship-blocker refusal in a
release build.
19. **`src/trade/orderBookService.test.ts`**: the live depth aggregation: cursor-paginated
pages, the num/denom price rational, the invalid-cursor page-1 restart and the honest
null last-fill.
19. **`src/trade/orders.test.ts`**: order create/fill/conclude over the bindings double: the
20. **`src/trade/orders.test.ts`**: order create/fill/conclude over the bindings double: the
witness mix, order id extraction, nonce and height inputs, the fill guards (frozen,
concluded, overbid, off-band price) and the lying-broadcast refusals.
20. **`src/trade/htlc.test.ts`**: the HTLC flows: lock output parameters, the build/broadcast
21. **`src/trade/htlc.test.ts`**: the HTLC flows: lock output parameters, the build/broadcast
split (nothing broadcasts until the prepared lock is confirmed), the claim witness with
the secret, the refund timelock refusal, lying-broadcast refusals and the secret
extraction round-trip.
21. **`src/trade/swapSession.test.ts`**: the swap session machine: transitions (including the
22. **`src/trade/swapSession.test.ts`**: the swap session machine: transitions (including the
offered -> locked broadcast step), persistence round-trip, corrupt-row dropping,
legacy-column stripping and the no-preimage guarantee.
22. **`src/trade/priceGuards.test.ts`**: the slippage band, minimum fill floor, amount sanity
23. **`src/trade/priceGuards.test.ts`**: the slippage band, minimum fill floor, amount sanity
and the swap timelock rule margin, with typed NaN results.
23. **`src/trade/bindingsParity.test.ts`**: the vendored-signature parity pin: every seam
24. **`src/trade/bindingsParity.test.ts`**: the vendored-signature parity pin: every seam
function (including the privateKey and secret carriers) line-pinned against the vendored
Swift plus the checksum that fails on any vendor upgrade.
24. **`src/keys/bip39.test.ts`**: published BIP39 seed vectors, checksum/word/length rejection,
25. **`src/keys/bip39.test.ts`**: published BIP39 seed vectors, checksum/word/length rejection,
NFKD normalization, wordlist integrity, supplied-entropy generation.
25. **`src/keys/mlAccounts.test.ts`**: the bindings parity vectors (both networks) for account
26. **`src/keys/mlAccounts.test.ts`**: the bindings parity vectors (both networks) for account
blobs, receiving blobs and addresses, plus the custom-path scan.
26. **`src/keys/BtcKeyring.test.ts`**: BIP84 zpub and address vectors, branch separation, custom
27. **`src/keys/BtcKeyring.test.ts`**: BIP84 zpub and address vectors, branch separation, custom
account paths.
27. **`src/send/validation.test.ts`**: send address validation (mtc1/tmt1/bc1/tb1, wrong-network
28. **`src/send/validation.test.ts`**: send address validation (mtc1/tmt1/bc1/tb1, wrong-network
detection, non-standard HRP rejection) and exact amount parsing against published vectors.
28. **`src/send/mlTxBuilder.test.ts`**: the ML planner and assembler: selection determinism, the
29. **`src/send/mlTxBuilder.test.ts`**: the ML planner and assembler: selection determinism, the
implicit-fee invariant, token-remainder sizing on the real output list, signer loopback.
29. **`src/send/btcTxBuilder.test.ts`**: the BTC builder: plan-fee equals signed-fee on the BIP84
30. **`src/send/btcTxBuilder.test.ts`**: the BTC builder: plan-fee equals signed-fee on the BIP84
vectors, multi-origin signing, confirmed-input policy, typed dust and insufficient funds.
30. **`src/send/TxTracker.test.ts`**: the pending-to-confirmed lifecycle with injected timers:
31. **`src/send/TxTracker.test.ts`**: the pending-to-confirmed lifecycle with injected timers:
poll cadence, attempt caps, terminal stop, flaky-read tolerance.
31. **`src/data/real/realSend.test.ts`**: the real send service over an in-memory manager:
32. **`src/data/real/realSend.test.ts`**: the real send service over an in-memory manager:
funding across every managed address with fresh branch 1 change, typed busy refusal,
broadcast-answer verification, fee pinning, quote purity, post-broadcast warning, the
origin walk over long change histories and the failed-send change release.
32. **`src/data/mock/mockSend.test.ts`**: the R3 demo send path: fixture fee tiers, the same
33. **`src/data/mock/mockSend.test.ts`**: the R3 demo send path: fixture fee tiers, the same
address and amount validation rejections and deterministic demo-labelled ids.
33. **`src/keys/session.test.ts`**: KeySession closure isolation, zeroize of the seed buffer,
34. **`src/data/mock/localWaitlist.test.ts`**: the sealed local waitlist store: the
ciphertext carries no plaintext bytes, one slot per install with duplicate
refusal, the idempotent rejoin, and leave wiping both the blob bytes and the
key.
35. **`src/waitlist/waitlistForm.test.ts`**: the waitlist form machine: the validation
matrix (length caps, forbidden characters, unicode normalization), the phase
transitions, no double submits, the submit-time address freeze and retry
scoping.

34. **`src/keys/session.test.ts`**: KeySession closure isolation, zeroize of the seed buffer,
release semantics, xpub parity.
34. **`scripts/no-console.ts`**: no `console.*` in the native facade or the secret-handling
modules (keys, send, storage, data, onboarding, trade, screens).
35. **`scripts/no-em-dash.ts`**: no em or en dashes anywhere in code, specs or docs.
36. **`tsc --noEmit`**: strict TypeScript.
37. **`eslint .`**: `eslint-config-expo`, including the `react-hooks` rules.
37. **`scripts/no-console.ts`**: no `console.*` in the native facade or the secret-handling
modules (keys, send, storage, data, onboarding, trade, screens, waitlist).
38. **`scripts/no-em-dash.ts`**: no em or en dashes anywhere in code, specs or docs.
39. **`tsc --noEmit`**: strict TypeScript.
40. **`eslint .`**: `eslint-config-expo`, including the `react-hooks` rules.

**There is no UI/component test suite yet.** Adding one (React Native Testing Library +
`jest-expo`) is a welcome contribution: start with the onboarding flow, which holds the most
logic. Until then, changes touching navigation or gestures should be verified on a device or
simulator: a green `tsc` has repeatedly failed to catch runtime issues here (a modal that
swallowed every touch typechecked and bundled perfectly).

### Manual checks (device, gated-vault paths)
### Manual checks (device, gated-vault and waitlist paths)

The native auth gate cannot be exercised in Node; verify these by hand on a device build:
The native auth gate cannot be exercised in Node; verify these by hand on a device build.
The waitlist matrix (18 to 24) runs in mock mode on a dev build: it needs no backend.

1. **Biometric choice gates the key.** Onboard with "Enable Face ID" (or fingerprint): the first
seal at finish shows the OS biometric prompt from inside the module, and every unlock runs it.
Expand Down Expand Up @@ -392,6 +411,30 @@ The native auth gate cannot be exercised in Node; verify these by hand on a devi
#500+), a send drawing on that change address still succeeds. A failed send (underfunded
amount or refused broadcast) leaves the change counter untouched, so the next successful
send allocates exactly one change index.
18. **Waitlist empty state.** On the card tab with no waitlist slot on the device: the form
is empty, the submit button is disabled, and (dev build, gauge visible) the counter shows
the fixture seed without this install's slot.
19. **Waitlist invalid input.** Type an invalid address (double @, an empty local part or
domain, an over-254 address, control bytes or markup delimiters) and submit: the invalid
callout shows, the provider is never called, and nothing is persisted.
20. **Waitlist success and counter.** Join with a valid mixed-case, padded address: the
confirmation screen names the masked address (first local-part character, domain), Done
returns to the card, and the gauge has incremented by exactly one.
21. **Waitlist duplicate.** Join again with a different address: the amber duplicate callout
shows the masked on-file address and View confirmation opens the same masked
confirmation. Rejoining the address already on file succeeds idempotently with no new
position.
22. **Waitlist offline submit.** Go offline and submit a fresh address: the unavailable
callout and retry button show. Back online, tap retry: the join completes with the
address currently in the field, and the confirmation names that same address. Editing
the draft while a live join is in flight never renames the confirmation (the submitted
address is frozen).
23. **Waitlist leave and rejoin.** In Settings, Leave the waitlist: the row clears and the
gauge drops back to the seed; the app relaunch keeps it cleared (the wipe persists).
Join again afterwards: a fresh slot is allocated. A leave that fails (secure storage
unavailable) surfaces the leave-failed alert and the row stays joined.
24. **Waitlist small-device keyboard.** On a 320-class screen with the keyboard open: the
email field, callouts and submit button stay reachable, and the return key submits.

---

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ios:dev": "expo run:ios",
"android:dev": "expo run:android",
"prebuild": "expo prebuild",
"check": "tsx src/theme.test.ts && tsx src/i18n/strings.test.ts && tsx src/money.test.ts && tsx src/data/polling.test.ts && tsx src/data/ml/indexerClient.test.ts && tsx src/data/btc/btcChainService.test.ts && tsx src/data/addresses/addressManager.test.ts && tsx src/storage/addressStore.test.ts && tsx src/data/activity/activityService.test.ts && tsx src/storage/secureStore.test.ts && tsx src/storage/walletVault.test.ts && tsx src/storage/pinStore.test.ts && tsx src/storage/appSettings.test.ts && tsx src/data/real/realWalletData.test.ts && tsx src/data/providers/providers.test.ts && tsx src/data/providers/broadcast.test.ts && tsx src/data/providers/bridge.test.ts && tsx src/trade/orderBookService.test.ts && tsx src/trade/orders.test.ts && tsx src/trade/htlc.test.ts && tsx src/trade/swapSession.test.ts && tsx src/trade/priceGuards.test.ts && tsx src/trade/bindingsParity.test.ts && tsx src/keys/bip39.test.ts && tsx src/keys/mlAccounts.test.ts && tsx src/keys/BtcKeyring.test.ts && tsx src/send/validation.test.ts && tsx src/send/mlTxBuilder.test.ts && tsx src/send/btcTxBuilder.test.ts && tsx src/send/TxTracker.test.ts && tsx src/data/real/realSend.test.ts && tsx src/data/mock/mockSend.test.ts && tsx src/keys/session.test.ts && tsx scripts/no-console.ts && tsx scripts/no-em-dash.ts && tsc --noEmit && eslint .",
"check": "tsx src/theme.test.ts && tsx src/i18n/strings.test.ts && tsx src/money.test.ts && tsx src/data/polling.test.ts && tsx src/data/ml/indexerClient.test.ts && tsx src/data/btc/btcChainService.test.ts && tsx src/data/addresses/addressManager.test.ts && tsx src/storage/addressStore.test.ts && tsx src/data/activity/activityService.test.ts && tsx src/storage/secureStore.test.ts && tsx src/storage/walletVault.test.ts && tsx src/storage/pinStore.test.ts && tsx src/storage/appSettings.test.ts && tsx src/data/real/realWalletData.test.ts && tsx src/data/providers/providers.test.ts && tsx src/data/providers/broadcast.test.ts && tsx src/data/providers/bridge.test.ts && tsx src/data/providers/WaitlistProvider.test.ts && tsx src/trade/orderBookService.test.ts && tsx src/trade/orders.test.ts && tsx src/trade/htlc.test.ts && tsx src/trade/swapSession.test.ts && tsx src/trade/priceGuards.test.ts && tsx src/trade/bindingsParity.test.ts && tsx src/keys/bip39.test.ts && tsx src/keys/mlAccounts.test.ts && tsx src/keys/BtcKeyring.test.ts && tsx src/send/validation.test.ts && tsx src/send/mlTxBuilder.test.ts && tsx src/send/btcTxBuilder.test.ts && tsx src/send/TxTracker.test.ts && tsx src/data/real/realSend.test.ts && tsx src/data/mock/mockSend.test.ts && tsx src/data/mock/localWaitlist.test.ts && tsx src/waitlist/waitlistForm.test.ts && tsx src/keys/session.test.ts && tsx scripts/no-console.ts && tsx scripts/no-em-dash.ts && tsc --noEmit && eslint .",
"lint": "eslint ."
},
"dependencies": {
Expand Down
24 changes: 24 additions & 0 deletions plans/mojito-neo/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ wired would be worse than an honest alert. The `scan.*` i18n keys land with
the sheet, not before. Revisit when the milestone that owns scanning picks
the camera library.

## R4. The waitlist ships local-only in v1 (option C), real backend before ship

2026-11-17. The M5 card screen needs an early-access waitlist, but no waitlist
backend exists: missing-architecture gap 4 proposes the POST /v1/waitlist
contract, with options A and B for the hosted or self-hosted backend. Decision:
ship v1 as option C, the sealed device-local store
(`src/data/mock/localWaitlist.ts`): one slot per install, the email sealed
under the `waitlist.email.v1` key id, never logged, never sent anywhere. The
HTTP provider (`src/data/providers/WaitlistProvider.ts`) is complete against
the proposed contract and activates on a config flip only
(`endpoints.waitlistBase`), so going real stays a URL change.

This is a ship blocker: a production build must never run the local-only
waitlist. The gate lives in `createWaitlistProvider` behind
`FLAGS.localWaitlistOnly`: where dev fallbacks are not allowed (a release
build), construction without a configured backend refuses with
`LocalWaitlistShipBlockerError` instead of silently shipping the device-local
store.

Retention: the email is personal data, so it joins the destructive boundaries.
Settings > Leave wipes the sealed entry (a failed wipe surfaces and the row
stays joined), and wallet sign-out wipes it together with the vault and the
PIN, verifying the blob is gone before the app returns to onboarding.

## M4 change log

### Bindings seam corrected to the vendored signatures (M4 review, critical)
Expand Down
10 changes: 10 additions & 0 deletions plans/ux-deferred.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ The 240 px QR plus the card paddings clips on 320-class screens (224 pt
inner width); every audited device width (360 to 430) is safe. Deferred
because no supported target sits below 360 today. If one lands, scale the
QR size from the measured inner width instead of shrinking the quiet zone.

## Waitlist duplicate copy assumes the local store (revisit with the backend)

`card.waitlist.duplicate.body` ("This device already holds a spot for {email}")
hardcodes local semantics for a provider-agnostic machine: once the HTTP
backend lands (missing-architecture gap 4), a duplicate may be server-side,
meaning the address joined from another device, and the status-refusal
fallback masks the typed address instead of a verified on-file one. The copy
is accurate for the v1 local-only store (decision R4 in
plans/mojito-neo/decisions.md); revisit it with that milestone.
Loading
Loading