FFI' redactPCZTForSigner adopted
- Plus code cleanup after rebase
This commit is contained in:
parent
90cee937d1
commit
1f7df3c84d
|
@ -99,7 +99,8 @@ let package = Package(
|
|||
.package(url: "https://github.com/pointfreeco/swift-url-routing", from: "0.6.2"),
|
||||
.package(url: "https://github.com/zcash-hackworks/MnemonicSwift", from: "2.2.4"),
|
||||
// .package(url: "https://github.com/Electric-Coin-Company/zcash-swift-wallet-sdk", from: "2.2.8"),
|
||||
.package(url: "https://github.com/LukasKorba/ZcashLightClientKit", branch: "1526-Failed-transaction-timestamps"),
|
||||
// .package(url: "https://github.com/LukasKorba/ZcashLightClientKit", branch: "1526-Failed-transaction-timestamps"),
|
||||
.package(url: "https://github.com/LukasKorba/ZcashLightClientKit", branch: "preview-ffi-0.13.0"),
|
||||
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "11.6.0"),
|
||||
.package(url: "https://github.com/flexa/flexa-ios.git", from: "1.0.9"),
|
||||
.package(url: "https://github.com/pacu/zcash-swift-payment-uri", from: "0.1.0-beta.10"),
|
||||
|
@ -347,10 +348,8 @@ let package = Package(
|
|||
dependencies: [
|
||||
"Generated",
|
||||
"Models",
|
||||
"SDKSynchronizer",
|
||||
"TaxExporter",
|
||||
"UIComponents",
|
||||
"Utils",
|
||||
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
|
||||
],
|
||||
path: "Sources/Features/ExportTransactionHistory"
|
||||
|
|
|
@ -74,7 +74,8 @@ public struct SDKSynchronizerClient {
|
|||
public var addProofsToPCZT: (Pczt) async throws -> Pczt
|
||||
public var createTransactionFromPCZT: (Pczt, Pczt) async throws -> CreateProposedTransactionsResult
|
||||
public var urEncoderForPCZT: (Pczt) -> UREncoder?
|
||||
|
||||
public var redactPCZTForSigner: (Pczt) async throws -> Pczt
|
||||
|
||||
// Search
|
||||
public var fetchTxidsWithMemoContaining: (String) async throws -> [Data]
|
||||
}
|
||||
|
|
|
@ -267,6 +267,9 @@ extension SDKSynchronizerClient: DependencyKey {
|
|||
|
||||
return encoder
|
||||
},
|
||||
redactPCZTForSigner: { pczt in
|
||||
try await synchronizer.redactPCZTForSigner(pczt: pczt)
|
||||
},
|
||||
fetchTxidsWithMemoContaining: { searchTerm in
|
||||
try await synchronizer.fetchTxidsWithMemoContaining(searchTerm: searchTerm)
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ extension SDKSynchronizerClient: TestDependencyKey {
|
|||
addProofsToPCZT: unimplemented("\(Self.self).addProofsToPCZT", placeholder: Pczt()),
|
||||
createTransactionFromPCZT: unimplemented("\(Self.self).createTransactionFromPCZT", placeholder: .success(txIds: [])),
|
||||
urEncoderForPCZT: unimplemented("\(Self.self).urEncoderForPCZT", placeholder: nil),
|
||||
redactPCZTForSigner: unimplemented("\(Self.self).redactPCZTForSigner", placeholder: Pczt()),
|
||||
fetchTxidsWithMemoContaining: unimplemented("\(Self.self).fetchTxidsWithMemoContaining", placeholder: [])
|
||||
)
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ extension SDKSynchronizerClient {
|
|||
addProofsToPCZT: { _ in Pczt() },
|
||||
createTransactionFromPCZT: { _, _ in .success(txIds: []) },
|
||||
urEncoderForPCZT: { _ in nil },
|
||||
redactPCZTForSigner: { _ in Pczt() },
|
||||
fetchTxidsWithMemoContaining: { _ in [] }
|
||||
)
|
||||
|
||||
|
@ -191,6 +193,7 @@ extension SDKSynchronizerClient {
|
|||
addProofsToPCZT: @escaping (Data) async throws -> Pczt = { _ in Pczt() },
|
||||
createTransactionFromPCZT: @escaping (Pczt, Pczt) async throws -> CreateProposedTransactionsResult = { _, _ in .success(txIds: []) },
|
||||
urEncoderForPCZT: @escaping (Pczt) -> UREncoder? = { _ in nil },
|
||||
redactPCZTForSigner: @escaping (Pczt) async throws -> Pczt = { _ in Pczt() },
|
||||
fetchTxidsWithMemoContaining: @escaping (String) async throws -> [Data] = { _ in [] }
|
||||
) -> SDKSynchronizerClient {
|
||||
SDKSynchronizerClient(
|
||||
|
@ -225,6 +228,7 @@ extension SDKSynchronizerClient {
|
|||
addProofsToPCZT: addProofsToPCZT,
|
||||
createTransactionFromPCZT: createTransactionFromPCZT,
|
||||
urEncoderForPCZT: urEncoderForPCZT,
|
||||
redactPCZTForSigner: redactPCZTForSigner,
|
||||
fetchTxidsWithMemoContaining: fetchTxidsWithMemoContaining
|
||||
)
|
||||
}
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
import Foundation
|
||||
import ComposableArchitecture
|
||||
import ZcashLightClientKit
|
||||
import Models
|
||||
import Generated
|
||||
import Utils
|
||||
import SwiftUI
|
||||
import ZcashSDKEnvironment
|
||||
import TaxExporter
|
||||
import SDKSynchronizer
|
||||
import Models
|
||||
|
||||
@Reducer
|
||||
public struct ExportTransactionHistory {
|
||||
|
@ -24,6 +20,7 @@ public struct ExportTransactionHistory {
|
|||
public var isExportingData = false
|
||||
public var dataURL: URL = .emptyURL
|
||||
@Shared(.inMemory(.selectedWalletAccount)) public var selectedWalletAccount: WalletAccount? = nil
|
||||
@Shared(.inMemory(.transactions)) public var transactions: IdentifiedArrayOf<TransactionState> = []
|
||||
|
||||
public var isExportPossible: Bool {
|
||||
!isExportingData
|
||||
|
@ -38,7 +35,6 @@ public struct ExportTransactionHistory {
|
|||
|
||||
public enum Action: Equatable {
|
||||
case exportRequested
|
||||
case onAppear
|
||||
case preparationOfUrlsFailed
|
||||
case shareFinished
|
||||
case urlsPrepared(URL)
|
||||
|
@ -46,36 +42,24 @@ public struct ExportTransactionHistory {
|
|||
|
||||
public init() { }
|
||||
|
||||
@Dependency(\.mainQueue) var mainQueue
|
||||
@Dependency(\.taxExporter) var taxExporter
|
||||
@Dependency(\.sdkSynchronizer) var sdkSynchronizer
|
||||
|
||||
public var body: some Reducer<State, Action> {
|
||||
Reduce { state, action in
|
||||
switch action {
|
||||
case .onAppear:
|
||||
return .none
|
||||
|
||||
case .exportRequested:
|
||||
guard let account = state.selectedWalletAccount else {
|
||||
return .none
|
||||
}
|
||||
state.isExportingData = true
|
||||
return .run { send in
|
||||
var url: URL = .emptyURL
|
||||
|
||||
if let transactions = try? await sdkSynchronizer.getAllTransactions(account.id) {
|
||||
let accountName = account.vendor.name()
|
||||
do {
|
||||
url = try taxExporter.cointrackerCSVfor(transactions, accountName)
|
||||
} catch {
|
||||
await send(.preparationOfUrlsFailed)
|
||||
}
|
||||
}
|
||||
|
||||
await send(.urlsPrepared(url))
|
||||
let accountName = account.vendor.name()
|
||||
do {
|
||||
let url = try taxExporter.cointrackerCSVfor(state.transactions.elements, accountName)
|
||||
return .send(.urlsPrepared(url))
|
||||
} catch {
|
||||
return .send(.preparationOfUrlsFailed)
|
||||
}
|
||||
|
||||
|
||||
case .preparationOfUrlsFailed:
|
||||
state.isExportingData = false
|
||||
return .none
|
||||
|
|
|
@ -50,7 +50,6 @@ public struct ExportTransactionHistoryView: View {
|
|||
}
|
||||
}
|
||||
.zashiBack()
|
||||
.onAppear { store.send(.onAppear)}
|
||||
.walletStatusPanel()
|
||||
|
||||
shareLogsView()
|
||||
|
|
|
@ -89,6 +89,7 @@ public struct SendConfirmation {
|
|||
public var randomSuccessIconIndex = 0
|
||||
public var randomFailureIconIndex = 0
|
||||
public var randomResubmissionIconIndex = 0
|
||||
public var redactedPcztForSigner: Pczt?
|
||||
public var rejectSendRequest = false
|
||||
public var result: Result?
|
||||
public var scanState: Scan.State = .initial
|
||||
|
@ -206,6 +207,8 @@ public struct SendConfirmation {
|
|||
case pcztResolved(Pczt)
|
||||
case pcztSendFailed(ZcashError?)
|
||||
case pcztWithProofsResolved(Pczt)
|
||||
case redactedPCZTForSigner(Pczt)
|
||||
case redactPCZTForSigner
|
||||
case resetPCZTs
|
||||
case resolvePCZT
|
||||
case sharePCZT
|
||||
|
@ -317,8 +320,7 @@ public struct SendConfirmation {
|
|||
return .none
|
||||
}
|
||||
return .run { send in
|
||||
if await !localAuthentication.authenticate() {
|
||||
await send(.sendFailed(nil, true))
|
||||
guard await localAuthentication.authenticate() else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -536,8 +538,34 @@ public struct SendConfirmation {
|
|||
|
||||
case .pcztResolved(let pczt):
|
||||
state.pczt = pczt
|
||||
return .send(.addProofsToPczt)
|
||||
return .merge(
|
||||
.send(.addProofsToPczt),
|
||||
.send(.redactPCZTForSigner)
|
||||
)
|
||||
|
||||
case .redactPCZTForSigner:
|
||||
guard let pczt = state.pczt else {
|
||||
return .run { send in
|
||||
try? await mainQueue.sleep(for: .seconds(Constants.delay))
|
||||
await send(.updateFailedData(-797, "redactPCZTForSigner failed to start the process", ""))
|
||||
await send(.pcztSendFailed("redactPCZTForSigner failed to start the process".toZcashError()))
|
||||
}
|
||||
}
|
||||
return .run { send in
|
||||
do {
|
||||
let redactedPczt = try await sdkSynchronizer.redactPCZTForSigner(Pczt(pczt))
|
||||
await send(.redactedPCZTForSigner(redactedPczt))
|
||||
} catch {
|
||||
try? await mainQueue.sleep(for: .seconds(Constants.delay))
|
||||
await send(.updateFailedData(-796, error.toZcashError().detailedMessage, ""))
|
||||
await send(.pcztSendFailed("redactPCZTForSigner failed".toZcashError()))
|
||||
}
|
||||
}
|
||||
|
||||
case .redactedPCZTForSigner(let redactedPczt):
|
||||
state.redactedPcztForSigner = redactedPczt
|
||||
return .none
|
||||
|
||||
case .addProofsToPczt:
|
||||
guard let pczt = state.pczt else {
|
||||
return .run { send in
|
||||
|
@ -573,7 +601,10 @@ public struct SendConfirmation {
|
|||
let pcztMessage =
|
||||
"""
|
||||
original pczt:
|
||||
\(state.pczt!.hexEncodedString())
|
||||
\(state.pczt?.hexEncodedString() ?? "failed to unwrap")
|
||||
|
||||
redactedPcztForSigner:
|
||||
\(state.redactedPcztForSigner?.hexEncodedString() ?? "failed to unwrap")
|
||||
|
||||
pcztWithProofs:
|
||||
\(pcztWithProofs.hexEncodedString())
|
||||
|
|
|
@ -84,7 +84,7 @@ public struct SignWithKeystoneView: View {
|
|||
}
|
||||
.padding(.top, 40)
|
||||
|
||||
if let pczt = store.pczt, let encoder = sdkSynchronizer.urEncoderForPCZT(Pczt(pczt)), !isPresented {
|
||||
if let pczt = store.redactedPcztForSigner, let encoder = sdkSynchronizer.urEncoderForPCZT(Pczt(pczt)), !isPresented {
|
||||
AnimatedQRCode(urEncoder: encoder, size: 250)
|
||||
.frame(width: 216, height: 216)
|
||||
.padding(24)
|
||||
|
@ -210,7 +210,7 @@ public struct SignWithKeystoneView: View {
|
|||
.navigationBarTitleDisplayMode(.inline)
|
||||
.screenTitle(L10n.Keystone.SignWith.signTransaction)
|
||||
.overlay {
|
||||
if let pczt = store.pczt, let encoder = sdkSynchronizer.urEncoderForPCZT(Pczt(pczt)), isPresented {
|
||||
if let pczt = store.redactedPcztForSigner, let encoder = sdkSynchronizer.urEncoderForPCZT(Pczt(pczt)), isPresented {
|
||||
Color.black.opacity(0.9)
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
.onTapGesture {
|
||||
|
|
|
@ -2514,7 +2514,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "zashi-internal.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_ASSET_PATHS = "\"secant/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = RLPRR8CPQG;
|
||||
|
@ -2527,7 +2527,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 0.4.10;
|
||||
MARKETING_VERSION = 0.4.11;
|
||||
OTHER_SWIFT_FLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "co.electriccoin.secant-testnet";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -2545,7 +2545,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "zashi-internal.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"secant/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = RLPRR8CPQG;
|
||||
ENABLE_BITCODE = NO;
|
||||
|
@ -2557,7 +2557,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 0.4.10;
|
||||
MARKETING_VERSION = 0.4.11;
|
||||
OTHER_SWIFT_FLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "co.electriccoin.secant-testnet";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -2575,7 +2575,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "zashi-internal.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"secant/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = RLPRR8CPQG;
|
||||
ENABLE_BITCODE = NO;
|
||||
|
@ -2587,7 +2587,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 0.4.10;
|
||||
MARKETING_VERSION = 0.4.11;
|
||||
OTHER_SWIFT_FLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "co.electriccoin.secant-testnet";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
|
@ -554,8 +554,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Electric-Coin-Company/zcash-light-client-ffi",
|
||||
"state" : {
|
||||
"revision" : "11b0db058288b12ada9c5a95ed56f17f82d2868f",
|
||||
"version" : "0.12.0"
|
||||
"revision" : "8e7f8207b5f225cfe6b1e5cbc096fcd24b96776b"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -572,8 +571,8 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/LukasKorba/ZcashLightClientKit",
|
||||
"state" : {
|
||||
"branch" : "1526-Failed-transaction-timestamps",
|
||||
"revision" : "4c7b8004ebcc65f513c5116c11c0180176787bf0"
|
||||
"branch" : "preview-ffi-0.13.0",
|
||||
"revision" : "970d6edbbba2f696c5f3256a6d4f7c29d503493c"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue