Updated on 2026-08-14
This commit is contained in:
parent
2554d98487
commit
6f8770007e
9 changed files with 25 additions and 16 deletions
|
|
@ -37,6 +37,7 @@ import com.tangem.datasource.local.config.environment.EnvironmentConfigStorage
|
|||
import com.tangem.datasource.local.config.issuers.IssuersConfigStorage
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.utils.NetworkLogsSaveInterceptor
|
||||
import com.tangem.domain.appcurrency.repository.AppCurrencyRepository
|
||||
import com.tangem.domain.apptheme.GetAppThemeModeUseCase
|
||||
import com.tangem.domain.apptheme.repository.AppThemeModeRepository
|
||||
|
|
@ -311,6 +312,7 @@ abstract class TangemApplication : Application(), ImageLoaderFactory, Configurat
|
|||
TangemApiServiceLogging.addInterceptors(
|
||||
createNetworkLoggingInterceptor(),
|
||||
ChuckerInterceptor(this),
|
||||
NetworkLogsSaveInterceptor(appLogsStore),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
|||
import com.tangem.wallet.BuildConfig
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
|
@ -64,7 +65,7 @@ internal class DefaultCardSdkProvider @Inject constructor(
|
|||
if (BuildConfig.TESTER_MENU_ENABLED) {
|
||||
appPreferencesStore.getObjectMap<ApiEnvironment>(PreferencesKeys.apiConfigsEnvironmentKey)
|
||||
.map {
|
||||
when (it[ApiConfig.ID.TangemCardSdk.name]) {
|
||||
when (it[ApiConfig.ID.Attestation.name]) {
|
||||
ApiEnvironment.DEV,
|
||||
ApiEnvironment.STAGE,
|
||||
-> false
|
||||
|
|
@ -73,6 +74,7 @@ internal class DefaultCardSdkProvider @Inject constructor(
|
|||
-> true
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.onEach { isProd ->
|
||||
holder?.let {
|
||||
it.sdk.config.isTangemAttestationProdEnv = isProd
|
||||
|
|
@ -170,7 +172,7 @@ internal class DefaultCardSdkProvider @Inject constructor(
|
|||
config = config.apply {
|
||||
isNewOnlineAttestationEnabled = cardSdkFeatureToggles.isNewAttestationEnabled
|
||||
|
||||
val apiConfig = apiConfigsManager.getEnvironmentConfig(id = ApiConfig.ID.TangemCardSdk)
|
||||
val apiConfig = apiConfigsManager.getEnvironmentConfig(id = ApiConfig.ID.Attestation)
|
||||
isTangemAttestationProdEnv = apiConfig.environment == ApiEnvironment.PROD
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ sealed class ApiConfig {
|
|||
TangemTech,
|
||||
StakeKit,
|
||||
TangemVisa,
|
||||
TangemCardSdk,
|
||||
Attestation,
|
||||
BlockAid,
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ sealed class ApiConfig {
|
|||
is TangemTech -> ID.TangemTech
|
||||
is StakeKit -> ID.StakeKit
|
||||
is TangemVisa -> ID.TangemVisa
|
||||
is TangemCardSdk -> ID.TangemCardSdk
|
||||
is Attestation -> ID.Attestation
|
||||
is BlockAid -> ID.BlockAid
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.datasource.api.common.config
|
||||
|
||||
/**
|
||||
* Tangem API [ApiConfig] that used in CardSDK
|
||||
* Attestation [ApiConfig] that used in CardSDK
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class TangemCardSdk : ApiConfig() {
|
||||
internal class Attestation : ApiConfig() {
|
||||
|
||||
override val defaultEnvironment: ApiEnvironment = ApiEnvironment.PROD
|
||||
|
||||
|
|
@ -49,5 +49,5 @@ internal object ApiConfigsModule {
|
|||
|
||||
@Provides
|
||||
@IntoSet
|
||||
fun provideTangemCardSdkConfig(): ApiConfig = TangemCardSdk()
|
||||
fun provideAttestationConfig(): ApiConfig = Attestation()
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ private const val JSON_INDENT_SPACES = 4
|
|||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class NetworkLogsSaveInterceptor(
|
||||
class NetworkLogsSaveInterceptor(
|
||||
private val appLogsStore: AppLogsStore,
|
||||
) : Interceptor {
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ internal class ProdApiConfigsManagerTest(private val model: Model) {
|
|||
is TangemTech -> createTangemTechModel()
|
||||
is StakeKit -> createStakeKitModel()
|
||||
is TangemVisa -> createVisaModel()
|
||||
is TangemCardSdk -> createTangemCardSdkModel()
|
||||
is Attestation -> createAttestationModel()
|
||||
is BlockAid -> createBlockAidSdkModel()
|
||||
}
|
||||
}
|
||||
|
|
@ -189,9 +189,9 @@ internal class ProdApiConfigsManagerTest(private val model: Model) {
|
|||
)
|
||||
}
|
||||
|
||||
private fun createTangemCardSdkModel(): Model {
|
||||
private fun createAttestationModel(): Model {
|
||||
return Model(
|
||||
id = ApiConfig.ID.TangemCardSdk,
|
||||
id = ApiConfig.ID.Attestation,
|
||||
expected = ApiEnvironmentConfig(
|
||||
environment = ApiEnvironment.PROD,
|
||||
baseUrl = "https://api.tangem-tech.com/",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.domain.core.utils.catchOn
|
|||
import com.tangem.domain.quotes.multi.MultiQuoteFetcher
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -53,7 +54,11 @@ internal class DefaultMultiQuoteFetcher @Inject constructor(
|
|||
val coinIds = replacementIdsResult.idsForRequest.joinToString(separator = ",")
|
||||
|
||||
val response = safeApiCallWithTimeout(
|
||||
call = { tangemTechApi.getQuotes(currencyId = appCurrencyId, coinIds = coinIds).bind() },
|
||||
call = {
|
||||
withContext(dispatchers.io) {
|
||||
tangemTechApi.getQuotes(currencyId = appCurrencyId, coinIds = coinIds).bind()
|
||||
}
|
||||
},
|
||||
onError = { error -> throw error },
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -96,15 +96,15 @@ internal class EnvironmentsTogglesViewModel @Inject constructor(
|
|||
viewModelScope.launch {
|
||||
val environment = ApiEnvironment.valueOf(name)
|
||||
|
||||
handleIfTangemCardSdkConfig(id = id, environment = environment)
|
||||
handleIfAttestationConfig(id = id, environment = environment)
|
||||
|
||||
mutableApiConfigsManager.changeEnvironment(id = id, environment = environment)
|
||||
}
|
||||
}
|
||||
|
||||
/** Special logic for [ApiConfig.ID.TangemCardSdk] */
|
||||
private fun handleIfTangemCardSdkConfig(id: String, environment: ApiEnvironment) {
|
||||
if (id == ApiConfig.ID.TangemCardSdk.name) {
|
||||
/** Special logic for [ApiConfig.ID.Attestation] */
|
||||
private fun handleIfAttestationConfig(id: String, environment: ApiEnvironment) {
|
||||
if (id == ApiConfig.ID.Attestation.name) {
|
||||
cardSdkConfigRepository.setTangemApiProdEnvFlag(
|
||||
flag = when (environment) {
|
||||
ApiEnvironment.PROD -> true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue