-
Notifications
You must be signed in to change notification settings - Fork 1
feat(cashu): C1b — persist escrow-mode overrides and surface the backend in About #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
edc489d
feat(cashu): C1b — persist escrow-mode overrides and surface the back…
grunch 983bd48
fix(cashu): C1b review round 1 — override race, build-time controller…
grunch 077a4d5
fix(cashu): CodeRabbit round on #234 — parser divergence, stale seed,…
grunch 4302f8e
test(cashu): make the dev-card seed test actually exercise the race
grunch 8286c36
merge: main into feat/cashu-c1b-escrow-mode-persistence
grunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
|
||
| import 'package:mostro/src/rust/api/escrow.dart' as escrow_api; | ||
| import 'package:mostro/src/rust/api/types.dart'; | ||
|
|
||
| /// The settlement backend the active Mostro node runs, as resolved by Rust. | ||
| /// | ||
| /// Emits the current value immediately, then every time it changes: a node | ||
| /// capability fetch, a node switch, or a developer override flip. | ||
| /// | ||
| /// This is the **client-side resolution**, developer overrides included — it is | ||
| /// what gates behaviour. It is deliberately *not* what the About screen shows: | ||
| /// About reports what the node itself advertises (see `MostroInstance`), so a | ||
| /// forced override can never make About claim a node said something it did not. | ||
| final escrowModeProvider = StreamProvider<EscrowModeInfo>((ref) async* { | ||
| // Subscribe before reading the snapshot so no change is missed in between. | ||
| final stream = await escrow_api.onEscrowModeChanged(); | ||
| yield await escrow_api.getEscrowMode(); | ||
|
|
||
| while (true) { | ||
| yield await stream.next(); | ||
| } | ||
| }); | ||
|
|
||
| /// Whether a Cashu path may run against the active node. | ||
| /// | ||
| /// The single question the rest of the app asks. Mirrors Rust's | ||
| /// `is_cashu_mode()`: the mode must be Cashu **and** there must be a usable | ||
| /// mint. False while loading and on error, so every Cashu path stays shut | ||
| /// unless the node was positively identified. | ||
| final isCashuAvailableProvider = Provider<bool>((ref) { | ||
| return ref.watch(escrowModeProvider).valueOrNull?.isCashuAvailable ?? false; | ||
| }); | ||
|
|
||
| // ── Developer override ──────────────────────────────────────────────────────── | ||
|
|
||
| /// Writes the developer escrow overrides (§4.3 of `docs/cashu/README.md`). | ||
| /// | ||
| /// Exists so a tester can work against a daemon branch that implements Cashu | ||
| /// before it publishes the Kind 38385 tags. Every caller must be behind | ||
| /// [kDebugMode] — release builds must not be able to force a backend the node | ||
| /// does not run. The assertions below make a misuse fail loudly in a debug | ||
| /// build rather than silently ship a switch to users. | ||
| class EscrowOverrideController { | ||
| const EscrowOverrideController(); | ||
|
|
||
| /// Force (or stop forcing) Cashu mode regardless of the node's tags. | ||
| Future<void> setForceCashu(bool forceCashu) { | ||
| assert(kDebugMode, 'the escrow override is a debug-only affordance'); | ||
| return escrow_api.setEscrowModeOverride(forceCashu: forceCashu); | ||
| } | ||
|
|
||
| /// Point Cashu at a specific mint. `null` or blank clears the override. | ||
| /// | ||
| /// Throws when the URL is not an `http(s)` URL with a host — the Rust side | ||
| /// validates and returns an `InvalidMintUrl` marker. | ||
| Future<void> setMintUrl(String? mintUrl) { | ||
| assert(kDebugMode, 'the escrow override is a debug-only affordance'); | ||
| return escrow_api.setCashuMintUrlOverride(mintUrl: mintUrl); | ||
| } | ||
| } | ||
|
|
||
| final escrowOverrideControllerProvider = Provider<EscrowOverrideController>( | ||
| (ref) => const EscrowOverrideController(), | ||
| ); |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.