Updated on 2026-08-14

This commit is contained in:
Tangem 2024-07-09 14:39:17 +01:00
parent 4e21f84b90
commit b168f321b8
7 changed files with 23 additions and 15 deletions

View file

@ -177,9 +177,9 @@ class WalletConnectSdkHelper {
is Result.Success -> gasLimitResult.data.toBigDecimal().multiply(BigDecimal("1.2"))
is Result.Failure -> {
(gasLimitResult.error as? Throwable)?.let { Timber.e(it, "getGasLimit failed") }
BigDecimal(DEFAULT_MAX_GASLIMIT) // Set high gasLimit if not provided
DEFAULT_MAX_GASLIMIT.toBigDecimal() // Set high gasLimit if not provided
}
else -> BigDecimal(DEFAULT_MAX_GASLIMIT) // Set high gasLimit if not provided
else -> DEFAULT_MAX_GASLIMIT.toBigDecimal() // Set high gasLimit if not provided
}
}

View file

@ -7,14 +7,14 @@ data class ExchangeStatusResponse(
@Json(name = "providerId")
val providerId: String,
@Json(name = "externalTxId")
val externalTxId: String,
@Json(name = "status")
val status: ExchangeStatus,
@Json(name = "externalTxId")
val externalTxId: String?,
@Json(name = "externalTxUrl")
val externalTxUrl: String,
val externalTxUrl: String?,
@Json(name = "error")
val error: ExchangeStatusError?,

View file

@ -10,9 +10,12 @@ interface SwapTransactionStatusStore {
}
enum class ExchangeAnalyticsStatus(val value: String) {
WaitingTxHash("Waiting tx hash"),
InProgress("In Progress"),
Done("Done"),
Fail("Fail"),
FailTx("Fail tx"),
Unknown("Unknown"),
KYC("KYC"),
Refunded("Refunded"),
Cancelled("Canceled"),

View file

@ -20,5 +20,6 @@ enum class ExchangeStatus {
Finished,
Refunded,
Cancelled,
TxFailed,
Unknown,
}

View file

@ -317,8 +317,8 @@ internal class SwapInteractorImpl @Inject constructor(
val fromTokenAddress = getTokenAddress(fromToken.currency)
val isAllowedToSpend = quotes.fold(
ifRight = {
it.allowanceContract?.let {
ifRight = { quotes ->
quotes.allowanceContract?.let {
isAllowedToSpend(networkId, fromToken.currency, amount, it)
} ?: true
},
@ -870,7 +870,7 @@ internal class SwapInteractorImpl @Inject constructor(
)
blockchain == Blockchain.Aptos -> {
val gasUnitPrice = fee.feeValue.divide(
BigDecimal(fee.gasLimit),
fee.gasLimit.toBigDecimal(),
Blockchain.Aptos.decimals(),
RoundingMode.HALF_UP,
)
@ -1970,7 +1970,6 @@ internal class SwapInteractorImpl @Inject constructor(
normalFee = ProxyFee.Common(
gasLimit = 1.toBigInteger(),
fee = demoFee.copy(value = normalDemoFee),
),
priorityFee = ProxyFee.Common(
gasLimit = 1.toBigInteger(),

View file

@ -156,23 +156,28 @@ internal class ExchangeStatusFactory(
)
}
private fun ExchangeStatus?.isTerminal() =
this == ExchangeStatus.Refunded || this == ExchangeStatus.Finished || this == ExchangeStatus.Cancelled
private fun ExchangeStatus?.isTerminal() = this == ExchangeStatus.Refunded ||
this == ExchangeStatus.Finished ||
this == ExchangeStatus.Cancelled ||
this == ExchangeStatus.TxFailed ||
this == ExchangeStatus.Unknown
private fun toAnalyticStatus(status: ExchangeStatus?): ExchangeAnalyticsStatus? {
return when (status) {
ExchangeStatus.New,
ExchangeStatus.Waiting,
ExchangeStatus.WaitingTxHash,
ExchangeStatus.Sending,
ExchangeStatus.Confirming,
ExchangeStatus.Exchanging,
-> ExchangeAnalyticsStatus.InProgress
ExchangeStatus.WaitingTxHash -> ExchangeAnalyticsStatus.WaitingTxHash
ExchangeStatus.Verifying -> ExchangeAnalyticsStatus.KYC
ExchangeStatus.Failed -> ExchangeAnalyticsStatus.Fail
ExchangeStatus.TxFailed -> ExchangeAnalyticsStatus.FailTx
ExchangeStatus.Finished -> ExchangeAnalyticsStatus.Done
ExchangeStatus.Refunded -> ExchangeAnalyticsStatus.Refunded
ExchangeStatus.Cancelled -> ExchangeAnalyticsStatus.Cancelled
ExchangeStatus.Unknown -> ExchangeAnalyticsStatus.Unknown
else -> null
}
}

View file

@ -5,7 +5,7 @@ import java.math.BigDecimal
import java.math.BigInteger
internal fun BigInteger.toBigDecimal(decimals: Int): BigDecimal {
return BigDecimal(this).movePointLeft(decimals)
return this.toBigDecimal().movePointLeft(decimals)
}
internal fun BigInteger.toInstant(): Instant {