diff --git a/DerivationToolTests/DerivationToolTests.swift b/DerivationToolTests/DerivationToolTests.swift index 94f77e74..edc4db3d 100644 --- a/DerivationToolTests/DerivationToolTests.swift +++ b/DerivationToolTests/DerivationToolTests.swift @@ -4,7 +4,7 @@ // // Created by Francisco Gindre on 10/9/20. // - +//swiftlint:disable force_unwrapping import XCTest import ZcashLightClientKit diff --git a/ZcashLightClientKit/Block/DatabaseStorage/DatabaseMigrationManager.swift b/ZcashLightClientKit/Block/DatabaseStorage/DatabaseMigrationManager.swift index 05557a56..182fd79c 100644 --- a/ZcashLightClientKit/Block/DatabaseStorage/DatabaseMigrationManager.swift +++ b/ZcashLightClientKit/Block/DatabaseStorage/DatabaseMigrationManager.swift @@ -151,7 +151,6 @@ class MigrationManager { } let derivationTool = DerivationTool.default - for tuple in zip(accounts, viewingKeys) { let tAddr = try derivationTool.deriveTransparentAddressFromPublicKey(tuple.1.extpub) var account = tuple.0 diff --git a/ZcashLightClientKit/Block/Processor/CompactBlockDownloadOperation.swift b/ZcashLightClientKit/Block/Processor/CompactBlockDownloadOperation.swift index 742cf728..7e9d85f7 100644 --- a/ZcashLightClientKit/Block/Processor/CompactBlockDownloadOperation.swift +++ b/ZcashLightClientKit/Block/Processor/CompactBlockDownloadOperation.swift @@ -138,7 +138,6 @@ class CompactBlockStreamDownloadOperation: ZcashOperation { } } - class CompactBlockBatchDownloadOperation: ZcashOperation { enum CompactBlockBatchDownloadOperationError: Error { case startHeightMissing diff --git a/ZcashLightClientKit/Block/Processor/CompactBlockProcessor.swift b/ZcashLightClientKit/Block/Processor/CompactBlockProcessor.swift index a68fffb8..854f1147 100644 --- a/ZcashLightClientKit/Block/Processor/CompactBlockProcessor.swift +++ b/ZcashLightClientKit/Block/Processor/CompactBlockProcessor.swift @@ -93,7 +93,6 @@ public enum CompactBlockProgress { } } - protocol EnhancementStreamDelegate: AnyObject { func transactionEnhancementProgressUpdated(_ progress: EnhancementProgress) } @@ -116,7 +115,6 @@ public struct EnhancementStreamProgress: EnhancementProgress { } } - public extension Notification.Name { /** Processing progress update @@ -503,7 +501,6 @@ public class CompactBlockProcessor { func validateServerInfo(_ info: LightWalletdInfo) throws { - do { // check network types guard let remoteNetworkType = ZcashSDK.NetworkType(info.chainName) else { @@ -560,7 +557,6 @@ public class CompactBlockProcessor { public func rewindTo(_ height: BlockHeight?) throws -> BlockHeight { self.stop() - let lastDownloaded = try downloader.lastDownloadedBlockHeight() let height = Int32(height ?? lastDownloaded) let nearestHeight = rustBackend.getNearestRewindHeight(dbData: config.dataDb, height: height) @@ -810,7 +806,7 @@ public class CompactBlockProcessor { func notifyProgress(_ progress: CompactBlockProgress) { - var userInfo = [AnyHashable : Any]() + var userInfo = [AnyHashable: Any]() userInfo[CompactBlockProcessorNotificationKey.progress] = progress LoggerProxy.debug(""" @@ -1248,7 +1244,6 @@ extension CompactBlockProcessor: CompactBlockProgressDelegate { } } - extension CompactBlockProcessor: EnhancementStreamDelegate { func transactionEnhancementProgressUpdated(_ progress: EnhancementProgress) { NotificationCenter.default.post(name: .blockProcessorEnhancementProgress, object: self, userInfo: [ CompactBlockProcessorNotificationKey.enhancementProgress : progress]) diff --git a/ZcashLightClientKit/Block/Processor/CompactBlockScanningOperation.swift b/ZcashLightClientKit/Block/Processor/CompactBlockScanningOperation.swift index add738fb..5ed85094 100644 --- a/ZcashLightClientKit/Block/Processor/CompactBlockScanningOperation.swift +++ b/ZcashLightClientKit/Block/Processor/CompactBlockScanningOperation.swift @@ -65,7 +65,7 @@ public class SDKMetrics { static func blockReportFromNotification(_ notification: Notification) -> BlockMetricReport? { guard notification.name == notificationName, - let info = notification.userInfo, + let info = notification.userInfo, let startHeight = info[startBlockHeightKey] as? BlockHeight, let targetHeight = info[targetBlockHeightKey] as? BlockHeight, let task = info[taskReportedKey] as? TaskReported, diff --git a/ZcashLightClientKit/Block/Processor/ZcashOperation.swift b/ZcashLightClientKit/Block/Processor/ZcashOperation.swift index b5e5674a..ae68c421 100644 --- a/ZcashLightClientKit/Block/Processor/ZcashOperation.swift +++ b/ZcashLightClientKit/Block/Processor/ZcashOperation.swift @@ -37,9 +37,7 @@ class ZcashOperation: Operation { self.init() self.handlerDispatchQueue = completionDispatchQueue } - - - + func shouldCancel() -> Bool { self.error != nil || isCancelled || dependencyCancelled() } diff --git a/ZcashLightClientKit/Entity/AccountEntity.swift b/ZcashLightClientKit/Entity/AccountEntity.swift index 5e5c351a..7efe8e8f 100644 --- a/ZcashLightClientKit/Entity/AccountEntity.swift +++ b/ZcashLightClientKit/Entity/AccountEntity.swift @@ -14,7 +14,6 @@ protocol AccountEntity { var transparentAddress: String { get set } } - struct Account: AccountEntity, Encodable, Decodable { enum CodingKeys: String, CodingKey { @@ -129,7 +128,7 @@ class AccountSQDAO: AccountRepository { class CachingAccountDao: AccountRepository { var dao: AccountRepository - lazy var cache: [Int : AccountEntity] = { + lazy var cache: [Int: AccountEntity] = { var c = [Int : AccountEntity]() guard let all = try? dao.getAll() else { return c @@ -146,7 +145,7 @@ class CachingAccountDao: AccountRepository { func getAll() throws -> [AccountEntity] { guard cache.isEmpty else { - return cache.values.sorted(by: {$0.account < $1.account}) + return cache.values.sorted(by: { $0.account < $1.account }) } let all = try dao.getAll() diff --git a/ZcashLightClientKit/Initializer.swift b/ZcashLightClientKit/Initializer.swift index b5227355..193ba0d7 100644 --- a/ZcashLightClientKit/Initializer.swift +++ b/ZcashLightClientKit/Initializer.swift @@ -149,9 +149,7 @@ public class Initializer { self.walletBirthday = WalletBirthday.birthday(with: walletBirthday) } - /** - Initialize the wallet with the given seed and return the related private keys for each account specified or null if the wallet was previously initialized and block data exists on disk. When this method returns null, that signals that the wallet will need to retrieve the diff --git a/ZcashLightClientKit/Model/WalletTypes.swift b/ZcashLightClientKit/Model/WalletTypes.swift index be9c228c..190e0082 100644 --- a/ZcashLightClientKit/Model/WalletTypes.swift +++ b/ZcashLightClientKit/Model/WalletTypes.swift @@ -32,12 +32,10 @@ public struct WalletBirthday { public private(set) var tree: String = "" } - /** Groups a Sapling Extended Full Viewing Key an a tranparent address extended public key. */ - public typealias ExtendedFullViewingKey = String public typealias ExtendedPublicKey = String @@ -46,7 +44,6 @@ public protocol UnifiedViewingKey { var extpub: ExtendedPublicKey { get set } } - public typealias TransparentAddress = String public typealias SaplingShieldedAddress = String diff --git a/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/ZcashLightClientKit/Rust/ZcashRustBackend.swift index 16e33187..d614f469 100644 --- a/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -125,11 +125,9 @@ class ZcashRustBackend: ZcashRustBackendWelding { let extpubPtr = UnsafeMutablePointer.allocate(capacity: extpubCStr.count) extpubPtr.initialize(from:extpubCStr, count: extpubCStr.count) - ffiUvks.append(FFIUnifiedViewingKey(extfvk: extfvkPtr, extpub: extpubPtr)) } - var result = false ffiUvks.withContiguousMutableStorageIfAvailable { p in let slice = UnsafeMutablePointer.allocate(capacity: 1) @@ -137,7 +135,6 @@ class ZcashRustBackend: ZcashRustBackendWelding { result = zcashlc_init_accounts_table_with_keys(dbData.0, dbData.1, slice) slice.deinitialize(count: 1) -// slice.deallocate() } defer { diff --git a/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift b/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift index 81b74d5e..b46a68c7 100644 --- a/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift +++ b/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift @@ -72,7 +72,6 @@ public protocol ZcashRustBackendWelding { */ static func initAccountsTable(dbData: URL, uvks: [UnifiedViewingKey]) throws -> Bool - /** initialize the blocks table from a given checkpoint (birthday) - Parameters: @@ -199,7 +198,6 @@ public protocol ZcashRustBackendWelding { */ static func putUnspentTransparentOutput(dbData: URL, address: String, txid: [UInt8], index: Int, script: [UInt8], value: Int64, height: BlockHeight) throws -> Bool - /** clears the cached utxos for the given address from the specified height on - Parameters: diff --git a/ZcashLightClientKit/Service/LightWalletGRPCService.swift b/ZcashLightClientKit/Service/LightWalletGRPCService.swift index 5f0157f3..e7811da4 100644 --- a/ZcashLightClientKit/Service/LightWalletGRPCService.swift +++ b/ZcashLightClientKit/Service/LightWalletGRPCService.swift @@ -314,7 +314,6 @@ extension LightWalletGRPCService: LightWalletService { case .ok: result(.success(blocks.asZcashCompactBlocks())) - default: result(.failure(.mapCode(status))) } diff --git a/ZcashLightClientKit/Synchronizer.swift b/ZcashLightClientKit/Synchronizer.swift index ba3ccd37..304e3d7e 100644 --- a/ZcashLightClientKit/Synchronizer.swift +++ b/ZcashLightClientKit/Synchronizer.swift @@ -74,7 +74,6 @@ public enum ConnectionState { case shutdown } - /** Primary interface for interacting with the SDK. Defines the contract that specific implementations like SdkSynchronizer fulfill. @@ -291,7 +290,6 @@ public enum SyncStatus: Equatable { } } - /** Kind of transactions handled by a Synchronizer */ @@ -315,9 +313,6 @@ public enum RewindPolicy { case quick } - - - extension SyncStatus { public static func == (lhs: SyncStatus, rhs: SyncStatus) -> Bool { switch lhs { diff --git a/ZcashLightClientKit/Tool/DerivationTool.swift b/ZcashLightClientKit/Tool/DerivationTool.swift index 9c08805f..0c792e9b 100644 --- a/ZcashLightClientKit/Tool/DerivationTool.swift +++ b/ZcashLightClientKit/Tool/DerivationTool.swift @@ -326,10 +326,8 @@ extension DerivationTool: KeyValidation { throw KeyDerivationErrors.derivationError(underlyingError: error) } } - } - fileprivate struct ConcreteUnifiedAddress: UnifiedAddress { var tAddress: TransparentAddress var zAddress: SaplingShieldedAddress diff --git a/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift b/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift index bb028be0..ae76e6ed 100644 --- a/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift +++ b/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift @@ -327,9 +327,7 @@ public class SDKSynchronizer: Synchronizer { let progress = userInfo[CompactBlockProcessorNotificationKey.progress] as? CompactBlockProgress else { return } - var blockDate: Date? = nil - self.notify(progress: progress) } @@ -608,7 +606,6 @@ public class SDKSynchronizer: Synchronizer { var height: BlockHeight? - switch policy { case .quick: break @@ -637,7 +634,7 @@ public class SDKSynchronizer: Synchronizer { // MARK: notify state private func notify(progress: CompactBlockProgress) { - var userInfo = [AnyHashable : Any]() + var userInfo = [AnyHashable: Any]() userInfo[NotificationKeys.progress] = progress userInfo[NotificationKeys.blockHeight] = progress.progressHeight userInfo[NotificationKeys.blockDate] = progress.progressHeight @@ -807,8 +804,6 @@ extension ConnectionState { } } - - fileprivate struct NullEnhancementProgress: EnhancementProgress { var totalTransactions: Int { 0 } var enhancedTransactions: Int { 0 }