Skip to content

Commit

Permalink
Refactors
Browse files Browse the repository at this point in the history
- Added enum Error for throws
- Reset the PartnerData plist code
- reset tags

Signed-off-by: kcw-grunt <[email protected]>
  • Loading branch information
kcw-grunt committed May 11, 2024
1 parent 9e880c1 commit 107a241
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions litewallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@
C3FDADED28B2DB090054FC80 /* SendAddressHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FDADEC28B2DB090054FC80 /* SendAddressHostingController.swift */; };
C3FF4D5F28AC5A5800713139 /* SendAddressCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FF4D5E28AC5A5800713139 /* SendAddressCellView.swift */; };
C3FF4D6128AC5AC100713139 /* SendAddressCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FF4D6028AC5AC100713139 /* SendAddressCellViewModel.swift */; };
C738969F2BEA3C0200029095 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C738969E2BEA3C0200029095 /* GoogleService-Info.plist */; };
C73896A12BEA3C4900029095 /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C73896A02BEA3C4900029095 /* partner-keys.plist */; };
C738969F2BEA3C0200029095 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C738969E2BEA3C0200029095 /* GoogleService-Info.plist */; settings = {ASSET_TAGS = ("initial-resources", ); }; };
C73896A12BEA3C4900029095 /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C73896A02BEA3C4900029095 /* partner-keys.plist */; settings = {ASSET_TAGS = ("initial-resources", ); }; };
CE03EC741EF256AC0038E3A8 /* SimpleUTXO.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE03EC731EF256AC0038E3A8 /* SimpleUTXO.swift */; };
CE0CD1591DBFBCF5004023DA /* ModalPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0CD1581DBFBCF5004023DA /* ModalPresenter.swift */; };
CE124CF81E67A8E500DFA146 /* TransactionDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE124CF71E67A8E500DFA146 /* TransactionDirection.swift */; };
Expand Down
23 changes: 11 additions & 12 deletions litewallet/PartnerData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,17 @@ struct Partner {
}

case .litewalletOps:
return "ltc1qrk9t25v3s2r64knehcgdu9n4pwl2ccvf8z49fa"
// if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject],
// let opsArray = dictionary["litewallet-ops"] as? [String]
// {
// let randomInt = Int.random(in: 0 ..< opsArray.count)
// let key = opsArray[randomInt]
// return key
// } else {
// let errorDescription = "error_litewallet_opskey"
// LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
// return errorDescription
// }
if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject],
let opsArray = dictionary["litewallet-ops"] as? [String]
{
let randomInt = Int.random(in: 0 ..< opsArray.count)
let key = opsArray[randomInt]
return key
} else {
let errorDescription = "error_litewallet_opskey"
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
return errorDescription
}

case .litewalletStart:

Expand Down
6 changes: 6 additions & 0 deletions litewallet/Platform/BRReplicatedKVStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public enum BRReplicatedKVStoreError: Error {
case malformedData
}

/// MakeTransactionError: Error
public enum MakeTransactionError: Error {
case replicatedKVStoreNotFound
case rateNotFound
}

public enum BRRemoteKVStoreError: Error {
case notFound
case conflict
Expand Down
4 changes: 2 additions & 2 deletions litewallet/WalletCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ class WalletCoordinator: Subscriber, Trackable {

func makeTransactionViewModels(transactions: [BRTxRef?], walletManager: WalletManager, kvStore: BRReplicatedKVStore?, rate: Rate?) async throws -> [Transaction] {
guard let kvStore = kvStore else {
// throw MakeTransactionError.replicatedKVStoreNotFound
// throw MakeTransactionError.replicatedKVStoreNotFound
return []
}

guard let rate = rate else {
// throw MakeTransactionError.rateNotFound
// throw MakeTransactionError.rateNotFound
return []
}

Expand Down

0 comments on commit 107a241

Please sign in to comment.