From d435509f0a83ab69e4ad54f680a217623fe00375 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 19 Dec 2024 15:31:06 +0600 Subject: [PATCH] Handle exception when checking for Tron active account --- .../modules/balance/BalanceAdapterRepository.kt | 3 +-- .../modules/receive/viewmodels/ReceiveAddressViewModel.kt | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceAdapterRepository.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceAdapterRepository.kt index 88fdf5d0da5..adc7b0c6d6c 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceAdapterRepository.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceAdapterRepository.kt @@ -17,7 +17,6 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.reactive.asFlow import java.math.BigDecimal -import java.net.UnknownHostException class BalanceAdapterRepository( private val adapterManager: IAdapterManager, @@ -115,7 +114,7 @@ class BalanceAdapterRepository( return BalanceWarning.TronInactiveAccountWarning } } - } catch (e: UnknownHostException) { + } catch (e: Exception) { e.printStackTrace() } return null diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/receive/viewmodels/ReceiveAddressViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/receive/viewmodels/ReceiveAddressViewModel.kt index ba98b4781d4..dd5c1828401 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/receive/viewmodels/ReceiveAddressViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/receive/viewmodels/ReceiveAddressViewModel.kt @@ -101,9 +101,15 @@ class ReceiveAddressViewModel( usedAddresses = adapter.usedAddresses(false) usedChangeAddresses = adapter.usedAddresses(true) uri = getUri() - accountActive = adapter.isAddressActive(adapter.receiveAddress) mainNet = adapter.isMainNet viewState = ViewState.Success + + accountActive = try { + adapter.isAddressActive(adapter.receiveAddress) + } catch (e: Exception) { + viewState = ViewState.Error(e) + false + } } else { viewState = ViewState.Error(NullPointerException()) }