From 8e3544b732b99ea63ec119dc93925ef1d4d4e0e8 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 1 Dec 2022 15:31:30 +0100 Subject: [PATCH] [#499] Refactor Route to Destination (#500) - Route -> Destination refactor done - test working - cleanup of URLRouting usage --- secant/Dependencies/Deeplink/Deeplink.swift | 8 +-- .../Deeplink/DeeplinkInterface.swift | 2 +- secant/Features/App/AppStore.swift | 58 +++++++++---------- secant/Features/App/AppView.swift | 12 ++-- secant/Features/Home/HomeStore.swift | 38 ++++++------ secant/Features/Home/HomeView.swift | 12 ++-- .../OnboardingFlow/OnboardingFlowStore.swift | 20 +++---- .../Views/OnboardingFooterView.swift | 2 +- secant/Features/Profile/ProfileStore.swift | 22 +++---- secant/Features/Profile/ProfileView.swift | 4 +- .../RecoveryPhraseValidationFlowStore.swift | 48 +++++++-------- .../RecoveryPhraseValidationFlowView.swift | 2 +- secant/Features/Sandbox/SandboxStore.swift | 28 ++++----- secant/Features/Sandbox/SandboxView.swift | 38 ++++++------ secant/Features/SendFlow/SendFlowStore.swift | 56 +++++++++--------- secant/Features/SendFlow/SendFlowView.swift | 2 +- .../Views/CreateTransactionView.swift | 2 +- .../Views/TransactionFailedView.swift | 2 +- .../SendFlow/Views/TransactionSentView.swift | 2 +- secant/Features/Settings/SettingsStore.swift | 22 +++---- .../WalletEventsFlowStore.swift | 24 ++++---- .../WalletEventsFlowView.swift | 6 +- .../AppTests/AppInitializationTests.swift | 14 ++--- secantTests/AppTests/AppTests.swift | 4 +- secantTests/DeeplinkTests/DeeplinkTests.swift | 38 ++++++------ secantTests/HomeTests/HomeTests.swift | 22 +++---- .../RecoveryPhraseValidationTests.swift | 8 +-- secantTests/SendTests/SendTests.swift | 24 ++++---- secantTests/SettingsTests/SettingsTests.swift | 10 ++-- .../WalletEventsSnapshotTests.swift | 8 +-- .../WalletEventsTests/WalletEventsTests.swift | 6 +- 31 files changed, 272 insertions(+), 272 deletions(-) diff --git a/secant/Dependencies/Deeplink/Deeplink.swift b/secant/Dependencies/Deeplink/Deeplink.swift index 0675578..723f5a2 100644 --- a/secant/Dependencies/Deeplink/Deeplink.swift +++ b/secant/Dependencies/Deeplink/Deeplink.swift @@ -11,12 +11,12 @@ import ComposableArchitecture import ZcashLightClientKit struct Deeplink { - enum Route: Equatable { + enum Destination: Equatable { case home case send(amount: Int64, address: String, memo: String) } - func resolveDeeplinkURL(_ url: URL, isValidZcashAddress: (String) throws -> Bool) throws -> Route { + func resolveDeeplinkURL(_ url: URL, isValidZcashAddress: (String) throws -> Bool) throws -> Destination { // simplified format zcash:
// TODO [#109]: simplified for now until ZIP-321 is implememnted (https://github.com/zcash/secant-ios-wallet/issues/109) let address = url.absoluteString.replacingOccurrences(of: "zcash:", with: "") @@ -29,12 +29,12 @@ struct Deeplink { // regular URL format zcash:// let appRouter = OneOf { // GET /home - URLRouting.Route(.case(Route.home)) { + Route(.case(Destination.home)) { Path { "home" } } // GET /home/send?amount=:amount&address=:address&memo=:memo - URLRouting.Route(.case(Route.send(amount:address:memo:))) { + Route(.case(Destination.send(amount:address:memo:))) { Path { "home"; "send" } Query { Field("amount", default: 0) { Int64.parser() } diff --git a/secant/Dependencies/Deeplink/DeeplinkInterface.swift b/secant/Dependencies/Deeplink/DeeplinkInterface.swift index afeefe0..c8c52bd 100644 --- a/secant/Dependencies/Deeplink/DeeplinkInterface.swift +++ b/secant/Dependencies/Deeplink/DeeplinkInterface.swift @@ -17,5 +17,5 @@ extension DependencyValues { } struct DeeplinkClient { - let resolveDeeplinkURL: (URL, DerivationToolClient) throws -> Deeplink.Route + let resolveDeeplinkURL: (URL, DerivationToolClient) throws -> Deeplink.Destination } diff --git a/secant/Features/App/AppStore.swift b/secant/Features/App/AppStore.swift index 8ae4166..9ea2030 100644 --- a/secant/Features/App/AppStore.swift +++ b/secant/Features/App/AppStore.swift @@ -10,7 +10,7 @@ struct AppReducer: ReducerProtocol { private enum CancelId {} struct State: Equatable { - enum Route: Equatable { + enum Destination: Equatable { case welcome case startup case onboarding @@ -25,17 +25,17 @@ struct AppReducer: ReducerProtocol { var onboardingState: OnboardingFlowReducer.State var phraseValidationState: RecoveryPhraseValidationFlowReducer.State var phraseDisplayState: RecoveryPhraseDisplayReducer.State - var prevRoute: Route? - var internalRoute: Route = .welcome + var prevDestination: Destination? + var internalDestination: Destination = .welcome var sandboxState: SandboxReducer.State var storedWallet: StoredWallet? var welcomeState: WelcomeReducer.State - var route: Route { - get { internalRoute } + var destination: Destination { + get { internalDestination } set { - prevRoute = internalRoute - internalRoute = newValue + prevDestination = internalDestination + internalDestination = newValue } } } @@ -56,7 +56,7 @@ struct AppReducer: ReducerProtocol { case phraseValidation(RecoveryPhraseValidationFlowReducer.Action) case respondToWalletInitializationState(InitializationState) case sandbox(SandboxReducer.Action) - case updateRoute(AppReducer.State.Route) + case updateDestination(AppReducer.State.Destination) case welcome(WelcomeReducer.Action) } @@ -93,29 +93,29 @@ struct AppReducer: ReducerProtocol { Reduce { state, action in switch action { - case let .updateRoute(route): - state.route = route + case let .updateDestination(destination): + state.destination = destination case .sandbox(.reset): - state.route = .startup + state.destination = .startup case .onboarding(.createNewWallet): return Effect(value: .createNewWallet) case .phraseValidation(.proceedToHome): - state.route = .home + state.destination = .home case .phraseValidation(.displayBackedUpPhrase): - state.route = .phraseDisplay + state.destination = .phraseDisplay case .phraseDisplay(.finishedPressed): // user is still supposed to do the backup phrase validation test - if state.prevRoute == .welcome || state.prevRoute == .onboarding { - state.route = .phraseValidation + if state.prevDestination == .welcome || state.prevDestination == .onboarding { + state.destination = .phraseValidation } // user wanted to see the backup phrase once again (at validation finished screen) - if state.prevRoute == .phraseValidation { - state.route = .home + if state.prevDestination == .phraseValidation { + state.destination = .home } case .deeplink(let url): @@ -144,13 +144,13 @@ struct AppReducer: ReducerProtocol { } case .deeplinkHome: - state.route = .home - state.homeState.route = nil + state.destination = .home + state.homeState.destination = nil return .none case let .deeplinkSend(amount, address, memo): - state.route = .home - state.homeState.route = .send + state.destination = .home + state.homeState.destination = .send state.homeState.sendState.amount = amount state.homeState.sendState.address = address state.homeState.sendState.memoState.text = memo @@ -162,7 +162,7 @@ struct AppReducer: ReducerProtocol { } return Effect(value: .deeplink(url)) - /// Default is meaningful here because there's `appReducer` handling actions and this reducer is handling only routes. We don't here plenty of unused cases. + /// Default is meaningful here because there's `appReducer` handling actions and this reducer is handling only destinations. We don't here plenty of unused cases. default: break } @@ -206,7 +206,7 @@ struct AppReducer: ReducerProtocol { ) case .uninitialized: state.appInitializationState = .uninitialized - return Effect(value: .updateRoute(.onboarding)) + return Effect(value: .updateDestination(.onboarding)) .delay(for: 3, scheduler: mainQueue) .eraseToEffect() .cancellable(id: CancelId.self, cancelInFlight: true) @@ -257,7 +257,7 @@ struct AppReducer: ReducerProtocol { return .none } - var landingRoute: AppReducer.State.Route = .home + var landingDestination: AppReducer.State.Destination = .home if !storedWallet.hasUserPassedPhraseBackupTest { do { @@ -266,7 +266,7 @@ struct AppReducer: ReducerProtocol { let recoveryPhrase = RecoveryPhrase(words: phraseWords) state.phraseDisplayState.phrase = recoveryPhrase state.phraseValidationState = randomRecoveryPhrase.random(recoveryPhrase) - landingRoute = .phraseDisplay + landingDestination = .phraseDisplay } catch { // TODO [#201]: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States return .none @@ -275,7 +275,7 @@ struct AppReducer: ReducerProtocol { state.appInitializationState = .initialized - return Effect(value: .updateRoute(landingRoute)) + return Effect(value: .updateDestination(landingDestination)) .delay(for: 3, scheduler: mainQueue) .eraseToEffect() .cancellable(id: CancelId.self, cancelInFlight: true) @@ -325,16 +325,16 @@ struct AppReducer: ReducerProtocol { case .welcome(.debugMenuStartup), .home(.debugMenuStartup): return .concatenate( Effect.cancel(id: CancelId.self), - Effect(value: .updateRoute(.startup)) + Effect(value: .updateDestination(.startup)) ) case .onboarding(.importWallet(.successfullyRecovered)): - return Effect(value: .updateRoute(.home)) + return Effect(value: .updateDestination(.home)) case .onboarding(.importWallet(.initializeSDK)): return Effect(value: .initializeSDK) - /// Default is meaningful here because there's `routeReducer` handling routes and this reducer is handling only actions. We don't here plenty of unused cases. + /// Default is meaningful here because there's `destinationReducer` handling destinations and this reducer is handling only actions. We don't here plenty of unused cases. default: return .none } diff --git a/secant/Features/App/AppView.swift b/secant/Features/App/AppView.swift index 3a77f14..978c627 100644 --- a/secant/Features/App/AppView.swift +++ b/secant/Features/App/AppView.swift @@ -8,7 +8,7 @@ struct AppView: View { var body: some View { WithViewStore(store) { viewStore in Group { - switch viewStore.route { + switch viewStore.destination { case .home: NavigationView { HomeView( @@ -86,21 +86,21 @@ struct AppView: View { private extension AppView { @ViewBuilder func debugView(_ viewStore: AppViewStore) -> some View { List { - Section(header: Text("Navigation Stack Routes")) { + Section(header: Text("Navigation Stack Destinations")) { Button("Go To Sandbox (navigation proof)") { - viewStore.send(.updateRoute(.sandbox)) + viewStore.send(.updateDestination(.sandbox)) } Button("Go To Onboarding") { - viewStore.send(.updateRoute(.onboarding)) + viewStore.send(.updateDestination(.onboarding)) } Button("Go To Phrase Validation Demo") { - viewStore.send(.updateRoute(.phraseValidation)) + viewStore.send(.updateDestination(.phraseValidation)) } Button("Restart the app") { - viewStore.send(.updateRoute(.welcome)) + viewStore.send(.updateDestination(.welcome)) } Button("[Be careful] Nuke Wallet") { diff --git a/secant/Features/Home/HomeStore.swift b/secant/Features/Home/HomeStore.swift index 20c0abe..3121867 100644 --- a/secant/Features/Home/HomeStore.swift +++ b/secant/Features/Home/HomeStore.swift @@ -12,7 +12,7 @@ struct HomeReducer: ReducerProtocol { private enum CancelId {} struct State: Equatable { - enum Route: Equatable { + enum Destination: Equatable { case notEnoughFreeDiskSpace case profile case request @@ -21,7 +21,7 @@ struct HomeReducer: ReducerProtocol { case balanceBreakdown } - var route: Route? + var destination: Destination? var balanceBreakdownState: BalanceBreakdownReducer.State var drawerOverlay: DrawerOverlay @@ -68,7 +68,7 @@ struct HomeReducer: ReducerProtocol { case synchronizerStateChanged(SDKSynchronizerState) case walletEvents(WalletEventsFlowReducer.Action) case updateDrawer(DrawerOverlay) - case updateRoute(HomeReducer.State.Route?) + case updateDestination(HomeReducer.State.Destination?) case updateSynchronizerStatus case updateWalletEvents([WalletEvent]) } @@ -110,9 +110,9 @@ struct HomeReducer: ReducerProtocol { .map(HomeReducer.Action.synchronizerStateChanged) .eraseToEffect() .cancellable(id: CancelId.self, cancelInFlight: true) - return .concatenate(Effect(value: .updateRoute(nil)), syncEffect) + return .concatenate(Effect(value: .updateDestination(nil)), syncEffect) } else { - return Effect(value: .updateRoute(.notEnoughFreeDiskSpace)) + return Effect(value: .updateDestination(.notEnoughFreeDiskSpace)) } case .onDisappear: @@ -145,16 +145,16 @@ struct HomeReducer: ReducerProtocol { } return .none - case .updateRoute(let route): - state.route = route + case .updateDestination(let destination): + state.destination = destination return .none case .profile(.back): - state.route = nil + state.destination = nil return .none case .profile(.settings(.quickRescan)): - state.route = nil + state.destination = nil return Effect.task { do { try await sdkSynchronizer.rewind(.quick) @@ -165,7 +165,7 @@ struct HomeReducer: ReducerProtocol { } case .profile(.settings(.fullRescan)): - state.route = nil + state.destination = nil return Effect.task { do { try await sdkSynchronizer.rewind(.birthday) @@ -185,30 +185,30 @@ struct HomeReducer: ReducerProtocol { // TODO [#221]: error we need to handle (https://github.com/zcash/secant-ios-wallet/issues/221) return .none - case .walletEvents(.updateRoute(.all)): + case .walletEvents(.updateDestination(.all)): return state.drawerOverlay != .full ? Effect(value: .updateDrawer(.full)) : .none - case .walletEvents(.updateRoute(.latest)): + case .walletEvents(.updateDestination(.latest)): return state.drawerOverlay != .partial ? Effect(value: .updateDrawer(.partial)) : .none case .walletEvents: return .none - case .send(.updateRoute(.done)): - return Effect(value: .updateRoute(nil)) + case .send(.updateDestination(.done)): + return Effect(value: .updateDestination(nil)) case .send: return .none case .scan(.found): audioServices.systemSoundVibrate() - return Effect(value: .updateRoute(nil)) + return Effect(value: .updateDestination(nil)) case .scan: return .none case .balanceBreakdown(.onDisappear): - state.route = nil + state.destination = nil return .none case .balanceBreakdown: @@ -270,11 +270,11 @@ extension HomeStore { // MARK: - ViewStore extension HomeViewStore { - func bindingForRoute(_ route: HomeReducer.State.Route) -> Binding { + func bindingForDestination(_ destination: HomeReducer.State.Destination) -> Binding { self.binding( - get: { $0.route == route }, + get: { $0.destination == destination }, send: { isActive in - return .updateRoute(isActive ? route : nil) + return .updateDestination(isActive ? destination : nil) } ) } diff --git a/secant/Features/Home/HomeView.swift b/secant/Features/Home/HomeView.swift index f4387db..550212f 100644 --- a/secant/Features/Home/HomeView.swift +++ b/secant/Features/Home/HomeView.swift @@ -27,12 +27,12 @@ struct HomeView: View { .navigationBarHidden(true) .onAppear(perform: { viewStore.send(.onAppear) }) .onDisappear(perform: { viewStore.send(.onDisappear) }) - .fullScreenCover(isPresented: viewStore.bindingForRoute(.balanceBreakdown)) { + .fullScreenCover(isPresented: viewStore.bindingForDestination(.balanceBreakdown)) { BalanceBreakdownView(store: store.balanceBreakdownStore()) } } .navigationLinkEmpty( - isActive: viewStore.bindingForRoute(.notEnoughFreeDiskSpace), + isActive: viewStore.bindingForDestination(.notEnoughFreeDiskSpace), destination: { NotEnoughFreeSpaceView(viewStore: viewStore) } ) } @@ -52,7 +52,7 @@ extension HomeView { .frame(width: 60, height: 60) .padding(.trailing, 15) .navigationLink( - isActive: viewStore.bindingForRoute(.profile), + isActive: viewStore.bindingForDestination(.profile), destination: { ProfileView(store: store.profileStore()) } @@ -82,7 +82,7 @@ extension HomeView { .padding(.horizontal, 50) .neumorphicButton() .navigationLink( - isActive: viewStore.bindingForRoute(.send), + isActive: viewStore.bindingForDestination(.send), destination: { SendFlowView(store: store.sendStore()) } @@ -101,7 +101,7 @@ extension HomeView { .padding(.top, 7) .padding(.leading, 22) .navigationLink( - isActive: viewStore.bindingForRoute(.scan), + isActive: viewStore.bindingForDestination(.scan), destination: { ScanView(store: store.scanStore()) } @@ -128,7 +128,7 @@ extension HomeView { VStack { Button { - viewStore.send(.updateRoute(.balanceBreakdown)) + viewStore.send(.updateDestination(.balanceBreakdown)) } label: { Text("$\(viewStore.shieldedBalance.total.decimalString())") .font(.custom(FontFamily.Zboto.regular.name, size: 40)) diff --git a/secant/Features/OnboardingFlow/OnboardingFlowStore.swift b/secant/Features/OnboardingFlow/OnboardingFlowStore.swift index f7bc38e..c28b55b 100644 --- a/secant/Features/OnboardingFlow/OnboardingFlowStore.swift +++ b/secant/Features/OnboardingFlow/OnboardingFlowStore.swift @@ -14,7 +14,7 @@ typealias OnboardingFlowViewStore = ViewStore = Self.onboardingSteps var index = 0 var skippedAtindex: Int? - var route: Route? + var destination: Destination? var currentStep: Step { steps[index] } var isFinalStep: Bool { steps.count == index + 1 } @@ -51,7 +51,7 @@ struct OnboardingFlowReducer: ReducerProtocol { case next case back case skip - case updateRoute(OnboardingFlowReducer.State.Route?) + case updateDestination(OnboardingFlowReducer.State.Destination?) case createNewWallet case importExistingWallet case importWallet(ImportWalletReducer.Action) @@ -85,16 +85,16 @@ struct OnboardingFlowReducer: ReducerProtocol { state.index = state.steps.count - 1 return .none - case .updateRoute(let route): - state.route = route + case .updateDestination(let destination): + state.destination = destination return .none case .createNewWallet: - state.route = .createNewWallet + state.destination = .createNewWallet return .none case .importExistingWallet: - state.route = .importExistingWallet + state.destination = .importExistingWallet return .none case .importWallet: @@ -142,11 +142,11 @@ extension OnboardingFlowReducer.State { // MARK: - ViewStore extension OnboardingFlowViewStore { - func bindingForRoute(_ route: OnboardingFlowReducer.State.Route) -> Binding { + func bindingForDestination(_ destination: OnboardingFlowReducer.State.Destination) -> Binding { self.binding( - get: { $0.route == route }, + get: { $0.destination == destination }, send: { isActive in - return .updateRoute(isActive ? route : nil) + return .updateDestination(isActive ? destination : nil) } ) } diff --git a/secant/Features/OnboardingFlow/Views/OnboardingFooterView.swift b/secant/Features/OnboardingFlow/Views/OnboardingFooterView.swift index 9be6691..ad50258 100644 --- a/secant/Features/OnboardingFlow/Views/OnboardingFooterView.swift +++ b/secant/Features/OnboardingFlow/Views/OnboardingFooterView.swift @@ -47,7 +47,7 @@ struct OnboardingFooterView: View { } } .navigationLinkEmpty( - isActive: viewStore.bindingForRoute(.importExistingWallet), + isActive: viewStore.bindingForDestination(.importExistingWallet), destination: { ImportWalletView( store: store.scope( diff --git a/secant/Features/Profile/ProfileStore.swift b/secant/Features/Profile/ProfileStore.swift index e9a5fc3..e3e66c7 100644 --- a/secant/Features/Profile/ProfileStore.swift +++ b/secant/Features/Profile/ProfileStore.swift @@ -6,7 +6,7 @@ typealias ProfileViewStore = ViewStore { + var destinationBinding: Binding { self.binding( - get: \.route, - send: ProfileReducer.Action.updateRoute + get: \.destination, + send: ProfileReducer.Action.updateDestination ) } var bindingForAddressDetails: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .addressDetails }, embed: { $0 ? .addressDetails : nil } ) } var bindingForSettings: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .settings }, embed: { $0 ? .settings : nil } ) @@ -116,7 +116,7 @@ extension ProfileReducer.State { static var placeholder: Self { .init( addressDetailsState: .placeholder, - route: nil, + destination: nil, settingsState: .placeholder ) } diff --git a/secant/Features/Profile/ProfileView.swift b/secant/Features/Profile/ProfileView.swift index d4e307e..b370893 100644 --- a/secant/Features/Profile/ProfileView.swift +++ b/secant/Features/Profile/ProfileView.swift @@ -17,7 +17,7 @@ struct ProfileView: View { .padding(30) Button( - action: { viewStore.send(.updateRoute(.addressDetails)) }, + action: { viewStore.send(.updateDestination(.addressDetails)) }, label: { Text("See address details") } ) .activeButtonStyle @@ -30,7 +30,7 @@ struct ProfileView: View { .foregroundColor(Asset.Colors.TextField.Underline.purple.color) Button( - action: { viewStore.send(.updateRoute(.settings)) }, + action: { viewStore.send(.updateDestination(.settings)) }, label: { Text("Settings") } ) .primaryButtonStyle diff --git a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift index 645eed0..c108ad8 100644 --- a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift +++ b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowStore.swift @@ -14,7 +14,7 @@ typealias RecoveryPhraseValidationFlowViewStore = ViewStore Binding { + func bindingForDestination(_ destination: RecoveryPhraseValidationFlowReducer.State.Destination) -> Binding { self.binding( - get: { $0.route == route }, + get: { $0.destination == destination }, send: { isActive in - return .updateRoute(isActive ? route : nil) + return .updateDestination(isActive ? destination : nil) } ) } @@ -182,27 +182,27 @@ extension RecoveryPhraseValidationFlowViewStore { extension RecoveryPhraseValidationFlowViewStore { var bindingForValidation: Binding { self.binding( - get: { $0.route != nil }, + get: { $0.destination != nil }, send: { isActive in - return .updateRoute(isActive ? .validation : nil) + return .updateDestination(isActive ? .validation : nil) } ) } var bindingForSuccess: Binding { self.binding( - get: { $0.route == .success }, + get: { $0.destination == .success }, send: { isActive in - return .updateRoute(isActive ? .success : .validation) + return .updateDestination(isActive ? .success : .validation) } ) } var bindingForFailure: Binding { self.binding( - get: { $0.route == .failure }, + get: { $0.destination == .failure }, send: { isActive in - return .updateRoute(isActive ? .failure : .validation) + return .updateDestination(isActive ? .failure : .validation) } ) } @@ -221,7 +221,7 @@ extension RecoveryPhraseValidationFlowReducer.State { .unassigned(word: "garlic") ], validationWords: [], - route: nil + destination: nil ) static let placeholderStep1 = RecoveryPhraseValidationFlowReducer.State( @@ -236,7 +236,7 @@ extension RecoveryPhraseValidationFlowReducer.State { validationWords: [ .init(groupIndex: 2, word: "morning") ], - route: nil + destination: nil ) static let placeholderStep2 = RecoveryPhraseValidationFlowReducer.State( @@ -252,7 +252,7 @@ extension RecoveryPhraseValidationFlowReducer.State { .init(groupIndex: 2, word: "morning"), .init(groupIndex: 0, word: "thank") ], - route: nil + destination: nil ) static let placeholderStep3 = RecoveryPhraseValidationFlowReducer.State( @@ -269,7 +269,7 @@ extension RecoveryPhraseValidationFlowReducer.State { .init(groupIndex: 0, word: "thank"), .init(groupIndex: 3, word: "garlic") ], - route: nil + destination: nil ) static let placeholderStep4 = RecoveryPhraseValidationFlowReducer.State( @@ -287,7 +287,7 @@ extension RecoveryPhraseValidationFlowReducer.State { .init(groupIndex: 3, word: "garlic"), .init(groupIndex: 1, word: "boil") ], - route: nil + destination: nil ) } diff --git a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowView.swift b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowView.swift index 37f5d99..3f351d0 100644 --- a/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowView.swift +++ b/secant/Features/RecoveryPhraseValidationFlow/RecoveryPhraseValidationFlowView.swift @@ -51,7 +51,7 @@ struct RecoveryPhraseValidationFlowView: View { } Button( - action: { viewStore.send(.updateRoute(.validation)) }, + action: { viewStore.send(.updateDestination(.validation)) }, label: { Text("recoveryPhraseTestPreamble.button.goNext") } ) .activeButtonStyle diff --git a/secant/Features/Sandbox/SandboxStore.swift b/secant/Features/Sandbox/SandboxStore.swift index b266b80..6138444 100644 --- a/secant/Features/Sandbox/SandboxStore.swift +++ b/secant/Features/Sandbox/SandboxStore.swift @@ -6,7 +6,7 @@ typealias SandboxViewStore = ViewStore ComposableArchitecture.EffectTask { switch action { - case let .updateRoute(route): - state.route = route + case let .updateDestination(destination): + state.destination = destination return .none case let .walletEvents(walletEventsAction): @@ -73,22 +73,22 @@ extension SandboxViewStore { func toggleSelectedTransaction() { let isAlreadySelected = (self.selectedTranactionID != nil) let walletEvent = self.walletEventsState.walletEvents[5] - let newRoute = isAlreadySelected ? nil : WalletEventsFlowReducer.State.Route.showWalletEvent(walletEvent) - send(.walletEvents(.updateRoute(newRoute))) + let newDestination = isAlreadySelected ? nil : WalletEventsFlowReducer.State.Destination.showWalletEvent(walletEvent) + send(.walletEvents(.updateDestination(newDestination))) } var selectedTranactionID: String? { self.walletEventsState - .route - .flatMap(/WalletEventsFlowReducer.State.Route.showWalletEvent) + .destination + .flatMap(/WalletEventsFlowReducer.State.Destination.showWalletEvent) .map(\.id) } - func bindingForRoute(_ route: SandboxReducer.State.Route) -> Binding { + func bindingForDestination(_ destination: SandboxReducer.State.Destination) -> Binding { self.binding( - get: { $0.route == route }, + get: { $0.destination == destination }, send: { isActive in - return .updateRoute(isActive ? route : nil) + return .updateDestination(isActive ? destination : nil) } ) } @@ -101,7 +101,7 @@ extension SandboxReducer.State { .init( walletEventsState: .placeHolder, profileState: .placeholder, - route: nil + destination: nil ) } } @@ -112,7 +112,7 @@ extension SandboxStore { initialState: SandboxReducer.State( walletEventsState: .placeHolder, profileState: .placeholder, - route: nil + destination: nil ), reducer: SandboxReducer() ) diff --git a/secant/Features/Sandbox/SandboxView.swift b/secant/Features/Sandbox/SandboxView.swift index 4fa08fc..c8ccb26 100644 --- a/secant/Features/Sandbox/SandboxView.swift +++ b/secant/Features/Sandbox/SandboxView.swift @@ -2,25 +2,25 @@ import SwiftUI import ComposableArchitecture struct SandboxView: View { - struct SandboxRouteValue: Identifiable { + struct SandboxDestinationValue: Identifiable { let id: Int - let route: SandboxReducer.State.Route + let destination: SandboxReducer.State.Destination } let store: SandboxStore - var navigationRouteValues: [SandboxRouteValue] = SandboxReducer.State.Route.allCases + var navigationDestinationValues: [SandboxDestinationValue] = SandboxReducer.State.Destination.allCases .enumerated() .filter { $0.1 != .history } - .map { SandboxRouteValue(id: $0.0, route: $0.1) } + .map { SandboxDestinationValue(id: $0.0, destination: $0.1) } - var modalRoutes: [SandboxRouteValue] = SandboxReducer.State.Route.allCases + var modalDestinations: [SandboxDestinationValue] = SandboxReducer.State.Destination.allCases .enumerated() .filter { $0.1 == .history } - .map { SandboxRouteValue(id: $0.0, route: $0.1) } + .map { SandboxDestinationValue(id: $0.0, destination: $0.1) } - @ViewBuilder func view(for route: SandboxReducer.State.Route) -> some View { - switch route { + @ViewBuilder func view(for destination: SandboxReducer.State.Destination) -> some View { + switch destination { case .history: WalletEventsFlowView(store: store.historyStore()) case .send: @@ -45,23 +45,23 @@ struct SandboxView: View { WithViewStore(store) { viewStore in VStack { List { - Section(header: Text("Navigation Stack Routes")) { - ForEach(navigationRouteValues) { routeValue in - Text("\(String(describing: routeValue.route))") + Section(header: Text("Navigation Stack Destinations")) { + ForEach(navigationDestinationValues) { destinationValue in + Text("\(String(describing: destinationValue.destination))") .navigationLink( - isActive: viewStore.bindingForRoute(routeValue.route), + isActive: viewStore.bindingForDestination(destinationValue.destination), destination: { - view(for: routeValue.route) + view(for: destinationValue.destination) } ) } } - Section(header: Text("Modal Routes")) { - ForEach(modalRoutes) { routeValue in + Section(header: Text("Modal Destinations")) { + ForEach(modalDestinations) { destinationValue in Button( - action: { viewStore.send(.updateRoute(routeValue.route)) }, - label: { Text("\(String(describing: routeValue.route))") } + action: { viewStore.send(.updateDestination(destinationValue.destination)) }, + label: { Text("\(String(describing: destinationValue.destination))") } ) } } @@ -80,13 +80,13 @@ struct SandboxView: View { } } .fullScreenCover( - isPresented: viewStore.bindingForRoute(.history), + isPresented: viewStore.bindingForDestination(.history), content: { NavigationView { WalletEventsFlowView(store: store.historyStore()) .toolbar { ToolbarItem { - Button("Done") { viewStore.send(.updateRoute(nil)) } + Button("Done") { viewStore.send(.updateDestination(nil)) } } } } diff --git a/secant/Features/SendFlow/SendFlowStore.swift b/secant/Features/SendFlow/SendFlowStore.swift index 2980a32..f393bbe 100644 --- a/secant/Features/SendFlow/SendFlowStore.swift +++ b/secant/Features/SendFlow/SendFlowStore.swift @@ -16,7 +16,7 @@ struct SendFlowReducer: ReducerProtocol { private enum SyncStatusUpdatesID {} struct State: Equatable { - enum Route: Equatable { + enum Destination: Equatable { case confirmation case inProgress case success @@ -27,7 +27,7 @@ struct SendFlowReducer: ReducerProtocol { var addMemoState: Bool var isSendingTransaction = false var memoState: MultiLineTextFieldReducer.State - var route: Route? + var destination: Destination? var shieldedBalance = WalletBalance.zero var transactionAddressInputState: TransactionAddressTextFieldReducer.State var transactionAmountInputState: TransactionAmountTextFieldReducer.State @@ -83,7 +83,7 @@ struct SendFlowReducer: ReducerProtocol { case synchronizerStateChanged(SDKSynchronizerState) case transactionAddressInput(TransactionAddressTextFieldReducer.Action) case transactionAmountInput(TransactionAmountTextFieldReducer.Action) - case updateRoute(SendFlowReducer.State.Route?) + case updateDestination(SendFlowReducer.State.Destination?) } @Dependency(\.derivationTool) var derivationTool @@ -115,27 +115,27 @@ struct SendFlowReducer: ReducerProtocol { case .addMemo: return .none - case .updateRoute(.done): - state.route = nil + case .updateDestination(.done): + state.destination = nil state.memoState.text = "" state.transactionAmountInputState.textFieldState.text = "" state.transactionAmountInputState.amount = 0 state.transactionAddressInputState.textFieldState.text = "" return .none - case .updateRoute(.failure): - state.route = .failure + case .updateDestination(.failure): + state.destination = .failure state.isSendingTransaction = false return .none - case .updateRoute(.confirmation): + case .updateDestination(.confirmation): state.amount = Zatoshi(state.transactionAmountInputState.amount) state.address = state.transactionAddressInputState.textFieldState.text - state.route = .confirmation + state.destination = .confirmation return .none - case let .updateRoute(route): - state.route = route + case let .updateDestination(destination): + state.destination = destination return .none case .sendConfirmationPressed: @@ -169,20 +169,20 @@ struct SendFlowReducer: ReducerProtocol { .eraseToEffect() return .concatenate( - Effect(value: .updateRoute(.inProgress)), + Effect(value: .updateDestination(.inProgress)), sendTransActionEffect ) } catch { - return Effect(value: .updateRoute(.failure)) + return Effect(value: .updateDestination(.failure)) } case .sendTransactionResult(let result): state.isSendingTransaction = false do { _ = try result.get() - return Effect(value: .updateRoute(.success)) + return Effect(value: .updateDestination(.success)) } catch { - return Effect(value: .updateRoute(.failure)) + return Effect(value: .updateDestination(.failure)) } case .transactionAmountInput: @@ -239,47 +239,47 @@ extension SendFlowStore { // MARK: - ViewStore extension SendFlowViewStore { - var routeBinding: Binding { + var destinationBinding: Binding { self.binding( - get: \.route, - send: SendFlowReducer.Action.updateRoute + get: \.destination, + send: SendFlowReducer.Action.updateDestination ) } var bindingForConfirmation: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .confirmation || $0 == .inProgress || $0 == .success || $0 == .failure }, - embed: { $0 ? SendFlowReducer.State.Route.confirmation : nil } + embed: { $0 ? SendFlowReducer.State.Destination.confirmation : nil } ) } var bindingForInProgress: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .inProgress || $0 == .success || $0 == .failure }, - embed: { $0 ? SendFlowReducer.State.Route.inProgress : SendFlowReducer.State.Route.confirmation } + embed: { $0 ? SendFlowReducer.State.Destination.inProgress : SendFlowReducer.State.Destination.confirmation } ) } var bindingForSuccess: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .success }, - embed: { _ in SendFlowReducer.State.Route.success } + embed: { _ in SendFlowReducer.State.Destination.success } ) } var bindingForFailure: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .failure }, - embed: { _ in SendFlowReducer.State.Route.failure } + embed: { _ in SendFlowReducer.State.Destination.failure } ) } } @@ -291,7 +291,7 @@ extension SendFlowReducer.State { .init( addMemoState: true, memoState: .placeholder, - route: nil, + destination: nil, transactionAddressInputState: .placeholder, transactionAmountInputState: .amount ) @@ -301,7 +301,7 @@ extension SendFlowReducer.State { .init( addMemoState: true, memoState: .placeholder, - route: nil, + destination: nil, transactionAddressInputState: .placeholder, transactionAmountInputState: .placeholder ) diff --git a/secant/Features/SendFlow/SendFlowView.swift b/secant/Features/SendFlow/SendFlowView.swift index 18b52dd..ee8907e 100644 --- a/secant/Features/SendFlow/SendFlowView.swift +++ b/secant/Features/SendFlow/SendFlowView.swift @@ -36,7 +36,7 @@ struct SendFLowView_Previews: PreviewProvider { initialState: .init( addMemoState: true, memoState: .placeholder, - route: nil, + destination: nil, transactionAddressInputState: .placeholder, transactionAmountInputState: .placeholder ), diff --git a/secant/Features/SendFlow/Views/CreateTransactionView.swift b/secant/Features/SendFlow/Views/CreateTransactionView.swift index c03944c..493f0b3 100644 --- a/secant/Features/SendFlow/Views/CreateTransactionView.swift +++ b/secant/Features/SendFlow/Views/CreateTransactionView.swift @@ -71,7 +71,7 @@ struct CreateTransaction: View { .padding() Button( - action: { viewStore.send(.updateRoute(.confirmation)) }, + action: { viewStore.send(.updateDestination(.confirmation)) }, label: { Text("Send") } ) .activeButtonStyle diff --git a/secant/Features/SendFlow/Views/TransactionFailedView.swift b/secant/Features/SendFlow/Views/TransactionFailedView.swift index 7fb77e8..dcb55ff 100644 --- a/secant/Features/SendFlow/Views/TransactionFailedView.swift +++ b/secant/Features/SendFlow/Views/TransactionFailedView.swift @@ -10,7 +10,7 @@ struct TransactionFailed: View { Button( action: { - viewStore.send(.updateRoute(.done)) + viewStore.send(.updateDestination(.done)) }, label: { Text("Close") } ) diff --git a/secant/Features/SendFlow/Views/TransactionSentView.swift b/secant/Features/SendFlow/Views/TransactionSentView.swift index 165247d..3dd5825 100644 --- a/secant/Features/SendFlow/Views/TransactionSentView.swift +++ b/secant/Features/SendFlow/Views/TransactionSentView.swift @@ -10,7 +10,7 @@ struct TransactionSent: View { Button( action: { - viewStore.send(.updateRoute(.done)) + viewStore.send(.updateDestination(.done)) }, label: { Text("Close") } ) diff --git a/secant/Features/Settings/SettingsStore.swift b/secant/Features/Settings/SettingsStore.swift index 6b6da69..cd38241 100644 --- a/secant/Features/Settings/SettingsStore.swift +++ b/secant/Features/Settings/SettingsStore.swift @@ -6,13 +6,13 @@ typealias SettingsViewStore = ViewStore? - var route: Route? + var destination: Destination? } enum Action: Equatable { @@ -23,7 +23,7 @@ struct SettingsReducer: ReducerProtocol { case phraseDisplay(RecoveryPhraseDisplayReducer.Action) case quickRescan case rescanBlockchain - case updateRoute(SettingsReducer.State.Route?) + case updateDestination(SettingsReducer.State.Destination?) } @Dependency(\.localAuthentication) var localAuthentication @@ -47,7 +47,7 @@ struct SettingsReducer: ReducerProtocol { let phraseWords = try mnemonic.asWords(storedWallet.seedPhrase) let recoveryPhrase = RecoveryPhrase(words: phraseWords) state.phraseDisplayState.phrase = recoveryPhrase - return Effect(value: .updateRoute(.backupPhrase)) + return Effect(value: .updateDestination(.backupPhrase)) } catch { // TODO [#201]: - merge with issue 201 (https://github.com/zcash/secant-ios-wallet/issues/201) and its Error States return .none @@ -70,11 +70,11 @@ struct SettingsReducer: ReducerProtocol { return .none case .phraseDisplay: - state.route = nil + state.destination = nil return .none - case .updateRoute(let route): - state.route = route + case .updateDestination(let destination): + state.destination = destination return .none } } @@ -88,15 +88,15 @@ struct SettingsReducer: ReducerProtocol { // MARK: - ViewStore extension SettingsViewStore { - var routeBinding: Binding { + var destinationBinding: Binding { self.binding( - get: \.route, - send: SettingsReducer.Action.updateRoute + get: \.destination, + send: SettingsReducer.Action.updateDestination ) } var bindingForBackupPhrase: Binding { - self.routeBinding.map( + self.destinationBinding.map( extract: { $0 == .backupPhrase }, embed: { $0 ? .backupPhrase : nil } ) diff --git a/secant/Features/WalletEventsFlow/WalletEventsFlowStore.swift b/secant/Features/WalletEventsFlow/WalletEventsFlowStore.swift index 5caff69..7111218 100644 --- a/secant/Features/WalletEventsFlow/WalletEventsFlowStore.swift +++ b/secant/Features/WalletEventsFlow/WalletEventsFlowStore.swift @@ -9,13 +9,13 @@ struct WalletEventsFlowReducer: ReducerProtocol { private enum CancelId {} struct State: Equatable { - enum Route: Equatable { + enum Destination: Equatable { case latest case all case showWalletEvent(WalletEvent) } - var route: Route? + var destination: Destination? @BindableState var alert: AlertState? var latestMinedHeight: BlockHeight? @@ -31,7 +31,7 @@ struct WalletEventsFlowReducer: ReducerProtocol { case onAppear case onDisappear case openBlockExplorer(URL?) - case updateRoute(WalletEventsFlowReducer.State.Route?) + case updateDestination(WalletEventsFlowReducer.State.Destination?) case replyTo(String) case synchronizerStateChanged(SDKSynchronizerState) case updateWalletEvents([WalletEvent]) @@ -76,14 +76,14 @@ struct WalletEventsFlowReducer: ReducerProtocol { state.walletEvents = IdentifiedArrayOf(uniqueElements: sortedWalletEvents) return .none - case .updateRoute(.showWalletEvent(let walletEvent)): + case .updateDestination(.showWalletEvent(let walletEvent)): state.selectedWalletEvent = walletEvent - state.route = .showWalletEvent(walletEvent) + state.destination = .showWalletEvent(walletEvent) return .none - case .updateRoute(let route): - state.route = route - if route == nil { + case .updateDestination(let destination): + state.destination = destination + if destination == nil { state.selectedWalletEvent = nil } return .none @@ -130,7 +130,7 @@ struct WalletEventsFlowReducer: ReducerProtocol { // MARK: - ViewStore extension WalletEventsFlowViewStore { - private typealias Route = WalletEventsFlowReducer.State.Route + private typealias Destination = WalletEventsFlowReducer.State.Destination func bindingForSelectedWalletEvent(_ walletEvent: WalletEvent?) -> Binding { self.binding( @@ -139,14 +139,14 @@ extension WalletEventsFlowViewStore { return false } - return $0.route.map(/WalletEventsFlowReducer.State.Route.showWalletEvent) == walletEvent + return $0.destination.map(/WalletEventsFlowReducer.State.Destination.showWalletEvent) == walletEvent }, send: { isActive in guard let walletEvent = walletEvent else { - return WalletEventsFlowReducer.Action.updateRoute(nil) + return WalletEventsFlowReducer.Action.updateDestination(nil) } - return WalletEventsFlowReducer.Action.updateRoute( isActive ? WalletEventsFlowReducer.State.Route.showWalletEvent(walletEvent) : nil) + return WalletEventsFlowReducer.Action.updateDestination( isActive ? WalletEventsFlowReducer.State.Destination.showWalletEvent(walletEvent) : nil) } ) } diff --git a/secant/Features/WalletEventsFlow/WalletEventsFlowView.swift b/secant/Features/WalletEventsFlow/WalletEventsFlowView.swift index 7630236..1aad0ec 100644 --- a/secant/Features/WalletEventsFlow/WalletEventsFlowView.swift +++ b/secant/Features/WalletEventsFlow/WalletEventsFlowView.swift @@ -42,7 +42,7 @@ extension WalletEventsFlowView { ForEach(viewStore.walletEvents) { walletEvent in walletEvent.rowView(viewStore) .onTapGesture { - viewStore.send(.updateRoute(.showWalletEvent(walletEvent))) + viewStore.send(.updateDestination(.showWalletEvent(walletEvent))) } .listRowInsets(EdgeInsets()) .foregroundColor(Asset.Colors.Text.body.color) @@ -54,7 +54,7 @@ extension WalletEventsFlowView { HStack(spacing: 0) { VStack { Button { - viewStore.send(.updateRoute(.latest)) + viewStore.send(.updateDestination(.latest)) } label: { Text("Latest") .font(.custom(FontFamily.Rubik.regular.name, size: 18)) @@ -70,7 +70,7 @@ extension WalletEventsFlowView { VStack { Button { - viewStore.send(.updateRoute(.all)) + viewStore.send(.updateDestination(.all)) } label: { Text("All") .font(.custom(FontFamily.Rubik.regular.name, size: 18)) diff --git a/secantTests/AppTests/AppInitializationTests.swift b/secantTests/AppTests/AppInitializationTests.swift index 004022f..37db7d6 100644 --- a/secantTests/AppTests/AppInitializationTests.swift +++ b/secantTests/AppTests/AppInitializationTests.swift @@ -34,7 +34,7 @@ class AppInitializationTests: XCTestCase { validationWords: [ .init(groupIndex: 2, word: "dizzy") ], - route: nil + destination: nil ) let recoveryPhraseRandomizer = RecoveryPhraseRandomizerClient( @@ -122,9 +122,9 @@ class AppInitializationTests: XCTestCase { await testScheduler.advance(by: 3.00) // ad 5. - await store.receive(.updateRoute(.phraseDisplay)) { state in - state.prevRoute = .welcome - state.internalRoute = .phraseDisplay + await store.receive(.updateDestination(.phraseDisplay)) { state in + state.prevDestination = .welcome + state.internalDestination = .phraseDisplay } } @@ -191,9 +191,9 @@ class AppInitializationTests: XCTestCase { store.receive(.respondToWalletInitializationState(.uninitialized)) // ad 3. - store.receive(.updateRoute(.onboarding)) { state in - state.prevRoute = .welcome - state.internalRoute = .onboarding + store.receive(.updateDestination(.onboarding)) { state in + state.prevDestination = .welcome + state.internalDestination = .onboarding } } } diff --git a/secantTests/AppTests/AppTests.swift b/secantTests/AppTests/AppTests.swift index 1d56007..0fe1afc 100644 --- a/secantTests/AppTests/AppTests.swift +++ b/secantTests/AppTests/AppTests.swift @@ -70,8 +70,8 @@ class AppTests: XCTestCase { Self.testScheduler.advance(by: 3) - store.receive(.updateRoute(.onboarding)) { - $0.route = .onboarding + store.receive(.updateDestination(.onboarding)) { + $0.destination = .onboarding $0.appInitializationState = .uninitialized } } diff --git a/secantTests/DeeplinkTests/DeeplinkTests.swift b/secantTests/DeeplinkTests/DeeplinkTests.swift index d9d1515..8efd3d6 100644 --- a/secantTests/DeeplinkTests/DeeplinkTests.swift +++ b/secantTests/DeeplinkTests/DeeplinkTests.swift @@ -12,9 +12,9 @@ import ZcashLightClientKit @MainActor class DeeplinkTests: XCTestCase { - func testActionDeeplinkHome_SameRouteLevel() throws { + func testActionDeeplinkHome_SameDestinationLevel() throws { var appState = AppReducer.State.placeholder - appState.route = .welcome + appState.destination = .welcome let store = TestStore( initialState: appState, @@ -22,14 +22,14 @@ class DeeplinkTests: XCTestCase { ) store.send(.deeplinkHome) { state in - state.route = .home + state.destination = .home } } func testActionDeeplinkHome_GeetingBack() throws { var appState = AppReducer.State.placeholder - appState.route = .home - appState.homeState.route = .send + appState.destination = .home + appState.homeState.destination = .send let store = TestStore( initialState: appState, @@ -37,14 +37,14 @@ class DeeplinkTests: XCTestCase { ) store.send(.deeplinkHome) { state in - state.route = .home - state.homeState.route = nil + state.destination = .home + state.homeState.destination = nil } } func testActionDeeplinkSend() throws { var appState = AppReducer.State.placeholder - appState.route = .welcome + appState.destination = .welcome let store = TestStore( initialState: appState, @@ -56,8 +56,8 @@ class DeeplinkTests: XCTestCase { let memo = "testing some memo" store.send(.deeplinkSend(amount, address, memo)) { state in - state.route = .home - state.homeState.route = .send + state.destination = .home + state.homeState.destination = .send state.homeState.sendState.amount = amount state.homeState.sendState.address = address state.homeState.sendState.memoState.text = memo @@ -71,12 +71,12 @@ class DeeplinkTests: XCTestCase { let result = try Deeplink().resolveDeeplinkURL(url, isValidZcashAddress: { _ in false }) - XCTAssertEqual(result, Deeplink.Route.home) + XCTAssertEqual(result, Deeplink.Destination.home) } func testDeeplinkRequest_Received_Home() async throws { var appState = AppReducer.State.placeholder - appState.route = .welcome + appState.destination = .welcome appState.appInitializationState = .initialized let store = TestStore( @@ -84,7 +84,7 @@ class DeeplinkTests: XCTestCase { reducer: AppReducer() ) { dependencies in dependencies.deeplink = DeeplinkClient( - resolveDeeplinkURL: { _, _ in Deeplink.Route.home } + resolveDeeplinkURL: { _, _ in Deeplink.Destination.home } ) let synchronizer = NoopSDKSynchronizer() synchronizer.updateStateChanged(.synced) @@ -98,7 +98,7 @@ class DeeplinkTests: XCTestCase { _ = await store.send(.deeplink(url)) await store.receive(.deeplinkHome) { state in - state.route = .home + state.destination = .home } await store.finish() @@ -111,7 +111,7 @@ class DeeplinkTests: XCTestCase { let result = try Deeplink().resolveDeeplinkURL(url, isValidZcashAddress: { _ in false }) - XCTAssertEqual(result, Deeplink.Route.send(amount: 123_000_000, address: "address", memo: "some text")) + XCTAssertEqual(result, Deeplink.Destination.send(amount: 123_000_000, address: "address", memo: "some text")) } func testDeeplinkRequest_Received_Send() async throws { @@ -119,7 +119,7 @@ class DeeplinkTests: XCTestCase { synchronizer.updateStateChanged(.synced) var appState = AppReducer.State.placeholder - appState.route = .welcome + appState.destination = .welcome appState.appInitializationState = .initialized let store = TestStore( @@ -127,7 +127,7 @@ class DeeplinkTests: XCTestCase { reducer: AppReducer() ) { dependencies in dependencies.deeplink = DeeplinkClient( - resolveDeeplinkURL: { _, _ in Deeplink.Route.send(amount: 123_000_000, address: "address", memo: "some text") } + resolveDeeplinkURL: { _, _ in Deeplink.Destination.send(amount: 123_000_000, address: "address", memo: "some text") } ) dependencies.sdkSynchronizer = synchronizer } @@ -143,8 +143,8 @@ class DeeplinkTests: XCTestCase { let memo = "some text" await store.receive(.deeplinkSend(amount, address, memo)) { state in - state.route = .home - state.homeState.route = .send + state.destination = .home + state.homeState.destination = .send state.homeState.sendState.amount = amount state.homeState.sendState.address = address state.homeState.sendState.memoState.text = memo diff --git a/secantTests/HomeTests/HomeTests.swift b/secantTests/HomeTests/HomeTests.swift index 1a0003c..3f2faab 100644 --- a/secantTests/HomeTests/HomeTests.swift +++ b/secantTests/HomeTests/HomeTests.swift @@ -85,8 +85,8 @@ class HomeTests: XCTestCase { reducer: HomeReducer() ) - store.send(.walletEvents(.updateRoute(.all))) { state in - state.walletEventsState.route = .all + store.send(.walletEvents(.updateDestination(.all))) { state in + state.walletEventsState.destination = .all } store.receive(.updateDrawer(.full)) { state in @@ -113,8 +113,8 @@ class HomeTests: XCTestCase { reducer: HomeReducer() ) - store.send(.walletEvents(.updateRoute(.latest))) { state in - state.walletEventsState.route = .latest + store.send(.walletEvents(.updateDestination(.latest))) { state in + state.walletEventsState.destination = .latest } store.receive(.updateDrawer(.partial)) { state in @@ -138,7 +138,7 @@ class HomeTests: XCTestCase { } // expected side effects as a result of .onAppear registration - store.receive(.updateRoute(nil)) + store.receive(.updateDestination(nil)) store.receive(.synchronizerStateChanged(.unknown)) store.receive(.updateSynchronizerStatus) @@ -160,8 +160,8 @@ class HomeTests: XCTestCase { } // expected side effects as a result of .onAppear registration - store.receive(.updateRoute(.notEnoughFreeDiskSpace)) { state in - state.route = .notEnoughFreeDiskSpace + store.receive(.updateDestination(.notEnoughFreeDiskSpace)) { state in + state.destination = .notEnoughFreeDiskSpace } // long-living (cancelable) effects need to be properly canceled. @@ -171,7 +171,7 @@ class HomeTests: XCTestCase { @MainActor func testQuickRescan_ResetToHomeScreen() async throws { let homeState = HomeReducer.State( - route: .profile, + destination: .profile, balanceBreakdownState: .placeholder, drawerOverlay: .full, profileState: .placeholder, @@ -189,7 +189,7 @@ class HomeTests: XCTestCase { ) _ = await store.send(.profile(.settings(.quickRescan))) { state in - state.route = nil + state.destination = nil } await store.receive(.rewindDone(true, .quickRescan)) @@ -197,7 +197,7 @@ class HomeTests: XCTestCase { @MainActor func testFullRescan_ResetToHomeScreen() async throws { let homeState = HomeReducer.State( - route: .profile, + destination: .profile, balanceBreakdownState: .placeholder, drawerOverlay: .full, profileState: .placeholder, @@ -215,7 +215,7 @@ class HomeTests: XCTestCase { ) _ = await store.send(.profile(.settings(.fullRescan))) { state in - state.route = nil + state.destination = nil } await store.receive(.rewindDone(true, .fullRescan)) diff --git a/secantTests/RecoveryPhraseValidationTests/RecoveryPhraseValidationTests.swift b/secantTests/RecoveryPhraseValidationTests/RecoveryPhraseValidationTests.swift index 771b362..948f17c 100644 --- a/secantTests/RecoveryPhraseValidationTests/RecoveryPhraseValidationTests.swift +++ b/secantTests/RecoveryPhraseValidationTests/RecoveryPhraseValidationTests.swift @@ -321,7 +321,7 @@ class RecoveryPhraseValidationTests: XCTestCase { store.receive(.succeed) { XCTAssertTrue($0.isComplete) - $0.route = .success + $0.destination = .success } } @@ -394,7 +394,7 @@ class RecoveryPhraseValidationTests: XCTestCase { store.receive(.failureFeedback) store.receive(.fail) { - $0.route = .failure + $0.destination = .failure XCTAssertFalse($0.isValid) } } @@ -612,7 +612,7 @@ class RecoveryPhraseValidationTests: XCTestCase { missingIndices: missingIndices, missingWordChips: phrase.words(fromMissingIndices: missingIndices), validationWords: completion, - route: nil + destination: nil ) XCTAssertTrue(result.isValid) @@ -651,7 +651,7 @@ class RecoveryPhraseValidationTests: XCTestCase { missingIndices: missingIndices, missingWordChips: phrase.words(fromMissingIndices: missingIndices), validationWords: completion, - route: nil + destination: nil ) XCTAssertFalse(result.isValid) diff --git a/secantTests/SendTests/SendTests.swift b/secantTests/SendTests/SendTests.swift index 3d6eddc..7d8f329 100644 --- a/secantTests/SendTests/SendTests.swift +++ b/secantTests/SendTests/SendTests.swift @@ -77,8 +77,8 @@ class SendTests: XCTestCase { ) // first it's expected that progress screen is showed - await store.receive(.updateRoute(.inProgress)) { state in - state.route = .inProgress + await store.receive(.updateDestination(.inProgress)) { state in + state.destination = .inProgress } // check the success transaction to be received back @@ -89,8 +89,8 @@ class SendTests: XCTestCase { } // all went well, the success screen is triggered - await store.receive(.updateRoute(.success)) { state in - state.route = .success + await store.receive(.updateDestination(.success)) { state in + state.destination = .success } } @@ -145,8 +145,8 @@ class SendTests: XCTestCase { ) // first it's expected that progress screen is showed - await store.receive(.updateRoute(.inProgress)) { state in - state.route = .inProgress + await store.receive(.updateDestination(.inProgress)) { state in + state.destination = .inProgress } // check the success transaction to be received back @@ -157,8 +157,8 @@ class SendTests: XCTestCase { } // all went well, the success screen is triggered - await store.receive(.updateRoute(.success)) { state in - state.route = .success + await store.receive(.updateDestination(.success)) { state in + state.destination = .success } } @@ -198,8 +198,8 @@ class SendTests: XCTestCase { await testScheduler.advance(by: 0.01) // first it's expected that progress screen is showed - await store.receive(.updateRoute(.inProgress)) { state in - state.route = .inProgress + await store.receive(.updateDestination(.inProgress)) { state in + state.destination = .inProgress } // check the failure transaction to be received back @@ -210,8 +210,8 @@ class SendTests: XCTestCase { } // the failure screen is triggered as expected - await store.receive(.updateRoute(.failure)) { state in - state.route = .failure + await store.receive(.updateDestination(.failure)) { state in + state.destination = .failure } } diff --git a/secantTests/SettingsTests/SettingsTests.swift b/secantTests/SettingsTests/SettingsTests.swift index 90fecf3..444b54e 100644 --- a/secantTests/SettingsTests/SettingsTests.swift +++ b/secantTests/SettingsTests/SettingsTests.swift @@ -59,8 +59,8 @@ class SettingsTests: XCTestCase { await store.receive(.backupWallet) { state in state.phraseDisplayState.phrase = RecoveryPhrase(words: mnemonic.components(separatedBy: " ")) } - await store.receive(.updateRoute(.backupPhrase)) { state in - state.route = .backupPhrase + await store.receive(.updateDestination(.backupPhrase)) { state in + state.destination = .backupPhrase } } @@ -109,7 +109,7 @@ class SettingsTests: XCTestCase { .cancel(TextState("Cancel")) ] ), - route: nil + destination: nil ), reducer: SettingsReducer() ) @@ -132,7 +132,7 @@ class SettingsTests: XCTestCase { .cancel(TextState("Cancel")) ] ), - route: nil + destination: nil ), reducer: SettingsReducer() ) @@ -155,7 +155,7 @@ class SettingsTests: XCTestCase { .cancel(TextState("Cancel")) ] ), - route: nil + destination: nil ), reducer: SettingsReducer() ) diff --git a/secantTests/SnapshotTests/WalletEventsSnapshotTests/WalletEventsSnapshotTests.swift b/secantTests/SnapshotTests/WalletEventsSnapshotTests/WalletEventsSnapshotTests.swift index 96b3668..d3b6cca 100644 --- a/secantTests/SnapshotTests/WalletEventsSnapshotTests/WalletEventsSnapshotTests.swift +++ b/secantTests/SnapshotTests/WalletEventsSnapshotTests/WalletEventsSnapshotTests.swift @@ -97,7 +97,7 @@ class WalletEventsSnapshotTests: XCTestCase { reducer: HomeReducer() ) - ViewStore(store).send(.walletEvents(.updateRoute(.showWalletEvent(walletEvent)))) + ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent)))) let walletEventsStore = WalletEventsFlowStore( initialState: .placeHolder, reducer: WalletEventsFlowReducer() @@ -144,7 +144,7 @@ class WalletEventsSnapshotTests: XCTestCase { reducer: HomeReducer() ) - ViewStore(store).send(.walletEvents(.updateRoute(.showWalletEvent(walletEvent)))) + ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent)))) let walletEventsStore = WalletEventsFlowStore( initialState: .placeHolder, reducer: WalletEventsFlowReducer() @@ -196,7 +196,7 @@ class WalletEventsSnapshotTests: XCTestCase { walletEvents: .placeholder ) - ViewStore(store).send(.walletEvents(.updateRoute(.showWalletEvent(walletEvent)))) + ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent)))) let walletEventsStore = WalletEventsFlowStore( initialState: walletEventsState, reducer: WalletEventsFlowReducer() @@ -244,7 +244,7 @@ class WalletEventsSnapshotTests: XCTestCase { reducer: HomeReducer() ) - ViewStore(store).send(.walletEvents(.updateRoute(.showWalletEvent(walletEvent)))) + ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent)))) let walletEventsStore = WalletEventsFlowStore( initialState: .placeHolder, reducer: WalletEventsFlowReducer() diff --git a/secantTests/WalletEventsTests/WalletEventsTests.swift b/secantTests/WalletEventsTests/WalletEventsTests.swift index 1e29999..6b77531 100644 --- a/secantTests/WalletEventsTests/WalletEventsTests.swift +++ b/secantTests/WalletEventsTests/WalletEventsTests.swift @@ -16,7 +16,7 @@ class WalletEventsTests: XCTestCase { func testSynchronizerSubscription() throws { let store = TestStore( initialState: WalletEventsFlowReducer.State( - route: .latest, + destination: .latest, isScrollable: true, walletEvents: [] ), @@ -71,7 +71,7 @@ class WalletEventsTests: XCTestCase { let store = TestStore( initialState: WalletEventsFlowReducer.State( - route: .latest, + destination: .latest, isScrollable: true, walletEvents: identifiedWalletEvents ), @@ -103,7 +103,7 @@ class WalletEventsTests: XCTestCase { let store = TestStore( initialState: WalletEventsFlowReducer.State( - route: .latest, + destination: .latest, isScrollable: true, walletEvents: [] ),