From e03e742b50b9373b69e16e7e1f8e4b290644f8f8 Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Thu, 10 Sep 2026 14:31:05 +0300 Subject: [PATCH] Exclude withdrawn currencies from the web currency list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intl.supportedValuesOf('currency') includes several codes for currencies that have actually been withdrawn/superseded — unlike JVM/Android/Apple, which derive "currently used" from each ISO country's live-assigned currency (java.util.Currency/NSLocale), the web platform has no equivalent API, so this app was showing them unfiltered. Confirmed exactly which codes by diffing the web list against the JVM's own live-derived set: ANG, CUC, HRK, SLL, and ZWL are genuinely withdrawn/superseded national currencies, now excluded via a manually maintained list (the web platform's only option here). XDR and XSU were also missing from the JVM's set, but only because they aren't tied to any ISO country — not because they're withdrawn — so those stay, same reasoning this codebase already applies to precious metals. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy --- .../tyiu/satsprice/SystemCurrencies.web.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/shared/src/webMain/kotlin/xyz/tyiu/satsprice/SystemCurrencies.web.kt b/shared/src/webMain/kotlin/xyz/tyiu/satsprice/SystemCurrencies.web.kt index 6e11b44..550c276 100644 --- a/shared/src/webMain/kotlin/xyz/tyiu/satsprice/SystemCurrencies.web.kt +++ b/shared/src/webMain/kotlin/xyz/tyiu/satsprice/SystemCurrencies.web.kt @@ -12,13 +12,28 @@ private fun jsCurrencyDisplayName(code: String): String = js( "(function() { var names = new Intl.DisplayNames(undefined, { type: 'currency' }); return names.of(code); })()", ) +/** + * `Intl.supportedValuesOf('currency')` includes a handful of codes for currencies that have + * actually been withdrawn/superseded since — unlike JVM/Android/Apple, there's no web API to + * derive "currently assigned to some country" the way `java.util.Currency`/`NSLocale` do (see + * [localeCurrencyCode] below), so this is a manually maintained exclusion list instead, checked + * (2026-09-10) against the JVM's own live-derived set. Needs a new entry whenever another + * currency is retired. + */ +private val WITHDRAWN_CURRENCY_CODES = setOf( + "ANG", // Netherlands Antillean Guilder — replaced by XCG (Caribbean Guilder), April 2025 + "CUC", // Cuban Convertible Peso — unified into CUP, January 2021 + "HRK", // Croatian Kuna — replaced by EUR, January 2023 + "SLL", // Sierra Leonean Leone (old) — redenominated to SLE, 2022 + "ZWL", // Zimbabwean Dollar (old) — replaced by ZWG (Zimbabwe Gold), April 2024 +) + actual fun systemCurrencies(): List = jsSupportedCurrencyCodes() .toList() - .map { jsCode -> - val code = jsCode.toString() - CurrencyInfo(code, jsCurrencyDisplayName(code)) - } + .map { it.toString() } + .filterNot { it in WITHDRAWN_CURRENCY_CODES } + .map { code -> CurrencyInfo(code, jsCurrencyDisplayName(code)) } .sortedBy { it.code } /**