taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit edbd19e34285be11f78345acb358e4dea0aacdf4
parent 4e7c76460f26906ad360571ade591764921f0373
Author: Marc Stibane <marc@taler.net>
Date:   Tue, 16 Jun 2026 16:32:22 +0200

stage (faked)

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 11+++++++++--
MTalerWallet1/Controllers/TalerWallet1App.swift | 8+++++++-
MTalerWallet1/Model/Model+Exchange.swift | 10+++++++---
3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -458,7 +458,7 @@ class Controller: ObservableObject { } // MARK: - @MainActor - func initWalletCore(_ model: WalletModel, setTesting: Bool, delay: TimeInterval) + func initWalletCore(_ model: WalletModel, stage: Bool, setTesting: Bool, delay: TimeInterval) async throws { if backendState == .instantiated { backendState = .initing @@ -474,7 +474,14 @@ class Controller: ObservableObject { try await model.setConfig(setTesting: false) } #endif - defaultExchanges = await model.getDefaultExchanges() + defaultExchanges = await model.getDefaultExchanges(stage: stage) + if stage, let talerOps = defaultExchanges.first { + let stageExc = DefaultExchange(talerUri: "taler://withdraw-exchange/exchange.stage.taler-ops.ch", + currency: talerOps.currency, + currencySpec: talerOps.currencySpec + ) + defaultExchanges.insert(stageExc, at: 0) + } DispatchQueue.main.asyncAfter(deadline: .now() + delay) { self.backendState = .ready // dismiss the launch animation } diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift @@ -22,6 +22,11 @@ struct TalerWallet1App: App { @Environment(\.scenePhase) private var phase @AppStorage("pasteAutomatically") var pasteAutomatically: Bool = false @AppStorage("preferredColorScheme") var preferredColorScheme: Int = 0 +#if DEBUG + @AppStorage("developerMode") var developerMode: Bool = true +#else + @AppStorage("developerMode") var developerMode: Bool = false +#endif @StateObject private var viewState = ViewState.shared // popToRootView() @StateObject private var viewState2 = ViewState2.shared // popToRootView() @@ -119,7 +124,8 @@ struct TalerWallet1App: App { let testing = false let delay: TimeInterval = 2.25 #endif - try! await controller.initWalletCore(model, setTesting: testing, delay: delay) // will (and should) crash on failure + try! await controller.initWalletCore(model, stage: developerMode, + setTesting: testing, delay: delay) // will (and should) crash on failure } if #available(iOS 16.4, *) { return WindowGroup { diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift @@ -164,8 +164,12 @@ fileprivate struct ListExchanges: WalletBackendFormattedRequest { fileprivate struct DefaultExchanges: WalletBackendFormattedRequest { func operation() -> String { "getDefaultExchanges" } func args() -> Args { Args() } +// func args() -> Args { Args(stage: stage) } - struct Args: Encodable {} // no arguments needed + var stage: Bool + struct Args: Encodable { +// var stage: Bool + } struct Response: Decodable { // list of known exchanges var defaultExchanges: [DefaultExchange] @@ -290,10 +294,10 @@ extension WalletModel { } /// ask wallet-core for its list of default exchanges ==> currently only taler-ops.ch - nonisolated func getDefaultExchanges(viewHandles: Bool = false) + nonisolated func getDefaultExchanges(stage: Bool, viewHandles: Bool = false) async -> [DefaultExchange] { // M for MainActor do { - let request = DefaultExchanges() + let request = DefaultExchanges(stage: stage) let response = try await sendRequest(request, viewHandles: viewHandles) return response.defaultExchanges } catch {