Updated on 2026-08-14
This commit is contained in:
commit
75c9a89de5
5 changed files with 39 additions and 26 deletions
|
|
@ -49,7 +49,7 @@ enum class ExchangeStatus {
|
|||
@Json(name = "verifying")
|
||||
VERIFYING,
|
||||
|
||||
@Json(name = "cancelled")
|
||||
@Json(name = "expired")
|
||||
CANCELLED,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ class DefaultWalletManagersFacade(
|
|||
derivationPath = derivationPath,
|
||||
)
|
||||
if (walletManager == null || blockchain == Blockchain.Unknown) {
|
||||
Timber.w("Unable to get a wallet manager for blockchain: $blockchain")
|
||||
Timber.w("Unable to create or find a wallet manager for $blockchain")
|
||||
return UpdateWalletManagerResult.Unreachable
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.domain.common.DerivationStyleProvider
|
|||
import com.tangem.domain.common.extensions.makeWalletManagerForApp
|
||||
import com.tangem.domain.common.util.derivationStyleProvider
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import timber.log.Timber
|
||||
|
||||
internal class WalletManagerFactory(
|
||||
private val configManager: ConfigManager,
|
||||
|
|
@ -26,11 +27,16 @@ internal class WalletManagerFactory(
|
|||
): WalletManager? {
|
||||
val derivationParams = getDerivationParams(derivationPath, scanResponse.derivationStyleProvider)
|
||||
|
||||
return sdkWalletManagerFactory.makeWalletManagerForApp(
|
||||
scanResponse = scanResponse,
|
||||
blockchain = blockchain,
|
||||
derivationParams = derivationParams,
|
||||
)
|
||||
return try {
|
||||
sdkWalletManagerFactory.makeWalletManagerForApp(
|
||||
scanResponse = scanResponse,
|
||||
blockchain = blockchain,
|
||||
derivationParams = derivationParams,
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
Timber.w(e, "Failed to create wallet manager for $blockchain")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDerivationParams(
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ internal class DefaultSwapRepository @Inject constructor(
|
|||
if (txDetails.requestId != requestId) {
|
||||
return@withContext DataError.InvalidRequestIdError().left()
|
||||
}
|
||||
if (toAddress != txDetails.payoutAddress) {
|
||||
if (!toAddress.equals(txDetails.payoutAddress, ignoreCase = true)) {
|
||||
return@withContext DataError.InvalidPayoutAddressError().left()
|
||||
}
|
||||
expressDataConverter.convert(
|
||||
|
|
|
|||
|
|
@ -852,19 +852,12 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
amount: SwapAmount,
|
||||
fromToken: CryptoCurrency,
|
||||
): IncludeFeeInAmount {
|
||||
if (fromToken is CryptoCurrency.Token) {
|
||||
return IncludeFeeInAmount.Excluded
|
||||
}
|
||||
|
||||
val tokenForFeeBalance =
|
||||
userWalletManager.getNativeTokenBalance(
|
||||
networkId,
|
||||
fromToken.network.derivationPath.value,
|
||||
) ?: ProxyAmount.empty()
|
||||
|
||||
if (amount.value > tokenForFeeBalance.value) {
|
||||
return IncludeFeeInAmount.BalanceNotEnough
|
||||
}
|
||||
val feeValue = when (txFee) {
|
||||
TxFeeState.Empty -> BigDecimal.ZERO
|
||||
is TxFeeState.MultipleFeeState -> txFee.priorityFee.feeValue
|
||||
|
|
@ -872,19 +865,33 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
}
|
||||
|
||||
val amountWithFee = amount.value + feeValue
|
||||
return if (amountWithFee < tokenForFeeBalance.value) {
|
||||
IncludeFeeInAmount.Excluded
|
||||
} else {
|
||||
if (feeValue < amount.value) {
|
||||
IncludeFeeInAmount.Included(
|
||||
SwapAmount(
|
||||
tokenForFeeBalance.value - feeValue,
|
||||
transactionManager.getNativeTokenDecimals(networkId),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
|
||||
return when {
|
||||
fromToken is CryptoCurrency.Token -> {
|
||||
if (feeValue > tokenForFeeBalance.value) {
|
||||
IncludeFeeInAmount.BalanceNotEnough
|
||||
} else {
|
||||
IncludeFeeInAmount.Excluded
|
||||
}
|
||||
}
|
||||
amount.value > tokenForFeeBalance.value -> {
|
||||
IncludeFeeInAmount.BalanceNotEnough
|
||||
}
|
||||
amountWithFee < tokenForFeeBalance.value -> {
|
||||
IncludeFeeInAmount.Excluded
|
||||
}
|
||||
else -> {
|
||||
if (feeValue < amount.value) {
|
||||
IncludeFeeInAmount.Included(
|
||||
SwapAmount(
|
||||
tokenForFeeBalance.value - feeValue,
|
||||
transactionManager.getNativeTokenDecimals(networkId),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
IncludeFeeInAmount.BalanceNotEnough
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue