[#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
This commit is contained in:
Lukas Korba 2023-10-13 16:36:50 +02:00 committed by GitHub
parent 2d4ddd72c6
commit 9f4243b475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 48 additions and 66 deletions

View File

@ -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<Action> {
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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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)):

View File

@ -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 {

View File

@ -88,6 +88,7 @@ public struct TabsView: View {
.foregroundColor(.clear)
}
}
.frame(minHeight: 50)
}
if item.rawValue < TabsReducer.State.Tab.allCases.count-1 {

View File

@ -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.

View File

@ -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

View File

@ -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"
}
}
],

View File

@ -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))
}
}

View File

@ -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
}
}
}