- synchronizer's protocol cleaned up - latest SDK adopted - memos back toincleared transactions - recipient back in cleared transactions - unit tets fixed - pending transaction memos are back - recieved recipients no longer available, removed from the UI
This commit is contained in:
parent
a727f49817
commit
fe1e7b758c
|
@ -3651,7 +3651,7 @@
|
|||
repositoryURL = "https://github.com/zcash/ZcashLightClientKit.git";
|
||||
requirement = {
|
||||
kind = revision;
|
||||
revision = 16d70cfead166ae214bc813fd245d3eb62588cfd;
|
||||
revision = 88e120509b44104790949504fa58d0add9fb970e;
|
||||
};
|
||||
};
|
||||
6654C7382715A38000901167 /* XCRemoteSwiftPackageReference "swift-composable-architecture" */ = {
|
||||
|
|
|
@ -329,8 +329,8 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
||||
"state" : {
|
||||
"revision" : "c2dd0eff1defbe6dfb6197c3a42ab21ea2db2fc2",
|
||||
"version" : "0.2.0"
|
||||
"revision" : "bf5992c2e53749ad11c1e85ad5d9c63e39bdf3cc",
|
||||
"version" : "0.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -338,7 +338,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/zcash/ZcashLightClientKit.git",
|
||||
"state" : {
|
||||
"revision" : "16d70cfead166ae214bc813fd245d3eb62588cfd"
|
||||
"revision" : "88e120509b44104790949504fa58d0add9fb970e"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -23,6 +23,9 @@ struct DerivationToolClient {
|
|||
/// - Returns: the spending keys that correspond to the seed, formatted as Strings.
|
||||
var deriveSpendingKey: ([UInt8], Int) throws -> UnifiedSpendingKey
|
||||
|
||||
/// Given a unified spending key, returns the associated unified viewwing key.
|
||||
var deriveUnifiedFullViewingKey: (UnifiedSpendingKey) throws -> UnifiedFullViewingKey
|
||||
|
||||
/// Checks validity of the unified address.
|
||||
var isUnifiedAddress: (String) -> Bool
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ extension DerivationToolClient: DependencyKey {
|
|||
deriveSpendingKey: { seed, accountIndex in
|
||||
try derivationTool.deriveUnifiedSpendingKey(seed: seed, accountIndex: accountIndex)
|
||||
},
|
||||
deriveUnifiedFullViewingKey: { spendingKey in
|
||||
try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||
},
|
||||
isUnifiedAddress: { address in
|
||||
do {
|
||||
if case .unified = try Recipient(address, network: TargetConstants.zcashNetwork.networkType) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import ZcashLightClientKit
|
|||
extension DerivationToolClient: TestDependencyKey {
|
||||
static let testValue = Self(
|
||||
deriveSpendingKey: XCTUnimplemented("\(Self.self).deriveSpendingKey"),
|
||||
deriveUnifiedFullViewingKey: XCTUnimplemented("\(Self.self).deriveUnifiedFullViewingKey"),
|
||||
isUnifiedAddress: XCTUnimplemented("\(Self.self).isUnifiedAddress", placeholder: false),
|
||||
isSaplingAddress: XCTUnimplemented("\(Self.self).isSaplingAddress", placeholder: false),
|
||||
isTransparentAddress: XCTUnimplemented("\(Self.self).isTransparentAddress", placeholder: false),
|
||||
|
@ -22,6 +23,7 @@ extension DerivationToolClient: TestDependencyKey {
|
|||
extension DerivationToolClient {
|
||||
static let noOp = Self(
|
||||
deriveSpendingKey: { _, _ in throw "NotImplemented" },
|
||||
deriveUnifiedFullViewingKey: { _ in throw "NotImplemented" },
|
||||
isUnifiedAddress: { _ in return false },
|
||||
isSaplingAddress: { _ in return false },
|
||||
isTransparentAddress: { _ in return false },
|
||||
|
|
|
@ -33,10 +33,6 @@ struct SDKSynchronizerClient {
|
|||
|
||||
let getShieldedBalance: () -> WalletBalance?
|
||||
let getTransparentBalance: () -> WalletBalance?
|
||||
let getAllSentTransactions: () async throws -> [WalletEvent]
|
||||
let getAllReceivedTransactions: () async throws -> [WalletEvent]
|
||||
let getAllClearedTransactions: () async throws -> [WalletEvent]
|
||||
let getAllPendingTransactions: () async throws -> [WalletEvent]
|
||||
let getAllTransactions: () async throws -> [WalletEvent]
|
||||
|
||||
let getUnifiedAddress: (_ account: Int) async throws -> UnifiedAddress?
|
||||
|
|
|
@ -37,13 +37,10 @@ extension SDKSynchronizerClient: DependencyKey {
|
|||
stateStream: { synchronizer.stateStream },
|
||||
eventStream: { synchronizer.eventStream },
|
||||
latestState: { synchronizer.latestState },
|
||||
latestScannedHeight: { synchronizer.latestScannedHeight },
|
||||
latestScannedHeight: { synchronizer.latestState.latestScannedHeight },
|
||||
prepareWith: { seedBytes, viewingKey, walletBirtday in
|
||||
let result = try await synchronizer.prepare(with: seedBytes, viewingKeys: [viewingKey], walletBirthday: walletBirtday)
|
||||
|
||||
if result != .success {
|
||||
throw SynchronizerError.initFailed(message: "")
|
||||
}
|
||||
if result != .success { throw ZcashError.synchronizerNotPrepared }
|
||||
},
|
||||
start: { retry in try await synchronizer.start(retry: retry) },
|
||||
stop: { await synchronizer.stop() },
|
||||
|
@ -52,64 +49,46 @@ extension SDKSynchronizerClient: DependencyKey {
|
|||
rewind: { synchronizer.rewind($0) },
|
||||
getShieldedBalance: { synchronizer.latestState.shieldedBalance },
|
||||
getTransparentBalance: { synchronizer.latestState.transparentBalance },
|
||||
getAllSentTransactions: {
|
||||
let transactions = try await synchronizer.allSentTransactions()
|
||||
var walletEvents: [WalletEvent] = []
|
||||
for sentTransaction in transactions {
|
||||
let memos = try await synchronizer.getMemos(for: sentTransaction)
|
||||
let transaction = TransactionState.init(transaction: sentTransaction, memos: memos)
|
||||
walletEvents.append(WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp))
|
||||
}
|
||||
|
||||
return walletEvents
|
||||
},
|
||||
getAllReceivedTransactions: {
|
||||
let transactions = try await synchronizer.allReceivedTransactions()
|
||||
var walletEvents: [WalletEvent] = []
|
||||
for receivedTransaction in transactions {
|
||||
let memos = try await synchronizer.getMemos(for: receivedTransaction)
|
||||
let transaction = TransactionState.init(transaction: receivedTransaction, memos: memos)
|
||||
walletEvents.append(WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp))
|
||||
}
|
||||
|
||||
return walletEvents
|
||||
},
|
||||
getAllClearedTransactions: {
|
||||
let transactions = try await synchronizer.allClearedTransactions()
|
||||
var walletEvents: [WalletEvent] = []
|
||||
for clearedTransaction in transactions {
|
||||
let memos = try await synchronizer.getMemos(for: clearedTransaction)
|
||||
let transaction = TransactionState.init(transaction: clearedTransaction, memos: memos)
|
||||
walletEvents.append(WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp))
|
||||
}
|
||||
|
||||
return walletEvents
|
||||
},
|
||||
getAllPendingTransactions: {
|
||||
let transactions = try await synchronizer.allPendingTransactions()
|
||||
var walletEvents: [WalletEvent] = []
|
||||
for pendingTransaction in transactions {
|
||||
let transaction = TransactionState.init(
|
||||
pendingTransaction: pendingTransaction,
|
||||
latestBlockHeight: synchronizer.latestScannedHeight
|
||||
)
|
||||
walletEvents.append(WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp))
|
||||
}
|
||||
|
||||
return walletEvents
|
||||
},
|
||||
getAllTransactions: {
|
||||
let pendingTransactions = try await synchronizer.allPendingTransactions()
|
||||
let clearedTransactions = try await synchronizer.allClearedTransactions()
|
||||
|
||||
let clearedTxs: [WalletEvent] = clearedTransactions.map {
|
||||
let transaction = TransactionState.init(transaction: $0)
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
var clearedTxs: [WalletEvent] = []
|
||||
for clearedTransaction in clearedTransactions {
|
||||
var transaction = TransactionState.init(
|
||||
transaction: clearedTransaction,
|
||||
memos: clearedTransaction.memoCount > 0 ? try await synchronizer.getMemos(for: clearedTransaction) : nil
|
||||
)
|
||||
|
||||
let recipients = await synchronizer.getRecipients(for: clearedTransaction)
|
||||
let addresses = recipients.compactMap {
|
||||
if case let .address(address) = $0 {
|
||||
return address
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
transaction.zAddress = addresses.first?.stringEncoded
|
||||
|
||||
clearedTxs.append(
|
||||
WalletEvent(
|
||||
id: transaction.id,
|
||||
state: clearedTransaction.isSentTransaction ? .sent(transaction) : .received(transaction),
|
||||
timestamp: transaction.timestamp
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
let pendingTxs: [WalletEvent] = pendingTransactions.map {
|
||||
let transaction = TransactionState.init(pendingTransaction: $0, latestBlockHeight: synchronizer.latestScannedHeight)
|
||||
return WalletEvent(id: transaction.id, state: .pending(transaction), timestamp: transaction.timestamp)
|
||||
let transaction = TransactionState.init(pendingTransaction: $0, latestBlockHeight: synchronizer.latestState.latestScannedHeight)
|
||||
return WalletEvent(
|
||||
id: transaction.id,
|
||||
state: .pending(transaction),
|
||||
timestamp: transaction.timestamp
|
||||
)
|
||||
}
|
||||
|
||||
var cTxs = clearedTxs.filter { transaction in
|
||||
pendingTxs.first { pending in
|
||||
pending.id == transaction.id
|
||||
|
|
|
@ -24,10 +24,6 @@ extension SDKSynchronizerClient: TestDependencyKey {
|
|||
rewind: XCTUnimplemented("\(Self.self).rewind", placeholder: Fail(error: "Error").eraseToAnyPublisher()),
|
||||
getShieldedBalance: XCTUnimplemented("\(Self.self).getShieldedBalance", placeholder: WalletBalance.zero),
|
||||
getTransparentBalance: XCTUnimplemented("\(Self.self).getTransparentBalance", placeholder: WalletBalance.zero),
|
||||
getAllSentTransactions: XCTUnimplemented("\(Self.self).getAllSentTransactions", placeholder: []),
|
||||
getAllReceivedTransactions: XCTUnimplemented("\(Self.self).getAllReceivedTransactions", placeholder: []),
|
||||
getAllClearedTransactions: XCTUnimplemented("\(Self.self).getAllClearedTransactions", placeholder: []),
|
||||
getAllPendingTransactions: XCTUnimplemented("\(Self.self).getAllPendingTransactions", placeholder: []),
|
||||
getAllTransactions: XCTUnimplemented("\(Self.self).getAllTransactions", placeholder: []),
|
||||
getUnifiedAddress: XCTUnimplemented("\(Self.self).getUnifiedAddress", placeholder: nil),
|
||||
getTransparentAddress: XCTUnimplemented("\(Self.self).getTransparentAddress", placeholder: nil),
|
||||
|
@ -52,15 +48,11 @@ extension SDKSynchronizerClient {
|
|||
rewind: { _ in return Empty<Void, Error>().eraseToAnyPublisher() },
|
||||
getShieldedBalance: { .zero },
|
||||
getTransparentBalance: { .zero },
|
||||
getAllSentTransactions: { [] },
|
||||
getAllReceivedTransactions: { [] },
|
||||
getAllClearedTransactions: { [] },
|
||||
getAllPendingTransactions: { [] },
|
||||
getAllTransactions: { [] },
|
||||
getUnifiedAddress: { _ in return nil },
|
||||
getTransparentAddress: { _ in return nil },
|
||||
getSaplingAddress: { _ in return nil },
|
||||
sendTransaction: { _, _, _, _ in return EffectTask(value: Result.failure(SynchronizerError.criticalError as NSError)) },
|
||||
sendTransaction: { _, _, _, _ in return EffectTask(value: Result.failure(ZcashError.synchronizerNotPrepared as NSError)) },
|
||||
shieldFunds: { _, _, _ in return .placeholder },
|
||||
wipe: { Empty<Void, Error>().eraseToAnyPublisher() }
|
||||
)
|
||||
|
@ -82,98 +74,6 @@ extension SDKSynchronizerClient {
|
|||
rewind: @escaping (RewindPolicy) -> AnyPublisher<Void, Error> = { _ in return Empty<Void, Error>().eraseToAnyPublisher() },
|
||||
getShieldedBalance: @escaping () -> WalletBalance? = { WalletBalance(verified: Zatoshi(12345000), total: Zatoshi(12345000)) },
|
||||
getTransparentBalance: @escaping () -> WalletBalance? = { WalletBalance(verified: Zatoshi(12345000), total: Zatoshi(12345000)) },
|
||||
getAllSentTransactions: @escaping () -> [WalletEvent] = {
|
||||
let mocked: [TransactionStateMockHelper] = [
|
||||
TransactionStateMockHelper(date: 1651039202, amount: Zatoshi(1), status: .paid(success: false), uuid: "aa11"),
|
||||
TransactionStateMockHelper(date: 1651039101, amount: Zatoshi(2), uuid: "bb22"),
|
||||
TransactionStateMockHelper(date: 1651039000, amount: Zatoshi(3), status: .paid(success: true), uuid: "cc33"),
|
||||
TransactionStateMockHelper(date: 1651039505, amount: Zatoshi(4), uuid: "dd44"),
|
||||
TransactionStateMockHelper(date: 1651039404, amount: Zatoshi(5), uuid: "ee55")
|
||||
]
|
||||
|
||||
return mocked
|
||||
.map {
|
||||
let transaction = TransactionState.placeholder(
|
||||
amount: $0.amount,
|
||||
fee: Zatoshi(10),
|
||||
shielded: $0.shielded,
|
||||
status: $0.status,
|
||||
timestamp: $0.date,
|
||||
uuid: $0.uuid
|
||||
)
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp ?? 0)
|
||||
}
|
||||
},
|
||||
getAllReceivedTransactions: @escaping () -> [WalletEvent] = {
|
||||
let mocked: [TransactionStateMockHelper] = [
|
||||
TransactionStateMockHelper(date: 1651039202, amount: Zatoshi(1), status: .paid(success: false), uuid: "aa11"),
|
||||
TransactionStateMockHelper(date: 1651039101, amount: Zatoshi(2), uuid: "bb22"),
|
||||
TransactionStateMockHelper(date: 1651039000, amount: Zatoshi(3), status: .paid(success: true), uuid: "cc33"),
|
||||
TransactionStateMockHelper(date: 1651039505, amount: Zatoshi(4), uuid: "dd44"),
|
||||
TransactionStateMockHelper(date: 1651039404, amount: Zatoshi(5), uuid: "ee55")
|
||||
]
|
||||
|
||||
return mocked
|
||||
.map {
|
||||
let transaction = TransactionState.placeholder(
|
||||
amount: $0.amount,
|
||||
fee: Zatoshi(10),
|
||||
shielded: $0.shielded,
|
||||
status: $0.status,
|
||||
timestamp: $0.date,
|
||||
uuid: $0.uuid
|
||||
)
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp ?? 0)
|
||||
}
|
||||
},
|
||||
getAllClearedTransactions: @escaping () -> [WalletEvent] = {
|
||||
let mocked: [TransactionStateMockHelper] = [
|
||||
TransactionStateMockHelper(date: 1651039202, amount: Zatoshi(1), status: .paid(success: false), uuid: "aa11"),
|
||||
TransactionStateMockHelper(date: 1651039101, amount: Zatoshi(2), uuid: "bb22"),
|
||||
TransactionStateMockHelper(date: 1651039000, amount: Zatoshi(3), status: .paid(success: true), uuid: "cc33"),
|
||||
TransactionStateMockHelper(date: 1651039505, amount: Zatoshi(4), uuid: "dd44"),
|
||||
TransactionStateMockHelper(date: 1651039404, amount: Zatoshi(5), uuid: "ee55")
|
||||
]
|
||||
|
||||
return mocked
|
||||
.map {
|
||||
let transaction = TransactionState.placeholder(
|
||||
amount: $0.amount,
|
||||
fee: Zatoshi(10),
|
||||
shielded: $0.shielded,
|
||||
status: $0.status,
|
||||
timestamp: $0.date,
|
||||
uuid: $0.uuid
|
||||
)
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp ?? 0)
|
||||
}
|
||||
},
|
||||
getAllPendingTransactions: @escaping () -> [WalletEvent] = {
|
||||
let mocked: [TransactionStateMockHelper] = [
|
||||
TransactionStateMockHelper(
|
||||
date: 1651039606,
|
||||
amount: Zatoshi(6),
|
||||
status: .paid(success: false),
|
||||
uuid: "ff66"
|
||||
),
|
||||
TransactionStateMockHelper(date: 1651039303, amount: Zatoshi(7), uuid: "gg77"),
|
||||
TransactionStateMockHelper(date: 1651039707, amount: Zatoshi(8), status: .paid(success: true), uuid: "hh88"),
|
||||
TransactionStateMockHelper(date: 1651039808, amount: Zatoshi(9), uuid: "ii99")
|
||||
]
|
||||
|
||||
return mocked
|
||||
.map {
|
||||
let transaction = TransactionState.placeholder(
|
||||
amount: $0.amount,
|
||||
fee: Zatoshi(10),
|
||||
shielded: $0.shielded,
|
||||
status: $0.amount.amount > 5 ? .pending : $0.status,
|
||||
timestamp: $0.date,
|
||||
uuid: $0.uuid
|
||||
)
|
||||
return WalletEvent(id: transaction.id, state: .pending(transaction), timestamp: transaction.timestamp)
|
||||
}
|
||||
},
|
||||
getAllTransactions: @escaping () -> [WalletEvent] = {
|
||||
let mockedCleared: [TransactionStateMockHelper] = [
|
||||
TransactionStateMockHelper(date: 1651039202, amount: Zatoshi(1), status: .paid(success: false), uuid: "aa11"),
|
||||
|
@ -193,7 +93,7 @@ extension SDKSynchronizerClient {
|
|||
timestamp: $0.date,
|
||||
uuid: $0.uuid
|
||||
)
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp ?? 0)
|
||||
return WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp ?? 0)
|
||||
}
|
||||
|
||||
let mockedPending: [TransactionStateMockHelper] = [
|
||||
|
@ -292,10 +192,6 @@ extension SDKSynchronizerClient {
|
|||
rewind: rewind,
|
||||
getShieldedBalance: getShieldedBalance,
|
||||
getTransparentBalance: getTransparentBalance,
|
||||
getAllSentTransactions: getAllSentTransactions,
|
||||
getAllReceivedTransactions: getAllReceivedTransactions,
|
||||
getAllClearedTransactions: getAllClearedTransactions,
|
||||
getAllPendingTransactions: getAllPendingTransactions,
|
||||
getAllTransactions: getAllTransactions,
|
||||
getUnifiedAddress: getUnifiedAddress,
|
||||
getTransparentAddress: getTransparentAddress,
|
||||
|
|
|
@ -322,7 +322,7 @@ extension HomeStore {
|
|||
settingsState: .placeholder,
|
||||
shieldedBalance: Balance.zero,
|
||||
synchronizerStatusSnapshot: .snapshotFor(
|
||||
state: .error(SynchronizerError.syncFailed)
|
||||
state: .error(ZcashError.synchronizerNotPrepared)
|
||||
),
|
||||
walletConfig: .default,
|
||||
walletEventsState: .emptyPlaceHolder
|
||||
|
|
|
@ -119,7 +119,7 @@ extension RootReducer {
|
|||
try mnemonic.isValid(storedWallet.seedPhrase.value())
|
||||
let seedBytes = try mnemonic.toSeed(storedWallet.seedPhrase.value())
|
||||
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0)
|
||||
let viewingKey = try spendingKey.deriveFullViewingKey()
|
||||
let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(spendingKey)
|
||||
|
||||
return .run { send in
|
||||
do {
|
||||
|
|
|
@ -33,11 +33,12 @@ struct TransactionDetailView: View {
|
|||
.padding()
|
||||
address(mark: .inactive, viewStore: viewStore)
|
||||
memo(transaction, viewStore, mark: .highlight)
|
||||
|
||||
case .received:
|
||||
Text(L10n.Transaction.youReceived(transaction.zecAmount.decimalString(), TargetConstants.tokenName))
|
||||
.padding()
|
||||
address(mark: .inactive, viewStore: viewStore)
|
||||
memo(transaction, viewStore, mark: .highlight)
|
||||
|
||||
case .failed:
|
||||
Text(L10n.Transaction.youDidNotSent(transaction.zecAmount.decimalString(), TargetConstants.tokenName))
|
||||
.padding()
|
||||
|
|
|
@ -115,7 +115,9 @@ extension TransactionState {
|
|||
fee = Zatoshi(10)
|
||||
minedHeight = pendingTransaction.minedHeight
|
||||
errorMessage = pendingTransaction.errorMessage
|
||||
|
||||
if let data = pendingTransaction.memo, let memo = try? Memo(bytes: [UInt8](data)) {
|
||||
memos = [memo]
|
||||
}
|
||||
switch pendingTransaction.recipient {
|
||||
case let .address(recipient):
|
||||
zAddress = recipient.stringEncoded
|
||||
|
|
|
@ -14,7 +14,7 @@ import ZcashLightClientKit
|
|||
|
||||
struct WalletEvent: Equatable, Identifiable, Redactable {
|
||||
enum WalletEventState: Equatable {
|
||||
case send(TransactionState)
|
||||
case sent(TransactionState)
|
||||
case pending(TransactionState)
|
||||
case received(TransactionState)
|
||||
case failed(TransactionState)
|
||||
|
@ -32,7 +32,7 @@ struct WalletEvent: Equatable, Identifiable, Redactable {
|
|||
extension WalletEvent {
|
||||
@ViewBuilder func rowView(_ viewStore: WalletEventsFlowViewStore) -> some View {
|
||||
switch state {
|
||||
case .send(let transaction),
|
||||
case .sent(let transaction),
|
||||
.pending(let transaction),
|
||||
.received(let transaction),
|
||||
.failed(let transaction):
|
||||
|
@ -56,7 +56,7 @@ extension WalletEvent {
|
|||
extension WalletEvent {
|
||||
@ViewBuilder func detailView(_ store: WalletEventsFlowStore) -> some View {
|
||||
switch state {
|
||||
case .send(let transaction),
|
||||
case .sent(let transaction),
|
||||
.pending(let transaction),
|
||||
.received(let transaction),
|
||||
.failed(let transaction):
|
||||
|
@ -83,7 +83,7 @@ private extension WalletEvent {
|
|||
case 3: return .shielded(Zatoshi(234_000_000))
|
||||
case 4: return .walletImport(BlockHeight(1_629_724))
|
||||
case 5: return .pending(.statePlaceholder(.pending))
|
||||
default: return .send(.placeholder)
|
||||
default: return .sent(.placeholder)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ private extension WalletEvent {
|
|||
case 0: return .received(.statePlaceholder(.received))
|
||||
case 1: return .failed(.statePlaceholder(.failed))
|
||||
case 2: return .pending(.statePlaceholder(.pending))
|
||||
case 3: return .send(.placeholder)
|
||||
default: return .send(.placeholder)
|
||||
case 3: return .sent(.placeholder)
|
||||
default: return .sent(.placeholder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class BalanceBreakdownTests: XCTestCase {
|
|||
reducer: BalanceBreakdownReducer()
|
||||
)
|
||||
|
||||
store.dependencies.sdkSynchronizer = .mocked(shieldFunds: { _, _, _ in throw SynchronizerError.criticalError })
|
||||
store.dependencies.sdkSynchronizer = .mocked(shieldFunds: { _, _, _ in throw ZcashError.synchronizerNotPrepared })
|
||||
store.dependencies.derivationTool = .liveValue
|
||||
store.dependencies.mnemonic = .mock
|
||||
store.dependencies.walletStorage.exportWallet = { .placeholder }
|
||||
|
@ -76,11 +76,17 @@ class BalanceBreakdownTests: XCTestCase {
|
|||
await store.send(.shieldFunds) { state in
|
||||
state.shieldingFunds = true
|
||||
}
|
||||
await store.receive(.shieldFundsFailure(SynchronizerError.criticalError.localizedDescription)) { state in
|
||||
await store.receive(.shieldFundsFailure(ZcashError.synchronizerNotPrepared.localizedDescription)) { state in
|
||||
state.shieldingFunds = false
|
||||
}
|
||||
|
||||
await store.receive(.alert(.balanceBreakdown(.shieldFundsFailure("A critical Error Occurred"))))
|
||||
await store.receive(
|
||||
.alert(
|
||||
.balanceBreakdown(
|
||||
.shieldFundsFailure("The operation couldn’t be completed. (ZcashLightClientKit.ZcashError error 168.)")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// long-living (cancelable) effects need to be properly canceled.
|
||||
// the .onDisappear action cancels the observer of the synchronizer status change.
|
||||
|
|
|
@ -61,7 +61,6 @@ class HomeTests: XCTestCase {
|
|||
|
||||
// expected side effects as a result of .onAppear registration
|
||||
store.receive(.updateDestination(nil))
|
||||
store.receive(.resolveReviewRequest)
|
||||
store.receive(.synchronizerStateChanged(.zero)) { state in
|
||||
state.synchronizerStatusSnapshot = SyncStatusSnapshot.snapshotFor(state: .unprepared)
|
||||
}
|
||||
|
@ -89,15 +88,13 @@ class HomeTests: XCTestCase {
|
|||
state.destination = .notEnoughFreeDiskSpace
|
||||
}
|
||||
|
||||
store.receive(.resolveReviewRequest)
|
||||
|
||||
// long-living (cancelable) effects need to be properly canceled.
|
||||
// the .onDisappear action cancels the observer of the synchronizer status change.
|
||||
store.send(.onDisappear)
|
||||
}
|
||||
|
||||
func testSynchronizerErrorBringsUpAlert() {
|
||||
let testError = SynchronizerError.syncFailed
|
||||
let testError = ZcashError.synchronizerNotPrepared
|
||||
let errorSnapshot = SyncStatusSnapshot.snapshotFor(
|
||||
state: .error(testError)
|
||||
)
|
||||
|
@ -116,6 +113,12 @@ class HomeTests: XCTestCase {
|
|||
|
||||
store.receive(.showSynchronizerErrorAlert(errorSnapshot))
|
||||
|
||||
store.receive(.alert(.home(.syncFailed("Error: Synchronizer failed", "Dismiss"))))
|
||||
store.receive(
|
||||
.alert(
|
||||
.home(
|
||||
.syncFailed("Error: The operation couldn’t be completed. (ZcashLightClientKit.ZcashError error 168.)", "Dismiss")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ class SendTests: XCTestCase {
|
|||
}
|
||||
|
||||
// check the failure transaction to be received back
|
||||
await store.receive(.sendTransactionResult(Result.failure(SynchronizerError.criticalError as NSError))) { state in
|
||||
await store.receive(.sendTransactionResult(Result.failure(ZcashError.synchronizerNotPrepared as NSError))) { state in
|
||||
// from this moment on the sending next transaction is allowed again
|
||||
// the 'isSendingTransaction' needs to be false again
|
||||
state.isSendingTransaction = false
|
||||
|
|
|
@ -30,7 +30,7 @@ class HomeSnapshotTests: XCTestCase {
|
|||
)
|
||||
transaction.zAddress = "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po"
|
||||
|
||||
return WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
return WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp)
|
||||
}
|
||||
|
||||
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
||||
|
|
|
@ -49,7 +49,7 @@ class WalletEventsSnapshotTests: XCTestCase {
|
|||
zecAmount: Zatoshi(25_000_000)
|
||||
)
|
||||
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp)
|
||||
|
||||
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
||||
let store = HomeStore(
|
||||
|
@ -102,7 +102,7 @@ class WalletEventsSnapshotTests: XCTestCase {
|
|||
zecAmount: Zatoshi(25_000_000)
|
||||
)
|
||||
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp)
|
||||
|
||||
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
||||
let store = HomeStore(
|
||||
|
@ -155,7 +155,7 @@ class WalletEventsSnapshotTests: XCTestCase {
|
|||
zecAmount: Zatoshi(25_000_000)
|
||||
)
|
||||
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp)
|
||||
|
||||
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
||||
let store = HomeStore(
|
||||
|
@ -214,7 +214,7 @@ class WalletEventsSnapshotTests: XCTestCase {
|
|||
zecAmount: Zatoshi(25_000_000)
|
||||
)
|
||||
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
||||
let walletEvent = WalletEvent(id: transaction.id, state: .sent(transaction), timestamp: transaction.timestamp)
|
||||
|
||||
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
||||
let store = HomeStore(
|
||||
|
|
|
@ -63,7 +63,7 @@ class WalletEventsTests: XCTestCase {
|
|||
)
|
||||
return WalletEvent(
|
||||
id: transaction.id,
|
||||
state: transaction.status == .pending ? .pending(transaction) : .send(transaction),
|
||||
state: transaction.status == .pending ? .pending(transaction) : .sent(transaction),
|
||||
timestamp: transaction.timestamp
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue