mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
Adds a cache-backed Cashu mint directory sibling to LocalCache.relayHints that aggregates mint URLs from every relevant event the cache sees, and wires it into the AddCashuWallet mint-URL text field as inline autocomplete so users don't have to remember mint URLs. What feeds the directory: - NutzapInfoEvent (kind:10019) — every nostr user with a Cashu wallet publishes their accepted mints there. A typical inbox of cached profiles seeds a useful starter directory automatically. - MintRecommendationEvent (kind:38000) — explicit public vouches. - CashuMintEvent (kind:38172) — formal mint announcements from the NIP-87 directory subscription. How it's populated: - LocalCache.updateMintIndex(event) is called from justConsumeAndUpdateIndexes alongside updateHintIndexes, so every new event with a mint URL adds to the index. wasNew gating prevents re-emissions from inflating popularity counters. - LocalCache.ensureMintDirectoryBackfilled() does a one-shot scan of the existing notes + addressables maps. The autocomplete UI kicks this in a LaunchedEffect on screen open so suggestions are useful before the next relay round-trip. Where it surfaces today: - AddCashuWalletScreen — under the mint-URL OutlinedTextField, a MintSuggestionList card shows up to 6 cache-derived suggestions ranked by popularity desc + URL asc. Tapping a row fills the field (does not auto-add — users typically want to Verify first). Filters out URLs the user already added and exact matches of what they typed. The MintPicker dropdown inside the Receive / Send dialogs is unchanged — those only need to choose between mints the user already has in their wallet, so no directory autocomplete applies there. Tests: 8 unit tests cover normalisation (case-insensitive, trailing-slash stripping, http(s) gating), popularity ranking, substring filtering, limit enforcement, and malformed-URL handling. URL normalisation: trimmed, lower-cased, trailing `/` stripped, scheme must be http(s). Same URL with different casing or trailing slash collapses to one entry so popularity counts correctly. Implementation notes: - MintDirectoryIndex lives in commons/jvmAndroid (uses ConcurrentHashMap; iOS doesn't ship Cashu wallet yet). - Thread-safe; safe to read from any dispatcher. - No persistence — purely in-memory, accumulates over the session. - Entries are never removed: stale entries don't hurt (user always verifies before adding), and tracking which event added which URL would add bookkeeping without UX benefit. https://claude.ai/code/session_01MdWddiar819f8XYt5N8BjP