From 00d55ff5a64e8d66915fec41c7422fc243e7b9c8 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 12 Dec 2025 15:11:58 +0500 Subject: [PATCH] Updated on 2026-08-14 --- core/ui/detekt-baseline-debug.xml | 1 - data/swap/detekt-baseline-debug.xml | 19 ---- .../data/swap/DefaultSwapRepositoryV2.kt | 51 ++++----- .../swap/DefaultSwapTransactionRepository.kt | 28 ++--- .../data/swap/converter/SwapDataConverter.kt | 6 +- detekt_baseline_report.txt | 30 +++-- domain/staking/detekt-baseline-debug.xml | 1 - .../impl/detekt-baseline-debug.xml | 1 - .../markets/impl/detekt-baseline-debug.xml | 1 - .../impl/detekt-baseline-debug.xml | 2 - .../referral/impl/detekt-baseline-debug.xml | 1 - .../swap-v2/impl/detekt-baseline-debug.xml | 46 -------- .../analytics/SwapAmountAnalyticEvents.kt | 2 +- .../v2/impl/amount/entity/SwapAmountUM.kt | 4 +- .../v2/impl/amount/model/SwapAmountModel.kt | 106 +++++++++--------- .../SwapAmountPrimaryReadyStateTransformer.kt | 6 +- ...wapAmountSecondaryReadyStateTransformer.kt | 6 +- .../SwapAmountSelectQuoteTransformer.kt | 4 +- .../SwapAmountSetQuotesTransformer.kt | 10 +- .../impl/amount/ui/SwapAmountBlockContent.kt | 4 +- .../v2/impl/amount/ui/SwapAmountContent.kt | 10 +- .../ui/preview/SwapAmountContentPreview.kt | 8 +- .../model/SwapChooseProviderModel.kt | 14 +-- .../SwapProviderListItemConverter.kt | 6 +- .../converter/SwapProviderStateConverter.kt | 6 +- .../model/SwapChooseTokenNetworkModel.kt | 8 +- .../swap/v2/impl/common/SwapAlertFactory.kt | 3 +- .../swap/v2/impl/common/entity/ConfirmUM.kt | 2 +- .../analytics/SendWithSwapAnalyticEvents.kt | 2 +- .../confirm/model/SendWithSwapConfirmModel.kt | 33 +++--- .../confirm/model/SwapTransactionSender.kt | 10 +- ...dWithSwapConfirmInitialStateTransformer.kt | 2 +- ...wapConfirmationNotificationsTransformer.kt | 8 +- .../sendviaswap/model/SendWithSwapModel.kt | 10 +- .../success/ui/SendWithSwapSuccessContent.kt | 2 +- .../sendviaswap/ui/SendWithSwapContent.kt | 10 +- .../tester/impl/detekt-baseline-debug.xml | 2 - .../impl/detekt-baseline-debug.xml | 1 - .../wallet/impl/detekt-baseline-debug.xml | 1 - 39 files changed, 195 insertions(+), 272 deletions(-) delete mode 100644 data/swap/detekt-baseline-debug.xml delete mode 100644 features/swap-v2/impl/detekt-baseline-debug.xml diff --git a/core/ui/detekt-baseline-debug.xml b/core/ui/detekt-baseline-debug.xml index a625c6029f..662bc3318f 100644 --- a/core/ui/detekt-baseline-debug.xml +++ b/core/ui/detekt-baseline-debug.xml @@ -24,7 +24,6 @@ NoNameShadowing:TextAnimatedCounter.kt$char PropertyUsedBeforeDeclaration:InputManager.kt$InputManager$_query ReusedModifierInstance:EllipsisText.kt$Text( text = layoutText, color = color, style = style, fontStyle = fontStyle, textDecoration = textDecoration, textAlign = textAlign, softWrap = softWrap, maxLines = 1, onTextLayout = { textLayoutResultState.value = it }, modifier = modifier, ) - ReusedModifierInstance:Label.kt$Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = modifier .padding(horizontal = 4.dp) .clip(TangemTheme.shapes.roundedCorners8) .background(color = backgroundColor) .then( if (state.onClick != null) { Modifier.clickable( interactionSource = remember { MutableInteractionSource() }, indication = ripple(), onClick = state.onClick, ) } else { Modifier }, ) .padding(horizontal = 8.dp, vertical = 4.dp), ) { Text( modifier = Modifier.weight(1.0f, fill = false), text = text.resolveReference(), style = TangemTheme.typography.caption1, color = textColor, ) AnimatedVisibility(state.icon != null) { val wrappedIcon = remember(this) { requireNotNull(state.icon) } Icon( imageVector = ImageVector.vectorResource(wrappedIcon), tint = iconColor, contentDescription = null, modifier = Modifier .size(16.dp) .clickable( interactionSource = remember { MutableInteractionSource() }, indication = ripple(bounded = false), onClick = { state.onIconClick?.invoke() }, ), ) } } ReusedModifierInstance:TangemRadioButton.kt$AnimatedVisibility( visible = isSelected, label = "Radio button animation", modifier = modifier .size(TangemTheme.dimens.size24), ) { Icon( painter = painterResource(id = R.drawable.ic_check_circle_24), contentDescription = null, tint = TangemTheme.colors.control.checked, ) } ReusedModifierInstance:TokenPrice.kt$Icon( modifier = modifier, painter = painterResource( id = when (animatedType) { PriceChangeType.UP -> R.drawable.ic_arrow_up_8 PriceChangeType.DOWN -> R.drawable.ic_arrow_down_8 PriceChangeType.NEUTRAL -> R.drawable.ic_elipse_8 }, ), tint = when (animatedType) { PriceChangeType.UP -> TangemTheme.colors.icon.accent PriceChangeType.DOWN -> TangemTheme.colors.icon.warning PriceChangeType.NEUTRAL -> TangemTheme.colors.icon.inactive }, contentDescription = null, ) UnnecessaryEventHandlerParameter:PinTextField.kt$onValueChange: (String) -> Unit diff --git a/data/swap/detekt-baseline-debug.xml b/data/swap/detekt-baseline-debug.xml deleted file mode 100644 index b047ac0eff..0000000000 --- a/data/swap/detekt-baseline-debug.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - MaxChainedCallsOnSameLine:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2$fromCryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value.orEmpty() - MultilineLambdaItParameter:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2${ Timber.w(it, "Unable to get pairs") throw it } - MultilineLambdaItParameter:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2${ it.currency.getContractAddress() == pair.from.contractAddress && it.currency.network.backendId == pair.from.network } - MultilineLambdaItParameter:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2${ it.currency.getContractAddress() == pair.to.contractAddress && it.currency.network.backendId == pair.to.network } - MultilineLambdaItParameter:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2${ it.getContractAddress() == pair.from.contractAddress && it.network.backendId == pair.from.network } - MultilineLambdaItParameter:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2${ it.getContractAddress() == pair.to.contractAddress && it.network.backendId == pair.to.network } - MultilineLambdaItParameter:DefaultSwapTransactionRepository.kt$DefaultSwapTransactionRepository${ it.checkId( checkUserWalletId = userWalletId, fromCurrencyId = fromCryptoCurrency.id, toCurrencyId = toCryptoCurrency.id, ) } - MultilineLambdaItParameter:DefaultSwapTransactionRepository.kt$DefaultSwapTransactionRepository${ it.userWalletId == userWallet.walletId.stringValue && ( it.toCryptoCurrencyId == cryptoCurrencyId.value || it.fromCryptoCurrencyId == cryptoCurrencyId.value ) } - MultilineLambdaItParameter:DefaultSwapTransactionRepository.kt$DefaultSwapTransactionRepository${ listConverter.convertBack( value = it, multiAccountList = multiAccountList, userWallet = userWallet, txStatuses = txStatuses, ) } - MultilineLambdaItParameter:DefaultSwapTransactionRepository.kt$DefaultSwapTransactionRepository${ storeTransactionState( txId = transaction.txId, status = it, accountWithCurrency = fromAccount?.accountId to fromCryptoCurrency, ) } - MultilineLambdaItParameter:SwapDataConverter.kt$SwapDataConverter${ if (it == "0") { BigDecimal.ZERO } else { requireNotNull(it.toBigDecimalOrNull()) { "wrong amount format, use only digits" } } } - NoNameShadowing:DefaultSwapRepositoryV2.kt$DefaultSwapRepositoryV2$mappedProviders - NoNameShadowing:DefaultSwapTransactionRepository.kt$DefaultSwapTransactionRepository${ it.txId == txId } - - diff --git a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapRepositoryV2.kt b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapRepositoryV2.kt index 51c2a6700d..94583d0bee 100644 --- a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapRepositoryV2.kt +++ b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapRepositoryV2.kt @@ -79,23 +79,23 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( userWallet = userWallet, filterProviderTypes = filterProviderTypes, ) - val mappedProviders = providers.associateBy(ExpressProvider::providerId) + val expressProviders = providers.associateBy(ExpressProvider::providerId) allPairs.map { pair -> async { val statusFrom = cryptoCurrencyStatusList - .firstOrNull { - it.currency.getContractAddress() == pair.from.contractAddress && - it.currency.network.backendId == pair.from.network + .firstOrNull { currencyStatus -> + currencyStatus.currency.getContractAddress() == pair.from.contractAddress && + currencyStatus.currency.network.backendId == pair.from.network } val statusTo = cryptoCurrencyStatusList - .firstOrNull { - it.currency.getContractAddress() == pair.to.contractAddress && - it.currency.network.backendId == pair.to.network + .firstOrNull { currencyStatus -> + currencyStatus.currency.getContractAddress() == pair.to.contractAddress && + currencyStatus.currency.network.backendId == pair.to.network } val mappedProviders = pair.providers.mapNotNull { - mappedProviders[it.providerId] + expressProviders[it.providerId] }.filterYieldSupplyProvider(statusFrom) if (statusFrom != null && statusTo != null && mappedProviders.isNotEmpty()) { @@ -135,16 +135,16 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( async { val statusFromDeferred = async { cryptoCurrencyList - .firstOrNull { - it.getContractAddress() == pair.from.contractAddress && - it.network.backendId == pair.from.network + .firstOrNull { currency -> + currency.getContractAddress() == pair.from.contractAddress && + currency.network.backendId == pair.from.network } } val statusToDeferred = async { cryptoCurrencyList - .firstOrNull { - it.getContractAddress() == pair.to.contractAddress && - it.network.backendId == pair.to.network + .firstOrNull { currency -> + currency.getContractAddress() == pair.to.contractAddress && + currency.network.backendId == pair.to.network } } @@ -213,27 +213,27 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( expressOperationType: ExpressOperationType, ): SwapDataModel = withContext(coroutineDispatcher.io) { val requestId = UUID.randomUUID().toString() - val fromCryptoCurrency = fromCryptoCurrencyStatus.currency + val (fromCurrency, fromStatus) = fromCryptoCurrencyStatus val refundData = when (expressProvider.type) { ExpressProviderType.CEX, ExpressProviderType.DEX_BRIDGE, ExpressProviderType.DEX, -> SwapRefundData( - refundAddress = fromCryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value, + refundAddress = fromStatus.networkAddress?.defaultAddress?.value, refundExtraId = null, // currently always null ) else -> null } val response = tangemExpressApi.getExchangeData( - fromContractAddress = fromCryptoCurrency.getContractAddress(), + fromContractAddress = fromCurrency.getContractAddress(), toContractAddress = toCryptoCurrency.getContractAddress(), - fromNetwork = fromCryptoCurrency.network.backendId, + fromNetwork = fromCurrency.network.backendId, toNetwork = toCryptoCurrency.network.backendId, - fromAddress = fromCryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value.orEmpty(), + fromAddress = fromStatus.networkAddress?.defaultAddress?.value.orEmpty(), toAddress = toAddress, - fromDecimals = fromCryptoCurrency.decimals, + fromDecimals = fromCurrency.decimals, toDecimals = toCryptoCurrency.decimals, fromAmount = fromAmount, providerId = expressProvider.providerId, @@ -277,6 +277,7 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( txHash: String, txExtraId: String?, ) { + val (currency, status) = fromCryptoCurrencyStatus withContext(coroutineDispatcher.io) { tangemExpressApi.exchangeSent( userWalletId = userWallet.walletId.stringValue, @@ -286,8 +287,8 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( ), body = ExchangeSentRequestBody( txId = txId, - fromNetwork = fromCryptoCurrencyStatus.currency.network.backendId, - fromAddress = fromCryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value.orEmpty(), + fromNetwork = currency.network.backendId, + fromAddress = status.networkAddress?.defaultAddress?.value.orEmpty(), payinAddress = toAddress, payinExtraId = txExtraId, txHash = txHash, @@ -364,9 +365,9 @@ internal class DefaultSwapRepositoryV2 @Inject constructor( ), ).getOrThrow() }, - onError = { - Timber.w(it, "Unable to get pairs") - throw it + onError = { error -> + Timber.w(error, "Unable to get pairs") + throw error }, ) } diff --git a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt index 0e2d2a1a79..cbcb56f715 100644 --- a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt +++ b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt @@ -64,10 +64,10 @@ internal class DefaultSwapTransactionRepository( toAccount: Account.CryptoPortfolio?, transaction: SwapTransactionModel, ) { - transaction.status?.let { + transaction.status?.let { swapTxList -> storeTransactionState( txId = transaction.txId, - status = it, + status = swapTxList, accountWithCurrency = fromAccount?.accountId to fromCryptoCurrency, ) } @@ -76,8 +76,8 @@ internal class DefaultSwapTransactionRepository( key = PreferencesKeys.SWAP_TRANSACTIONS_KEY, ) val tokenTransactions = savedTransactions - ?.firstOrNull { - it.checkId( + ?.firstOrNull { swapTxList -> + swapTxList.checkId( checkUserWalletId = userWalletId, fromCurrencyId = fromCryptoCurrency.id, toCurrencyId = toCryptoCurrency.id, @@ -129,17 +129,17 @@ internal class DefaultSwapTransactionRepository( }, ) { savedTransactions, txStatuses, multiAccountList -> val currencyTxs = savedTransactions - ?.filter { - it.userWalletId == userWallet.walletId.stringValue && + ?.filter { swapTxList -> + swapTxList.userWalletId == userWallet.walletId.stringValue && ( - it.toCryptoCurrencyId == cryptoCurrencyId.value || - it.fromCryptoCurrencyId == cryptoCurrencyId.value + swapTxList.toCryptoCurrencyId == cryptoCurrencyId.value || + swapTxList.fromCryptoCurrencyId == cryptoCurrencyId.value ) } - currencyTxs?.mapNotNull { + currencyTxs?.mapNotNull { swapTxList -> listConverter.convertBack( - value = it, + value = swapTxList, multiAccountList = multiAccountList, userWallet = userWallet, txStatuses = txStatuses, @@ -155,8 +155,8 @@ internal class DefaultSwapTransactionRepository( ) val tokenTransactions = savedList ?.asSequence() - ?.map { - it.copy(transactions = it.transactions.filterNot { it.txId == txId }) + ?.map { swapTxList -> + swapTxList.copy(transactions = swapTxList.transactions.filterNot { swapTx -> swapTx.txId == txId }) }?.filterNot { it.transactions.isEmpty() } ?.toList() @@ -257,8 +257,8 @@ internal class DefaultSwapTransactionRepository( toAccount = toAccount, tokenTransactions = transactions, ), - predicate = { - it.checkId( + predicate = { swapTxList -> + swapTxList.checkId( checkUserWalletId = userWalletId, fromCurrencyId = fromCryptoCurrency.id, toCurrencyId = toCryptoCurrency.id, diff --git a/data/swap/src/main/java/com/tangem/data/swap/converter/SwapDataConverter.kt b/data/swap/src/main/java/com/tangem/data/swap/converter/SwapDataConverter.kt index 34f26aed27..0bac85ac2e 100644 --- a/data/swap/src/main/java/com/tangem/data/swap/converter/SwapDataConverter.kt +++ b/data/swap/src/main/java/com/tangem/data/swap/converter/SwapDataConverter.kt @@ -31,11 +31,11 @@ internal class SwapDataConverter : Converter + if (otherFee == "0") { BigDecimal.ZERO } else { - requireNotNull(it.toBigDecimalOrNull()) { "wrong amount format, use only digits" } + requireNotNull(otherFee.toBigDecimalOrNull()) { "wrong amount format, use only digits" } } } SwapDataTransactionModel.DEX( diff --git a/detekt_baseline_report.txt b/detekt_baseline_report.txt index d2f8545c7e..2822eda3e2 100644 --- a/detekt_baseline_report.txt +++ b/detekt_baseline_report.txt @@ -1,7 +1,7 @@ ========================================== Detekt Baseline Updater & Issue Counter ========================================== -Date: 2025-12-08 12:25:24 +Date: 2025-12-12 13:10:21 Step 1: Running detekt to check for new issues... @@ -17,13 +17,13 @@ Counting issues in baseline files... ========================================== Summary: - Total Issues: 1311 - Modules with Issues: 48 + Total Issues: 1247 + Modules with Issues: 46 Average Issues per Module: 27 Progress: - Fixed: 491 out of 1802 (27%) - Remaining: 1311 + Fixed: 555 out of 1802 (30%) + Remaining: 1247 ========================================== All Modules with Issues (sorted by count) @@ -31,21 +31,20 @@ All Modules with Issues (sorted by count) Module Issues ──────────────────────────────────────────────────────────────── -features/markets/impl 148 -features/wallet/impl 145 -features/onboarding-v2/impl 130 +features/markets/impl 147 +features/wallet/impl 144 +features/onboarding-v2/impl 128 features/swap/impl 67 data/wallet-connect 54 features/hot-wallet/impl 51 features/walletconnect/impl 47 -features/tokendetails/impl 46 features/staking/impl 46 -features/manage-tokens/impl 45 -features/swap-v2/impl 40 +features/tokendetails/impl 45 +features/manage-tokens/impl 44 domain/wallets 37 features/nft/impl 34 -features/tester/impl 30 -core/ui 27 +features/tester/impl 28 +core/ui 26 features/swap/domain 25 domain/tokens 25 common/ui 24 @@ -55,20 +54,19 @@ data/visa 21 data/nft 19 features/swap/data 15 data/wallets 13 -data/swap 13 features/token-recieve/impl 11 features/qr-scanning/impl 11 data/onramp 11 core/datasource 11 data/markets 10 features/details/impl 9 -domain/staking 9 domain/account/status 9 data/yield-supply 9 data/networks 9 -features/referral/impl 8 domain/transaction 8 +domain/staking 8 libs/tangem-sdk-api 7 +features/referral/impl 7 data/txhistory 7 features/welcome/impl 6 libs/visa 5 diff --git a/domain/staking/detekt-baseline-debug.xml b/domain/staking/detekt-baseline-debug.xml index 212e197fcc..ced29d17bf 100644 --- a/domain/staking/detekt-baseline-debug.xml +++ b/domain/staking/detekt-baseline-debug.xml @@ -2,7 +2,6 @@ - CanBeNonNullable:StakingAnalyticsEvent.kt$StakingAnalyticsEvent$value: Any? MultilineLambdaItParameter:FetchStakingYieldBalanceUseCase.kt$FetchStakingYieldBalanceUseCase${ when (it) { is StakingIdFactory.Error.UnableToGetAddress -> raise(StakingError.DomainError("$it")) StakingIdFactory.Error.UnsupportedCurrency -> Unit.right() } return@either } MultilineLambdaItParameter:InvalidatePendingTransactionsUseCase.kt$InvalidatePendingTransactionsUseCase${ !it.isPending && action.amount < it.amount && it.type == BalanceType.STAKED && it.validatorAddress == action.validatorAddress } NamedArguments:GetConstructedStakingTransactionUseCase.kt$GetConstructedStakingTransactionUseCase$constructTransaction(networkId, fee, amount, transactionId) diff --git a/features/manage-tokens/impl/detekt-baseline-debug.xml b/features/manage-tokens/impl/detekt-baseline-debug.xml index d580e5706e..6c3a7af5c8 100644 --- a/features/manage-tokens/impl/detekt-baseline-debug.xml +++ b/features/manage-tokens/impl/detekt-baseline-debug.xml @@ -15,7 +15,6 @@ MultilineLambdaItParameter:ChooseManagedTokenContent.kt${ add( CurrencyItemUM.Basic( id = ManagedCryptoCurrency.ID( value = "ID+$it", ), name = "Bitcoin", symbol = "BTC", icon = CurrencyIconState.Loading, networks = CurrencyItemUM.Basic.NetworksUM.Collapsed, onExpandClick = {}, ), ) } MultilineLambdaItParameter:ChooseManagedTokensModel.kt$ChooseManagedTokensModel${ it.copy( notificationUM = null, ) } MultilineLambdaItParameter:CurrencyItemMapper.kt${ it.toCurrencyNetworkModel( isSelected = it.network in addedIn, isEditable = false, onSelectedStateChange = { _, _ -> }, onLongTap = { _ -> }, ) } - MultilineLambdaItParameter:CurrencyNetworksMapper.kt${ it.toCurrencyNetworkModel( isSelected = it.network in addedIn, isEditable = isItemsEditable, onSelectedStateChange = onSelectedStateChange, onLongTap = onLongTap, ) } MultilineLambdaItParameter:CustomCurrencyFormOperations.kt${ it[Field.CONTRACT_ADDRESS] = it.getValue(Field.CONTRACT_ADDRESS).copy( error = when (exception) { CustomTokenFormValidationException.ContractAddress.Invalid -> { resourceReference(R.string.custom_token_creation_error_invalid_contract_address) } }, ) } MultilineLambdaItParameter:CustomCurrencyFormOperations.kt${ it[Field.DECIMALS] = it.getValue(Field.DECIMALS).copy( error = when (exception) { is CustomTokenFormValidationException.Decimals.Empty -> { null // Should not display this error } is CustomTokenFormValidationException.Decimals.Invalid -> { resourceReference( R.string.custom_token_creation_error_wrong_decimals, wrappedList(ValidateTokenFormUseCase.MAX_DECIMALS), ) } }, ) } MultilineLambdaItParameter:CustomTokenFormContent.kt$PreviewCustomTokenFormComponentProvider${ it[Field.CONTRACT_ADDRESS] = it[Field.CONTRACT_ADDRESS]!!.copy( label = stringReference("Contract address"), value = "0x1234567890", error = stringReference("Contract address is invalid"), placeholder = stringReference("0x1234567890"), ) } diff --git a/features/markets/impl/detekt-baseline-debug.xml b/features/markets/impl/detekt-baseline-debug.xml index 7c8b95b9d3..d9fe99460d 100644 --- a/features/markets/impl/detekt-baseline-debug.xml +++ b/features/markets/impl/detekt-baseline-debug.xml @@ -57,7 +57,6 @@ MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ when (val status = it.status) { is PaginationStatus.Paginating -> { if (status.lastResult is BatchFetchResult.Success) { it.data.size == 1 } else { null } } is PaginationStatus.EndOfPagination -> { it.data.size == 1 } else -> null } } MultilineLambdaItParameter:MarketsListItem.kt${ if (Random.nextBoolean()) { it.first.inc() to PriceChangeType.UP } else { it.first.dec() to PriceChangeType.DOWN } } MultilineLambdaItParameter:MarketsListLazyColumn.kt${ (it.key as? String)?.split(TOKEN_LAZY_LIST_ID_SEPARATOR)?.first() ?.let { rawId -> CryptoCurrency.RawID(rawId) } } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it == BottomSheetState.EXPANDED) { analyticsEventHandler.send(MarketsListAnalyticsEvent.BottomSheetOpened) } } MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it) { analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(tokenFound = false)) } } MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it.isNotEmpty()) { activeListManager.getBatchKeysByItemIds(visibleItemIds.value) } else { null } } MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it.list !is ListUM.Content) { visibleItemIds.value = emptyList() } } diff --git a/features/onboarding-v2/impl/detekt-baseline-debug.xml b/features/onboarding-v2/impl/detekt-baseline-debug.xml index 7d217909cf..1cc4bb2e21 100644 --- a/features/onboarding-v2/impl/detekt-baseline-debug.xml +++ b/features/onboarding-v2/impl/detekt-baseline-debug.xml @@ -98,7 +98,6 @@ MultilineLambdaItParameter:OnboardingVisaModel.kt$OnboardingVisaModel${ val derivedKey = it.derivedKeys[VisaUtilities.visaDefaultDerivationPath] ?: return@any false VisaWalletPublicKeyUtility.validateExtendedPublicKey( targetAddress = targetAddress, extendedPublicKey = derivedKey, ).onLeft { return@any VisaWalletPublicKeyUtility.findKeyWithoutDerivation( targetAddress = targetAddress, card = wallet.scanResponse.card, ).isRight() }.isRight() } MultilineLambdaItParameter:OnboardingVisaOtherWalletModel.kt$OnboardingVisaOtherWalletModel${ if (it is VisaActivationRemoteState.AwaitingPinCode) { onDone.emit(it.activationOrderInfo) return@launch } } MultilineLambdaItParameter:OnboardingVisaOtherWalletModel.kt$OnboardingVisaOtherWalletModel${ uiMessageSender.showErrorDialog(it) analyticsEventHandler.send(VisaAnalyticsEvent.ErrorOnboarding(it)) delay(timeMillis = 60_000) } - MultilineLambdaItParameter:OnboardingVisaPinCodeModel.kt$OnboardingVisaPinCodeModel${ it.copy( pinCode = pin, submitButtonEnabled = PinCodeValidation.validate(pin), error = if (isError) { analyticsEventHandler.send(OnboardingVisaAnalyticsEvent.ErrorPinValidation) resourceReference(R.string.visa_onboarding_pin_validation_error_message) } else { null }, ) } MultilineLambdaItParameter:OnboardingVisaWelcomeModel.kt$OnboardingVisaWelcomeModel${ onError(it) return@launch } MultilineLambdaItParameter:SeedPhraseCheckUiStateBuilder.kt$SeedPhraseCheckUiStateBuilder${ checkWordField( word = it.word.text, shownIndex = it.index, ) } MultilineLambdaItParameter:TwinWalletArtwork.kt${ animationState = it val maxTime = maxOf( transition1.totalDurationNanos, transition2.totalDurationNanos, ) delay(TimeUnit.NANOSECONDS.toMillis(maxTime)) } @@ -126,7 +125,6 @@ UseEmptyCounterpart:OnboardingEvent.kt$OnboardingEvent$mapOf() UseEmptyCounterpart:OnboardingEvent.kt$OnboardingEvent.Backup$mapOf() UseEmptyCounterpart:OnboardingEvent.kt$OnboardingEvent.CreateWallet$mapOf() - UseEmptyCounterpart:OnboardingEvent.kt$OnboardingEvent.Topup$mapOf() UseEmptyCounterpart:OnboardingEvent.kt$OnboardingEvent.Twins$mapOf() UseEmptyCounterpart:OnboardingVisaAnalyticsEvent.kt$OnboardingVisaAnalyticsEvent$mapOf() UseEmptyCounterpart:VisaAnalyticsEvent.kt$VisaAnalyticsEvent$mapOf() diff --git a/features/referral/impl/detekt-baseline-debug.xml b/features/referral/impl/detekt-baseline-debug.xml index da51d44c59..9f594c6c2e 100644 --- a/features/referral/impl/detekt-baseline-debug.xml +++ b/features/referral/impl/detekt-baseline-debug.xml @@ -3,7 +3,6 @@ MultilineLambdaItParameter:AgreementText.kt${ val clickableSpanStyle = requireNotNull(agreementText.spanStyles.getOrNull(1)) if (it in clickableSpanStyle.start..clickableSpanStyle.end) { onClick() } } - MultilineLambdaItParameter:ReferralModel.kt$ReferralModel${ analyticsEventHandler.send(ReferralEvents.ParticipateSuccessful) referralData.value = it } MultilineLambdaItParameter:ReferralScreen.kt${ // TODO: use StateEvent if (stateHolder.errorSnackbar != null) { TangemSnackbar(data = it, actionOnNewLine = true) } else { CopiedTextSnackbar(it) } } MultilineLambdaItParameter:ReferralScreen.kt${ ReferralContent( stateHolder = stateHolder, snackbarHostState = snackbarHostState, onAgreementClick = stateHolder.analytics.onAgreementClicked, modifier = Modifier.padding(it), ) } NamedArguments:ReferralScreen.kt$Text( formatAwardConditionsString( quantity = award, network = networkName, address = if (!address.isNullOrBlank()) " $address" else "", ), color = TangemTheme.colors.text.tertiary, style = TangemTheme.typography.body2, modifier = Modifier.testTag(ReferralProgramScreenTestTags.INFO_FOR_YOU_TEXT), ) diff --git a/features/swap-v2/impl/detekt-baseline-debug.xml b/features/swap-v2/impl/detekt-baseline-debug.xml deleted file mode 100644 index d76a6dfe29..0000000000 --- a/features/swap-v2/impl/detekt-baseline-debug.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - BooleanPropertyNaming:ConfirmUM.kt$ConfirmUM.Content$val showTapHelp: Boolean - BooleanPropertyNaming:SwapAmountModel.kt$SwapAmountModel$private var showBestRateAnimation: Boolean = false - BooleanPropertyNaming:SwapAmountModel.kt$SwapAmountModel$val showSendViaSwapNotification = shouldShowNotificationUseCase( NotificationId.SendViaSwapTokenSelectorNotification.key, ) - BooleanPropertyNaming:SwapAmountPrimaryReadyStateTransformer.kt$SwapAmountPrimaryReadyStateTransformer$private val showBestRateAnimation: Boolean - BooleanPropertyNaming:SwapAmountSecondaryReadyStateTransformer.kt$SwapAmountSecondaryReadyStateTransformer$private val showBestRateAnimation: Boolean - BooleanPropertyNaming:SwapAmountSelectQuoteTransformer.kt$SwapAmountSelectQuoteTransformer$private val needApplyFCARestrictions: Boolean - BooleanPropertyNaming:SwapAmountSetQuotesTransformer.kt$SwapAmountSetQuotesTransformer$private val needApplyFcaRestrictions: Boolean - BooleanPropertyNaming:SwapAmountUM.kt$SwapAmountUM.Content$val showBestRateAnimation: Boolean - BooleanPropertyNaming:SwapAmountUM.kt$SwapAmountUM.Content$val showFCAWarning: Boolean - BooleanPropertyNaming:SwapChooseProviderModel.kt$SwapChooseProviderModel$private val needApplyFCARestrictions = params.userCountry.needApplyFCARestrictions() - BooleanPropertyNaming:SwapProviderListItemConverter.kt$SwapProviderListItemConverter$private val needApplyFCARestrictions: Boolean - BooleanPropertyNaming:SwapProviderStateConverter.kt$SwapProviderStateConverter$private val needApplyFCARestrictions: Boolean - CouldBeSequence:SwapAmountModel.kt$SwapAmountModel$filter { it.currencyStatus.currency.id == toCryptoCurrency.id } - MaxChainedCallsOnSameLine:SwapAlertFactory.kt$SwapAlertFactory$confirmData?.fee?.amount?.value?.toString().orEmpty() - MultilineLambdaItParameter:SendWithSwapConfirmModel.kt$SendWithSwapConfirmModel${ it.copy( confirmUM = SendWithSwapConfirmInitialStateTransformer( isShowTapHelp = isShowTapHelp, ).transform(uiState.value.confirmUM), ) } - MultilineLambdaItParameter:SendWithSwapConfirmModel.kt$SendWithSwapConfirmModel${ val confirmUM = it.confirmUM as? ConfirmUM.Content it.copy(confirmUM = confirmUM?.copy(showTapHelp = showTapHelp) ?: it.confirmUM) } - MultilineLambdaItParameter:SendWithSwapConfirmModel.kt$SendWithSwapConfirmModel${ val feeUM = it.feeSelectorUM as? FeeSelectorUM.Content it.copy( confirmUM = (it.confirmUM as? ConfirmUM.Content)?.copy( isPrimaryButtonEnabled = !hasError && feeUM != null, ) ?: it.confirmUM, ) } - MultilineLambdaItParameter:SendWithSwapConfirmationNotificationsTransformer.kt$SendWithSwapConfirmationNotificationsTransformer${ ConfirmUM.Content.LegalUM( title = resourceReference(R.string.common_privacy_policy), link = it, ) } - MultilineLambdaItParameter:SendWithSwapConfirmationNotificationsTransformer.kt$SendWithSwapConfirmationNotificationsTransformer${ ConfirmUM.Content.LegalUM( title = resourceReference(R.string.common_terms_of_use), link = it, ) } - MultilineLambdaItParameter:SendWithSwapModel.kt$SendWithSwapModel${ Timber.w(it.toString()) swapAlertFactory.getGenericErrorState( expressError = ExpressError.UnknownError, onFailedTxEmailClick = { modelScope.launch { swapAlertFactory.onFailedTxEmailClick( userWallet = userWallet, cryptoCurrency = params.currency, errorMessage = it.toString(), ) } }, popBack = ::onBackClick, ) } - MultilineLambdaItParameter:SendWithSwapModel.kt$SendWithSwapModel${ it.copy( destinationUM = DestinationUM.Empty(), feeSelectorUM = FeeSelectorUM.Loading, confirmUM = ConfirmUM.Empty, navigationUM = NavigationUM.Empty, ) } - MultilineLambdaItParameter:SwapAmountSetQuotesTransformer.kt$SwapAmountSetQuotesTransformer${ it is SwapQuoteUM.Content || it is SwapQuoteUM.Allowance || (it as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError } - MultilineLambdaItParameter:SwapChooseProviderModel.kt$SwapChooseProviderModel${ it is SwapQuoteUM.Content || it is SwapQuoteUM.Allowance || (it as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError } - MultilineLambdaItParameter:SwapChooseTokenNetworkModel.kt$SwapChooseTokenNetworkModel${ Timber.e("Failed to get user wallet: $it") swapChooseTokenAlertFactory.getGenericErrorState(params.onDismiss) return } - MultilineLambdaItParameter:SwapChooseTokenNetworkModel.kt$SwapChooseTokenNetworkModel${ Timber.e(it.toString()) uiState.update( SwapChooseErrorStateTransformer( tokenName = params.token.name, onDismiss = params.onDismiss, ), ) return@launch } - MultilineLambdaItParameter:SwapTransactionSender.kt$SwapTransactionSender${ Timber.e(it, "Failed to create swap CEX tx data") onSendError(SendTransactionError.UnknownError(Exception(it))) return } - MultilineLambdaItParameter:SwapTransactionSender.kt$SwapTransactionSender${ onExpressError(it); return } - NamedArguments:SwapTransactionSender.kt$SwapTransactionSender$getSwapDataUseCase( userWallet = userWallet, fromCryptoCurrencyStatus = fromStatus, fromAmount = fromAmount.toStringWithRightOffset(fromStatus.currency.decimals), toCryptoCurrency = toStatus.currency, toAddress = destination, expressProvider = provider, rateType = rateType, expressOperationType, ) - NoNameShadowing:SendWithSwapContent.kt$navigationUM - NoNameShadowing:SwapAmountContent.kt$amountFieldUM - NullableToStringCall:SendWithSwapConfirmModel.kt$SendWithSwapConfirmModel$error.toString() - NullableToStringCall:SwapAmountModel.kt$SwapAmountModel$$primaryStatus - NullableToStringCall:SwapAmountModel.kt$SwapAmountModel$$secondaryStatus - PropertyUsedBeforeDeclaration:SendWithSwapConfirmModel.kt$SendWithSwapConfirmModel$amountUM - UnnecessaryEventHandlerParameter:SwapAmountContent.kt$onExpandEditField: (SwapAmountType) -> Unit - UseEmptyCounterpart:SendWithSwapAnalyticEvents.kt$SendWithSwapAnalyticEvents$mapOf() - UseEmptyCounterpart:SendWithSwapSuccessContent.kt$listOf() - UseEmptyCounterpart:SwapAmountAnalyticEvents.kt$SwapAmountAnalyticEvents$mapOf() - VarCouldBeVal:SwapAmountModel.kt$SwapAmountModel$private var primaryCryptoCurrency: CryptoCurrency = params.primaryCryptoCurrencyStatusFlow.value.currency - VarCouldBeVal:SwapAmountModel.kt$SwapAmountModel$private var userWallet = params.userWallet - - diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/analytics/SwapAmountAnalyticEvents.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/analytics/SwapAmountAnalyticEvents.kt index 197bd8a27c..4dd7c9562d 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/analytics/SwapAmountAnalyticEvents.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/analytics/SwapAmountAnalyticEvents.kt @@ -6,7 +6,7 @@ import com.tangem.core.analytics.models.AnalyticsParam.Key.PROVIDER internal sealed class SwapAmountAnalyticEvents( category: String, event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = category, event = event, params = params) { data class ProviderSelectorClicked( diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt index 62eb8a0d3b..4cbc2867a6 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt @@ -48,11 +48,11 @@ internal sealed class SwapAmountUM { val swapCurrencies: SwapCurrencies, val swapQuotes: ImmutableList, val selectedQuote: SwapQuoteUM, - val showFCAWarning: Boolean, + val isShowFCAWarning: Boolean, // extra data val appCurrency: AppCurrency?, - val showBestRateAnimation: Boolean, + val isShowBestRateAnimation: Boolean, ) : SwapAmountUM() } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt index da46d20b3f..8546a9c6e2 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt @@ -26,11 +26,8 @@ import com.tangem.domain.notifications.ShouldShowNotificationUseCase import com.tangem.domain.settings.usercountry.GetUserCountryUseCase import com.tangem.domain.settings.usercountry.models.UserCountry import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions -import com.tangem.domain.swap.models.SwapCurrencies -import com.tangem.domain.swap.models.SwapDirection +import com.tangem.domain.swap.models.* import com.tangem.domain.swap.models.SwapDirection.Companion.withSwapDirection -import com.tangem.domain.swap.models.SwapQuoteModel -import com.tangem.domain.swap.models.getGroupWithDirection import com.tangem.domain.swap.usecase.GetSwapQuoteUseCase import com.tangem.domain.swap.usecase.SelectInitialPairUseCase import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase @@ -99,9 +96,9 @@ internal class SwapAmountModel @Inject constructor( private val params: SwapAmountComponentParams = paramsContainer.require() private val swapDirection = params.swapDirection private var appCurrency = AppCurrency.Default - private var userWallet = params.userWallet + private val userWallet = params.userWallet - private var primaryCryptoCurrency: CryptoCurrency = params.primaryCryptoCurrencyStatusFlow.value.currency + private val primaryCryptoCurrency: CryptoCurrency = params.primaryCryptoCurrencyStatusFlow.value.currency private var primaryMaximumAmountBoundary: EnterAmountBoundary by Delegates.notNull() private var primaryMinimumAmountBoundary: EnterAmountBoundary by Delegates.notNull() @@ -111,7 +108,7 @@ internal class SwapAmountModel @Inject constructor( private var userCountry: UserCountry = UserCountry.Other(Locale.getDefault().country) val bottomSheetNavigation: SlotNavigation = SlotNavigation() - private var showBestRateAnimation: Boolean = false + private var isShowBestRateAnimation: Boolean = false val uiState: StateFlow field = MutableStateFlow(params.amountUM) @@ -124,7 +121,7 @@ internal class SwapAmountModel @Inject constructor( appCurrency = getSelectedAppCurrencyUseCase.invokeSync().getOrElse { AppCurrency.Default } userCountry = getUserCountryUseCase.invokeSync().getOrNull() ?: UserCountry.Other(Locale.getDefault().country) - showBestRateAnimation = swapBestRateAnimationStore.getSyncOrNull() + isShowBestRateAnimation = swapBestRateAnimationStore.getSyncOrNull() } configAmountNavigation() subscribeOnCryptoCurrencyStatusFlow() @@ -169,7 +166,7 @@ internal class SwapAmountModel @Inject constructor( quoteUM = quoteUM, secondaryMaximumAmountBoundary = secondaryMaximumAmountBoundary, secondaryMinimumAmountBoundary = secondaryMinimumAmountBoundary, - needApplyFCARestrictions = userCountry.needApplyFCARestrictions(), + isNeedApplyFCARestrictions = userCountry.needApplyFCARestrictions(), ), ) } @@ -270,7 +267,7 @@ internal class SwapAmountModel @Inject constructor( override fun onSelectTokenClick() { val amountParams = params as? SwapAmountComponentParams.AmountParams ?: return modelScope.launch { - val showSendViaSwapNotification = shouldShowNotificationUseCase( + val isShowSendViaSwapNotification = shouldShowNotificationUseCase( NotificationId.SendViaSwapTokenSelectorNotification.key, ) val isEditMode = amountParams.currentRoute.firstOrNull()?.isEditMode == true @@ -281,7 +278,7 @@ internal class SwapAmountModel @Inject constructor( initialCurrency = primaryCryptoCurrency, selectedCurrency = selectedCurrency.takeIf { isEditMode }, source = AppRoute.ChooseManagedTokens.Source.SendViaSwap, - shouldShowSendViaSwapNotification = showSendViaSwapNotification, + shouldShowSendViaSwapNotification = isShowSendViaSwapNotification, analyticsCategoryName = params.analyticsCategoryName, ), ) @@ -306,7 +303,7 @@ internal class SwapAmountModel @Inject constructor( fun onFinishAnimation() { uiState.update { - (it as? SwapAmountUM.Content)?.copy(showBestRateAnimation = false) ?: it + (it as? SwapAmountUM.Content)?.copy(isShowBestRateAnimation = false) ?: it } } @@ -367,7 +364,7 @@ internal class SwapAmountModel @Inject constructor( swapDirection = swapDirection, clickIntents = this, isBalanceHidden = params.isBalanceHidingFlow.value, - showBestRateAnimation = showBestRateAnimation, + isShowBestRateAnimation = isShowBestRateAnimation, isSingleWallet = isOnlyOneWallet, isAccountsMode = params.isAccountModeFlow.value, account = params.accountFlow.value, @@ -418,7 +415,7 @@ internal class SwapAmountModel @Inject constructor( swapDirection = swapDirection, clickIntents = this, isBalanceHidden = params.isBalanceHidingFlow.value, - showBestRateAnimation = showBestRateAnimation, + isShowBestRateAnimation = isShowBestRateAnimation, isSingleWallet = isOnlyOneWallet, isAccountsMode = isAccountsMode, account = account, @@ -532,7 +529,7 @@ internal class SwapAmountModel @Inject constructor( swapDirection = swapDirection, clickIntents = this@SwapAmountModel, isBalanceHidden = params.isBalanceHidingFlow.value, - showBestRateAnimation = showBestRateAnimation, + isShowBestRateAnimation = isShowBestRateAnimation, isSingleWallet = isOnlyOneWallet, isAccountsMode = params.isAccountModeFlow.value, account = params.accountFlow.value, @@ -540,6 +537,7 @@ internal class SwapAmountModel @Inject constructor( ) startLoadingQuotesTask(isSilentReload = false) } else { + @Suppress("NullableToStringCall") Timber.e( """ Invalid cryptocurrencies status: @@ -596,50 +594,50 @@ internal class SwapAmountModel @Inject constructor( val isAmountScreen = params is SwapAmountComponentParams.AmountParams val isAmountError = fromAmount?.amountTextField?.isError == true || fromAmountValue.isNullOrZero() if (isAmountScreen && isAmountError) { - uiState.transformerUpdate(SwapQuoteEmptyStateTransformer) - return + uiState.transformerUpdate(SwapQuoteEmptyStateTransformer); return } if (!isSilentReload) uiState.transformerUpdate(SwapQuoteLoadingStateTransformer) modelScope.launch { - val quotes = state.swapCurrencies.getGroupWithDirection(state.swapDirection).available.filter { - it.currencyStatus.currency.id == toCryptoCurrency.id - }.flatMap { - it.providers - }.map { provider -> - async { - getSwapQuoteUseCase( - userWallet = userWallet, - fromCryptoCurrency = fromCryptoCurrency, - toCryptoCurrency = toCryptoCurrency, - fromAmount = fromAmountValue, - provider = provider, - ).fold( - ifLeft = { error -> - SwapQuoteUM.Error( - provider = provider, - expressError = error, - ) - }, - ifRight = { quote: SwapQuoteModel -> - SwapQuoteUMConverter( - primaryCurrency = fromCryptoCurrency, - secondaryCurrency = toCryptoCurrency, - swapDirection = swapDirection, - allowanceContract = quote.allowanceContract, - isApprovalNeeded = checkAllowance(state, quote), - fromAmount = fromAmountValue, - ).convert( - SwapQuoteUMConverter.Data( - quote = quote, + val quotes = state.swapCurrencies.getGroupWithDirection(state.swapDirection).available + .asSequence() + .filter { swapCurrencyStatus -> swapCurrencyStatus.currencyStatus.currency.id == toCryptoCurrency.id } + .flatMap(SwapCryptoCurrency::providers) + .toList() + .map { provider -> + async { + getSwapQuoteUseCase( + userWallet = userWallet, + fromCryptoCurrency = fromCryptoCurrency, + toCryptoCurrency = toCryptoCurrency, + fromAmount = fromAmountValue, + provider = provider, + ).fold( + ifLeft = { error -> + SwapQuoteUM.Error( provider = provider, - ), - ) - }, - ) - } - }.awaitAll() + expressError = error, + ) + }, + ifRight = { quote: SwapQuoteModel -> + SwapQuoteUMConverter( + primaryCurrency = fromCryptoCurrency, + secondaryCurrency = toCryptoCurrency, + swapDirection = swapDirection, + allowanceContract = quote.allowanceContract, + isApprovalNeeded = checkAllowance(state, quote), + fromAmount = fromAmountValue, + ).convert( + SwapQuoteUMConverter.Data( + quote = quote, + provider = provider, + ), + ) + }, + ) + } + }.awaitAll() uiState.transformerUpdate( SwapAmountSetQuotesTransformer( @@ -647,7 +645,7 @@ internal class SwapAmountModel @Inject constructor( secondaryMaximumAmountBoundary = secondaryMaximumAmountBoundary, secondaryMinimumAmountBoundary = secondaryMinimumAmountBoundary, isSilentReload = isSilentReload, - needApplyFcaRestrictions = userCountry.needApplyFCARestrictions(), + isNeedApplyFcaRestrictions = userCountry.needApplyFCARestrictions(), ), ) feeSelectorReloadTrigger.triggerUpdate() diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt index 9d39c5e8f4..ca25cc3fda 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt @@ -24,7 +24,7 @@ internal class SwapAmountPrimaryReadyStateTransformer( private val clickIntents: AmountScreenClickIntents, private val swapDirection: SwapDirection, private val isBalanceHidden: Boolean, - private val showBestRateAnimation: Boolean, + private val isShowBestRateAnimation: Boolean, private val isSingleWallet: Boolean, private val isAccountsMode: Boolean, private val account: Account.CryptoPortfolio?, @@ -60,8 +60,8 @@ internal class SwapAmountPrimaryReadyStateTransformer( swapQuotes = persistentListOf(), selectedQuote = SwapQuoteUM.Empty, appCurrency = appCurrency, - showBestRateAnimation = showBestRateAnimation, - showFCAWarning = false, + isShowBestRateAnimation = isShowBestRateAnimation, + isShowFCAWarning = false, ) } } \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt index 7d4a258917..298b11ad75 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt @@ -25,7 +25,7 @@ internal class SwapAmountSecondaryReadyStateTransformer( private val clickIntents: AmountScreenClickIntents, private val swapDirection: SwapDirection, private val isBalanceHidden: Boolean, - private val showBestRateAnimation: Boolean, + private val isShowBestRateAnimation: Boolean, private val isSingleWallet: Boolean, private val isAccountsMode: Boolean, private val account: Account.CryptoPortfolio?, @@ -59,8 +59,8 @@ internal class SwapAmountSecondaryReadyStateTransformer( swapQuotes = persistentListOf(), selectedQuote = SwapQuoteUM.Empty, appCurrency = appCurrency, - showBestRateAnimation = showBestRateAnimation, - showFCAWarning = false, + isShowBestRateAnimation = isShowBestRateAnimation, + isShowFCAWarning = false, ) } } \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSelectQuoteTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSelectQuoteTransformer.kt index cd0df36880..03058c869b 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSelectQuoteTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSelectQuoteTransformer.kt @@ -19,7 +19,7 @@ internal class SwapAmountSelectQuoteTransformer( private val quoteUM: SwapQuoteUM, private val secondaryMaximumAmountBoundary: EnterAmountBoundary?, private val secondaryMinimumAmountBoundary: EnterAmountBoundary?, - private val needApplyFCARestrictions: Boolean, + private val isNeedApplyFCARestrictions: Boolean, ) : Transformer { override fun transform(prevState: SwapAmountUM): SwapAmountUM { if (prevState !is SwapAmountUM.Content) return prevState @@ -31,7 +31,7 @@ internal class SwapAmountSelectQuoteTransformer( return prevState.copy( isPrimaryButtonEnabled = quoteUM is SwapQuoteUM.Content, selectedQuote = quoteUM, - showFCAWarning = needApplyFCARestrictions && quoteUM.provider?.isRestrictedByFCA() == true, + isShowFCAWarning = isNeedApplyFCARestrictions && quoteUM.provider?.isRestrictedByFCA() == true, primaryAmount = if (prevState.selectedAmountType == SwapAmountType.From) { val swapAmountField = prevState.primaryAmount as? SwapAmountFieldUM.Content val amountField = swapAmountField?.amountField as? AmountState.Data diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSetQuotesTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSetQuotesTransformer.kt index 941fa7e8ec..cd19623928 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSetQuotesTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSetQuotesTransformer.kt @@ -22,14 +22,14 @@ internal class SwapAmountSetQuotesTransformer( private val secondaryMaximumAmountBoundary: EnterAmountBoundary?, private val secondaryMinimumAmountBoundary: EnterAmountBoundary?, private val isSilentReload: Boolean, - private val needApplyFcaRestrictions: Boolean, + private val isNeedApplyFcaRestrictions: Boolean, ) : Transformer { override fun transform(prevState: SwapAmountUM): SwapAmountUM { if (prevState !is SwapAmountUM.Content) return prevState - val isSingleProvider = quotes.filter { - it is SwapQuoteUM.Content || it is SwapQuoteUM.Allowance || - (it as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError + val isSingleProvider = quotes.filter { swapQuoteUM -> + swapQuoteUM is SwapQuoteUM.Content || swapQuoteUM is SwapQuoteUM.Allowance || + (swapQuoteUM as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError }.isSingleItem() val sortedQuotes = quotes.sortedWith(SwapQuotesComparator) @@ -49,7 +49,7 @@ internal class SwapAmountSetQuotesTransformer( quoteUM = selectedQuote, secondaryMaximumAmountBoundary = secondaryMaximumAmountBoundary, secondaryMinimumAmountBoundary = secondaryMinimumAmountBoundary, - needApplyFCARestrictions = needApplyFcaRestrictions && + isNeedApplyFCARestrictions = isNeedApplyFcaRestrictions && selectedQuote.provider?.isRestrictedByFCA() == true, ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt index 5fc6dc2696..008e402a09 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt @@ -88,7 +88,7 @@ internal fun SwapAmountBlockContent( SwapChooseProviderContent( isBestRate = isBestRate, isSingleProvider = quoteContent?.isSingleProvider == true, - showBestRateAnimation = amountUM.showBestRateAnimation, + showBestRateAnimation = amountUM.isShowBestRateAnimation, expressProvider = amountUM.selectedQuote.provider, onClick = onProviderSelectClick, onFinishAnimation = onFinishAnimation, @@ -98,7 +98,7 @@ internal fun SwapAmountBlockContent( start.linkTo(parent.start) end.linkTo(parent.end) }, - showFCAWarning = amountUM.showFCAWarning, + showFCAWarning = amountUM.isShowFCAWarning, ) } } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt index 91c6f69e30..61ec2095f4 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt @@ -175,7 +175,7 @@ private fun SwapAmountBlock( selectedQuote = selectedQuote, isSelectedAmountType = isSelectedAmountType, isFixedRate = isFixedRate, - onExpandEditField = clickIntents::onExpandEditField, + onExpandEditField = { clickIntents.onExpandEditField(amountFieldUM.amountType) }, onSelectTokenClick = clickIntents::onSelectTokenClick, onMaxAmountClick = clickIntents::onMaxValueClick, ) @@ -195,14 +195,14 @@ private fun SwapAmountEditBlock( verticalArrangement = Arrangement.spacedBy(12.dp), modifier = modifier.padding(top = 48.dp, bottom = 28.dp), ) { - when (val amountFieldUM = amountFieldUM.amountField) { + when (val amountField = amountFieldUM.amountField) { !is AmountState.Data -> { TextShimmer( style = TangemTheme.typography.caption2, modifier = Modifier.width(60.dp), ) } - else -> AccountTitle(amountFieldUM.accountTitleUM) + else -> AccountTitle(amountField.accountTitleUM) } AmountFieldV2( amountUM = amountFieldUM.amountField, @@ -221,7 +221,7 @@ private fun SwapAmountInfo( selectedQuote: SwapQuoteUM?, isSelectedAmountType: Boolean, isFixedRate: Boolean, - onExpandEditField: (SwapAmountType) -> Unit, + onExpandEditField: () -> Unit, onMaxAmountClick: () -> Unit, onSelectTokenClick: () -> Unit, modifier: Modifier = Modifier, @@ -237,7 +237,7 @@ private fun SwapAmountInfo( enabled = (amountFieldUM as? SwapAmountFieldUM.Content)?.isClickEnabled == true, onClick = { if (isFixedRate) { - onExpandEditField(amountFieldUM.amountType) + onExpandEditField() } else { onSelectTokenClick() } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt index 01c4c02b06..798b7fd4d0 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt @@ -90,8 +90,8 @@ internal data object SwapAmountContentPreview { secondaryCryptoCurrencyStatus = cryptoCurrencyStatus, swapRateType = ExpressRateType.Float, appCurrency = AppCurrency.Default, - showBestRateAnimation = false, - showFCAWarning = false, + isShowBestRateAnimation = false, + isShowFCAWarning = false, ) val defaultState = SwapAmountUM.Content( @@ -129,8 +129,8 @@ internal data object SwapAmountContentPreview { secondaryCryptoCurrencyStatus = cryptoCurrencyStatus, swapRateType = ExpressRateType.Float, isPrimaryButtonEnabled = true, - showBestRateAnimation = false, - showFCAWarning = true, + isShowBestRateAnimation = false, + isShowFCAWarning = true, ) val defaultStateAccount: SwapAmountUM.Content diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/SwapChooseProviderModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/SwapChooseProviderModel.kt index 0ac41aea88..dc784cc913 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/SwapChooseProviderModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/SwapChooseProviderModel.kt @@ -25,13 +25,13 @@ internal class SwapChooseProviderModel @Inject constructor( private val params: SwapChooseProviderComponent.Params = paramsContainer.require() - private val needApplyFCARestrictions = params.userCountry.needApplyFCARestrictions() + private val isNeedApplyFCARestrictions = params.userCountry.needApplyFCARestrictions() private val swapProviderListItemConverter by lazy(LazyThreadSafetyMode.NONE) { SwapProviderListItemConverter( cryptoCurrency = params.cryptoCurrency, selectedProvider = params.selectedProvider, - needApplyFCARestrictions = needApplyFCARestrictions, + isNeedApplyFCARestrictions = isNeedApplyFCARestrictions, needBestRateBadge = params.providers.filterIsInstance().isSingleItem().not(), ) } @@ -45,13 +45,13 @@ internal class SwapChooseProviderModel @Inject constructor( } private fun getInitialState(): SwapChooseProviderBottomSheetContent { - val filteredProviderList = params.providers.filter { - it is SwapQuoteUM.Content || - it is SwapQuoteUM.Allowance || - (it as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError + val filteredProviderList = params.providers.filter { swapQuoteUM -> + swapQuoteUM is SwapQuoteUM.Content || + swapQuoteUM is SwapQuoteUM.Allowance || + (swapQuoteUM as? SwapQuoteUM.Error)?.expressError is ExpressError.AmountError } return SwapChooseProviderBottomSheetContent( - isApplyFCARestrictions = needApplyFCARestrictions && params.selectedProvider.isRestrictedByFCA(), + isApplyFCARestrictions = isNeedApplyFCARestrictions && params.selectedProvider.isRestrictedByFCA(), providerList = swapProviderListItemConverter.convertList(filteredProviderList) .filterNotNull() .toPersistentList(), diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderListItemConverter.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderListItemConverter.kt index 045d882f8f..56c7a0f93a 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderListItemConverter.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderListItemConverter.kt @@ -21,14 +21,14 @@ import com.tangem.utils.converter.Converter internal class SwapProviderListItemConverter( private val cryptoCurrency: CryptoCurrency, private val selectedProvider: ExpressProvider, - private val needApplyFCARestrictions: Boolean, + private val isNeedApplyFCARestrictions: Boolean, needBestRateBadge: Boolean, ) : Converter { private val providerStateConverter = SwapProviderStateConverter( cryptoCurrency = cryptoCurrency, selectedProvider = selectedProvider, - needApplyFCARestrictions = needApplyFCARestrictions, + isNeedApplyFCARestrictions = isNeedApplyFCARestrictions, isNeedBestRateBadge = needBestRateBadge, ) @@ -78,7 +78,7 @@ internal class SwapProviderListItemConverter( }, ) } - is SwapQuoteUM.Content -> if (needApplyFCARestrictions && value.provider.isRestrictedByFCA()) { + is SwapQuoteUM.Content -> if (isNeedApplyFCARestrictions && value.provider.isRestrictedByFCA()) { ProviderChooseUM.ExtraUM.Action( text = resourceReference(R.string.express_provider_fca_warning_list), ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderStateConverter.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderStateConverter.kt index 317f0d733f..54f3030f4f 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderStateConverter.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/chooseprovider/model/converter/SwapProviderStateConverter.kt @@ -20,7 +20,7 @@ internal class SwapProviderStateConverter( private val cryptoCurrency: CryptoCurrency, private val selectedProvider: ExpressProvider, private val isNeedBestRateBadge: Boolean, - private val needApplyFCARestrictions: Boolean, + private val isNeedApplyFCARestrictions: Boolean, ) : Converter { override fun convert(value: SwapQuoteUM): SwapProviderState { @@ -41,7 +41,7 @@ internal class SwapProviderStateConverter( } val additionalBadge = when { - needApplyFCARestrictions && provider.isRestrictedByFCA() -> AdditionalBadge.FCAWarningList + isNeedApplyFCARestrictions && provider.isRestrictedByFCA() -> AdditionalBadge.FCAWarningList isNeedBestRateBadge && isBestRate -> AdditionalBadge.BestTrade else -> AdditionalBadge.Empty } @@ -59,7 +59,7 @@ internal class SwapProviderStateConverter( private fun SwapQuoteUM.Error.convertToErrorContent(): SwapProviderState { val additionalBadge = when { - needApplyFCARestrictions && provider.isRestrictedByFCA() -> AdditionalBadge.FCAWarningList + isNeedApplyFCARestrictions && provider.isRestrictedByFCA() -> AdditionalBadge.FCAWarningList else -> AdditionalBadge.Empty } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/choosetoken/fromSupported/model/SwapChooseTokenNetworkModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/choosetoken/fromSupported/model/SwapChooseTokenNetworkModel.kt index 8d2c61caf1..a9312fc84a 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/choosetoken/fromSupported/model/SwapChooseTokenNetworkModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/choosetoken/fromSupported/model/SwapChooseTokenNetworkModel.kt @@ -66,8 +66,8 @@ internal class SwapChooseTokenNetworkModel @Inject constructor( } private fun initContent() { - val userWallet = getUserWalletUseCase(params.userWalletId).getOrElse { - Timber.e("Failed to get user wallet: $it") + val userWallet = getUserWalletUseCase(params.userWalletId).getOrElse { error -> + Timber.e("Failed to get user wallet: $error") swapChooseTokenAlertFactory.getGenericErrorState(params.onDismiss) return } @@ -87,8 +87,8 @@ internal class SwapChooseTokenNetworkModel @Inject constructor( cryptoCurrencyList = cryptoCurrencyList + params.initialCurrency, filterProviderTypes = SEND_WITH_SWAP_PROVIDER_TYPES, swapTxType = SwapTxType.SendWithSwap, - ).getOrElse { - Timber.e(it.toString()) + ).getOrElse { error -> + Timber.e(error.toString()) uiState.update( SwapChooseErrorStateTransformer( tokenName = params.token.name, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapAlertFactory.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapAlertFactory.kt index d5360e2add..0994844d9b 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapAlertFactory.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/SwapAlertFactory.kt @@ -91,7 +91,8 @@ internal class SwapAlertFactory @Inject constructor( destinationAddress = confirmData?.enteredDestination.orEmpty(), tokenSymbol = confirmData?.toCryptoCurrencyStatus?.currency?.symbol.orEmpty(), amount = confirmData?.enteredAmount?.toString().orEmpty(), - fee = confirmData?.fee?.amount?.value?.toString().orEmpty(), + fee = confirmData?.fee?.amount?.value?.toString() + .orEmpty(), ), ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/ConfirmUM.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/ConfirmUM.kt index b105bed8a1..cf27f09d02 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/ConfirmUM.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/entity/ConfirmUM.kt @@ -15,7 +15,7 @@ internal sealed class ConfirmUM { data class Content( override val isPrimaryButtonEnabled: Boolean = false, val isTransactionInProcess: Boolean, - val showTapHelp: Boolean, + val isShowTapHelp: Boolean, val sendingFooter: TextReference, val notifications: ImmutableList, val tosUM: TosUM?, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/analytics/SendWithSwapAnalyticEvents.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/analytics/SendWithSwapAnalyticEvents.kt index ab38425164..e7e6ac5e7d 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/analytics/SendWithSwapAnalyticEvents.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/analytics/SendWithSwapAnalyticEvents.kt @@ -13,7 +13,7 @@ import com.tangem.features.send.v2.api.analytics.CommonSendAnalyticEvents internal sealed class SendWithSwapAnalyticEvents( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = CommonSendAnalyticEvents.SEND_CATEGORY, event = event, params = params) { data class TransactionScreenOpened( diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index c0d119b50f..3fcd6d870c 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -94,11 +94,7 @@ internal class SendWithSwapConfirmModel @Inject constructor( field = MutableStateFlow(params.sendWithSwapUM) val primaryCurrencyStatus: CryptoCurrencyStatus = params.primaryCryptoCurrencyStatusFlow.value - val secondaryCurrencyStatus: CryptoCurrencyStatus? = amountUM?.secondaryCryptoCurrencyStatus val primaryFeePaidCurrencyStatus: CryptoCurrencyStatus = params.primaryFeePaidCurrencyStatusFlow.value - val secondaryCurrency: CryptoCurrency = requireNotNull(amountUM?.secondaryCryptoCurrencyStatus?.currency) { - "Crypto currency must not be null" - } private val swapTransactionSender = swapTransactionSenderFactory.create(params.userWallet) @@ -111,6 +107,11 @@ internal class SendWithSwapConfirmModel @Inject constructor( private val feeSelectorUM get() = uiState.value.feeSelectorUM as? FeeSelectorUM.Content + val secondaryCurrencyStatus: CryptoCurrencyStatus? = amountUM?.secondaryCryptoCurrencyStatus + val secondaryCurrency: CryptoCurrency = requireNotNull(amountUM?.secondaryCryptoCurrencyStatus?.currency) { + "Crypto currency must not be null" + } + val confirmData: ConfirmData get() { val amountUM = amountUM @@ -270,13 +271,13 @@ internal class SendWithSwapConfirmModel @Inject constructor( uiState.transformerUpdate(SendWithSwapConfirmSendingStateTransformer(false)) swapAlertFactory.getSendTransactionErrorState( error = error, - onFailedTxEmailClick = { + onFailedTxEmailClick = { _ -> modelScope.launch { swapAlertFactory.onFailedTxEmailClick( userWallet = params.userWallet, cryptoCurrency = confirmData.fromCryptoCurrencyStatus?.currency, confirmData = confirmData, - errorMessage = error.toString(), + errorMessage = error?.toString().orEmpty(), ) } }, @@ -320,8 +321,8 @@ internal class SendWithSwapConfirmModel @Inject constructor( modelScope.launch { val isShowTapHelp = isSendTapHelpEnabledUseCase.invokeSync().getOrElse { false } if (confirmUM is ConfirmUM.Empty) { - uiState.update { - it.copy( + uiState.update { state -> + state.copy( confirmUM = SendWithSwapConfirmInitialStateTransformer( isShowTapHelp = isShowTapHelp, ).transform(uiState.value.confirmUM), @@ -335,9 +336,9 @@ internal class SendWithSwapConfirmModel @Inject constructor( private fun subscribeOnTapHelpUpdates() { isSendTapHelpEnabledUseCase().getOrNull() ?.onEach { showTapHelp -> - uiState.update { - val confirmUM = it.confirmUM as? ConfirmUM.Content - it.copy(confirmUM = confirmUM?.copy(showTapHelp = showTapHelp) ?: it.confirmUM) + uiState.update { state -> + val confirmUM = state.confirmUM as? ConfirmUM.Content + state.copy(confirmUM = confirmUM?.copy(isShowTapHelp = showTapHelp) ?: state.confirmUM) } }?.launchIn(modelScope) } @@ -376,12 +377,12 @@ internal class SendWithSwapConfirmModel @Inject constructor( flow2 = swapNotificationsUpdateListener.hasErrorFlow, ) { hasSendError, hasSwapError -> val hasError = hasSendError || hasSwapError - uiState.update { - val feeUM = it.feeSelectorUM as? FeeSelectorUM.Content - it.copy( - confirmUM = (it.confirmUM as? ConfirmUM.Content)?.copy( + uiState.update { state -> + val feeUM = state.feeSelectorUM as? FeeSelectorUM.Content + state.copy( + confirmUM = (state.confirmUM as? ConfirmUM.Content)?.copy( isPrimaryButtonEnabled = !hasError && feeUM != null, - ) ?: it.confirmUM, + ) ?: state.confirmUM, ) } }.launchIn(modelScope) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt index 3602881267..1c6a439eeb 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt @@ -98,8 +98,8 @@ internal class SwapTransactionSender @AssistedInject constructor( toAddress = destination, expressProvider = provider, rateType = rateType, - expressOperationType, - ).getOrElse { onExpressError(it); return } + expressOperationType = expressOperationType, + ).getOrElse { error -> onExpressError(error); return } createAndSendCexTransaction( fromAmount = fromAmount, @@ -141,9 +141,9 @@ internal class SwapTransactionSender @AssistedInject constructor( destination = swapTransaction.txTo, userWalletId = userWallet.walletId, network = fromStatus.currency.network, - ).getOrElse { - Timber.e(it, "Failed to create swap CEX tx data") - onSendError(SendTransactionError.UnknownError(Exception(it))) + ).getOrElse { error -> + Timber.e(error, "Failed to create swap CEX tx data") + onSendError(SendTransactionError.UnknownError(Exception(error))) return } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmInitialStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmInitialStateTransformer.kt index 64e34d1673..1beaabe312 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmInitialStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmInitialStateTransformer.kt @@ -12,7 +12,7 @@ internal class SendWithSwapConfirmInitialStateTransformer( return ConfirmUM.Content( isPrimaryButtonEnabled = false, isTransactionInProcess = false, - showTapHelp = isShowTapHelp, + isShowTapHelp = isShowTapHelp, sendingFooter = TextReference.EMPTY, notifications = persistentListOf(), tosUM = null, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmationNotificationsTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmationNotificationsTransformer.kt index 3176e70a6c..53fd2df373 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmationNotificationsTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/transformers/SendWithSwapConfirmationNotificationsTransformer.kt @@ -109,16 +109,16 @@ internal class SendWithSwapConfirmationNotificationsTransformer : Transformer ConfirmUM.Content.LegalUM( title = resourceReference(R.string.common_terms_of_use), - link = it, + link = termsOfUse, ) }, - policyLink = expressProvider.privacyPolicy?.let { + policyLink = expressProvider.privacyPolicy?.let { privacyPolicy -> ConfirmUM.Content.LegalUM( title = resourceReference(R.string.common_privacy_policy), - link = it, + link = privacyPolicy, ) }, ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt index 3d6968a554..629d37898d 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt @@ -132,8 +132,8 @@ internal class SendWithSwapModel @Inject constructor( } override fun resetSendWithSwapNavigation(resetNavigation: Boolean) { - uiState.update { - it.copy( + uiState.update { state -> + state.copy( destinationUM = DestinationUM.Empty(), feeSelectorUM = FeeSelectorUM.Loading, confirmUM = ConfirmUM.Empty, @@ -166,8 +166,8 @@ internal class SendWithSwapModel @Inject constructor( userWallet = wallet getPrimaryCurrencyStatusUpdates(params.currency) }, - ifLeft = { - Timber.w(it.toString()) + ifLeft = { error -> + Timber.w(error.toString()) swapAlertFactory.getGenericErrorState( expressError = ExpressError.UnknownError, onFailedTxEmailClick = { @@ -175,7 +175,7 @@ internal class SendWithSwapModel @Inject constructor( swapAlertFactory.onFailedTxEmailClick( userWallet = userWallet, cryptoCurrency = params.currency, - errorMessage = it.toString(), + errorMessage = error.toString(), ) } }, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/success/ui/SendWithSwapSuccessContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/success/ui/SendWithSwapSuccessContent.kt index 0ccf5aada7..c106e29968 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/success/ui/SendWithSwapSuccessContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/success/ui/SendWithSwapSuccessContent.kt @@ -344,7 +344,7 @@ private fun SendWithSwapSuccessContent_Preview() { txUrl = "https://tangem.com", provider = ExpressProvider( providerId = "changelly", - rateTypes = listOf(), + rateTypes = emptyList(), name = "Changelly", type = ExpressProviderType.CEX, imageLarge = "https://s3.eu-central-1.amazonaws.com/tangem.api/express/changelly-1024.png", diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/ui/SendWithSwapContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/ui/SendWithSwapContent.kt index fe0e00831b..9e3064dafc 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/ui/SendWithSwapContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/ui/SendWithSwapContent.kt @@ -36,7 +36,7 @@ internal fun SendWithSwapContent( stackState: ChildStack, onLinkClick: (String) -> Unit, ) { - val navigationUM = navigationUM as? NavigationUM.Content ?: return + val navigationUMContent = navigationUM as? NavigationUM.Content ?: return Column( modifier = Modifier @@ -47,9 +47,9 @@ internal fun SendWithSwapContent( horizontalAlignment = Alignment.CenterHorizontally, ) { AppBarWithBackButton( - text = navigationUM.title.resolveReference(), - onBackClick = navigationUM.backIconClick, - iconRes = navigationUM.additionalIconRes, + text = navigationUMContent.title.resolveReference(), + onBackClick = navigationUMContent.backIconClick, + iconRes = navigationUMContent.additionalIconRes, modifier = Modifier.height(TangemTheme.dimens.size56), ) Children( @@ -93,7 +93,7 @@ internal fun SendWithSwapContent( ) } NavigationPrimaryButton( - navigationUM.primaryButton, + navigationUMContent.primaryButton, modifier = Modifier.padding( start = 16.dp, end = 16.dp, diff --git a/features/tester/impl/detekt-baseline-debug.xml b/features/tester/impl/detekt-baseline-debug.xml index d115b8f9b6..be0960afae 100644 --- a/features/tester/impl/detekt-baseline-debug.xml +++ b/features/tester/impl/detekt-baseline-debug.xml @@ -22,12 +22,10 @@ MultilineLambdaItParameter:TesterAccountsViewModel.kt$TesterAccountsViewModel${ it.copy( accountListBottomSheetConfig = it.accountListBottomSheetConfig.copy( isAccountsShown = false, ), ) } MultilineLambdaItParameter:TesterAccountsViewModel.kt$TesterAccountsViewModel${ it.copy( walletSelector = it.walletSelector.copy(selected = userWallet), accountListBottomSheetConfig = it.accountListBottomSheetConfig.copy( accounts = getWalletAccounts(userWallet.walletId), ), ) } MultilineLambdaItParameter:TesterActionsScreen.kt${ builder.setStream( FileProvider.getUriForFile(activity, "${activity.packageName}.provider", it), ) } - MultilineLambdaItParameter:TesterActivity.kt$TesterActivity${ val route = when (it) { ButtonUM.FEATURE_TOGGLES -> TesterScreen.FEATURE_TOGGLES ButtonUM.EXCLUDED_BLOCKCHAINS -> TesterScreen.EXCLUDED_BLOCKCHAINS ButtonUM.ENVIRONMENT_TOGGLES -> TesterScreen.ENVIRONMENTS_TOGGLES ButtonUM.BLOCKCHAIN_PROVIDERS -> TesterScreen.BLOCKCHAIN_PROVIDERS ButtonUM.TESTER_ACTIONS -> TesterScreen.TESTER_ACTIONS ButtonUM.TEST_PUSHES -> TesterScreen.TEST_PUSHES ButtonUM.ACCOUNTS -> TesterScreen.ACCOUNTS } innerTesterRouter.open(route) } NoNameShadowing:AccountsScreen.kt$content NoNameShadowing:BlockchainProvidersViewModel.kt$BlockchainProvidersViewModel${ onAddProviderClick(id = blockchain.id, url = it) } NoNameShadowing:BlockchainProvidersViewModel.kt$BlockchainProvidersViewModel${ onPublicProviderUrlChange(id = blockchain.id, url = it) } NoNameShadowing:EnvironmentsTogglesViewModel.kt$EnvironmentsTogglesViewModel${ it.environment == currentEnvironment } - NoNameShadowing:TesterActivity.kt$TesterActivity${ val route = when (it) { ButtonUM.FEATURE_TOGGLES -> TesterScreen.FEATURE_TOGGLES ButtonUM.EXCLUDED_BLOCKCHAINS -> TesterScreen.EXCLUDED_BLOCKCHAINS ButtonUM.ENVIRONMENT_TOGGLES -> TesterScreen.ENVIRONMENTS_TOGGLES ButtonUM.BLOCKCHAIN_PROVIDERS -> TesterScreen.BLOCKCHAIN_PROVIDERS ButtonUM.TESTER_ACTIONS -> TesterScreen.TESTER_ACTIONS ButtonUM.TEST_PUSHES -> TesterScreen.TEST_PUSHES ButtonUM.ACCOUNTS -> TesterScreen.ACCOUNTS } innerTesterRouter.open(route) } PropertyUsedBeforeDeclaration:BlockchainProvidersViewModel.kt$BlockchainProvidersViewModel$_state PropertyUsedBeforeDeclaration:BlockchainProvidersViewModel.kt$BlockchainProvidersViewModel$searchQuery PropertyUsedBeforeDeclaration:EnvironmentsTogglesViewModel.kt$EnvironmentsTogglesViewModel$_uiState diff --git a/features/tokendetails/impl/detekt-baseline-debug.xml b/features/tokendetails/impl/detekt-baseline-debug.xml index f45527c13b..71ab124fb2 100644 --- a/features/tokendetails/impl/detekt-baseline-debug.xml +++ b/features/tokendetails/impl/detekt-baseline-debug.xml @@ -24,7 +24,6 @@ MultilineLambdaItParameter:TokenDetailsModel.kt$TokenDetailsModel${ internalUiState.value = stateFactory.getStateWithUpdatedHidden( isBalanceHidden = it.isBalanceHidden, ) } MultilineLambdaItParameter:TokenDetailsModel.kt$TokenDetailsModel${ sendButtonsEvents(it.states) internalUiState.value = stateFactory.getManageButtonsState(actions = it.states) } MultilineLambdaItParameter:TokenDetailsModel.kt$TokenDetailsModel${ val updatedState = stateFactory.getStateWithNotifications(it) notificationsAnalyticsSender.send(internalUiState.value, updatedState.notifications) internalUiState.value = updatedState } - MultilineLambdaItParameter:TokenDetailsOnrampTransactionStateConverter.kt$TokenDetailsOnrampTransactionStateConverter${ analyticsEventHandler.send(TokenOnrampAnalyticsEvent.GoToProvider) clickIntents.onGoToProviderClick(it) } MultilineLambdaItParameter:TokenDetailsScreen.kt${ Notification( modifier = itemModifier.animateItem(), config = it.config, iconTint = when (it) { is TokenDetailsNotification.Informational -> TangemTheme.colors.icon.accent is TokenDetailsNotification.UsedOutdatedData -> TangemTheme.colors.text.attention else -> null }, ) } MultilineLambdaItParameter:TokenDetailsTopAppBar.kt${ TangemDropdownItem( item = it, dismissParent = { showDropdownMenu = false }, ) } MultilineLambdaItParameter:TokenStakingBlock.kt${ when (it) { is StakingBlockUM.TemporaryUnavailable -> StakingTemporaryUnavailableBlock() is StakingBlockUM.Loading -> StakingLoading() is StakingBlockUM.Staked -> StakingBalanceBlock( state = it, isBalanceHidden = isBalanceHidden, ) is StakingBlockUM.StakeAvailable -> StakingAvailableContent( state = it, ) } } diff --git a/features/wallet/impl/detekt-baseline-debug.xml b/features/wallet/impl/detekt-baseline-debug.xml index 5a9fa2634b..f3a1111f2a 100644 --- a/features/wallet/impl/detekt-baseline-debug.xml +++ b/features/wallet/impl/detekt-baseline-debug.xml @@ -45,7 +45,6 @@ MultilineLambdaItParameter:SetRefreshStateTransformer.kt$SetRefreshStateTransformer${ it.mapNotNull { button -> when (button) { is WalletManageButton.Buy -> button.copy(enabled = isButtonsEnabled) is WalletManageButton.Send -> button.copy(enabled = isButtonsEnabled) is WalletManageButton.Sell -> button.copy(enabled = isButtonsEnabled) is WalletManageButton.Receive -> button is WalletManageButton.Stake -> null is WalletManageButton.Swap -> null } } } MultilineLambdaItParameter:SetVisaInfoTransformer.kt$SetVisaInfoTransformer${ if (it is RefreshTokenExpiredException) { return getRefreshTokenExpiredState(prevState) } return prevState.copy( buttons = createVisaButtonsDimmed(), walletCardState = getErrorWalletCardState(prevState.walletCardState), balancesAndLimitBlockState = BalancesAndLimitsBlockState.Error, ) } MultilineLambdaItParameter:SingleWalletExpressStatusesSubscriber.kt$SingleWalletExpressStatusesSubscriber${ Timber.e("Unable to get primary currency status: $it") return@onEach } - MultilineLambdaItParameter:SingleWalletOnrampTransactionConverter.kt$SingleWalletOnrampTransactionConverter${ analyticsEventHandler.send(TokenOnrampAnalyticsEvent.GoToProvider) clickIntents.onGoToProviderClick(it) } MultilineLambdaItParameter:TokenListAnalyticsSender.kt$TokenListAnalyticsSender${ val status = it.value if (status is CryptoCurrencyStatus.Loaded) { sendTokenBalancesForSpecificBlockchains(it, status) } } MultilineLambdaItParameter:TokenListStateConverter.kt$TokenListStateConverter${ if (isExtend) { clickIntents.onAccountCollapseClick(it) } else { clickIntents.onAccountExpandClick(it) } } MultilineLambdaItParameter:TxHistorySubscriber.kt$TxHistorySubscriber${ SetTxHistoryCountErrorTransformer( userWallet = userWallet, error = it, pendingTransactions = status.value.pendingTransactions, clickIntents = clickIntents, ) }