Updated on 2026-08-14
This commit is contained in:
parent
ec8857a55e
commit
03c5bdd053
25 changed files with 1176 additions and 179 deletions
|
|
@ -12,9 +12,12 @@ import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier
|
|||
import com.tangem.domain.account.status.utils.CryptoCurrencyStatusOperations.getCryptoCurrencyStatus
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.network.TxInfo
|
||||
import com.tangem.domain.txhistory.TxHistoryFeatureToggles
|
||||
import com.tangem.domain.txhistory.fetcher.AppTxHistoryFetcher
|
||||
import com.tangem.domain.txhistory.fetcher.TxHistoryFetchTrigger
|
||||
import com.tangem.domain.txhistory.model.ExpressTx
|
||||
import com.tangem.domain.txhistory.model.OnChainTx
|
||||
import com.tangem.domain.txhistory.list.HistoryTxListManager
|
||||
import com.tangem.domain.txhistory.list.txHistoryInfoFlow
|
||||
import com.tangem.domain.txhistory.model.TxHistoryInfo
|
||||
|
|
@ -346,10 +349,18 @@ internal class TxHistoryModel @Inject constructor(
|
|||
override fun onTransactionClick(item: TxHistoryInfo) {
|
||||
// manager is non-null only under the new tx-history toggle.
|
||||
val manager = historyTxListManager
|
||||
if (manager != null) {
|
||||
if (manager != null && item.opensInAppDetails()) {
|
||||
params.onTxDetailsRequested(manager.txHistoryInfoFlow(item))
|
||||
} else {
|
||||
item.explorerHash?.let(::openTxInExplorer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** On-chain transfers/swaps and every express op open the in-app details sheet; everything else goes to the explorer. */
|
||||
private fun TxHistoryInfo.opensInAppDetails(): Boolean = when (this) {
|
||||
is ExpressTx -> true
|
||||
is OnChainTx.BSDK -> txInfo.type is TxInfo.TransactionType.Transfer || txInfo.type is TxInfo.TransactionType.Swap
|
||||
// Standalone TangemPay rows are not yet rendered in-app; route them to the explorer for now.
|
||||
is OnChainTx.TangemPay -> false
|
||||
}
|
||||
|
|
@ -483,18 +483,6 @@ internal class ExpressTxToDetailsUMConverterTest : TxDetailsConverterTestBase()
|
|||
assertThat(result.to?.label).isEqualTo(resourceReference(R.string.common_to))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN swap without addresses WHEN convert THEN no owner and default labels`() {
|
||||
// Act — no fromAddress / payoutAddress plumbed (e.g. very old app version).
|
||||
val result = converter.convert(expressSwap(status = ExpressExchangeStatus.Finished))
|
||||
|
||||
// Assert
|
||||
assertThat(result.from?.owner).isNull()
|
||||
assertThat(result.to?.owner).isNull()
|
||||
assertThat(result.from?.label).isEqualTo(resourceReference(R.string.swapping_from_title_v2))
|
||||
assertThat(result.to?.label).isEqualTo(resourceReference(R.string.swapping_to_title))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN onramp to own account WHEN convert THEN from is You paid and to has account owner`() {
|
||||
// Arrange
|
||||
|
|
|
|||
|
|
@ -226,8 +226,8 @@ internal class ExpressTxToTransactionItemUMConverterTest {
|
|||
provider = null,
|
||||
payinHash = null,
|
||||
payoutHash = null,
|
||||
fromAddress = null,
|
||||
payoutAddress = null,
|
||||
fromAddress = "from-addr",
|
||||
payoutAddress = "payout-addr",
|
||||
fromAsset = ExpressTransactionAsset(
|
||||
id = ExpressAssetId(networkId = "eth", contractAddress = "0"),
|
||||
amount = fromAmount,
|
||||
|
|
@ -238,34 +238,48 @@ internal class ExpressTxToTransactionItemUMConverterTest {
|
|||
amount = toAmount,
|
||||
decimals = 8,
|
||||
),
|
||||
externalTxUrl = null,
|
||||
payinAddress = "payin-addr",
|
||||
updatedAtMillis = 100,
|
||||
refundAssetId = null,
|
||||
refundCurrency = null,
|
||||
fromAmount = fromAmount ?: BigDecimal.ZERO,
|
||||
toAmount = toAmount ?: BigDecimal.ZERO,
|
||||
toActualAmount = null,
|
||||
),
|
||||
isOutgoing = isOutgoing,
|
||||
txInfo = null,
|
||||
)
|
||||
|
||||
private fun createOnramp(status: ExpressOnrampStatus, toAmount: BigDecimal? = BigDecimal("0.006339")) =
|
||||
ExpressTx.Onramp(
|
||||
tx = OnrampTransaction(
|
||||
txId = "tx-2",
|
||||
status = status,
|
||||
createdAtMillis = 100,
|
||||
provider = null,
|
||||
payoutHash = null,
|
||||
payoutAddress = null,
|
||||
fromFiat = Amount(
|
||||
currencySymbol = "SEK",
|
||||
value = BigDecimal("100"),
|
||||
decimals = 2,
|
||||
type = AmountType.FiatType(code = "SEK"),
|
||||
),
|
||||
toAsset = ExpressTransactionAsset(
|
||||
id = ExpressAssetId(networkId = "btc", contractAddress = "0"),
|
||||
amount = toAmount,
|
||||
decimals = 8,
|
||||
),
|
||||
private fun createOnramp(
|
||||
status: ExpressOnrampStatus,
|
||||
toAmount: BigDecimal? = BigDecimal("0.006339"),
|
||||
) = ExpressTx.Onramp(
|
||||
tx = OnrampTransaction(
|
||||
txId = "tx-2",
|
||||
status = status,
|
||||
createdAtMillis = 100,
|
||||
provider = null,
|
||||
payoutHash = null,
|
||||
payoutAddress = "payout-addr",
|
||||
fromFiat = Amount(
|
||||
currencySymbol = "SEK",
|
||||
value = BigDecimal("100"),
|
||||
decimals = 2,
|
||||
type = AmountType.FiatType(code = "SEK"),
|
||||
),
|
||||
txInfo = null,
|
||||
)
|
||||
toAsset = ExpressTransactionAsset(
|
||||
id = ExpressAssetId(networkId = "btc", contractAddress = "0"),
|
||||
amount = toAmount,
|
||||
decimals = 8,
|
||||
),
|
||||
externalTxUrl = null,
|
||||
country = null,
|
||||
toAmount = toAmount,
|
||||
toActualAmount = null,
|
||||
),
|
||||
txInfo = null,
|
||||
)
|
||||
|
||||
private fun createCoin(symbol: String, decimals: Int): CryptoCurrency.Coin = CryptoCurrency.Coin(
|
||||
id = CryptoCurrency.ID(
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ internal open class TxDetailsConverterTestBase {
|
|||
txInfo: OnChainTx? = null,
|
||||
provider: ExpressProvider? = null,
|
||||
externalTxUrl: String? = null,
|
||||
fromAddress: String? = null,
|
||||
payoutAddress: String? = null,
|
||||
fromAddress: String = FROM_ADDRESS,
|
||||
payoutAddress: String = PAYOUT_ADDRESS,
|
||||
fromCurrency: CryptoCurrency? = null,
|
||||
): ExpressTx.Swap = ExpressTx.Swap(
|
||||
tx = ExchangeTransaction(
|
||||
|
|
@ -192,6 +192,13 @@ internal open class TxDetailsConverterTestBase {
|
|||
cryptoCurrency = bitcoin,
|
||||
),
|
||||
externalTxUrl = externalTxUrl,
|
||||
payinAddress = "payin-addr",
|
||||
updatedAtMillis = TIMESTAMP,
|
||||
refundAssetId = null,
|
||||
refundCurrency = null,
|
||||
fromAmount = BigDecimal("1.5"),
|
||||
toAmount = BigDecimal("0.001"),
|
||||
toActualAmount = null,
|
||||
),
|
||||
isOutgoing = isOutgoing,
|
||||
txInfo = txInfo,
|
||||
|
|
@ -201,7 +208,7 @@ internal open class TxDetailsConverterTestBase {
|
|||
status: ExpressOnrampStatus,
|
||||
txInfo: OnChainTx? = null,
|
||||
externalTxUrl: String? = null,
|
||||
payoutAddress: String? = null,
|
||||
payoutAddress: String = PAYOUT_ADDRESS,
|
||||
): ExpressTx.Onramp = ExpressTx.Onramp(
|
||||
tx = OnrampTransaction(
|
||||
txId = "onramp-1",
|
||||
|
|
@ -223,6 +230,9 @@ internal open class TxDetailsConverterTestBase {
|
|||
decimals = 8,
|
||||
cryptoCurrency = bitcoin,
|
||||
),
|
||||
country = null,
|
||||
toAmount = BigDecimal("0.006"),
|
||||
toActualAmount = null,
|
||||
),
|
||||
txInfo = txInfo,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ internal class TxHistoryInfoToTransactionItemUMConverterTest {
|
|||
provider = null,
|
||||
payinHash = null,
|
||||
payoutHash = null,
|
||||
fromAddress = null,
|
||||
payoutAddress = null,
|
||||
fromAddress = "from-addr",
|
||||
payoutAddress = "payout-addr",
|
||||
fromAsset = ExpressTransactionAsset(
|
||||
id = ExpressAssetId(networkId = "ethereum", contractAddress = "0"),
|
||||
amount = BigDecimal("1.5"),
|
||||
|
|
@ -120,6 +120,14 @@ internal class TxHistoryInfoToTransactionItemUMConverterTest {
|
|||
amount = BigDecimal("0.001"),
|
||||
decimals = 8,
|
||||
),
|
||||
externalTxUrl = null,
|
||||
payinAddress = "payin-addr",
|
||||
updatedAtMillis = TIMESTAMP,
|
||||
refundAssetId = null,
|
||||
refundCurrency = null,
|
||||
fromAmount = BigDecimal("1.5"),
|
||||
toAmount = BigDecimal("0.001"),
|
||||
toActualAmount = null,
|
||||
),
|
||||
isOutgoing = true,
|
||||
txInfo = null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue