Fix: app crash when displaying CryptoKitty with a cooldown that is longer than expected

pull/652/head
Hwee-Boon Yar 6 years ago
parent d4e0545c4f
commit a7d56f380d
  1. 8
      AlphaWallet/Redeem/ViewModels/TokenListFormatRowViewModel.swift
  2. 5
      AlphaWallet/Settings/Types/Constants.swift

@ -84,7 +84,13 @@ struct TokenListFormatRowViewModel {
generationText = ""
}
if let cooldown = traits.first(where: { $0.type == "cooldown_index" }), let cooldownIndex = Int(cooldown.value) {
let cooldownValue = Constants.cryptoKittiesCooldowns[cooldownIndex]
let cooldownValue: String
if Constants.cryptoKittiesCooldowns.indices.contains(cooldownIndex) {
cooldownValue = Constants.cryptoKittiesCooldowns[cooldownIndex]
} else {
//TODO localize
cooldownValue = "Unknown"
}
cooldownText = "\(cooldownValue) Cooldown"
} else {
cooldownText = ""

@ -69,7 +69,10 @@ public struct Constants {
"Ploddy",
"Slow",
"Slow",
"Sluggish"
"Sluggish",
"Sluggish",
"Catatonic",
"Catatonic"
]
//contract addresses that are compatible with opensea

Loading…
Cancel
Save