diff --git a/Sources/ZcashLightClientKit/DAO/PendingTransactionDao.swift b/Sources/ZcashLightClientKit/DAO/PendingTransactionDao.swift index beb2bf20..35bdeaa8 100644 --- a/Sources/ZcashLightClientKit/DAO/PendingTransactionDao.swift +++ b/Sources/ZcashLightClientKit/DAO/PendingTransactionDao.swift @@ -102,13 +102,13 @@ struct PendingTransaction: PendingTransactionEntity, Decodable, Encodable { let container = try decoder.container(keyedBy: CodingKeys.self) let toAddress: String? = try container.decodeIfPresent(String.self, forKey: .toAddress) - let toInternalAccount: UInt32? = try container.decode(UInt32.self, forKey: .toInternalAccount) + let toInternalAccount: Int? = try container.decodeIfPresent(Int.self, forKey: .toInternalAccount) switch (toAddress, toInternalAccount) { case let (.some(address), nil): self.recipient = .address(Recipient.forEncodedAddress(encoded: address)!.0) case let (nil, .some(accountId)): - self.recipient = .internalAccount(accountId) + self.recipient = .internalAccount(UInt32(accountId)) default: throw StorageError.malformedEntity(fields: ["toAddress", "toInternalAccount"]) } @@ -135,14 +135,12 @@ struct PendingTransaction: PendingTransactionEntity, Decodable, Encodable { var container = encoder.container(keyedBy: CodingKeys.self) var toAddress: String? - var accountId: UInt32? + var accountId: Int? switch (self.recipient) { case .address(let recipient): toAddress = recipient.stringEncoded case .internalAccount(let acct): - accountId = acct - default: - break + accountId = Int(acct) } try container.encode(toAddress, forKey: .toAddress) try container.encode(accountId, forKey: .toInternalAccount) diff --git a/Sources/ZcashLightClientKit/Initializer.swift b/Sources/ZcashLightClientKit/Initializer.swift index 2395cb3f..085ba55e 100644 --- a/Sources/ZcashLightClientKit/Initializer.swift +++ b/Sources/ZcashLightClientKit/Initializer.swift @@ -301,14 +301,14 @@ public class Initializer { checks if the provided address is a valid sapling address */ public func isValidSaplingAddress(_ address: String) -> Bool { - (try? rustBackend.isValidSaplingAddress(address, networkType: network.networkType)) ?? false + rustBackend.isValidSaplingAddress(address, networkType: network.networkType) } /** checks if the provided address is a transparent zAddress */ public func isValidTransparentAddress(_ address: String) -> Bool { - (try? rustBackend.isValidTransparentAddress(address, networkType: network.networkType)) ?? false + rustBackend.isValidTransparentAddress(address, networkType: network.networkType) } func isSpendParameterPresent() -> Bool { diff --git a/Tests/OfflineTests/PendingTransactionRepositoryTests.swift b/Tests/OfflineTests/PendingTransactionRepositoryTests.swift index ec2da1b8..bf2e34d8 100644 --- a/Tests/OfflineTests/PendingTransactionRepositoryTests.swift +++ b/Tests/OfflineTests/PendingTransactionRepositoryTests.swift @@ -20,10 +20,9 @@ class PendingTransactionRepositoryTests: XCTestCase { super.setUp() cleanUpDb() let pendingDbProvider = SimpleConnectionProvider(path: try! TestDbBuilder.pendingTransactionsDbURL().absoluteString) - let dao = PendingTransactionSQLDAO(dbProvider: pendingDbProvider) let migrations = try! MigrationManager(cacheDbConnection: InMemoryDbProvider(), pendingDbConnection: pendingDbProvider, networkType: .testnet) try! migrations.performMigration() - pendingRepository = dao + pendingRepository = PendingTransactionSQLDAO(dbProvider: pendingDbProvider) } override func tearDown() {