Updated on 2026-08-14

This commit is contained in:
Tangem 2020-09-25 22:20:37 +03:00
parent d501d7ce3e
commit e7fe22d1e4
4 changed files with 12 additions and 9 deletions

View file

@ -118,9 +118,9 @@ class TapWalletManager {
val error = result.error
val blockchain = walletManager.wallet.blockchain
if (error != null && blockchain.isNoAccountError(error)) {
val amountToCreateAccount = blockchain.amountToCreateAccount()
val amountToCreateAccount = blockchain.amountToCreateAccount(walletManager.wallet.token)
if (amountToCreateAccount != null) {
store.dispatch(WalletAction.LoadWallet.NoAccount(amountToCreateAccount))
store.dispatch(WalletAction.LoadWallet.NoAccount(amountToCreateAccount.toString()))
return@withContext
}
}

View file

@ -1,6 +1,7 @@
package com.tangem.tap.domain.extensions
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import org.stellar.sdk.requests.ErrorResponse
@ -14,10 +15,12 @@ fun Blockchain.isNoAccountError(exception: Throwable): Boolean {
}
}
fun Blockchain.amountToCreateAccount(): Int? {
fun Blockchain.amountToCreateAccount(token: Token? = null): Double? {
return when (this) {
Blockchain.Stellar -> 1
Blockchain.XRP -> 20
Blockchain.Stellar -> if (token?.symbol == NODL) 1.5 else 1.toDouble()
Blockchain.XRP -> 20.toDouble()
else -> null
}
}
}
private const val NODL = "NODL"

View file

@ -20,7 +20,7 @@ sealed class WalletAction : Action {
object LoadWallet : WalletAction() {
data class Success(val wallet: Wallet) : WalletAction()
data class NoAccount(val amountToCreateAccount: Int) : WalletAction()
data class NoAccount(val amountToCreateAccount: String) : WalletAction()
data class Failure(val errorMessage: String? = null) : WalletAction()
}

View file

@ -26,7 +26,7 @@ data class BalanceWidgetData(
val amount: String? = null,
val fiatAmount: String? = null,
val token: TokenData? = null,
val amountToCreateAccount: Int? = null,
val amountToCreateAccount: String? = null,
val errorMessage: String? = null
)
@ -100,7 +100,7 @@ class BalanceWidget(
fragment.tv_error_descriptions.text =
fragment.getString(
R.string.wallet_no_account_description,
data.amountToCreateAccount?.toString(), data.currencySymbol
data.amountToCreateAccount, data.currencySymbol
)
}
BalanceStatus.UnknownBlockchain -> {