feat(ecash): introduce custom unit ecash support#325
Open
a1denvalu3 wants to merge 13 commits into
Open
Conversation
This commit introduces support for custom unit ecash (units different from "sat" that mints may advertise) across the Numo application. The core objective is to disable fiat currency conversions and format inputs 1:1 if a unit other than "sat" is selected as the base unit. Updates include: - `MintManager`: Added a new setting to store the active `preferredBaseUnit` to allow selecting and tracking units outside "sat". - `CashuWalletManager`: Replaced all hardcoded usages of `CurrencyUnit.Sat` dynamically with the `preferredBaseUnit`. Whenever the unit changes, a wallet rebuild is triggered to re-bind the CDK wallet. - `AmountDisplayManager` & `TransactionDetailActivity`: Hidden UI components for currency switching and fiat conversions when a non-sat unit is active. Implemented verbatim custom unit printing string structures (e.g. `150 mxn`). - `TipSelectionActivity` & `PaymentRequestActivity`: Adjusted the logic to omit the toggle custom currency interactions if we're not operating with standard satoshis. - `MintsSettingsActivity`: Implemented Option B functionality; exposed a new selectable row below the active Lightning Mint card where users can swap their "Base Currency Unit" (pulling values dynamically from the parsed `MintLimits` methods).
If a custom unit is technically a known fiat currency code (like "usd", "eur"), map it using the `Amount.Currency` formatting utility so it displays as "$1.50" rather than verbatim "150 usd". This addresses the edge cases where custom units perfectly map to standard fiat. All UI components, test suites, and wallet abstractions properly integrate with the newly resolved `Amount.Currency` structures.
This correctly handles the fiat currency preference in `SettingsActivity` to prevent users from interacting with it when a custom base unit is currently set. The row is greyed out (opacity lowered to 0.5f) and tapping it will surface a descriptive Toast letting the user know they must revert back to standard `sat` first.
This replaces hardcoded internal string/formatting references that assumed "₿" with "sat", standardising eCash references safely alongside custom unit implementations. Also fixes the test suites that broke when the number formatting rules adapted.
Use `style="@style/Text.RowSubtitle"` instead of `android:textAppearance` to ensure the subtitle receives the correct text color attributes (grey), matching the other settings rows. Also added the missing 2dp top margin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces support for custom unit ecash (units different from
satthat mints may advertise).Objectives:
The core objective is to disable fiat currency conversions and format inputs 1:1 if a unit other than
satis selected as the base unit.Updates include:
preferredBaseUnitto allow selecting and tracking units outsidesat.CurrencyUnit.Satdynamically with thepreferredBaseUnit. Whenever the unit changes, a wallet rebuild is triggered to re-bind the CDK wallet.150 mxn).Base Currency Unit(pulling values dynamically from the parsedMintLimitsmethods).