From 9f4243b4752585bb7d7a24d9fd4d8d6dbf3f2403 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Fri, 13 Oct 2023 16:36:50 +0200 Subject: [PATCH] [#861] Remove lightwalletd related error dialogs (#862) - error dialogs removed - cleanup of the code [#861] Remove lightwalletd related error dialogs - sdk 2.0.2 adopted, version bumped - error dialogs removed - a few bugfixes: - phrase display can handle longer words and still render it fully with no truncation - tabs tap area increased - receive screen with addresses now uses the wallet's UA --- .../AddressDetails/AddressDetailsStore.swift | 8 ++++-- modules/Sources/Features/Home/HomeStore.swift | 25 ++----------------- .../RecoveryPhraseDisplayView.swift | 15 ++++++++--- .../Features/Root/RootInitialization.swift | 13 +++++++--- modules/Sources/Features/Root/RootStore.swift | 12 --------- modules/Sources/Features/Tabs/TabsView.swift | 1 + modules/Sources/Generated/L10n.swift | 12 --------- .../Generated/Resources/Localizable.strings | 5 ---- .../xcshareddata/swiftpm/Package.resolved | 4 +-- secantTests/HomeTests/HomeTests.swift | 4 +-- secantTests/RootTests/RootTests.swift | 15 +++++++++++ 11 files changed, 48 insertions(+), 66 deletions(-) diff --git a/modules/Sources/Features/AddressDetails/AddressDetailsStore.swift b/modules/Sources/Features/AddressDetails/AddressDetailsStore.swift index 55861aef..c0bdfdcb 100644 --- a/modules/Sources/Features/AddressDetails/AddressDetailsStore.swift +++ b/modules/Sources/Features/AddressDetails/AddressDetailsStore.swift @@ -51,15 +51,17 @@ public struct AddressDetailsReducer: ReducerProtocol { } @Dependency(\.pasteboard) var pasteboard - + public init() {} public func reduce(into state: inout State, action: Action) -> ComposableArchitecture.EffectTask { switch action { case .copySaplingAddressToPastboard: pasteboard.setString(state.saplingAddress.redacted) + case .copyTransparentAddressToPastboard: pasteboard.setString(state.transparentAddress.redacted) + case .copyUnifiedAddressToPastboard: pasteboard.setString(state.unifiedAddress.redacted) } @@ -70,7 +72,9 @@ public struct AddressDetailsReducer: ReducerProtocol { // MARK: - Placeholders extension AddressDetailsReducer.State { - public static let placeholder = AddressDetailsReducer.State( + public static let placeholder = AddressDetailsReducer.State() + + public static let demo = AddressDetailsReducer.State( uAddress: try! UnifiedAddress( encoding: "utest1vergg5jkp4xy8sqfasw6s5zkdpnxvfxlxh35uuc3me7dp596y2r05t6dv9htwe3pf8ksrfr8ksca2lskzjanqtl8uqp5vln3zyy246ejtx86vqftp73j7jg9099jxafyjhfm6u956j3", network: .testnet) diff --git a/modules/Sources/Features/Home/HomeStore.swift b/modules/Sources/Features/Home/HomeStore.swift index 5b0e5580..ced70536 100644 --- a/modules/Sources/Features/Home/HomeStore.swift +++ b/modules/Sources/Features/Home/HomeStore.swift @@ -183,15 +183,13 @@ public struct HomeReducer: ReducerProtocol { } } - case .showSynchronizerErrorAlert(let error): - state.alert = AlertState.syncFailed(error, L10n.Home.SyncFailed.dismiss) + case .showSynchronizerErrorAlert: return .none case .debugMenuStartup: return .none - case .syncFailed(let error): - state.alert = AlertState.syncFailed(error, L10n.General.ok) + case .syncFailed: return .none case .balanceBreakdown: @@ -235,25 +233,6 @@ extension HomeViewStore { } } -// MARK: Alerts - -extension AlertState where Action == HomeReducer.Action { - public static func syncFailed(_ error: ZcashError, _ secondaryButtonTitle: String) -> AlertState { - AlertState { - TextState(L10n.Home.SyncFailed.title) - } actions: { - ButtonState(action: .retrySync) { - TextState(L10n.Home.SyncFailed.retry) - } - ButtonState(action: .alert(.dismiss)) { - TextState(secondaryButtonTitle) - } - } message: { - TextState("\(error.message) (code: \(error.code.rawValue))") - } - } -} - // MARK: Placeholders extension HomeReducer.State { diff --git a/modules/Sources/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayView.swift b/modules/Sources/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayView.swift index 7176436d..2f85e884 100644 --- a/modules/Sources/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayView.swift +++ b/modules/Sources/Features/RecoveryPhraseDisplay/RecoveryPhraseDisplayView.swift @@ -20,7 +20,7 @@ public struct RecoveryPhraseDisplayView: View { public var body: some View { WithViewStore(self.store) { viewStore in - VStack(alignment: .center, spacing: 0) { + VStack(alignment: .center) { Spacer() Asset.Assets.zashiLogo.image @@ -46,10 +46,10 @@ public struct RecoveryPhraseDisplayView: View { Spacer() - HStack(spacing: 75) { + HStack { ForEach(groups, id: \.startIndex) { group in VStack(alignment: .leading) { - HStack { + HStack(spacing: 2) { VStack(alignment: .trailing, spacing: 2) { ForEach(Array(group.words.enumerated()), id: \.offset) { seedWord in Text("\(seedWord.offset + group.startIndex + 1).") @@ -61,13 +61,20 @@ public struct RecoveryPhraseDisplayView: View { ForEach(Array(group.words.enumerated()), id: \.offset) { seedWord in Text("\(seedWord.element.data)") .font(.custom(FontFamily.Inter.medium.name, size: 16)) + .minimumScaleFactor(0.5) } } + + if group.startIndex == 0 { + Spacer() + } } } } } - + .frame(maxWidth: .infinity) + .padding(.horizontal, 15) + Spacer() if let birthdayValue = viewStore.birthdayValue { diff --git a/modules/Sources/Features/Root/RootInitialization.swift b/modules/Sources/Features/Root/RootInitialization.swift index c062d09e..bf80629c 100644 --- a/modules/Sources/Features/Root/RootInitialization.swift +++ b/modules/Sources/Features/Root/RootInitialization.swift @@ -23,6 +23,7 @@ extension RootReducer { case initializeSDK(WalletInitMode) case initialSetups case initializationFailed(ZcashError) + case initializationSuccessfullyDone(UnifiedAddress?) case nukeWallet case nukeWalletRequest case respondToWalletInitializationState(InitializationState) @@ -44,8 +45,7 @@ extension RootReducer { .delay(for: 1.0, scheduler: mainQueue) .eraseToEffect() - case .initialization(.synchronizerStartFailed(let zcashError)): - state.alert = AlertState.retryStartFailed(zcashError) + case .initialization(.synchronizerStartFailed): return .none case .initialization(.retryStart): @@ -156,6 +156,9 @@ extension RootReducer { do { try await sdkSynchronizer.prepareWith(seedBytes, birthday, walletMode) try await sdkSynchronizer.start(false) + + let uAddress = try? await sdkSynchronizer.getUnifiedAddress(0) + await send(.initialization(.initializationSuccessfullyDone(uAddress))) } catch { await send(.initialization(.initializationFailed(error.toZcashError()))) } @@ -164,6 +167,10 @@ extension RootReducer { return EffectTask(value: .initialization(.initializationFailed(error.toZcashError()))) } + case .initialization(.initializationSuccessfullyDone(let uAddress)): + state.tabsState.addressDetailsState.uAddress = uAddress + return .none + case .initialization(.checkBackupPhraseValidation): guard let storedWallet = state.storedWallet else { state.appInitializationState = .failed @@ -236,7 +243,7 @@ extension RootReducer { case .updateStateAfterConfigUpdate(let walletConfig): state.walletConfig = walletConfig state.onboardingState.walletConfig = walletConfig -// state.tabsState.walletConfig = walletConfig + state.tabsState.homeState.walletConfig = walletConfig return .none case .initialization(.initializationFailed(let error)): diff --git a/modules/Sources/Features/Root/RootStore.swift b/modules/Sources/Features/Root/RootStore.swift index c95a87b4..2a942a85 100644 --- a/modules/Sources/Features/Root/RootStore.swift +++ b/modules/Sources/Features/Root/RootStore.swift @@ -267,18 +267,6 @@ extension AlertState where Action == RootReducer.Action { TextState(L10n.Root.Initialization.Alert.Wipe.message) } } - - public static func retryStartFailed(_ error: ZcashError) -> AlertState { - AlertState { - TextState(L10n.Root.Initialization.Alert.RetryStartFailed.title) - } actions: { - ButtonState(action: .initialization(.retryStart)) { - TextState(L10n.Home.SyncFailed.retry) - } - } message: { - TextState(L10n.Root.Initialization.Alert.RetryStartFailed.message) - } - } } extension ConfirmationDialogState where Action == RootReducer.Action { diff --git a/modules/Sources/Features/Tabs/TabsView.swift b/modules/Sources/Features/Tabs/TabsView.swift index 6cf044f7..14e8f5a7 100644 --- a/modules/Sources/Features/Tabs/TabsView.swift +++ b/modules/Sources/Features/Tabs/TabsView.swift @@ -88,6 +88,7 @@ public struct TabsView: View { .foregroundColor(.clear) } } + .frame(minHeight: 50) } if item.rawValue < TabsReducer.State.Tab.allCases.count-1 { diff --git a/modules/Sources/Generated/L10n.swift b/modules/Sources/Generated/L10n.swift index 1c4d7b44..aabfb8b6 100644 --- a/modules/Sources/Generated/L10n.swift +++ b/modules/Sources/Generated/L10n.swift @@ -161,18 +161,6 @@ public enum L10n { public static func sendZec(_ p1: Any) -> String { return L10n.tr("Localizable", "home.sendZec", String(describing: p1), fallback: "Send %@") } - /// ZASHI - public static let title = L10n.tr("Localizable", "home.title", fallback: "ZASHI") - /// See transaction history - public static let transactionHistory = L10n.tr("Localizable", "home.transactionHistory", fallback: "See transaction history") - public enum SyncFailed { - /// Dismiss - public static let dismiss = L10n.tr("Localizable", "home.syncFailed.dismiss", fallback: "Dismiss") - /// Retry - public static let retry = L10n.tr("Localizable", "home.syncFailed.retry", fallback: "Retry") - /// Sync failed! - public static let title = L10n.tr("Localizable", "home.syncFailed.title", fallback: "Sync failed!") - } } public enum ImportWallet { /// Enter your secret backup seed phrase. diff --git a/modules/Sources/Generated/Resources/Localizable.strings b/modules/Sources/Generated/Resources/Localizable.strings index 27045f53..e3af301d 100644 --- a/modules/Sources/Generated/Resources/Localizable.strings +++ b/modules/Sources/Generated/Resources/Localizable.strings @@ -90,11 +90,6 @@ // MARK: - Home Screen "home.sendZec" = "Send %@"; "home.receiveZec" = "Receive %@"; -"home.transactionHistory" = "See transaction history"; -"home.title" = "ZASHI"; -"home.syncFailed.title" = "Sync failed!"; -"home.syncFailed.dismiss" = "Dismiss"; -"home.syncFailed.retry" = "Retry"; "home.migratingDatabases" = "Upgrading databases…"; // MARK: - Receive ZEC diff --git a/secant.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/secant.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9a94a22d..c6d2d6a8 100644 --- a/secant.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/secant.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -338,8 +338,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/zcash/ZcashLightClientKit", "state" : { - "revision" : "bb99939415022a6088743a8f1271fec77f687464", - "version" : "2.0.1" + "revision" : "c1cc041ab0b88324c41348ad958b68ff99a98015", + "version" : "2.0.2" } } ], diff --git a/secantTests/HomeTests/HomeTests.swift b/secantTests/HomeTests/HomeTests.swift index 99eb816d..608a239b 100644 --- a/secantTests/HomeTests/HomeTests.swift +++ b/secantTests/HomeTests/HomeTests.swift @@ -103,8 +103,6 @@ class HomeTests: XCTestCase { state.migratingDatabase = false } - store.receive(.showSynchronizerErrorAlert(testError)) { state in - state.alert = AlertState.syncFailed(ZcashError.synchronizerNotPrepared, L10n.Home.SyncFailed.dismiss) - } + store.receive(.showSynchronizerErrorAlert(testError)) } } diff --git a/secantTests/RootTests/RootTests.swift b/secantTests/RootTests/RootTests.swift index 3927525e..f4d3d995 100644 --- a/secantTests/RootTests/RootTests.swift +++ b/secantTests/RootTests/RootTests.swift @@ -183,4 +183,19 @@ class RootTests: XCTestCase { state.alert = AlertState.initializationFailed(zcashError) } } + + func testInitializationSuccessfullyDone() throws { + let store = TestStore( + initialState: .placeholder, + reducer: RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) + ) + + // swiftlint:disable line_length + let uAddress = try UnifiedAddress(encoding: "utest1zkkkjfxkamagznjr6ayemffj2d2gacdwpzcyw669pvg06xevzqslpmm27zjsctlkstl2vsw62xrjktmzqcu4yu9zdhdxqz3kafa4j2q85y6mv74rzjcgjg8c0ytrg7dwyzwtgnuc76h", network: .testnet + ) + + store.send(.initialization(.initializationSuccessfullyDone(uAddress))) { state in + state.tabsState.addressDetailsState.uAddress = uAddress + } + } }