Updated on 2026-08-14
This commit is contained in:
parent
210f392373
commit
9f070d6023
4 changed files with 0 additions and 79 deletions
|
|
@ -10,7 +10,6 @@ import com.tangem.core.configtoggle.FeatureToggles
|
||||||
import com.tangem.core.configtoggle.feature.FeatureTogglesManager
|
import com.tangem.core.configtoggle.feature.FeatureTogglesManager
|
||||||
import com.tangem.data.common.api.safeApiCall
|
import com.tangem.data.common.api.safeApiCall
|
||||||
import com.tangem.data.swap.converter.SwapDataConverter
|
import com.tangem.data.swap.converter.SwapDataConverter
|
||||||
import com.tangem.data.swap.converter.SwapStatusConverter
|
|
||||||
import com.tangem.data.swap.converter.TokenInfoConverter
|
import com.tangem.data.swap.converter.TokenInfoConverter
|
||||||
import com.tangem.datasource.api.common.response.getOrThrow
|
import com.tangem.datasource.api.common.response.getOrThrow
|
||||||
import com.tangem.datasource.api.express.TangemExpressApi
|
import com.tangem.datasource.api.express.TangemExpressApi
|
||||||
|
|
@ -65,7 +64,6 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
||||||
|
|
||||||
private val swapDataConverter = SwapDataConverter()
|
private val swapDataConverter = SwapDataConverter()
|
||||||
private val tokenInfoConverter = TokenInfoConverter()
|
private val tokenInfoConverter = TokenInfoConverter()
|
||||||
private val exchangeStatusConverter = SwapStatusConverter()
|
|
||||||
private val txDetailsMoshiAdapter = moshi.adapter(TxDetails::class.java)
|
private val txDetailsMoshiAdapter = moshi.adapter(TxDetails::class.java)
|
||||||
|
|
||||||
override suspend fun getPairs(
|
override suspend fun getPairs(
|
||||||
|
|
@ -404,22 +402,6 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getExchangeStatus(userWallet: UserWallet, txId: String): SwapStatusModel =
|
|
||||||
withContext(coroutineDispatcher.io) {
|
|
||||||
exchangeStatusConverter.convert(
|
|
||||||
tangemExpressApi
|
|
||||||
.getExchangeStatus(
|
|
||||||
userWalletId = userWallet.walletId.stringValue,
|
|
||||||
refCode = ExpressUtils.getRefCode(
|
|
||||||
userWallet = userWallet,
|
|
||||||
appPreferencesStore = appPreferencesStore,
|
|
||||||
),
|
|
||||||
txId = txId,
|
|
||||||
)
|
|
||||||
.getOrThrow(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun CoroutineScope.getPairsInternal(
|
private suspend fun CoroutineScope.getPairsInternal(
|
||||||
userWallet: UserWallet,
|
userWallet: UserWallet,
|
||||||
initialCurrency: CryptoCurrency,
|
initialCurrency: CryptoCurrency,
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.tangem.data.swap.converter
|
|
||||||
|
|
||||||
import com.tangem.datasource.api.express.models.response.ExchangeStatusResponse
|
|
||||||
import com.tangem.domain.swap.models.SwapStatus
|
|
||||||
import com.tangem.domain.swap.models.SwapStatusModel
|
|
||||||
import com.tangem.utils.converter.Converter
|
|
||||||
|
|
||||||
internal class SwapStatusConverter : Converter<ExchangeStatusResponse, SwapStatusModel> {
|
|
||||||
override fun convert(value: ExchangeStatusResponse): SwapStatusModel {
|
|
||||||
return SwapStatusModel(
|
|
||||||
providerId = value.providerId,
|
|
||||||
status = SwapStatus.entries.firstOrNull {
|
|
||||||
it.name.lowercase() == value.status.name.lowercase()
|
|
||||||
},
|
|
||||||
txId = value.externalTxId,
|
|
||||||
txExternalUrl = value.externalTxUrl,
|
|
||||||
txExternalId = value.externalTxId,
|
|
||||||
refundNetwork = value.refundNetwork,
|
|
||||||
refundContractAddress = value.refundContractAddress,
|
|
||||||
createdAt = value.createdAt,
|
|
||||||
averageDuration = value.averageDuration,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -449,35 +449,6 @@ internal class DefaultSwapRepositoryV2Test {
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region getExchangeStatus
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `getExchangeStatus returns converted status model`() = runTest {
|
|
||||||
// Arrange
|
|
||||||
val statusResponse = ExchangeStatusResponse(
|
|
||||||
providerId = PROVIDER_ID,
|
|
||||||
status = ExchangeStatus.Finished,
|
|
||||||
externalTxId = "ext-tx-1",
|
|
||||||
externalTxUrl = "https://example.com/tx/1",
|
|
||||||
error = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
coEvery {
|
|
||||||
tangemExpressApi.getExchangeStatus(any(), any(), any())
|
|
||||||
} returns ApiResponse.Success(statusResponse)
|
|
||||||
|
|
||||||
// Act
|
|
||||||
val result = repository.getExchangeStatus(userWallet = userWallet, txId = "tx-123")
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(result.providerId).isEqualTo(PROVIDER_ID)
|
|
||||||
assertThat(result.status).isEqualTo(SwapStatus.Finished)
|
|
||||||
assertThat(result.txId).isEqualTo("ext-tx-1")
|
|
||||||
assertThat(result.txExternalUrl).isEqualTo("https://example.com/tx/1")
|
|
||||||
}
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region swapTransactionSent
|
// region swapTransactionSent
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -127,12 +127,4 @@ interface SwapRepositoryV2 {
|
||||||
txHash: String,
|
txHash: String,
|
||||||
txExtraId: String?,
|
txExtraId: String?,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns status [SwapStatusModel] on active swap
|
|
||||||
*
|
|
||||||
* @param userWallet selected user wallet
|
|
||||||
* @param txId transaction id in ExpressApi
|
|
||||||
*/
|
|
||||||
suspend fun getExchangeStatus(userWallet: UserWallet, txId: String): SwapStatusModel
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue