mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
get infura key from cloud kit
This commit is contained in:
parent
fece2efec5
commit
cde9f5e647
@ -7,10 +7,9 @@ struct Nodes {
|
||||
private static let infuraKey: String = {
|
||||
if let path = Bundle.main.path(forResource: "shared", ofType: "plist"),
|
||||
let dict = NSDictionary(contentsOfFile: path) as? [String: AnyObject],
|
||||
let infuraKey = dict["InfuraKey"] as? String {
|
||||
let infuraKey = dict["InfuraKey"] as? String, !infuraKey.isEmpty {
|
||||
return infuraKey
|
||||
} else {
|
||||
// TODO: get from CloudKit
|
||||
// TODO: hande infura key not being bundled
|
||||
return ""
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright © 2023 Tokenary. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
import CloudKit
|
||||
|
||||
class ConfigurationService {
|
||||
|
||||
@ -25,6 +26,10 @@ class ConfigurationService {
|
||||
if !shouldUpdateApp {
|
||||
getConfiguration()
|
||||
}
|
||||
getInfuraKeyFromCloudKit { infuraKey in
|
||||
// TODO: keep latest version in defaults and make it accessible to Nodes
|
||||
print(infuraKey)
|
||||
}
|
||||
}
|
||||
|
||||
func didPromptToUpdate() {
|
||||
@ -45,4 +50,21 @@ class ConfigurationService {
|
||||
dataTask.resume()
|
||||
}
|
||||
|
||||
private func getInfuraKeyFromCloudKit(completion: @escaping (String) -> Void) {
|
||||
let container = CKContainer(identifier: "iCloud.tokenary")
|
||||
let publicDatabase = container.publicCloudDatabase
|
||||
let predicate = NSPredicate(value: true)
|
||||
let query = CKQuery(recordType: "Config", predicate: predicate)
|
||||
publicDatabase.fetch(withQuery: query) { result in
|
||||
if case .success(let success) = result,
|
||||
case let .success(record) = success.matchResults.first?.1,
|
||||
let infuraKeys = record["infuraKeys"] as? [String],
|
||||
let infuraKey = infuraKeys.first {
|
||||
DispatchQueue.main.async {
|
||||
completion(infuraKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,14 @@
|
||||
<array>
|
||||
<string>applinks:tokenary.io</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.tokenary</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
<string>CloudKit</string>
|
||||
</array>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.io.tokenary</string>
|
||||
|
@ -6,6 +6,14 @@
|
||||
<array>
|
||||
<string>applinks:tokenary.io</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.tokenary</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
<string>CloudKit</string>
|
||||
</array>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
|
Loading…
Reference in New Issue
Block a user