Updated on 2026-08-14
This commit is contained in:
parent
cb62ebfd05
commit
ed0b07bc82
4 changed files with 21 additions and 6 deletions
|
|
@ -43,7 +43,7 @@ suspend fun WalletManager.safeUpdate(isDemoCard: Boolean): Result<Wallet> = try
|
|||
Result.Failure(TapError.NoInternetConnection)
|
||||
} else {
|
||||
val blockchain = wallet.blockchain
|
||||
val amountToCreateAccount = blockchain.amountToCreateAccount(wallet.getFirstToken())
|
||||
val amountToCreateAccount = blockchain.amountToCreateAccount(this, wallet.getFirstToken())
|
||||
|
||||
if (exception is BlockchainSdkError.AccountNotFound && amountToCreateAccount != null) {
|
||||
Result.Failure(TapError.WalletManager.NoAccountError(amountToCreateAccount.toString()))
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
val wallet = walletManager.wallet
|
||||
val blockchain = wallet.blockchain
|
||||
val firstWalletToken = wallet.getTokens().firstOrNull()
|
||||
val amount = amountToCreateAccount ?: blockchain.amountToCreateAccount(firstWalletToken)
|
||||
val amount = amountToCreateAccount ?: blockchain.amountToCreateAccount(walletManager, firstWalletToken)
|
||||
|
||||
return if (amount == null) {
|
||||
Timber.w("Unable to get required amount to create account for: $blockchain")
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ markdownComposeView = "0.5.4"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "develop-877"
|
||||
tangemBlockchainSdk = "develop-879"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-410"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.tangem.blockchainsdk.utils
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.ReserveAmountProvider
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import java.math.BigDecimal
|
||||
|
||||
@Suppress("ComplexMethod", "LongMethod")
|
||||
|
|
@ -390,10 +392,23 @@ fun Blockchain.toMigratedCointId(): String = when (this) {
|
|||
else -> toCoinId()
|
||||
}
|
||||
|
||||
fun Blockchain.amountToCreateAccount(token: Token? = null): BigDecimal? {
|
||||
fun Blockchain.amountToCreateAccount(walletManager: WalletManager, token: Token? = null): BigDecimal? {
|
||||
return when (this) {
|
||||
Blockchain.Stellar -> if (token?.symbol == NODL) BigDecimal(NODL_AMOUNT_TO_CREATE_ACCOUNT) else BigDecimal.ONE
|
||||
Blockchain.XRP -> BigDecimal.TEN
|
||||
Blockchain.Stellar -> {
|
||||
val reserve = if (walletManager is ReserveAmountProvider) {
|
||||
walletManager.getReserveAmount()
|
||||
} else {
|
||||
BigDecimal.ONE
|
||||
}
|
||||
if (token?.symbol == NODL) BigDecimal(NODL_AMOUNT_TO_CREATE_ACCOUNT) else reserve
|
||||
}
|
||||
Blockchain.XRP -> {
|
||||
if (walletManager is ReserveAmountProvider) {
|
||||
walletManager.getReserveAmount()
|
||||
} else {
|
||||
BigDecimal.ONE
|
||||
}
|
||||
}
|
||||
Blockchain.Near, Blockchain.NearTestnet -> 0.00182.toBigDecimal()
|
||||
Blockchain.Aptos, Blockchain.AptosTestnet,
|
||||
Blockchain.Filecoin,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue