diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt index 27eb47df0b..0f673b9ba6 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt @@ -133,11 +133,29 @@ internal class DefaultLegacyWalletConnectRepository( return } + val optionalMissingNetwork = findMissingNetworks( + namespaces = sessionProposal.optionalNamespaces, + userNamespaces = this@DefaultLegacyWalletConnectRepository.userNamespaces ?: emptyMap(), + ) + val optionalWithoutMissingNetworks = removeMissingNetworks( namespaces = sessionProposal.optionalNamespaces, userNamespaces = this@DefaultLegacyWalletConnectRepository.userNamespaces ?: emptyMap(), ) + // for cases when optionalNamespaces is not empty but we doesn't support none of them + if (optionalMissingNetwork.isNotEmpty() && optionalWithoutMissingNetworks.isEmpty()) { + Timber.i("Not added optional blockchains: $optionalMissingNetwork") + scope.launch { + _events.emit( + WalletConnectEvents.SessionApprovalError( + WalletConnectError.ApprovalErrorMissingNetworks(optionalMissingNetwork.toList()), + ), + ) + } + return + } + val requiredChainIds = sessionProposal.requiredNamespaces.values.flatMap { it.chains ?: emptyList() } val optionalChainIds = optionalWithoutMissingNetworks.toList() val networks = (requiredChainIds + optionalChainIds) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt index be7ff95089..2ba6a15344 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WalletConnectInteractor.kt @@ -149,21 +149,18 @@ class WalletConnectInteractor( Timber.i("WalletConnect: event: $wcEvent") when (wcEvent) { is WalletConnectEvents.SessionProposal -> { - val unsupportedNetworks = wcEvent.requiredChainIds.filter { - blockchainHelper.chainIdToNetworkIdOrNull(it) == null - } - - val supportedNetworks = (wcEvent.requiredChainIds + wcEvent.optionalChainIds) - .mapNotNull(blockchainHelper::chainIdToFullNameOrNull) - .distinct() - - if (unsupportedNetworks.isNotEmpty() || supportedNetworks.isEmpty()) { + val unsupportedNetworks = wcEvent.requiredChainIds + .filter { blockchainHelper.chainIdToNetworkIdOrNull(it) == null } + if (unsupportedNetworks.isNotEmpty()) { val error = WalletConnectError.ApprovalErrorUnsupportedNetwork(unsupportedNetworks) handler.onSessionRejected(error) return@onEach } - - handler.onProposalReceived(proposal = wcEvent, networksFormatted = supportedNetworks.toString()) + val networksFormatted = (wcEvent.requiredChainIds + wcEvent.optionalChainIds) + .mapNotNull { blockchainHelper.chainIdToFullNameOrNull(it) } + .distinct() + .toString() + handler.onProposalReceived(proposal = wcEvent, networksFormatted = networksFormatted) } is WalletConnectEvents.SessionApprovalError -> { val error = when (wcEvent.error) { diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/analytics/utils/StakingAnalyticSender.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/analytics/utils/StakingAnalyticSender.kt index e5911ef720..9fa18b8ed5 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/analytics/utils/StakingAnalyticSender.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/analytics/utils/StakingAnalyticSender.kt @@ -9,6 +9,7 @@ import com.tangem.domain.staking.model.stakekit.action.StakingActionType import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.staking.analytics.StakeScreenSource import com.tangem.domain.staking.analytics.StakingAnalyticsEvent +import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.features.staking.impl.presentation.state.* internal class StakingAnalyticSender( @@ -75,14 +76,14 @@ internal class StakingAnalyticSender( ) } - fun sendTransactionStakingAnalytics(value: StakingUiState) { + fun sendTransactionStakingAnalytics(value: StakingUiState, cryptoCurrencyStatus: CryptoCurrencyStatus) { val validatorState = value.validatorState as? StakingStates.ValidatorState.Data val validatorName = validatorState?.chosenValidator?.name ?: return analyticsEventHandler.send( Basic.TransactionSent( sentFrom = AnalyticsParam.TxSentFrom.Staking( - blockchain = value.cryptoCurrencyName, + blockchain = cryptoCurrencyStatus.currency.network.name, token = value.cryptoCurrencySymbol, feeType = AnalyticsParam.FeeType.Normal, ), diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt index 2c3eda379d..9b6c29105e 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt @@ -349,7 +349,10 @@ internal class StakingModel @Inject constructor( stateController.update(SetConfirmationStateResetAssentTransformer(cryptoCurrencyStatus)) }, onSendSuccess = { txUrl -> - stakingAnalyticSender.sendTransactionStakingAnalytics(stateController.value) + stakingAnalyticSender.sendTransactionStakingAnalytics( + stateController.value, + cryptoCurrencyStatus, + ) transactionsInProgress.clear() stateController.update(SetConfirmationStateCompletedTransformer(txUrl, cryptoCurrencyStatus)) }, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 7848653a92..f571e8e79d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -431,29 +431,16 @@ internal class WalletModel @Inject constructor( action.selectedWalletIndex } - /* - * Should not show scroll animation if WalletScreen isn't in the background. - * Example, reset card - */ - if (screenLifecycleProvider.isBackgroundState.value) { - updateStateByDeleteWalletTransformer( - selectedWalletIndex = newSelectedWalletIndex, - deletedWalletId = action.deletedWalletId, - ) - } else { - withContext(dispatchers.io) { delay(timeMillis = 1000) } - - scrollToWallet( - prevIndex = action.deletedWalletIndex, - newIndex = action.selectedWalletIndex, - onConsume = { - updateStateByDeleteWalletTransformer( - selectedWalletIndex = newSelectedWalletIndex, - deletedWalletId = action.deletedWalletId, - ) - }, - ) - } + scrollToWallet( + prevIndex = action.deletedWalletIndex, + newIndex = action.selectedWalletIndex, + onConsume = { + updateStateByDeleteWalletTransformer( + selectedWalletIndex = newSelectedWalletIndex, + deletedWalletId = action.deletedWalletId, + ) + }, + ) } private fun updateStateByDeleteWalletTransformer(selectedWalletIndex: Int, deletedWalletId: UserWalletId) { @@ -485,15 +472,20 @@ internal class WalletModel @Inject constructor( } private fun scrollToWallet(prevIndex: Int, newIndex: Int, onConsume: () -> Unit = {}) { - stateHolder.update( - ScrollToWalletTransformer( - prevIndex = prevIndex, - newIndex = newIndex, - currentStateProvider = Provider(action = stateHolder::value), - stateUpdater = { newState -> stateHolder.update { newState } }, - onConsume = onConsume, - ), - ) + // Should not show scroll animation if WalletScreen isn't in the background. + if (screenLifecycleProvider.isBackgroundState.value) { + onConsume() + } else { + stateHolder.update( + ScrollToWalletTransformer( + prevIndex = prevIndex, + newIndex = newIndex, + currentStateProvider = Provider(action = stateHolder::value), + stateUpdater = { newState -> stateHolder.update { newState } }, + onConsume = onConsume, + ), + ) + } } inner class AskBiometryModelCallbacks : AskBiometryComponent.ModelCallbacks { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/Wallet2CobrandImage.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/Wallet2CobrandImage.kt index d49cdd69fb..67d80b72bb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/Wallet2CobrandImage.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/Wallet2CobrandImage.kt @@ -49,6 +49,12 @@ internal enum class Wallet2CobrandImage( batchIds = setOf("AF33"), ), + BitcoinPizza2( + cards2ResId = R.drawable.ill_pizza_day2_card2_120_106, + cards3ResId = R.drawable.ill_pizza_day2_card3_120_106, + batchIds = setOf("AF990019"), + ), + BTC365( cards2ResId = R.drawable.ill_btc365_card2_120_106, cards3ResId = R.drawable.ill_btc365_card3_120_106, @@ -67,6 +73,12 @@ internal enum class Wallet2CobrandImage( batchIds = setOf("BB000013"), ), + Chilliz( + cards2ResId = R.drawable.ill_chilliz_card2_120_106, + cards3ResId = R.drawable.ill_chilliz_card3_120_106, + batchIds = setOf("BB000016"), + ), + CoinMetrica( cards2ResId = R.drawable.ill_coin_metrica_card2_120_106, cards3ResId = R.drawable.ill_coin_metrica_card3_120_106, @@ -206,6 +218,12 @@ internal enum class Wallet2CobrandImage( batchIds = setOf("AF43", "AF44", "AF45", "AF78", "AF79", "AF80"), ), + RamenCat( + cards2ResId = R.drawable.ill_ramen_cat_cards2_120_106, + cards3ResId = R.drawable.ill_ramen_cat_cards3_120_106, + batchIds = setOf("AF990006", "AF990007", "AF990008"), + ), + RedPanda( cards2ResId = R.drawable.ill_red_panda_card2_120_106, cards3ResId = R.drawable.ill_red_panda_card3_120_106, @@ -218,6 +236,12 @@ internal enum class Wallet2CobrandImage( batchIds = setOf("BB000012"), ), + Sakura( + cards2ResId = R.drawable.ill_sakura_card2_120_106, + cards3ResId = R.drawable.ill_sakura_card3_120_106, + batchIds = setOf("AF990029", "AF990030", "AF990031"), + ), + SatoshiFriends( cards2ResId = R.drawable.ill_satoshi_card2_120_106, cards3ResId = R.drawable.ill_satoshi_card3_120_106, diff --git a/features/wallet/impl/src/main/res/drawable/ill_chilliz_card2_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_chilliz_card2_120_106.webp new file mode 100644 index 0000000000..5f3c4676ca Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_chilliz_card2_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_chilliz_card3_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_chilliz_card3_120_106.webp new file mode 100644 index 0000000000..4130ca2f1b Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_chilliz_card3_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card2_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card2_120_106.webp new file mode 100644 index 0000000000..d50e70f111 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card2_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card3_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card3_120_106.webp new file mode 100644 index 0000000000..c9f830d69f Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_pizza_day2_card3_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards2_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards2_120_106.webp new file mode 100644 index 0000000000..e71a51a9f3 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards2_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards3_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards3_120_106.webp new file mode 100644 index 0000000000..37c8db9234 Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_ramen_cat_cards3_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_sakura_card2_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_sakura_card2_120_106.webp new file mode 100644 index 0000000000..d09b5a8c9e Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_sakura_card2_120_106.webp differ diff --git a/features/wallet/impl/src/main/res/drawable/ill_sakura_card3_120_106.webp b/features/wallet/impl/src/main/res/drawable/ill_sakura_card3_120_106.webp new file mode 100644 index 0000000000..38e7562a8b Binary files /dev/null and b/features/wallet/impl/src/main/res/drawable/ill_sakura_card3_120_106.webp differ