Merge pull request #5315 from BlueWallet/apifix

FIX: Type casting in Widget parse
This commit is contained in:
GLaDOS 2023-02-16 21:58:46 +00:00 committed by GitHub
commit 52c1a78c13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,11 +71,15 @@ class WidgetAPI {
let unix = Double(lastUpdated / 1_000)
let lastUpdatedString = ISO8601DateFormatter().string(from: Date(timeIntervalSince1970: unix))
latestRateDataStore = WidgetDataStore(rate: String(rateDouble), lastUpdate: lastUpdatedString, rateDouble: rateDouble)
case "Exir", "Bitstamp":
case "Exir":
guard let rateDouble = json["last"] as? Double else { break }
let rateString = String(rateDouble)
let lastUpdatedString = ISO8601DateFormatter().string(from: Date())
latestRateDataStore = WidgetDataStore(rate: rateString, lastUpdate: lastUpdatedString, rateDouble: rateDouble)
case "Bitstamp":
guard let rateString = json["last"] as? String, let rateDouble = Double(rateString) else { break }
let lastUpdatedString = ISO8601DateFormatter().string(from: Date())
latestRateDataStore = WidgetDataStore(rate: rateString, lastUpdate: lastUpdatedString, rateDouble: rateDouble)
case "wazirx":
guard let tickerDict = json["ticker"] as? [String: Any],
let rateString = tickerDict["buy"] as? String,