Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-14 15:36:53 +04:00
parent 5e6bf6aaae
commit aaf4419ebe
12 changed files with 257 additions and 58 deletions

View file

@ -14,6 +14,7 @@ import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.datasource.local.preferences.utils.getObjectList
import com.tangem.datasource.local.preferences.utils.getObjectListSync
import com.tangem.datasource.local.preferences.utils.getObjectMap
import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
@ -54,7 +55,7 @@ internal class DefaultSwapTransactionRepository(
storeTransactionState(
txId = transaction.txId,
status = it,
refundTokenCurrency = null,
accountWithCurrency = null,
)
}
appPreferencesStore.editData { mutablePreferences ->
@ -177,7 +178,7 @@ internal class DefaultSwapTransactionRepository(
override suspend fun storeTransactionState(
txId: String,
status: SwapStatusModel,
refundTokenCurrency: CryptoCurrency?,
accountWithCurrency: Pair<AccountId?, CryptoCurrency>?,
) {
appPreferencesStore.editData { mutablePreferences ->
val savedMap = mutablePreferences.getObjectMap<SwapStatusDTO>(
@ -187,8 +188,8 @@ internal class DefaultSwapTransactionRepository(
val updatesMap = savedMap.toMutableMap()
updatesMap[txId] = savedStatusConverter.convert(
status.copy(
refundTokensResponse = refundTokenCurrency?.let {
userTokensResponseFactory.createResponseToken(refundTokenCurrency)
refundTokensResponse = accountWithCurrency?.let { (accountId, currency) ->
userTokensResponseFactory.createResponseToken(currency, accountId)
},
),
)

View file

@ -25,10 +25,12 @@ internal class SavedSwapTransactionListConverter(
fromCryptoCurrencyId = value.fromCryptoCurrencyId,
toCryptoCurrencyId = value.toCryptoCurrencyId,
fromTokensResponse = userTokensResponseFactory.createResponseToken(
value.fromCryptoCurrency,
currency = value.fromCryptoCurrency,
accountId = null,
),
toTokensResponse = userTokensResponseFactory.createResponseToken(
value.toCryptoCurrency,
currency = value.toCryptoCurrency,
accountId = null,
),
transactions = savedSwapTransactionConverter.convertList(value.transactions),
)
@ -74,8 +76,11 @@ internal class SavedSwapTransactionListConverter(
userWalletId = userWalletId.stringValue,
fromCryptoCurrencyId = fromCryptoCurrency.id.value,
toCryptoCurrencyId = toCryptoCurrency.id.value,
fromTokensResponse = userTokensResponseFactory.createResponseToken(fromCryptoCurrency),
toTokensResponse = userTokensResponseFactory.createResponseToken(toCryptoCurrency),
fromTokensResponse = userTokensResponseFactory.createResponseToken(
currency = fromCryptoCurrency,
accountId = null,
),
toTokensResponse = userTokensResponseFactory.createResponseToken(currency = toCryptoCurrency, accountId = null),
transactions = tokenTransactions,
)
}