You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both functions getAccountBalances and getBalances are failing at the guard statement: print("Error: Cast Failed in \(#function)")
It seems like that response.json is actually not of the type [[String: String]] but actually gives back an answer. I adjusted the function now to this one here which seems works since I am creating a new Balance object and assign the values, though the rest of the krakenService.store.balances object later is then messed up e.g. ...xxx.currency.code etc. My function:
public func getAccountBalances(completion: @escaping (ResponseType) -> Void) {
let apiType = Kraken.API.getAccountBalance
if apiType.checkInterval(response: store.balanceResponse) {
completion(.cached)
} else {
krakenDataTaskFor(api: apiType) { (response) in
guard let json = response.json as? Dictionary<String, Any> else {
print("Error: Cast Failed in \(#function)")
return
}
let arrayOfCryptoBalances = json["result"] as! Dictionary<String,String>
var balances: [Balance] = []
for cryptoBalance in arrayOfCryptoBalances {
let newBalance = ["type": cryptoBalance.key,
"amount": cryptoBalance.value,
"available": cryptoBalance.value]
balances.append(Balance(json: newBalance, currencyStore: self))
}
self.store.balances = balances
self.store.balanceResponse = response.httpResponse
completion(.fetched)
}.resume()
}
}
Do you want me to create a pull request with my solution or are you taking care of it yourself? Maybe Kraken has updated the API since you wrote it. Also I found it annoying by Kraken that they decided to call most of the crypto currencies with own symbols. e.g. XBT instead of BTC for Bitcoin... is this what your overwrite function is for?
Best,
Matt
The text was updated successfully, but these errors were encountered:
Hey Sathya,
Both functions
getAccountBalances
andgetBalances
are failing at the guard statement:print("Error: Cast Failed in \(#function)")
It seems like that
response.json
is actually not of the type[[String: String]]
but actually gives back an answer. I adjusted the function now to this one here which seems works since I am creating a new Balance object and assign the values, though the rest of thekrakenService.store.balances
object later is then messed up e.g....xxx.currency.code
etc. My function:Do you want me to create a pull request with my solution or are you taking care of it yourself? Maybe Kraken has updated the API since you wrote it. Also I found it annoying by Kraken that they decided to call most of the crypto currencies with own symbols. e.g. XBT instead of BTC for Bitcoin... is this what your overwrite function is for?
Best,
Matt
The text was updated successfully, but these errors were encountered: