diff --git a/app/src/main/java/com/tangem/tap/common/entities/TapCurrency.kt b/app/src/main/java/com/tangem/tap/common/entities/TapCurrency.kt deleted file mode 100644 index 1aa3f5c351..0000000000 --- a/app/src/main/java/com/tangem/tap/common/entities/TapCurrency.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.tangem.tap.common.entities - -/** -[REDACTED_AUTHOR] - */ -class TapCurrency { - companion object{ - const val DEFAULT_FIAT_CURRENCY = "USD" - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt index 75dccd51ab..1e104b5dd4 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt @@ -24,7 +24,7 @@ class GlobalMiddleware { } } -private val globalMiddlewareHandler: Middleware = { dispatch, appState -> +private val globalMiddlewareHandler: Middleware = { _, appState -> { nextDispatch -> { action -> when (action) { diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt index e938026085..4dba1b6bd6 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsMiddleware.kt @@ -30,7 +30,7 @@ class DetailsMiddleware { private val eraseWalletMiddleware = EraseWalletMiddleware() private val appCurrencyMiddleware = AppCurrencyMiddleware() private val manageSecurityMiddleware = ManageSecurityMiddleware() - val detailsMiddleware: Middleware = { dispatch, state -> + val detailsMiddleware: Middleware = { _, _ -> { next -> { action -> when (action) { @@ -122,6 +122,8 @@ class DetailsMiddleware { store.dispatch(DetailsAction.ResetToFactory.Proceed.NotAllowedByCard) EraseWalletState.NotEmpty -> store.dispatch(DetailsAction.ResetToFactory.Proceed.NotEmpty) + else -> { /* no-op */ + } } } is DetailsAction.ResetToFactory.Cancel -> { @@ -150,6 +152,8 @@ class DetailsMiddleware { } } } + else -> { /* no-op */ + } } } } @@ -164,6 +168,8 @@ class DetailsMiddleware { store.dispatch(GlobalAction.ChangeAppCurrency(action.fiatCurrency)) store.dispatch(WalletAction.LoadFiatRate()) } + else -> { /* no-op */ + } } } } @@ -234,18 +240,22 @@ class DetailsMiddleware { actionToLog = Analytics.ActionToLog.ChangeSecOptions, parameters = mapOf( AnalyticsParam.NEW_SECURITY_OPTION to - (selectedOption?.name ?: "") + (selectedOption?.name ?: "") ), card = store.state.detailsState.scanResponse?.card ) } store.dispatch(DetailsAction.ManageSecurity.SaveChanges.Failure) } + else -> { /* no-op */ + } } } } } + else -> { /* no-op */ + } } } } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt index 3219b7cd2f..eb079d3116 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt @@ -70,9 +70,9 @@ private fun internalReduce(action: Action, state: AppState): WalletState { when (action.error) { is TapError.NoInternetConnection -> { val wallets = newState.wallets - .map { - it.copy( - walletsData = it.walletsData.map { + .map { store -> + store.copy( + walletsData = store.walletsData.map { it.copy( currencyData = it.currencyData.copy( status = BalanceStatus.Unreachable @@ -110,6 +110,8 @@ private fun internalReduce(action: Action, state: AppState): WalletState { ) ) } + else -> { /* no-op */ + } } } @@ -306,23 +308,23 @@ private fun internalReduce(action: Action, state: AppState): WalletState { } is WalletAction.SetWalletRent -> { var walletData = newState.getWalletData(action.blockchain) - if (walletData == null) { - newState - } else { - walletData = - walletData.copy(warningRent = WalletRent(action.minRent, action.rentExempt)) + if (walletData != null) { + walletData = walletData.copy( + warningRent = WalletRent(action.minRent, action.rentExempt) + ) newState = newState.updateWalletsData(listOf(walletData)) + } } is WalletAction.RemoveWalletRent -> { var walletData = newState.getWalletData(action.blockchain) - if (walletData == null) { - newState - } else { + if (walletData != null) { walletData = walletData.copy(warningRent = null) newState = newState.updateWalletsData(listOf(walletData)) } } + else -> { /* no-op */ + } } return newState } diff --git a/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapApi.kt b/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapApi.kt deleted file mode 100644 index 6836861c8c..0000000000 --- a/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapApi.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.tangem.tap.network.coinmarketcap - -import com.tangem.network.common.AddHeaderInterceptor -import com.tangem.network.common.createRetrofitInstance -import retrofit2.http.GET -import retrofit2.http.Query - -interface CoinMarketCapApi { - - @GET("v1/tools/price-conversion") - suspend fun getRateInfo( - @Query("amount") amount: Int, - @Query("symbol") cryptoCurrencyName: String, - @Query("convert") fiatCurrencyName: String? = null - ): RateInfoResponse - - @GET("v1/fiat/map") - suspend fun getFiatMap(): FiatMapResponse - - - companion object { - private const val baseUrl = "https://pro-api.coinmarketcap.com/" - - fun create(apiKey: String): CoinMarketCapApi { - return createRetrofitInstance( - baseUrl = baseUrl, - interceptors = listOf( - AddHeaderInterceptor(mapOf("X-CMC_PRO_API_KEY" to apiKey)), - ), - ).create(CoinMarketCapApi::class.java) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapService.kt b/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapService.kt deleted file mode 100644 index aa4de2bf44..0000000000 --- a/app/src/main/java/com/tangem/tap/network/coinmarketcap/CoinMarketCapService.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.tangem.tap.network.coinmarketcap - -import com.tangem.common.services.Result -import com.tangem.common.services.performRequest -import com.tangem.tap.common.redux.global.FiatCurrencyName -import com.tangem.tap.store -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import java.math.BigDecimal - -//TODO: refactoring: move to the domain module and aggregate it as the alternative service for TangemTech -class CoinMarketCapService() { - private val api: CoinMarketCapApi by lazy { CoinMarketCapApi.create(getApiKey()) } - - private fun getApiKey(): String { - return store.state.globalState.configManager?.config?.coinMarketCapKey ?: "" - } - - suspend fun getRate( - currency: String, fiatCurrency: FiatCurrencyName? = null - ): Result = withContext(Dispatchers.IO) { - val response = performRequest { api.getRateInfo(1, currency, fiatCurrency) } - return@withContext when (response) { - is Result.Success -> Result.Success(response.data.data.getRate()) - is Result.Failure -> response - } - } - - suspend fun getFiatCurrencies(): Result> = withContext(Dispatchers.IO) { - val response = performRequest { api.getFiatMap() } - return@withContext when (response) { - is Result.Success -> Result.Success(response.data.data.sortedBy { it.name }) - is Result.Failure -> response - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/network/coinmarketcap/Response.kt b/app/src/main/java/com/tangem/tap/network/coinmarketcap/Response.kt deleted file mode 100644 index 7320d9467c..0000000000 --- a/app/src/main/java/com/tangem/tap/network/coinmarketcap/Response.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.tangem.tap.network.coinmarketcap - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass -import java.math.BigDecimal - -@JsonClass(generateAdapter = true) -class RateInfoResponse : CoinMarketResponse() - -@JsonClass(generateAdapter = true) -data class RateData( - val quote: Map -) { - fun getRate(): BigDecimal = quote.values.first().price -} - -@JsonClass(generateAdapter = true) -data class CurrencyRate( - val price: BigDecimal -) - - -@JsonClass(generateAdapter = true) -data class Status( - val timestamp: String, - @Json(name = "error_code") - val errorCode: Int, - @Json(name = "error_message") - val errorMessage: String?, - val elapsed: Int, - @Json(name = "credit_count") - val creditCount: Int, - val notice: String? -) - -@JsonClass(generateAdapter = true) -class FiatMapResponse : CoinMarketResponse>() - -@JsonClass(generateAdapter = true) -open class CoinMarketResponse { - lateinit var status: Status - lateinit var data: T -} - -@JsonClass(generateAdapter = true) -data class FiatCurrency( - val id: Int, - val name: String, - val sign: String, - val symbol: String -)