[#1058] Cleanup dependency injection in reducers

- All work here is just cleanup of obsolete dependency injection. #981 introduced a brand new approach of DI for token name and SDK constants. That allowed me to deliver expected values directly in the TCA fashion so all reducers no longer needed those values to be passed via initializers.
This commit is contained in:
Lukas Korba 2024-02-14 14:41:21 +01:00
parent 48536e5fa0
commit 9b683651cf
52 changed files with 202 additions and 259 deletions

View File

@ -112,6 +112,7 @@ let package = Package(
"UIComponents", "UIComponents",
"Utils", "Utils",
"WalletStorage", "WalletStorage",
"ZcashSDKEnvironment",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
.product(name: "ZcashLightClientKit", package: "ZcashLightClientKit") .product(name: "ZcashLightClientKit", package: "ZcashLightClientKit")
], ],
@ -322,6 +323,7 @@ let package = Package(
"RestoreWalletStorage", "RestoreWalletStorage",
"UIComponents", "UIComponents",
"Utils", "Utils",
"ZcashSDKEnvironment",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture") .product(name: "ComposableArchitecture", package: "swift-composable-architecture")
], ],
path: "Sources/Features/PrivateDataConsent" path: "Sources/Features/PrivateDataConsent"
@ -410,6 +412,7 @@ let package = Package(
"URIParser", "URIParser",
"UIComponents", "UIComponents",
"Utils", "Utils",
"ZcashSDKEnvironment",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
.product(name: "ZcashLightClientKit", package: "ZcashLightClientKit") .product(name: "ZcashLightClientKit", package: "ZcashLightClientKit")
], ],

View File

