diff --git a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json index 6a91513972..711bf35291 100644 --- a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json +++ b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json @@ -57,7 +57,7 @@ }, { "name": "NEW_ONRAMP_MAIN_ENABLED", - "version": "undefined" + "version": "5.29.0" }, { "name": "ACCOUNTS_FEATURE_ENABLED", 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 f21dfe240a..81379472ab 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 @@ -32,7 +32,6 @@ import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.staking.* import com.tangem.domain.models.staking.action.StakingActionType -import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.staking.* import com.tangem.domain.staking.analytics.StakeScreenSource @@ -153,7 +152,11 @@ internal class StakingModel @Inject constructor( private var feeCryptoCurrencyStatus: CryptoCurrencyStatus? = null private var minimumTransactionAmount: EnterAmountBoundary? = null - private var userWallet: UserWallet by Delegates.notNull() + private val userWallet by lazy { + requireNotNull( + getUserWalletUseCase(userWalletId).getOrNull(), + ) { "No wallet found for id: $userWalletId" } + } private var appCurrency: AppCurrency by Delegates.notNull() private val balancesToShow: List @@ -925,17 +928,6 @@ internal class StakingModel @Inject constructor( } private fun subscribeOnCurrencyStatusUpdates() { - getUserWalletUseCase(userWalletId).fold( - ifRight = { wallet -> - userWallet = wallet - }, - ifLeft = { - stakingEventFactory.createGenericErrorAlert(it.toString()) - stateController.update( - SetConfirmationStateResetAssentTransformer(cryptoCurrencyStatus = cryptoCurrencyStatus), - ) - }, - ) getSingleCryptoCurrencyStatusUseCase.invokeMultiWallet( userWalletId = userWalletId, currencyId = cryptoCurrencyId, diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt index 34e730d7c1..6a7f2b979e 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt @@ -32,7 +32,6 @@ import com.tangem.domain.feedback.models.FeedbackEmailType import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.network.Network -import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.promo.GetStoryContentUseCase import com.tangem.domain.promo.ShouldShowStoriesUseCase @@ -77,7 +76,6 @@ import java.text.DecimalFormat import java.text.NumberFormat import java.util.Locale import javax.inject.Inject -import kotlin.properties.Delegates typealias SuccessLoadedSwapData = Map @@ -115,11 +113,15 @@ internal class SwapModel @Inject constructor( private val userWalletId = params.userWalletId private val isInitiallyReversed = params.isInitialReverseOrder + private val userWallet by lazy { + requireNotNull( + getUserWalletUseCase(userWalletId).getOrNull(), + ) { "No wallet found for id: $userWalletId" } + } private val swapInteractor = swapInteractorFactory.create(userWalletId) private lateinit var initialFromStatus: CryptoCurrencyStatus private var initialToStatus: CryptoCurrencyStatus? = null - private var userWallet: UserWallet by Delegates.notNull() private var isBalanceHidden = true @@ -186,12 +188,10 @@ internal class SwapModel @Inject constructor( val toStatus = initialCurrencyTo?.let { getSingleCryptoCurrencyStatusUseCase.invokeMultiWalletSync(userWalletId, it.id).getOrNull() } - val wallet = getUserWalletUseCase(userWalletId).getOrNull() - if (fromStatus == null || wallet == null) { + if (fromStatus == null) { uiState = stateBuilder.addAlert(uiState = uiState, onDismiss = swapRouter::back) } else { - userWallet = wallet initialFromStatus = fromStatus initialToStatus = toStatus initTokens(isInitiallyReversed)