Skip to content

Commit

Permalink
Handle UnknownHostException when getting Tron account info
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Nov 8, 2024
1 parent 974d1fb commit da035cb
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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,
Expand Down Expand Up @@ -107,11 +108,15 @@ class BalanceAdapterRepository(
}

suspend fun warning(wallet: Wallet): BalanceWarning? {
if (wallet.token.blockchainType is BlockchainType.Tron) {
(adapterManager.getAdapterForWallet(wallet) as? BaseTronAdapter)?.let { adapter ->
if (!adapter.isAddressActive(adapter.receiveAddress))
return BalanceWarning.TronInactiveAccountWarning
try {
if (wallet.token.blockchainType is BlockchainType.Tron) {
(adapterManager.getAdapterForWallet(wallet) as? BaseTronAdapter)?.let { adapter ->
if (!adapter.isAddressActive(adapter.receiveAddress))
return BalanceWarning.TronInactiveAccountWarning
}
}
} catch (e: UnknownHostException) {
e.printStackTrace()
}
return null
}
Expand Down

0 comments on commit da035cb

Please sign in to comment.