@ -16,8 +16,6 @@ public typealias AddressDetailsStore = Store<AddressDetailsReducer.State, Addres
public typealias AddressDetailsViewStore = ViewStore<AddressDetailsReducer.State, AddressDetailsReducer.Action> public typealias AddressDetailsViewStore = ViewStore<AddressDetailsReducer.State, AddressDetailsReducer.Action>
public struct AddressDetailsReducer: Reducer { public struct AddressDetailsReducer: Reducer {
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public var addressToShare: RedactableString? public var addressToShare: RedactableString?
public var uAddress: UnifiedAddress? public var uAddress: UnifiedAddress?
@ -61,9 +59,7 @@ public struct AddressDetailsReducer: Reducer {
@Dependency(\.pasteboard) var pasteboard @Dependency(\.pasteboard) var pasteboard
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public func reduce(into state: inout State, action: Action) -> ComposableArchitecture.Effect<Action> { public func reduce(into state: inout State, action: Action) -> ComposableArchitecture.Effect<Action> {
switch action { switch action {
@ -98,6 +94,6 @@ extension AddressDetailsStore {
public static let placeholder = AddressDetailsStore( public static let placeholder = AddressDetailsStore(
initialState: .initial initialState: .initial
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
} }

View File

@ -18,13 +18,13 @@ import SDKSynchronizer
import Models import Models
import SyncProgress import SyncProgress
import RestoreWalletStorage import RestoreWalletStorage
import ZcashSDKEnvironment
public typealias BalanceBreakdownStore = Store<BalanceBreakdownReducer.State, BalanceBreakdownReducer.Action> public typealias BalanceBreakdownStore = Store<BalanceBreakdownReducer.State, BalanceBreakdownReducer.Action>
public typealias BalanceBreakdownViewStore = ViewStore<BalanceBreakdownReducer.State, BalanceBreakdownReducer.Action> public typealias BalanceBreakdownViewStore = ViewStore<BalanceBreakdownReducer.State, BalanceBreakdownReducer.Action>
public struct BalanceBreakdownReducer: Reducer { public struct BalanceBreakdownReducer: Reducer {
private enum CancelId { case timer } private enum CancelId { case timer }
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
@PresentationState public var alert: AlertState<Action>? @PresentationState public var alert: AlertState<Action>?
@ -93,10 +93,9 @@ public struct BalanceBreakdownReducer: Reducer {
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
@Dependency(\.sdkSynchronizer) var sdkSynchronizer @Dependency(\.sdkSynchronizer) var sdkSynchronizer
@Dependency(\.walletStorage) var walletStorage @Dependency(\.walletStorage) var walletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Scope(state: \.syncProgressState, action: /Action.syncProgress) { Scope(state: \.syncProgressState, action: /Action.syncProgress) {
@ -143,7 +142,7 @@ public struct BalanceBreakdownReducer: Reducer {
do { do {
let storedWallet = try walletStorage.exportWallet() let storedWallet = try walletStorage.exportWallet()
let seedBytes = try mnemonic.toSeed(storedWallet.seedPhrase.value()) let seedBytes = try mnemonic.toSeed(storedWallet.seedPhrase.value())
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0, networkType) let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0, zcashSDKEnvironment.network.networkType)
let transaction = try await sdkSynchronizer.shieldFunds(spendingKey, Memo(string: ""), state.autoShieldingThreshold) let transaction = try await sdkSynchronizer.shieldFunds(spendingKey, Memo(string: ""), state.autoShieldingThreshold)
@ -224,6 +223,6 @@ extension BalanceBreakdownStore {
public static let placeholder = BalanceBreakdownStore( public static let placeholder = BalanceBreakdownStore(
initialState: .placeholder initialState: .placeholder
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
} }

View File

@ -278,7 +278,7 @@ extension BalanceBreakdownView {
transparentBalance: Zatoshi(25_234_778) transparentBalance: Zatoshi(25_234_778)
) )
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
}, },
tokenName: "ZEC" tokenName: "ZEC"
) )

View File

@ -20,7 +20,6 @@ public typealias HomeViewStore = ViewStore<HomeReducer.State, HomeReducer.Action
public struct HomeReducer: Reducer { public struct HomeReducer: Reducer {
private enum CancelStateId { case timer } private enum CancelStateId { case timer }
private enum CancelEventId { case timer } private enum CancelEventId { case timer }
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable { public enum Destination: Equatable {
@ -109,9 +108,7 @@ public struct HomeReducer: Reducer {
@Dependency(\.sdkSynchronizer) var sdkSynchronizer @Dependency(\.sdkSynchronizer) var sdkSynchronizer
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Scope(state: \.transactionListState, action: /Action.transactionList) { Scope(state: \.transactionListState, action: /Action.transactionList) {
@ -303,7 +300,7 @@ extension HomeStore {
HomeStore( HomeStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
} }
@ -320,7 +317,7 @@ extension HomeStore {
walletConfig: .initial walletConfig: .initial
) )
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
} }
} }

View File

@ -121,7 +121,7 @@ struct HomeView_Previews: PreviewProvider {
walletConfig: .initial walletConfig: .initial
) )
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
}, },
tokenName: "ZEC" tokenName: "ZEC"
) )

View File

@ -18,8 +18,6 @@ public typealias ImportWalletStore = Store<ImportWalletReducer.State, ImportWall
public typealias ImportWalletViewStore = ViewStore<ImportWalletReducer.State, ImportWalletReducer.Action> public typealias ImportWalletViewStore = ViewStore<ImportWalletReducer.State, ImportWalletReducer.Action>
public struct ImportWalletReducer: Reducer { public struct ImportWalletReducer: Reducer {
let saplingActivationHeight: BlockHeight
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable { public enum Destination: Equatable {
case birthday case birthday
@ -87,9 +85,7 @@ public struct ImportWalletReducer: Reducer {
@Dependency(\.walletStorage) var walletStorage @Dependency(\.walletStorage) var walletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(saplingActivationHeight: BlockHeight) { public init() { }
self.saplingActivationHeight = saplingActivationHeight
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Reduce { state, action in Reduce { state, action in
@ -113,7 +109,7 @@ public struct ImportWalletReducer: Reducer {
return .none return .none
case .birthdayInputChanged(let redactedBirthday): case .birthdayInputChanged(let redactedBirthday):
let saplingActivation = saplingActivationHeight let saplingActivation = zcashSDKEnvironment.network.constants.saplingActivationHeight
state.birthdayHeight = redactedBirthday state.birthdayHeight = redactedBirthday
@ -141,7 +137,7 @@ public struct ImportWalletReducer: Reducer {
// store it to the keychain, if the user did not input a height, // store it to the keychain, if the user did not input a height,
// fall back to sapling activation // fall back to sapling activation
let birthday = state.birthdayHeightValue ?? saplingActivationHeight.redacted let birthday = state.birthdayHeightValue ?? zcashSDKEnvironment.network.constants.saplingActivationHeight.redacted
try walletStorage.importWallet(state.importedSeedPhrase.data, birthday.data, .english, false) try walletStorage.importWallet(state.importedSeedPhrase.data, birthday.data, .english, false)
@ -232,6 +228,6 @@ extension ImportWalletStore {
public static let demo = Store( public static let demo = Store(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
} }

View File

@ -18,9 +18,6 @@ public typealias OnboardingFlowStore = Store<OnboardingFlowReducer.State, Onboar
public typealias OnboardingFlowViewStore = ViewStore<OnboardingFlowReducer.State, OnboardingFlowReducer.Action> public typealias OnboardingFlowViewStore = ViewStore<OnboardingFlowReducer.State, OnboardingFlowReducer.Action>
public struct OnboardingFlowReducer: Reducer { public struct OnboardingFlowReducer: Reducer {
let saplingActivationHeight: BlockHeight
let zcashNetwork: ZcashNetwork
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable, CaseIterable { public enum Destination: Equatable, CaseIterable {
case createNewWallet case createNewWallet
@ -54,18 +51,15 @@ public struct OnboardingFlowReducer: Reducer {
case updateDestination(OnboardingFlowReducer.State.Destination?) case updateDestination(OnboardingFlowReducer.State.Destination?)
} }
public init(saplingActivationHeight: BlockHeight, zcashNetwork: ZcashNetwork) { public init() { }
self.saplingActivationHeight = saplingActivationHeight
self.zcashNetwork = zcashNetwork
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Scope(state: \.importWalletState, action: /Action.importWallet) { Scope(state: \.importWalletState, action: /Action.importWallet) {
ImportWalletReducer(saplingActivationHeight: saplingActivationHeight) ImportWalletReducer()
} }
Scope(state: \.securityWarningState, action: /Action.securityWarning) { Scope(state: \.securityWarningState, action: /Action.securityWarning) {
SecurityWarningReducer(zcashNetwork: zcashNetwork) SecurityWarningReducer()
} }
Reduce { state, action in Reduce { state, action in

View File

@ -85,10 +85,7 @@ public struct PlainOnboardingView: View {
securityWarningState: .initial securityWarningState: .initial
) )
) { ) {
OnboardingFlowReducer( OnboardingFlowReducer()
saplingActivationHeight: 0,
zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)
)
} }
) )
} }

View File

@ -16,13 +16,12 @@ import ExportLogs
import DatabaseFiles import DatabaseFiles
import ExportLogs import ExportLogs
import RestoreWalletStorage import RestoreWalletStorage
import ZcashSDKEnvironment
public typealias PrivateDataConsentStore = Store<PrivateDataConsentReducer.State, PrivateDataConsentReducer.Action> public typealias PrivateDataConsentStore = Store<PrivateDataConsentReducer.State, PrivateDataConsentReducer.Action>
public typealias PrivateDataConsentViewStore = ViewStore<PrivateDataConsentReducer.State, PrivateDataConsentReducer.Action> public typealias PrivateDataConsentViewStore = ViewStore<PrivateDataConsentReducer.State, PrivateDataConsentReducer.Action>
public struct PrivateDataConsentReducer: Reducer { public struct PrivateDataConsentReducer: Reducer {
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public var exportBinding: Bool public var exportBinding: Bool
public var exportOnlyLogs = true public var exportOnlyLogs = true
@ -75,12 +74,11 @@ public struct PrivateDataConsentReducer: Reducer {
case shareFinished case shareFinished
} }
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
@Dependency(\.databaseFiles) var databaseFiles @Dependency(\.databaseFiles) var databaseFiles
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
BindingReducer() BindingReducer()
@ -92,7 +90,7 @@ public struct PrivateDataConsentReducer: Reducer {
Reduce { state, action in Reduce { state, action in
switch action { switch action {
case .onAppear: case .onAppear:
state.dataDbURL = [databaseFiles.dataDbURLFor(ZcashNetworkBuilder.network(for: networkType))] state.dataDbURL = [databaseFiles.dataDbURLFor(zcashSDKEnvironment.network)]
return .none return .none
case .exportLogs(.finished): case .exportLogs(.finished):
@ -145,7 +143,7 @@ extension PrivateDataConsentStore {
public static var demo = PrivateDataConsentStore( public static var demo = PrivateDataConsentStore(
initialState: .initial initialState: .initial
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
} }

View File

@ -121,7 +121,8 @@ private extension RootReducer {
deeplink: DeeplinkClient, deeplink: DeeplinkClient,
derivationTool: DerivationToolClient derivationTool: DerivationToolClient
) async throws -> RootReducer.Action { ) async throws -> RootReducer.Action {
let deeplink = try deeplink.resolveDeeplinkURL(url, zcashNetwork.networkType, derivationTool) @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
let deeplink = try deeplink.resolveDeeplinkURL(url, zcashSDKEnvironment.network.networkType, derivationTool)
switch deeplink { switch deeplink {
case .home: case .home:

View File

@ -175,7 +175,7 @@ extension RootReducer {
let walletState = RootReducer.walletInitializationState( let walletState = RootReducer.walletInitializationState(
databaseFiles: databaseFiles, databaseFiles: databaseFiles,
walletStorage: walletStorage, walletStorage: walletStorage,
zcashNetwork: zcashNetwork zcashNetwork: zcashSDKEnvironment.network
) )
return Effect.send(.initialization(.respondToWalletInitializationState(walletState))) return Effect.send(.initialization(.respondToWalletInitializationState(walletState)))

View File

@ -28,8 +28,6 @@ public struct RootReducer: Reducer {
enum CancelStateId { case timer } enum CancelStateId { case timer }
enum SynchronizerCancelId { case timer } enum SynchronizerCancelId { case timer }
enum WalletConfigCancelId { case timer } enum WalletConfigCancelId { case timer }
let tokenName: String
let zcashNetwork: ZcashNetwork
public struct State: Equatable { public struct State: Equatable {
@PresentationState public var alert: AlertState<Action>? @PresentationState public var alert: AlertState<Action>?
@ -122,19 +120,16 @@ public struct RootReducer: Reducer {
@Dependency(\.userStoredPreferences) var userStoredPreferences @Dependency(\.userStoredPreferences) var userStoredPreferences
@Dependency(\.walletConfigProvider) var walletConfigProvider @Dependency(\.walletConfigProvider) var walletConfigProvider
@Dependency(\.walletStorage) var walletStorage @Dependency(\.walletStorage) var walletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
@Dependency(\.readTransactionsStorage) var readTransactionsStorage @Dependency(\.readTransactionsStorage) var readTransactionsStorage
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(tokenName: String, zcashNetwork: ZcashNetwork) { public init() { }
self.tokenName = tokenName
self.zcashNetwork = zcashNetwork
}
@ReducerBuilder<State, Action> @ReducerBuilder<State, Action>
var core: some Reducer<State, Action> { var core: some Reducer<State, Action> {
Scope(state: \.tabsState, action: /Action.tabs) { Scope(state: \.tabsState, action: /Action.tabs) {
TabsReducer(tokenName: tokenName, networkType: zcashNetwork.networkType) TabsReducer()
} }
Scope(state: \.exportLogsState, action: /Action.exportLogs) { Scope(state: \.exportLogsState, action: /Action.exportLogs) {
@ -142,10 +137,7 @@ public struct RootReducer: Reducer {
} }
Scope(state: \.onboardingState, action: /Action.onboarding) { Scope(state: \.onboardingState, action: /Action.onboarding) {
OnboardingFlowReducer( OnboardingFlowReducer()
saplingActivationHeight: zcashNetwork.constants.saplingActivationHeight,
zcashNetwork: zcashNetwork
)
} }
Scope(state: \.sandboxState, action: /Action.sandbox) { Scope(state: \.sandboxState, action: /Action.sandbox) {
@ -191,9 +183,7 @@ extension RootReducer {
var keysPresent = false var keysPresent = false
do { do {
keysPresent = try walletStorage.areKeysPresent() keysPresent = try walletStorage.areKeysPresent()
let databaseFilesPresent = databaseFiles.areDbFilesPresentFor( let databaseFilesPresent = databaseFiles.areDbFilesPresentFor(zcashNetwork)
zcashNetwork
)
switch (keysPresent, databaseFilesPresent) { switch (keysPresent, databaseFilesPresent) {
case (false, false): case (false, false):
@ -352,10 +342,8 @@ extension RootStore {
RootStore( RootStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer( RootReducer()
tokenName: "ZEC", .logging()
zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)
).logging()
} }
} }
} }

View File

@ -206,7 +206,7 @@ struct RootView_Previews: PreviewProvider {
store: RootStore( store: RootStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
}, },
tokenName: "ZEC", tokenName: "ZEC",
networkType: .testnet networkType: .testnet

View File

@ -35,7 +35,7 @@ public struct SandboxView: View {
store: .init( store: .init(
initialState: .initial initialState: .initial
) { ) {
SendFlowReducer(networkType: networkType) SendFlowReducer()
}, },
tokenName: tokenName tokenName: tokenName
) )

View File

@ -12,13 +12,13 @@ import Utils
import URIParser import URIParser
import ZcashLightClientKit import ZcashLightClientKit
import Generated import Generated
import ZcashSDKEnvironment
public typealias ScanStore = Store<ScanReducer.State, ScanReducer.Action> public typealias ScanStore = Store<ScanReducer.State, ScanReducer.Action>
public typealias ScanViewStore = ViewStore<ScanReducer.State, ScanReducer.Action> public typealias ScanViewStore = ViewStore<ScanReducer.State, ScanReducer.Action>
public struct ScanReducer: Reducer { public struct ScanReducer: Reducer {
private enum CancelId { case timer } private enum CancelId { case timer }
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum ScanStatus: Equatable { public enum ScanStatus: Equatable {
@ -61,6 +61,7 @@ public struct ScanReducer: Reducer {
@Dependency(\.captureDevice) var captureDevice @Dependency(\.captureDevice) var captureDevice
@Dependency(\.mainQueue) var mainQueue @Dependency(\.mainQueue) var mainQueue
@Dependency(\.uriParser) var uriParser @Dependency(\.uriParser) var uriParser
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public enum Action: Equatable { public enum Action: Equatable {
case alert(PresentationAction<Action>) case alert(PresentationAction<Action>)
@ -72,9 +73,7 @@ public struct ScanReducer: Reducer {
case torchPressed case torchPressed
} }
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
// swiftlint:disable:next cyclomatic_complexity // swiftlint:disable:next cyclomatic_complexity
public var body: some ReducerOf<Self> { public var body: some ReducerOf<Self> {
@ -117,7 +116,7 @@ public struct ScanReducer: Reducer {
if let prevCode = state.scannedValue, prevCode == code.data { if let prevCode = state.scannedValue, prevCode == code.data {
return .none return .none
} }
if uriParser.isValidURI(code.data, networkType) { if uriParser.isValidURI(code.data, zcashSDKEnvironment.network.networkType) {
state.scanStatus = .value(code) state.scanStatus = .value(code)
// once valid URI is scanned we want to start the timer to deliver the code // once valid URI is scanned we want to start the timer to deliver the code
// any new code cancels the schedule and fires new one // any new code cancels the schedule and fires new one
@ -172,6 +171,6 @@ extension ScanStore {
public static let placeholder = ScanStore( public static let placeholder = ScanStore(
initialState: .initial initialState: .initial
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
} }

View File

@ -22,8 +22,6 @@ public typealias SecurityWarningStore = Store<SecurityWarningReducer.State, Secu
public typealias SecurityWarningViewStore = ViewStore<SecurityWarningReducer.State, SecurityWarningReducer.Action> public typealias SecurityWarningViewStore = ViewStore<SecurityWarningReducer.State, SecurityWarningReducer.Action>
public struct SecurityWarningReducer: Reducer { public struct SecurityWarningReducer: Reducer {
let zcashNetwork: ZcashNetwork
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable, CaseIterable { public enum Destination: Equatable, CaseIterable {
case createNewWallet case createNewWallet
@ -64,9 +62,7 @@ public struct SecurityWarningReducer: Reducer {
@Dependency(\.walletStorage) var walletStorage @Dependency(\.walletStorage) var walletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(zcashNetwork: ZcashNetwork) { public init() { }
self.zcashNetwork = zcashNetwork
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
BindingReducer() BindingReducer()
@ -137,7 +133,7 @@ extension SecurityWarningStore {
public static var demo = SecurityWarningStore( public static var demo = SecurityWarningStore(
initialState: .placeholder initialState: .placeholder
) { ) {
SecurityWarningReducer(zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) SecurityWarningReducer()
} }
} }

View File

@ -163,7 +163,7 @@ public struct SendFlowConfirmationView: View {
transactionAmountInputState: .initial transactionAmountInputState: .initial
) )
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
}, },
tokenName: "ZEC" tokenName: "ZEC"
) )

View File

@ -25,7 +25,6 @@ public typealias SendFlowViewStore = ViewStore<SendFlowReducer.State, SendFlowRe
public struct SendFlowReducer: Reducer { public struct SendFlowReducer: Reducer {
private enum SyncStatusUpdatesID { case timer } private enum SyncStatusUpdatesID { case timer }
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable { public enum Destination: Equatable {
@ -149,9 +148,7 @@ public struct SendFlowReducer: Reducer {
@Dependency(\.walletStorage) var walletStorage @Dependency(\.walletStorage) var walletStorage
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Scope(state: \.memoState, action: /Action.memo) { Scope(state: \.memoState, action: /Action.memo) {
@ -159,7 +156,7 @@ public struct SendFlowReducer: Reducer {
} }
Scope(state: \.transactionAddressInputState, action: /Action.transactionAddressInput) { Scope(state: \.transactionAddressInputState, action: /Action.transactionAddressInput) {
TransactionAddressTextFieldReducer(networkType: networkType) TransactionAddressTextFieldReducer()
} }
Scope(state: \.transactionAmountInputState, action: /Action.transactionAmountInput) { Scope(state: \.transactionAmountInputState, action: /Action.transactionAmountInput) {
@ -167,7 +164,7 @@ public struct SendFlowReducer: Reducer {
} }
Scope(state: \.scanState, action: /Action.scan) { Scope(state: \.scanState, action: /Action.scan) {
ScanReducer(networkType: networkType) ScanReducer()
} }
Reduce { state, action in Reduce { state, action in
@ -214,7 +211,8 @@ public struct SendFlowReducer: Reducer {
do { do {
let storedWallet = try walletStorage.exportWallet() let storedWallet = try walletStorage.exportWallet()
let seedBytes = try mnemonic.toSeed(storedWallet.seedPhrase.value()) let seedBytes = try mnemonic.toSeed(storedWallet.seedPhrase.value())
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0, networkType) let network = zcashSDKEnvironment.network.networkType
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0, network)
let memo: Memo? let memo: Memo?
if state.transactionAddressInputState.isValidTransparentAddress { if state.transactionAddressInputState.isValidTransparentAddress {
@ -225,7 +223,7 @@ public struct SendFlowReducer: Reducer {
memo = nil memo = nil
} }
let recipient = try Recipient(state.address, network: networkType) let recipient = try Recipient(state.address, network: network)
state.isSending = true state.isSending = true
return .run { [state] send in return .run { [state] send in
@ -279,7 +277,7 @@ public struct SendFlowReducer: Reducer {
state.transactionAddressInputState.isValidAddress = true state.transactionAddressInputState.isValidAddress = true
state.transactionAddressInputState.isValidTransparentAddress = derivationTool.isTransparentAddress( state.transactionAddressInputState.isValidTransparentAddress = derivationTool.isTransparentAddress(
address.data, address.data,
networkType zcashSDKEnvironment.network.networkType
) )
audioServices.systemSoundVibrate() audioServices.systemSoundVibrate()
return Effect.send(.updateDestination(nil)) return Effect.send(.updateDestination(nil))
@ -371,7 +369,7 @@ extension SendFlowStore {
SendFlowStore( SendFlowStore(
initialState: .initial initialState: .initial
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
} }
} }

View File

@ -182,7 +182,7 @@ public struct SendFlowView: View {
transactionAmountInputState: .initial transactionAmountInputState: .initial
) )
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
}, },
tokenName: "ZEC" tokenName: "ZEC"
) )

View File

@ -15,8 +15,6 @@ public typealias AdvancedSettingsStore = Store<AdvancedSettingsReducer.State, Ad
public typealias AdvancedSettingsViewStore = ViewStore<AdvancedSettingsReducer.State, AdvancedSettingsReducer.Action> public typealias AdvancedSettingsViewStore = ViewStore<AdvancedSettingsReducer.State, AdvancedSettingsReducer.Action>
public struct AdvancedSettingsReducer: Reducer { public struct AdvancedSettingsReducer: Reducer {
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum Destination { public enum Destination {
case backupPhrase case backupPhrase
@ -58,9 +56,7 @@ public struct AdvancedSettingsReducer: Reducer {
@Dependency(\.localAuthentication) var localAuthentication @Dependency(\.localAuthentication) var localAuthentication
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Reduce { state, action in Reduce { state, action in
@ -115,7 +111,7 @@ public struct AdvancedSettingsReducer: Reducer {
} }
Scope(state: \.privateDataConsentState, action: /Action.privateDataConsent) { Scope(state: \.privateDataConsentState, action: /Action.privateDataConsent) {
PrivateDataConsentReducer(networkType: networkType) PrivateDataConsentReducer()
} }
Scope(state: \.serverSetupState, action: /Action.serverSetup) { Scope(state: \.serverSetupState, action: /Action.serverSetup) {
@ -199,7 +195,7 @@ extension AdvancedSettingsStore {
public static let placeholder = AdvancedSettingsStore( public static let placeholder = AdvancedSettingsStore(
initialState: .initial initialState: .initial
) { ) {
AdvancedSettingsReducer(networkType: .testnet) AdvancedSettingsReducer()
} }
public static let demo = AdvancedSettingsStore( public static let demo = AdvancedSettingsStore(
@ -213,6 +209,6 @@ extension AdvancedSettingsStore {
serverSetupState: ServerSetup.State() serverSetupState: ServerSetup.State()
) )
) { ) {
AdvancedSettingsReducer(networkType: .testnet) AdvancedSettingsReducer()
} }
} }

View File

@ -13,8 +13,6 @@ public typealias SettingsStore = Store<SettingsReducer.State, SettingsReducer.Ac
public typealias SettingsViewStore = ViewStore<SettingsReducer.State, SettingsReducer.Action> public typealias SettingsViewStore = ViewStore<SettingsReducer.State, SettingsReducer.Action>
public struct SettingsReducer: Reducer { public struct SettingsReducer: Reducer {
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum Destination { public enum Destination {
case about case about
@ -60,9 +58,7 @@ public struct SettingsReducer: Reducer {
@Dependency(\.appVersion) var appVersion @Dependency(\.appVersion) var appVersion
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Reduce { state, action in Reduce { state, action in
@ -116,7 +112,7 @@ public struct SettingsReducer: Reducer {
.ifLet(\.$alert, action: /Action.alert) .ifLet(\.$alert, action: /Action.alert)
Scope(state: \.advancedSettingsState, action: /Action.advancedSettings) { Scope(state: \.advancedSettingsState, action: /Action.advancedSettings) {
AdvancedSettingsReducer(networkType: networkType) AdvancedSettingsReducer()
} }
} }
} }
@ -185,7 +181,7 @@ extension SettingsStore {
public static let placeholder = SettingsStore( public static let placeholder = SettingsStore(
initialState: .initial initialState: .initial
) { ) {
SettingsReducer(networkType: .testnet) SettingsReducer()
} }
public static let demo = SettingsStore( public static let demo = SettingsStore(
@ -195,6 +191,6 @@ extension SettingsStore {
appBuild: "54" appBuild: "54"
) )
) { ) {
SettingsReducer(networkType: .testnet) SettingsReducer()
} }
} }

View File

@ -22,9 +22,6 @@ public typealias TabsStore = Store<TabsReducer.State, TabsReducer.Action>
public typealias TabsViewStore = ViewStore<TabsReducer.State, TabsReducer.Action> public typealias TabsViewStore = ViewStore<TabsReducer.State, TabsReducer.Action>
public struct TabsReducer: Reducer { public struct TabsReducer: Reducer {
let tokenName: String
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public enum Destination: Equatable { public enum Destination: Equatable {
case settings case settings
@ -94,30 +91,27 @@ public struct TabsReducer: Reducer {
@Dependency(\.restoreWalletStorage) var restoreWalletStorage @Dependency(\.restoreWalletStorage) var restoreWalletStorage
public init(tokenName: String, networkType: NetworkType) { public init() { }
self.tokenName = tokenName
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Scope(state: \.sendState, action: /Action.send) { Scope(state: \.sendState, action: /Action.send) {
SendFlowReducer(networkType: networkType) SendFlowReducer()
} }
Scope(state: \.addressDetailsState, action: /Action.addressDetails) { Scope(state: \.addressDetailsState, action: /Action.addressDetails) {
AddressDetailsReducer(networkType: networkType) AddressDetailsReducer()
} }
Scope(state: \.balanceBreakdownState, action: /Action.balanceBreakdown) { Scope(state: \.balanceBreakdownState, action: /Action.balanceBreakdown) {
BalanceBreakdownReducer(networkType: networkType) BalanceBreakdownReducer()
} }
Scope(state: \.homeState, action: /Action.home) { Scope(state: \.homeState, action: /Action.home) {
HomeReducer(networkType: networkType) HomeReducer()
} }
Scope(state: \.settingsState, action: /Action.settings) { Scope(state: \.settingsState, action: /Action.settings) {
SettingsReducer(networkType: networkType) SettingsReducer()
} }
Reduce { state, action in Reduce { state, action in
@ -179,10 +173,7 @@ extension TabsStore {
public static var demo = TabsStore( public static var demo = TabsStore(
initialState: .initial initialState: .initial
) { ) {
TabsReducer( TabsReducer()
tokenName: "TAZ",
networkType: ZcashNetworkBuilder.network(for: .testnet).networkType
)
} }
} }

View File

@ -56,7 +56,7 @@ struct TransactionAddressTextField_Previews: PreviewProvider {
) )
) )
) { ) {
TransactionAddressTextFieldReducer(networkType: .testnet) TransactionAddressTextFieldReducer()
} }
) )
.preferredColorScheme(.light) .preferredColorScheme(.light)

View File

@ -14,8 +14,6 @@ import ZcashSDKEnvironment
public typealias TransactionAddressTextFieldStore = Store<TransactionAddressTextFieldReducer.State, TransactionAddressTextFieldReducer.Action> public typealias TransactionAddressTextFieldStore = Store<TransactionAddressTextFieldReducer.State, TransactionAddressTextFieldReducer.Action>
public struct TransactionAddressTextFieldReducer: Reducer { public struct TransactionAddressTextFieldReducer: Reducer {
let networkType: NetworkType
public struct State: Equatable { public struct State: Equatable {
public var isValidAddress = false public var isValidAddress = false
public var isValidTransparentAddress = false public var isValidTransparentAddress = false
@ -37,9 +35,7 @@ public struct TransactionAddressTextFieldReducer: Reducer {
@Dependency(\.derivationTool) var derivationTool @Dependency(\.derivationTool) var derivationTool
@Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment @Dependency(\.zcashSDKEnvironment) var zcashSDKEnvironment
public init(networkType: NetworkType) { public init() { }
self.networkType = networkType
}
public var body: some Reducer<State, Action> { public var body: some Reducer<State, Action> {
Reduce { state, action in Reduce { state, action in
@ -52,8 +48,9 @@ public struct TransactionAddressTextFieldReducer: Reducer {
return .none return .none
case .textField(.set(let address)): case .textField(.set(let address)):
state.isValidAddress = derivationTool.isZcashAddress(address.data, networkType) let network = zcashSDKEnvironment.network.networkType
state.isValidTransparentAddress = derivationTool.isTransparentAddress(address.data, networkType) state.isValidAddress = derivationTool.isZcashAddress(address.data, network)
state.isValidTransparentAddress = derivationTool.isTransparentAddress(address.data, network)
return .none return .none
} }
} }
@ -76,6 +73,6 @@ extension TransactionAddressTextFieldStore {
public static let placeholder = TransactionAddressTextFieldStore( public static let placeholder = TransactionAddressTextFieldStore(
initialState: .initial initialState: .initial
) { ) {
TransactionAddressTextFieldReducer(networkType: .testnet) TransactionAddressTextFieldReducer()
} }
} }

View File

@ -24,10 +24,8 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
let rootStore = RootStore( let rootStore = RootStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer( RootReducer()
tokenName: TargetConstants.tokenName, .logging()
zcashNetwork: TargetConstants.zcashNetwork
).logging()
} }
func application( func application(

View File

@ -24,7 +24,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
store.dependencies.pasteboard = testPasteboard store.dependencies.pasteboard = testPasteboard
@ -49,7 +49,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
store.dependencies.pasteboard = testPasteboard store.dependencies.pasteboard = testPasteboard
@ -72,7 +72,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
store.dependencies.pasteboard = testPasteboard store.dependencies.pasteboard = testPasteboard
@ -96,7 +96,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
let expectedAddress = try uAddress.transparentReceiver().stringEncoded let expectedAddress = try uAddress.transparentReceiver().stringEncoded
@ -114,7 +114,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
await store.send(.shareQR(uAddress.stringEncoded.redacted)) { state in await store.send(.shareQR(uAddress.stringEncoded.redacted)) { state in
@ -130,7 +130,7 @@ class AddressDetailsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: .testnet) AddressDetailsReducer()
} }
let expectedAddress = try uAddress.saplingReceiver().stringEncoded let expectedAddress = try uAddress.saplingReceiver().stringEncoded

View File

@ -21,7 +21,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .placeholder initialState: .placeholder
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
store.dependencies.sdkSynchronizer = .mocked() store.dependencies.sdkSynchronizer = .mocked()
@ -44,7 +44,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .placeholder initialState: .placeholder
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
store.dependencies.sdkSynchronizer = .mocked(shieldFunds: { _, _, _ in throw ZcashError.synchronizerNotPrepared }) store.dependencies.sdkSynchronizer = .mocked(shieldFunds: { _, _, _ in throw ZcashError.synchronizerNotPrepared })
@ -72,7 +72,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
XCTAssertFalse(store.state.isShieldingFunds) XCTAssertFalse(store.state.isShieldingFunds)
@ -93,7 +93,7 @@ class BalanceBreakdownTests: XCTestCase {
transparentBalance: Zatoshi(1_000_000) transparentBalance: Zatoshi(1_000_000)
) )
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
XCTAssertFalse(store.state.isShieldingFunds) XCTAssertFalse(store.state.isShieldingFunds)
@ -114,7 +114,7 @@ class BalanceBreakdownTests: XCTestCase {
transparentBalance: Zatoshi(1_000_000) transparentBalance: Zatoshi(1_000_000)
) )
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
XCTAssertTrue(store.state.isShieldingFunds) XCTAssertTrue(store.state.isShieldingFunds)
@ -129,7 +129,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
store.dependencies.restoreWalletStorage = .noOp store.dependencies.restoreWalletStorage = .noOp
@ -156,7 +156,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
await store.send(.updateHintBoxVisibility(true)) { state in await store.send(.updateHintBoxVisibility(true)) { state in
@ -173,7 +173,7 @@ class BalanceBreakdownTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
} }
await store.send(.updateHintBoxVisibility(false)) { state in await store.send(.updateHintBoxVisibility(false)) { state in

View File

@ -23,7 +23,7 @@ class DeeplinkTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
await store.send(.destination(.deeplinkHome)) { state in await store.send(.destination(.deeplinkHome)) { state in
@ -40,7 +40,7 @@ class DeeplinkTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
await store.send(.destination(.deeplinkHome)) { state in await store.send(.destination(.deeplinkHome)) { state in
@ -57,7 +57,7 @@ class DeeplinkTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
let amount = Zatoshi(123_000_000) let amount = Zatoshi(123_000_000)
@ -93,7 +93,7 @@ class DeeplinkTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.deeplink = DeeplinkClient( store.dependencies.deeplink = DeeplinkClient(
@ -139,7 +139,7 @@ class DeeplinkTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.deeplink = DeeplinkClient( store.dependencies.deeplink = DeeplinkClient(

View File

@ -31,7 +31,7 @@ class HomeTests: XCTestCase {
walletConfig: .initial walletConfig: .initial
) )
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
XCTAssertTrue(store.state.isSendButtonDisabled) XCTAssertTrue(store.state.isSendButtonDisabled)
@ -43,7 +43,7 @@ class HomeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -76,7 +76,7 @@ class HomeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
store.dependencies.diskSpaceChecker = .mockFullDisk store.dependencies.diskSpaceChecker = .mockFullDisk
@ -110,7 +110,7 @@ class HomeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
await store.send(.synchronizerStateChanged(state)) { state in await store.send(.synchronizerStateChanged(state)) { state in
@ -130,7 +130,7 @@ class HomeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
store.dependencies.restoreWalletStorage = .noOp store.dependencies.restoreWalletStorage = .noOp

View File

@ -18,7 +18,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
await store.send(.onAppear) { state in await store.send(.onAppear) { state in
@ -32,7 +32,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -53,7 +53,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -75,7 +75,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -102,7 +102,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 280_000) ImportWalletReducer()
} }
let birthday = "200000".redacted let birthday = "200000".redacted
@ -118,7 +118,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
let birthday = "abc".redacted let birthday = "abc".redacted
@ -134,7 +134,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
let birthday = "1700000".redacted let birthday = "1700000".redacted
@ -151,7 +151,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -184,7 +184,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 280_000) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -216,7 +216,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 280_000) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -253,7 +253,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -291,7 +291,7 @@ class ImportWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ImportWalletReducer.State(maxWordsCount: 24) initialState: ImportWalletReducer.State(maxWordsCount: 24)
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp
@ -335,7 +335,7 @@ class ImportWalletTests: XCTestCase {
wordsCount: 24 wordsCount: 24
) )
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
store.dependencies.mnemonic = .noOp store.dependencies.mnemonic = .noOp

View File

@ -16,7 +16,7 @@ final class PrivateDataConsentTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
let URL = URL(string: "https://electriccoin.co")! let URL = URL(string: "https://electriccoin.co")!
@ -39,7 +39,7 @@ final class PrivateDataConsentTests: XCTestCase {
exportOnlyLogs: true exportOnlyLogs: true
) )
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
store.dependencies.logsHandler = .noOp store.dependencies.logsHandler = .noOp
@ -71,7 +71,7 @@ final class PrivateDataConsentTests: XCTestCase {
exportOnlyLogs: false exportOnlyLogs: false
) )
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
store.dependencies.logsHandler = .noOp store.dependencies.logsHandler = .noOp
@ -103,7 +103,7 @@ final class PrivateDataConsentTests: XCTestCase {
isExportingLogs: true isExportingLogs: true
) )
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
await store.send(.shareFinished) { state in await store.send(.shareFinished) { state in
@ -122,7 +122,7 @@ final class PrivateDataConsentTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
PrivateDataConsentReducer(networkType: .testnet) PrivateDataConsentReducer()
} }
store.dependencies.restoreWalletStorage = .noOp store.dependencies.restoreWalletStorage = .noOp

View File

@ -27,7 +27,7 @@ final class ReviewRequestTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
let now = Date.now let now = Date.now
@ -64,7 +64,7 @@ final class ReviewRequestTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
} }
let now = Date.now let now = Date.now

View File

@ -30,7 +30,7 @@ class AppInitializationTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
let testQueue = DispatchQueue.test let testQueue = DispatchQueue.test
@ -104,7 +104,7 @@ class AppInitializationTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: appState initialState: appState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
let testQueue = DispatchQueue.test let testQueue = DispatchQueue.test
@ -180,7 +180,7 @@ class AppInitializationTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.databaseFiles = .noOp store.dependencies.databaseFiles = .noOp
@ -220,7 +220,7 @@ class AppInitializationTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.databaseFiles = .noOp store.dependencies.databaseFiles = .noOp
@ -283,7 +283,7 @@ class AppInitializationTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.databaseFiles = .noOp store.dependencies.databaseFiles = .noOp

View File

@ -17,7 +17,7 @@ class DebugTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
await store.send(.debug(.rescanBlockchain)) { state in await store.send(.debug(.rescanBlockchain)) { state in
@ -33,7 +33,7 @@ class DebugTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: mockState initialState: mockState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
await store.send(.debug(.cancelRescan)) { state in await store.send(.debug(.cancelRescan)) { state in
@ -49,7 +49,7 @@ class DebugTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: mockState initialState: mockState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -72,7 +72,7 @@ class DebugTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: mockState initialState: mockState
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate

View File

@ -19,7 +19,7 @@ final class RestoreWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -53,10 +53,7 @@ final class RestoreWalletTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: state initialState: state
) { ) {
RootReducer( RootReducer()
tokenName: "ZEC",
zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)
)
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate

View File

@ -101,7 +101,7 @@ class RootTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -123,7 +123,7 @@ class RootTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -160,7 +160,7 @@ class RootTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.walletStorage = .noOp store.dependencies.walletStorage = .noOp
@ -195,7 +195,7 @@ class RootTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.walletStorage = .noOp store.dependencies.walletStorage = .noOp
@ -222,7 +222,7 @@ class RootTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate

View File

@ -19,7 +19,7 @@ final class WalletNukeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
await store.send(.initialization(.nukeWalletRequest)) { state in await store.send(.initialization(.nukeWalletRequest)) { state in
@ -33,7 +33,7 @@ final class WalletNukeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
store.dependencies.sdkSynchronizer = .noOp store.dependencies.sdkSynchronizer = .noOp
@ -57,7 +57,7 @@ final class WalletNukeTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
var readIds: [RedactableString: Bool] = ["id1".redacted: true] var readIds: [RedactableString: Bool] = ["id1".redacted: true]

View File

@ -22,7 +22,7 @@ class ScanTests: XCTestCase {
scanStatus: .value("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po".redacted) scanStatus: .value("t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po".redacted)
) )
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
store.dependencies.captureDevice = .noOp store.dependencies.captureDevice = .noOp
@ -40,7 +40,7 @@ class ScanTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ScanReducer.State() initialState: ScanReducer.State()
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
store.dependencies.captureDevice = .noOp store.dependencies.captureDevice = .noOp
@ -58,7 +58,7 @@ class ScanTests: XCTestCase {
isTorchOn: true isTorchOn: true
) )
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
store.dependencies.captureDevice = .noOp store.dependencies.captureDevice = .noOp
@ -74,7 +74,7 @@ class ScanTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ScanReducer.State() initialState: ScanReducer.State()
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
store.dependencies.uriParser.isValidURI = { _, _ in false } store.dependencies.uriParser.isValidURI = { _, _ in false }
@ -92,7 +92,7 @@ class ScanTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ScanReducer.State() initialState: ScanReducer.State()
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -113,7 +113,7 @@ class ScanTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: ScanReducer.State() initialState: ScanReducer.State()
) { ) {
ScanReducer(networkType: .testnet) ScanReducer()
} }
await store.send(.scanFailed) { state in await store.send(.scanFailed) { state in

View File

@ -50,7 +50,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .liveValue store.dependencies.derivationTool = .liveValue
@ -104,7 +104,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
let error = "send failed".toZcashError() let error = "send failed".toZcashError()
@ -146,7 +146,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .liveValue store.dependencies.derivationTool = .liveValue
@ -173,7 +173,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -198,7 +198,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -226,7 +226,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: state initialState: state
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.numberFormatter = .noOp store.dependencies.numberFormatter = .noOp
@ -242,7 +242,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -282,7 +282,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.numberFormatter = .noOp store.dependencies.numberFormatter = .noOp
@ -325,7 +325,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.numberFormatter = .noOp store.dependencies.numberFormatter = .noOp
@ -352,6 +352,9 @@ class SendTests: XCTestCase {
} }
func testDifferentNumberFormats_LiveNumberFormatter() throws { func testDifferentNumberFormats_LiveNumberFormatter() throws {
let zcashNumberFormatter = NumberFormatter.zcashNumberFormatter
zcashNumberFormatter.locale = Locale(identifier: "en_US")
try numberFormatTest("1.234", NSNumber(1.234)) try numberFormatTest("1.234", NSNumber(1.234))
try numberFormatTest("1,234", NSNumber(1_234)) try numberFormatTest("1,234", NSNumber(1_234))
try numberFormatTest("1 234", NSNumber(1_234)) try numberFormatTest("1 234", NSNumber(1_234))
@ -388,7 +391,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -431,7 +434,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -473,7 +476,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -515,7 +518,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -556,7 +559,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.derivationTool = .noOp store.dependencies.derivationTool = .noOp
@ -610,7 +613,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
let value = "test".redacted let value = "test".redacted
@ -645,7 +648,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.mainQueue = .immediate store.dependencies.mainQueue = .immediate
@ -672,7 +675,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
store.dependencies.audioServices = AudioServicesClient(systemSoundVibrate: { }) store.dependencies.audioServices = AudioServicesClient(systemSoundVibrate: { })
@ -702,7 +705,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
await store.send(.reviewPressed) { state in await store.send(.reviewPressed) { state in
@ -724,13 +727,16 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
XCTAssertEqual(store.state.message, testMessage.data) XCTAssertEqual(store.state.message, testMessage.data)
} }
func testFeeFormat() throws { func testFeeFormat() throws {
let zashiBalanceFormatter = NumberFormatter.zashiBalanceFormatter
zashiBalanceFormatter.locale = Locale(identifier: "en_US")
let feeFormat = "(Fee < 0.001)" let feeFormat = "(Fee < 0.001)"
let sendState = SendFlowReducer.State( let sendState = SendFlowReducer.State(
@ -744,7 +750,7 @@ class SendTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: sendState initialState: sendState
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
} }
XCTAssertEqual(store.state.feeFormat, feeFormat) XCTAssertEqual(store.state.feeFormat, feeFormat)
@ -756,7 +762,7 @@ private extension SendTests {
_ amount: String, _ amount: String,
_ expectedResult: NSNumber? _ expectedResult: NSNumber?
) throws { ) throws {
if let number = NumberFormatterClient.liveValue.number(amount) { if let number = NumberFormatter.zcashNumberFormatter.number(from: amount) {
XCTAssertEqual(number, expectedResult) XCTAssertEqual(number, expectedResult)
return return
} else { } else {

View File

@ -23,7 +23,7 @@ class TransactionAddressTextFieldTests: XCTestCase {
) )
) )
) { ) {
TransactionAddressTextFieldReducer(networkType: .testnet) TransactionAddressTextFieldReducer()
} }
await store.send(.clearAddress) { state in await store.send(.clearAddress) { state in

View File

@ -59,7 +59,7 @@ class SettingsTests: XCTestCase {
serverSetupState: .initial serverSetupState: .initial
) )
) { ) {
AdvancedSettingsReducer(networkType: .testnet) AdvancedSettingsReducer()
} }
store.dependencies.localAuthentication = .mockAuthenticationSucceeded store.dependencies.localAuthentication = .mockAuthenticationSucceeded
@ -78,7 +78,7 @@ class SettingsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
AdvancedSettingsReducer(networkType: .testnet) AdvancedSettingsReducer()
} }
store.dependencies.localAuthentication = .mockAuthenticationFailed store.dependencies.localAuthentication = .mockAuthenticationFailed
@ -95,7 +95,7 @@ class SettingsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
SettingsReducer(networkType: .testnet) SettingsReducer()
} }
store.dependencies.restoreWalletStorage = .noOp store.dependencies.restoreWalletStorage = .noOp

View File

@ -25,7 +25,7 @@ class AddressDetailsSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: networkType) AddressDetailsReducer()
.dependency(\.walletConfigProvider, .noOp) .dependency(\.walletConfigProvider, .noOp)
} }
@ -44,7 +44,7 @@ class AddressDetailsSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: AddressDetailsReducer.State(uAddress: uAddress) initialState: AddressDetailsReducer.State(uAddress: uAddress)
) { ) {
AddressDetailsReducer(networkType: networkType) AddressDetailsReducer()
.dependency(\.walletConfigProvider, .noOp) .dependency(\.walletConfigProvider, .noOp)
} }

View File

@ -26,7 +26,7 @@ class BalanceBreakdownSnapshotTests: XCTestCase {
transparentBalance: Zatoshi(850_000_000) transparentBalance: Zatoshi(850_000_000)
) )
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
.dependency(\.sdkSynchronizer, .noOp) .dependency(\.sdkSynchronizer, .noOp)
.dependency(\.mainQueue, .immediate) .dependency(\.mainQueue, .immediate)
} }
@ -48,7 +48,7 @@ class BalanceBreakdownSnapshotTests: XCTestCase {
transparentBalance: Zatoshi(850_000_000) transparentBalance: Zatoshi(850_000_000)
) )
) { ) {
BalanceBreakdownReducer(networkType: .testnet) BalanceBreakdownReducer()
.dependency(\.sdkSynchronizer, .noOp) .dependency(\.sdkSynchronizer, .noOp)
.dependency(\.mainQueue, .immediate) .dependency(\.mainQueue, .immediate)
} }

View File

@ -45,7 +45,7 @@ class HomeSnapshotTests: XCTestCase {
walletConfig: .initial walletConfig: .initial
) )
) { ) {
HomeReducer(networkType: .testnet) HomeReducer()
.dependency(\.diskSpaceChecker, .mockEmptyDisk) .dependency(\.diskSpaceChecker, .mockEmptyDisk)
.dependency(\.sdkSynchronizer, .noOp) .dependency(\.sdkSynchronizer, .noOp)
.dependency(\.mainQueue, .immediate) .dependency(\.mainQueue, .immediate)

View File

@ -15,7 +15,7 @@ class ImportWalletSnapshotTests: XCTestCase {
let store = ImportWalletStore( let store = ImportWalletStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
addAttachments(ImportWalletView(store: store)) addAttachments(ImportWalletView(store: store))
@ -25,7 +25,7 @@ class ImportWalletSnapshotTests: XCTestCase {
let store = ImportWalletStore( let store = ImportWalletStore(
initialState: .initial initialState: .initial
) { ) {
ImportWalletReducer(saplingActivationHeight: 0) ImportWalletReducer()
} }
addAttachments(ImportBirthdayView(store: store)) addAttachments(ImportBirthdayView(store: store))

View File

@ -15,7 +15,7 @@ class PrivateDataConsentSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: .initial initialState: .initial
) { ) {
PrivateDataConsentReducer(networkType: .mainnet) PrivateDataConsentReducer()
.dependency(\.databaseFiles, .noOp) .dependency(\.databaseFiles, .noOp)
} }

View File

@ -16,7 +16,7 @@ class SecurityWarningSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: .initial initialState: .initial
) { ) {
SecurityWarningReducer(zcashNetwork: ZcashNetworkBuilder.network(for: .mainnet)) SecurityWarningReducer()
.dependency(\.appVersion, .mock) .dependency(\.appVersion, .mock)
} }

View File

@ -35,7 +35,7 @@ class SendSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: state initialState: state
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
.dependency(\.derivationTool, .live()) .dependency(\.derivationTool, .live())
.dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler()) .dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler())
.dependency(\.numberFormatter, .live()) .dependency(\.numberFormatter, .live())
@ -77,7 +77,7 @@ class SendSnapshotTests: XCTestCase {
) )
) )
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
.dependency(\.derivationTool, .live()) .dependency(\.derivationTool, .live())
.dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler()) .dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler())
.dependency(\.numberFormatter, .live()) .dependency(\.numberFormatter, .live())
@ -116,7 +116,7 @@ class SendSnapshotTests: XCTestCase {
) )
) )
) { ) {
SendFlowReducer(networkType: .testnet) SendFlowReducer()
.dependency(\.derivationTool, .live()) .dependency(\.derivationTool, .live())
.dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler()) .dependency(\.mainQueue, DispatchQueue.main.eraseToAnyScheduler())
.dependency(\.numberFormatter, .live()) .dependency(\.numberFormatter, .live())

View File

@ -16,7 +16,7 @@ class SettingsSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: .initial initialState: .initial
) { ) {
SettingsReducer(networkType: .mainnet) SettingsReducer()
.dependency(\.localAuthentication, .mockAuthenticationFailed) .dependency(\.localAuthentication, .mockAuthenticationFailed)
.dependency(\.sdkSynchronizer, .noOp) .dependency(\.sdkSynchronizer, .noOp)
.dependency(\.walletStorage, .noOp) .dependency(\.walletStorage, .noOp)
@ -30,7 +30,7 @@ class SettingsSnapshotTests: XCTestCase {
let store = Store( let store = Store(
initialState: .initial initialState: .initial
) { ) {
SettingsReducer(networkType: .mainnet) SettingsReducer()
.dependency(\.localAuthentication, .mockAuthenticationFailed) .dependency(\.localAuthentication, .mockAuthenticationFailed)
.dependency(\.sdkSynchronizer, .noOp) .dependency(\.sdkSynchronizer, .noOp)
.dependency(\.walletStorage, .noOp) .dependency(\.walletStorage, .noOp)

View File

@ -21,7 +21,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
await store.send(.home(.balanceBreakdown)) { state in await store.send(.home(.balanceBreakdown)) { state in
@ -33,7 +33,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
await store.send(.selectedTabChanged(.send)) { state in await store.send(.selectedTabChanged(.send)) { state in
@ -45,7 +45,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
await store.send(.updateDestination(.settings)) { state in await store.send(.updateDestination(.settings)) { state in
@ -60,7 +60,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: placeholderState initialState: placeholderState
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
await store.send(.updateDestination(nil)) { state in await store.send(.updateDestination(nil)) { state in
@ -75,7 +75,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: initialState initialState: initialState
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
store.dependencies.restoreWalletStorage = .noOp store.dependencies.restoreWalletStorage = .noOp
@ -153,7 +153,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: placeholderState initialState: placeholderState
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
let transaction = TransactionState.placeholder(uuid: "3") let transaction = TransactionState.placeholder(uuid: "3")
@ -178,7 +178,7 @@ class TabsTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: placeholderState initialState: placeholderState
) { ) {
TabsReducer(tokenName: "TAZ", networkType: .testnet) TabsReducer()
} }
store.dependencies.sdkSynchronizer = .mock store.dependencies.sdkSynchronizer = .mock

View File

@ -124,7 +124,7 @@ class WalletConfigProviderTests: XCTestCase {
let store = TestStore( let store = TestStore(
initialState: .initial initialState: .initial
) { ) {
RootReducer(tokenName: "ZEC", zcashNetwork: ZcashNetworkBuilder.network(for: .testnet)) RootReducer()
} }
// Change any of the flags from the default value // Change any of the flags from the default value