Skip to content

Commit a2ca9f6

Browse files
committed
Updated the Infura and partner IPFS access
- Required in the latest UD library Signed-off-by: kcw-grunt <[email protected]>
1 parent b97ec53 commit a2ca9f6

File tree

4 files changed

+65
-12
lines changed

4 files changed

+65
-12
lines changed

.gitignore

+2-8
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ Package.resolved
3030

3131
# Add this line if you want to avoid checking in Xcode SPM integration.
3232
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
33-
34-
# CocoaPods
35-
#
36-
# We recommend against adding the Pods directory to your .gitignore. However
37-
# you should judge for yourself, the pros and cons are mentioned at:
38-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
39-
40-
Pods/
33+
4134

4235
# SwiftFormat
4336
BuildTools/.build
@@ -47,3 +40,4 @@ BuildTools/.swiftpm
4740
# Sensitive Partner API
4841
Modules/litewallet-partner-api-ios
4942
litewallet-partner-api-ios
43+

loafwallet.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
C36DBF6128F1988900FBCB24 /* LocalWebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C36DBF6028F1988900FBCB24 /* LocalWebViewModel.swift */; };
283283
C39443F9269DDAD3002703E9 /* LitewalletIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C39443F8269DDAD3002703E9 /* LitewalletIconView.swift */; };
284284
C39A71472608CB4300E7B640 /* EmptyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C39A71462608CB4300E7B640 /* EmptyTableViewCell.swift */; };
285+
C3A01CBD2B069A5300CC156B /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C3A01CBC2B069A5300CC156B /* partner-keys.plist */; };
285286
C3A4647D259A646A00D74D81 /* DataValidation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A4647C259A646A00D74D81 /* DataValidation.swift */; };
286287
C3B7C3B9255EABBF00E98A64 /* SupportSafariViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B7C3B8255EABBF00E98A64 /* SupportSafariViewModel.swift */; };
287288
C3B7C3EE255FF59200E98A64 /* ConstantsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B7C3ED255FF59200E98A64 /* ConstantsTests.swift */; };
@@ -1440,6 +1441,7 @@
14401441
C36DBF6028F1988900FBCB24 /* LocalWebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalWebViewModel.swift; sourceTree = "<group>"; };
14411442
C39443F8269DDAD3002703E9 /* LitewalletIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LitewalletIconView.swift; sourceTree = "<group>"; };
14421443
C39A71462608CB4300E7B640 /* EmptyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyTableViewCell.swift; sourceTree = "<group>"; };
1444+
C3A01CBC2B069A5300CC156B /* partner-keys.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "partner-keys.plist"; path = "../../../../Desktop/partner-keys.plist"; sourceTree = "<group>"; };
14431445
C3A4647C259A646A00D74D81 /* DataValidation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataValidation.swift; sourceTree = "<group>"; };
14441446
C3ACF2DE25DED601008671D4 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
14451447
C3B7C3B8255EABBF00E98A64 /* SupportSafariViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportSafariViewModel.swift; sourceTree = "<group>"; };
@@ -2932,6 +2934,7 @@
29322934
75A2A7921DA5934300A983D8 /* loafwallet */ = {
29332935
isa = PBXGroup;
29342936
children = (
2937+
C3A01CBC2B069A5300CC156B /* partner-keys.plist */,
29352938
375DDB3D2697C253005E2B27 /* GoogleService-Info.plist */,
29362939
C3188E2526431E750008ADD1 /* Debug-GoogleService-Info.plist */,
29372940
C35ABD07257404C6002BB9BB /* SwiftUI+UIKit */,
@@ -3868,6 +3871,7 @@
38683871
24D5F25F22599C0B00225462 /* BarlowSemiCondensed-Regular.ttf in Resources */,
38693872
24DFCE6823B89CDE001F17F8 /* Settings.storyboard in Resources */,
38703873
24393B5C23C259400075218D /* Phrase.storyboard in Resources */,
3874+
C3A01CBD2B069A5300CC156B /* partner-keys.plist in Resources */,
38713875
75A2A79B1DA5934300A983D8 /* Assets.xcassets in Resources */,
38723876
);
38733877
runOnlyForDeploymentPostprocessing = 0;

loafwallet/PartnerData.swift

+56-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import UIKit
33

44
enum PartnerName {
55
case unstop
6-
case changeNow
6+
case infura
77
}
88

99
struct Partner {
@@ -20,4 +20,59 @@ struct Partner {
2020

2121
return [bitrefill, moonpay, simplex]
2222
}
23+
24+
/// Returns Partner Key
25+
/// - Parameter name: Enum for the different partners
26+
/// - Returns: Key string
27+
static func partnerKeyPath(name: PartnerName) -> String {
28+
/// Switch the config file based on the environment
29+
var filePath: String
30+
#if Release
31+
32+
// Loads the release Partner Keys config file.
33+
guard let releasePath = Bundle.main.path(forResource: "partner-keys",
34+
ofType: "plist")
35+
else {
36+
return "ERROR: FILE-NOT-FOUND"
37+
}
38+
filePath = releasePath
39+
#else
40+
41+
// Loads the debug Partner Keys config file.
42+
guard let debugPath = Bundle.main.path(forResource: "debug-partner-keys",
43+
ofType: "plist")
44+
else {
45+
return "ERROR: FILE-NOT-FOUND"
46+
}
47+
48+
filePath = debugPath
49+
50+
#endif
51+
52+
switch name {
53+
case .infura:
54+
55+
if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject],
56+
let key = dictionary["infura-api"] as? String
57+
{
58+
return "https://mainnet.infura.io/v3/" + key
59+
} else {
60+
let errorDescription = "ERROR-INFURA_KEY"
61+
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
62+
return errorDescription
63+
}
64+
65+
case .unstop:
66+
67+
if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject],
68+
let key = dictionary["change-now-api"] as? String
69+
{
70+
return key
71+
} else {
72+
let errorDescription = "ERROR-CHANGENOW_KEY"
73+
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription])
74+
return errorDescription
75+
}
76+
}
77+
}
2378
}

loafwallet/UnstoppableDomainViewModel.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class UnstoppableDomainViewModel: ObservableObject {
7474
// Otherwise, we may never get in the callback relative to UDR v4.0.0
7575
let group = DispatchGroup()
7676

77-
guard let resolution = try? Resolution()
77+
guard let resolution = try? Resolution(apiKey: Partner.partnerKeyPath(name: .infura))
7878
else {
7979
print("Init of Resolution instance with default parameters failed...")
8080
return
@@ -86,7 +86,7 @@ class UnstoppableDomainViewModel: ObservableObject {
8686
switch result {
8787
case let .success(returnValue):
8888

89-
let timestamp: String = dateFormatter?.string(from: Date()) ?? ""
89+
let timestamp: String = self.dateFormatter?.string(from: Date()) ?? ""
9090

9191
LWAnalytics.logEventWithParameters(itemName:
9292
CustomEvent._20201121_DRIA,
@@ -101,7 +101,7 @@ class UnstoppableDomainViewModel: ObservableObject {
101101

102102
case let .failure(error):
103103
let errorMessage = DomainResolutionFailure().messageWith(error: error)
104-
let timestamp: String = dateFormatter?.string(from: Date()) ?? ""
104+
let timestamp: String = self.dateFormatter?.string(from: Date()) ?? ""
105105

106106
LWAnalytics.logEventWithParameters(itemName:
107107
CustomEvent._20201121_FRIA,

0 commit comments

Comments
 (0)