diff --git a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt index 7115c1f18b..56a3421686 100644 --- a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt +++ b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt @@ -593,7 +593,7 @@ internal class ChildFactory @Inject constructor( is AppRoute.TangemPayDetails -> { createComponentChild( context = context, - params = TangemPayDetailsComponent.Params(userWalletId = route.userWalletId), + params = TangemPayDetailsComponent.Params(customerWalletAddress = route.customerWalletAddress), componentFactory = tangemPayDetailsComponentFactory, ) } diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt index c7f93ffccc..3893f51268 100644 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt +++ b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt @@ -439,7 +439,7 @@ sealed class AppRoute(val path: String) : Route { ) : AppRoute(path = "/archived_account/${userWalletId.stringValue}") @Serializable - data class TangemPayDetails(val userWalletId: UserWalletId) : AppRoute(path = "/tangem_pay_details") + data class TangemPayDetails(val customerWalletAddress: String) : AppRoute(path = "/tangem_pay_details") @Serializable data class TangemPayOnboarding( diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/visa/DefaultTangemPayTxHistoryItemsStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/visa/DefaultTangemPayTxHistoryItemsStore.kt index 1a6014d355..fd01586877 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/visa/DefaultTangemPayTxHistoryItemsStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/visa/DefaultTangemPayTxHistoryItemsStore.kt @@ -2,21 +2,20 @@ package com.tangem.datasource.local.visa import com.tangem.datasource.local.datastore.core.StringKeyDataStore import com.tangem.datasource.local.datastore.core.StringKeyDataStoreDecorator -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.visa.model.TangemPayTxHistoryItem internal class DefaultTangemPayTxHistoryItemsStore( dataStore: StringKeyDataStore>>, ) : TangemPayTxHistoryItemsStore, - StringKeyDataStoreDecorator>>(dataStore) { - override fun provideStringKey(key: UserWalletId): String = key.stringValue + StringKeyDataStoreDecorator>>(dataStore) { + override fun provideStringKey(key: String): String = key - override suspend fun getSyncOrNull(key: UserWalletId, cursor: String): List? { + override suspend fun getSyncOrNull(key: String, cursor: String): List? { val storedValue = getSyncOrNull(key) return storedValue?.get(cursor) } - override suspend fun store(key: UserWalletId, cursor: String, value: List) { + override suspend fun store(key: String, cursor: String, value: List) { val oldValue = getSyncOrNull(key).orEmpty() val newValue = oldValue.toMutableMap().apply { put(cursor, value) } store(key, newValue) diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/visa/TangemPayTxHistoryItemsStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/visa/TangemPayTxHistoryItemsStore.kt index c327023e6b..e18be41c5a 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/visa/TangemPayTxHistoryItemsStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/visa/TangemPayTxHistoryItemsStore.kt @@ -1,13 +1,12 @@ package com.tangem.datasource.local.visa -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.visa.model.TangemPayTxHistoryItem interface TangemPayTxHistoryItemsStore { - suspend fun getSyncOrNull(key: UserWalletId, cursor: String): List? + suspend fun getSyncOrNull(key: String, cursor: String): List? - suspend fun remove(key: UserWalletId) + suspend fun remove(key: String) - suspend fun store(key: UserWalletId, cursor: String, value: List) + suspend fun store(key: String, cursor: String, value: List) } \ No newline at end of file diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultOnboardingRepository.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultOnboardingRepository.kt index e626dc3cc5..450444bf67 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultOnboardingRepository.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultOnboardingRepository.kt @@ -68,11 +68,14 @@ internal class DefaultOnboardingRepository @Inject constructor( private fun getCustomerInfo(response: CustomerMeResponse.Result?): CustomerInfo { val card = response?.card val balance = response?.balance - val cardInfo = if (card != null && balance != null) { + val productInstance = response?.productInstance + val cardInfo = if (productInstance != null && card != null && balance != null) { CardInfo( lastFourDigits = card.cardNumberEnd, balance = balance.availableBalance, currencyCode = balance.currency, + customerWalletAddress = productInstance.cardWalletAddress, + ) } else { null diff --git a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultTangemPayTxHistoryRepository.kt b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultTangemPayTxHistoryRepository.kt index a5013ee703..1498a36a01 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultTangemPayTxHistoryRepository.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/pay/repository/DefaultTangemPayTxHistoryRepository.kt @@ -4,7 +4,6 @@ import com.tangem.data.common.cache.CacheRegistry import com.tangem.data.visa.utils.TangemPayTxHistoryItemConverter import com.tangem.datasource.api.pay.TangemPayApi import com.tangem.datasource.local.visa.TangemPayTxHistoryItemsStore -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.tangempay.model.TangemPayTxHistoryListBatchFlow import com.tangem.domain.tangempay.model.TangemPayTxHistoryListBatchingContext import com.tangem.domain.tangempay.model.TangemPayTxHistoryListConfig @@ -65,28 +64,28 @@ internal class DefaultTangemPayTxHistoryRepository @Inject constructor( limit: Int, ): List { cacheRegistry.invokeOnExpire( - key = getCacheKey(userWalletId = config.userWalletId, cursor = cursor), + key = getCacheKey(customerWalletAddress = config.customerWalletAddress, cursor = cursor), skipCache = config.refresh, - block = { fetch(userWalletId = config.userWalletId, cursor = cursor, pageSize = limit) }, + block = { fetch(customerWalletAddress = config.customerWalletAddress, cursor = cursor, pageSize = limit) }, ) return txHistoryItemsStore.getSyncOrNull( - key = config.userWalletId, + key = config.customerWalletAddress, cursor = cursor ?: INITIAL_CURSOR, ).orEmpty() } - private fun getCacheKey(userWalletId: UserWalletId, cursor: String?): String { - return "tangem_pay_tx_history_${userWalletId}_${cursor ?: INITIAL_CURSOR}" + private fun getCacheKey(customerWalletAddress: String, cursor: String?): String { + return "tangem_pay_tx_history_${customerWalletAddress}_${cursor ?: INITIAL_CURSOR}" } - private suspend fun fetch(userWalletId: UserWalletId, cursor: String?, pageSize: Int) { + private suspend fun fetch(customerWalletAddress: String, cursor: String?, pageSize: Int) { requestPerformer.runWithErrorLogs(TAG) { val result = requestPerformer.request { authHeader -> visaApi.getTangemPayTxHistory(authHeader = authHeader, limit = pageSize, cursor = cursor) }.result val items = TangemPayTxHistoryItemConverter.convertList(result.transactions) - txHistoryItemsStore.store(key = userWalletId, cursor = cursor ?: INITIAL_CURSOR, value = items) + txHistoryItemsStore.store(key = customerWalletAddress, cursor = cursor ?: INITIAL_CURSOR, value = items) } } } \ No newline at end of file diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/CustomerInfo.kt b/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/CustomerInfo.kt index 3341b39605..9a5438f259 100644 --- a/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/CustomerInfo.kt +++ b/domain/visa/src/main/kotlin/com/tangem/domain/pay/model/CustomerInfo.kt @@ -24,6 +24,7 @@ data class CustomerInfo( val lastFourDigits: String, val balance: BigDecimal, val currencyCode: String, + val customerWalletAddress: String, ) fun isKycApproved() = kycStatus == APPROVED_KYC_STATUS diff --git a/domain/visa/src/main/kotlin/com/tangem/domain/tangempay/model/TangemPayTxHistoryListConfig.kt b/domain/visa/src/main/kotlin/com/tangem/domain/tangempay/model/TangemPayTxHistoryListConfig.kt index e62a78f59a..538753c2f0 100644 --- a/domain/visa/src/main/kotlin/com/tangem/domain/tangempay/model/TangemPayTxHistoryListConfig.kt +++ b/domain/visa/src/main/kotlin/com/tangem/domain/tangempay/model/TangemPayTxHistoryListConfig.kt @@ -1,5 +1,3 @@ package com.tangem.domain.tangempay.model -import com.tangem.domain.models.wallet.UserWalletId - -data class TangemPayTxHistoryListConfig(val userWalletId: UserWalletId, val refresh: Boolean) \ No newline at end of file +data class TangemPayTxHistoryListConfig(val customerWalletAddress: String, val refresh: Boolean) \ No newline at end of file diff --git a/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayDetailsComponent.kt b/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayDetailsComponent.kt index bd9326f7e9..27d7af0cc1 100644 --- a/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayDetailsComponent.kt +++ b/features/tangempay/details/api/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayDetailsComponent.kt @@ -2,9 +2,8 @@ package com.tangem.features.tangempay.components import com.tangem.core.decompose.factory.ComponentFactory import com.tangem.core.ui.decompose.ComposableContentComponent -import com.tangem.domain.models.wallet.UserWalletId interface TangemPayDetailsComponent : ComposableContentComponent { - data class Params(val userWalletId: UserWalletId) + data class Params(val customerWalletAddress: String) interface Factory : ComponentFactory } \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/DefaultTangemPayDetailsComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/DefaultTangemPayDetailsComponent.kt index cd5e1f5b79..6f38bea920 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/DefaultTangemPayDetailsComponent.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/DefaultTangemPayDetailsComponent.kt @@ -23,7 +23,7 @@ internal class DefaultTangemPayDetailsComponent @AssistedInject constructor( private val model: TangemPayDetailsModel = getOrCreateModel(params = params) private val txHistoryComponent = DefaultTangemPayTxHistoryComponent( appComponentContext = child("txHistoryComponent"), - params = DefaultTangemPayTxHistoryComponent.Params(userWalletId = params.userWalletId), + params = DefaultTangemPayTxHistoryComponent.Params(customerWalletAddress = params.customerWalletAddress), ) @Composable diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/DefaultTangemPayTxHistoryComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/DefaultTangemPayTxHistoryComponent.kt index c0ccc0a291..4a881f8c23 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/DefaultTangemPayTxHistoryComponent.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/DefaultTangemPayTxHistoryComponent.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.LazyListState import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.model.getOrCreateModel -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.features.tangempay.model.TangemPayTxHistoryModel import com.tangem.features.txhistory.entity.TxHistoryUM import com.tangem.features.txhistory.ui.txHistoryItems @@ -22,5 +21,5 @@ internal class DefaultTangemPayTxHistoryComponent( txHistoryItems(listState, state) } - data class Params(val userWalletId: UserWalletId) + data class Params(val customerWalletAddress: String) } \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayTxHistoryModel.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayTxHistoryModel.kt index 998d340f7e..f7b8a89c8b 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayTxHistoryModel.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayTxHistoryModel.kt @@ -31,7 +31,7 @@ internal class TangemPayTxHistoryModel @Inject constructor( private val listManager = TangemPayTxHistoryListManager( repository = tangemPayTxHistoryRepository, dispatchers = dispatchers, - userWalletId = params.userWalletId, + customerWalletAddress = params.customerWalletAddress, txHistoryUiActions = this, ) @@ -86,7 +86,7 @@ internal class TangemPayTxHistoryModel @Inject constructor( } private fun loadMoreItems(): Boolean { - modelScope.launch { listManager.loadMore(params.userWalletId) } + modelScope.launch { listManager.loadMore(params.customerWalletAddress) } return true } diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/utils/TangemPayTxHistoryListManager.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/utils/TangemPayTxHistoryListManager.kt index 261dbcc875..08a015090c 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/utils/TangemPayTxHistoryListManager.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/utils/TangemPayTxHistoryListManager.kt @@ -1,6 +1,5 @@ package com.tangem.features.tangempay.utils -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.tangempay.model.TangemPayTxHistoryListBatchingContext import com.tangem.domain.tangempay.model.TangemPayTxHistoryListConfig import com.tangem.domain.tangempay.repository.TangemPayTxHistoryRepository @@ -23,7 +22,7 @@ private typealias TangemPayTxHistoryBatchAction = BatchAction Unit, ) : TangemPayState() } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayStateTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayStateTransformer.kt index a54982b7ac..ceadc84c7b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayStateTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/TangemPayStateTransformer.kt @@ -17,6 +17,7 @@ internal class TangemPayStateTransformer( private val value: MainScreenCustomerInfo? = null, private val onIssueOrderClick: () -> Unit = {}, private val onContinueKycClick: () -> Unit = {}, + private val cardOnClick: (String) -> Unit = {}, private val issueProgressState: Boolean = false, private val issueState: Boolean = false, ) : Transformer { @@ -63,6 +64,7 @@ internal class TangemPayStateTransformer( private fun getCardInfoState(cardInfo: CardInfo): TangemPayState = TangemPayState.Card( lastFourDigits = TextReference.Str("*${cardInfo.lastFourDigits}"), balanceText = TextReference.Str(getBalanceText(cardInfo)), + onClick = { cardOnClick(cardInfo.customerWalletAddress) }, ) private fun getBalanceText(cardInfo: CardInfo): String { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt index 7cc3d681e6..35c2b614fc 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/singlecurrency/TangemPayCardMainBlock.kt @@ -1,6 +1,7 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components.singlecurrency import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Surface @@ -21,7 +22,9 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.TangemPayState @Composable internal fun TangemPayCardMainBlock(state: TangemPayState.Card, modifier: Modifier = Modifier) { Surface( - modifier = modifier.fillMaxWidth(), + modifier = modifier + .fillMaxWidth() + .clickable { state.onClick() }, shape = TangemTheme.shapes.roundedCornersXMedium, color = TangemTheme.colors.background.primary, ) { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt index 786e56b157..ee134f6fea 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/TangemPayMainScreenBlock.kt @@ -81,6 +81,7 @@ private fun ResetCardScreenPreview() { TangemPayState.Card( lastFourDigits = TextReference.Str("*1234"), balanceText = TextReference.Str("$ 0.00"), + onClick = {}, ), ) }