From a7d56f380db225e09a4fa281f0c31b13e57d02f2 Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Wed, 29 Aug 2018 00:43:11 +0800 Subject: [PATCH] Fix: app crash when displaying CryptoKitty with a cooldown that is longer than expected --- .../Redeem/ViewModels/TokenListFormatRowViewModel.swift | 8 +++++++- AlphaWallet/Settings/Types/Constants.swift | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/AlphaWallet/Redeem/ViewModels/TokenListFormatRowViewModel.swift b/AlphaWallet/Redeem/ViewModels/TokenListFormatRowViewModel.swift index 8654c3f2f..164cf35eb 100644 --- a/AlphaWallet/Redeem/ViewModels/TokenListFormatRowViewModel.swift +++ b/AlphaWallet/Redeem/ViewModels/TokenListFormatRowViewModel.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 = "" diff --git a/AlphaWallet/Settings/Types/Constants.swift b/AlphaWallet/Settings/Types/Constants.swift index 560fb395c..ca818af75 100644 --- a/AlphaWallet/Settings/Types/Constants.swift +++ b/AlphaWallet/Settings/Types/Constants.swift @@ -69,7 +69,10 @@ public struct Constants { "Ploddy", "Slow", "Slow", - "Sluggish" + "Sluggish", + "Sluggish", + "Catatonic", + "Catatonic" ] //contract addresses that are compatible with opensea