From 27edc094d7bce52aad4321490f1dfb96e79a44ef Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 15:38:46 -0700 Subject: [PATCH 1/8] fix: constrain currency list to bottom --- .../maya/src/main/res/layout/fragment_currency_picker.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integrations/maya/src/main/res/layout/fragment_currency_picker.xml b/integrations/maya/src/main/res/layout/fragment_currency_picker.xml index ccaefcb49..0787bdafa 100644 --- a/integrations/maya/src/main/res/layout/fragment_currency_picker.xml +++ b/integrations/maya/src/main/res/layout/fragment_currency_picker.xml @@ -105,7 +105,7 @@ From 4117cc1ead817d9a8598a9b2eef9c4367205afbf Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 15:43:24 -0700 Subject: [PATCH 2/8] fix: show correct decimals for each currency --- .../wallet/integrations/maya/ui/MayaViewModel.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt index c02c7163f..580dc57a7 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt @@ -61,15 +61,16 @@ class MayaViewModel @Inject constructor( val log = LoggerFactory.getLogger(MayaViewModel::class.java) } - val fiatFormat = MonetaryFormat().minDecimals(2).withLocale(Locale.getDefault()).noCode() + var fiatFormat: MonetaryFormat = MonetaryFormat() + .minDecimals(GenericUtils.getCurrencyDigits()) + .withLocale(Locale.getDefault()) + .noCode() val networkError = SingleLiveEvent() private var dashExchangeRate: org.bitcoinj.utils.ExchangeRate? = null private var fiatExchangeRate: Fiat? = null - // val currencyList = MutableStateFlow>(listOf()) - private val _uiState = MutableStateFlow(MayaPortalUIState()) val uiState: StateFlow = _uiState.asStateFlow() @@ -86,7 +87,9 @@ class MayaViewModel @Inject constructor( .filterNotNull() .flatMapLatest(exchangeRatesProvider::observeExchangeRate) .onEach { rate -> - dashExchangeRate = rate?.let { org.bitcoinj.utils.ExchangeRate(Coin.COIN, rate.fiat) } + dashExchangeRate = rate?.let { + org.bitcoinj.utils.ExchangeRate(Coin.COIN, rate.fiat) + } _uiState.update { it.copy() } } .launchIn(viewModelScope) @@ -96,7 +99,10 @@ class MayaViewModel @Inject constructor( .onEach { log.info("selected currency: {}", it) } .flatMapLatest(fiatExchangeRateProvider::observeFiatRate) .onEach { - it?.let { fiatRate -> fiatExchangeRate = fiatRate.fiat } + it?.let { fiatRate -> + fiatFormat = fiatFormat.minDecimals(GenericUtils.getCurrencyDigits(it.currencyCode)) + fiatExchangeRate = fiatRate.fiat + } log.info("exchange rate: $it") } .flatMapLatest { mayaApi.observePoolList(it!!.fiat) } From 537d931090eb6a79998a02f4e0c4caa9bbbb9cb8 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 15:43:47 -0700 Subject: [PATCH 3/8] fix: add util function for decimal count --- .../main/java/org/dash/wallet/common/util/GenericUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/src/main/java/org/dash/wallet/common/util/GenericUtils.kt b/common/src/main/java/org/dash/wallet/common/util/GenericUtils.kt index 714883a3b..b635ecf7a 100644 --- a/common/src/main/java/org/dash/wallet/common/util/GenericUtils.kt +++ b/common/src/main/java/org/dash/wallet/common/util/GenericUtils.kt @@ -129,6 +129,11 @@ object GenericUtils { return currency?.defaultFractionDigits ?: 0 } + fun getCurrencyDigits(code: String): Int { + val currency: Currency? = Currency.getInstance(code) + return currency?.defaultFractionDigits ?: 2 + } + private fun stringToBigDecimal(value: String): BigDecimal { return try { val format = NumberFormat.getNumberInstance(getDeviceLocale()) From 6da97ee9fa45b005210017ee68010678f34ef21e Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 15:44:41 -0700 Subject: [PATCH 4/8] feat: replace bad rate service with three good services --- .../integrations/maya/api/ExchangeRateApi.kt | 27 ++++++++++++++---- .../maya/api/FiatExchangeRateApi.kt | 26 +++++++++++++++-- .../wallet/integrations/maya/di/MayaModule.kt | 19 ++++++++++++- .../maya/model/CurrencyBeaconResponse.kt | 28 +++++++++++++++++++ .../maya/model/ExchangeRateResponse.kt | 12 ++++---- .../maya/model/FreeCurrencyResponse.kt | 25 +++++++++++++++++ 6 files changed, 123 insertions(+), 14 deletions(-) create mode 100644 integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt create mode 100644 integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt index 5d01f8c4c..575398dd0 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt @@ -17,21 +17,36 @@ package org.dash.wallet.integrations.maya.api +import org.dash.wallet.integrations.maya.model.CurrencyBeaconResponse import org.dash.wallet.integrations.maya.model.ExchangeRateResponse +import org.dash.wallet.integrations.maya.model.FreeCurrencyResponse import retrofit2.Response import retrofit2.http.GET +import retrofit2.http.Header import retrofit2.http.Query /** - * https://exchangerate.host/#/docs + * https://v6.exchangerate-api.com/v6/{api-key}}/latest/USD */ interface ExchangeRateApi { - @GET("latest") - suspend fun getRates(@Query("base") baseCurrencyCode: String): Response + @GET("latest/USD") + suspend fun getRates(): Response +} +interface CurrencyBeaconApi { @GET("latest") - suspend fun getRate( + suspend fun getRates( @Query("base") baseCurrencyCode: String, - @Query("symbols") resultCurrencyCode: String - ): Response + @Query("symbols") resultCurrencyCode: String, + @Query("api_key") apiKey: String = "1xsN7q7S2Lo3gzlmtrpdmLufO96OBlRK" + ): Response +} + +interface FreeCurrencyApi { + @GET("latest") + suspend fun getRates( + @Query("base_currency") baseCurrencyCode: String = "USD", + @Query("currencies") resultCurrencyCode: String, + @Query("apikey") apiKey: String = "fca_live_SysbOIn5mJg21vRzfUVRYPA6hIxku1umZUaUkNty" + ): Response } diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt index 6815896a1..32073210e 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt @@ -31,13 +31,35 @@ import java.util.concurrent.TimeUnit import javax.inject.Inject class FiatExchangeRateApiAggregator @Inject constructor( - private val exchangeRateApi: ExchangeRateApi + private val exchangeRateApi: ExchangeRateApi, + private val currencyBeaconApi: CurrencyBeaconApi, + private val freeCurrencyApi: FreeCurrencyApi ) { companion object { val log: Logger = LoggerFactory.getLogger(FiatExchangeRateApiAggregator::class.java) } suspend fun getRate(currencyCode: String): ExchangeRate? { - val response = exchangeRateApi.getRates(MayaConstants.DEFAULT_EXCHANGE_CURRENCY).body() + val currencyBeaconResponse = currencyBeaconApi.getRates(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, currencyCode) + if (currencyBeaconResponse.isSuccessful) { + val response = currencyBeaconResponse.body() + val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 + log.info("exchange rate: {} {}", exchangeRate, currencyCode) + if (exchangeRate != 0.0) { + return ExchangeRate(currencyCode, exchangeRate.toString()) + } + } + + val freeCurrencyResponse = freeCurrencyApi.getRates(resultCurrencyCode = currencyCode) + if (freeCurrencyResponse.isSuccessful) { + val response = freeCurrencyResponse.body() + val exchangeRate = response?.data?.get(currencyCode) ?: 0.0 + log.info("exchange rate: {} {}", exchangeRate, currencyCode) + if (exchangeRate != 0.0) { + return ExchangeRate(currencyCode, exchangeRate.toString()) + } + } + + val response = exchangeRateApi.getRates().body() val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 log.info("exchange rate: {} {}", exchangeRate, currencyCode) return if (exchangeRate != 0.0) { diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt index 788e0b404..a59cb1d15 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt @@ -23,9 +23,11 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import org.dash.wallet.common.WalletDataProvider +import org.dash.wallet.integrations.maya.api.CurrencyBeaconApi import org.dash.wallet.integrations.maya.api.ExchangeRateApi import org.dash.wallet.integrations.maya.api.FiatExchangeRateAggregatedProvider import org.dash.wallet.integrations.maya.api.FiatExchangeRateProvider +import org.dash.wallet.integrations.maya.api.FreeCurrencyApi import org.dash.wallet.integrations.maya.api.MayaApi import org.dash.wallet.integrations.maya.api.MayaApiAggregator import org.dash.wallet.integrations.maya.api.MayaBlockchainApi @@ -61,11 +63,26 @@ abstract class MayaModule { @Provides fun provideExchangeRateEndpoint( remoteDataSource: RemoteDataSource, - walletDataProvider: WalletDataProvider ): ExchangeRateApi { val baseUrl = MayaConstants.EXCHANGERATE_BASE_URL return remoteDataSource.buildApi(ExchangeRateApi::class.java, baseUrl) } + + @Provides + fun provideCurrencyBeaconEndpoint( + remoteDataSource: RemoteDataSource + ): CurrencyBeaconApi { + val baseUrl = MayaConstants.CURRENCYBEACON_BASE_URL + return remoteDataSource.buildApi(CurrencyBeaconApi::class.java, baseUrl) + } + + @Provides + fun provideFreeCurrencyApiEndpoint( + remoteDataSource: RemoteDataSource, + ): FreeCurrencyApi { + val baseUrl = MayaConstants.FREE_CURRENCY_API_BASE_URL + return remoteDataSource.buildApi(FreeCurrencyApi::class.java, baseUrl) + } } @Binds diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt new file mode 100644 index 000000000..823c4d4b8 --- /dev/null +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2024 Dash Core Group. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.dash.wallet.integrations.maya.model + +/** + * Response from https://api.currencybeacon.com/v1/latest + */ +class CurrencyBeaconResponse( + val result: String, + val base: String, + val date: String, + val rates: Map +) \ No newline at end of file diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/ExchangeRateResponse.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/ExchangeRateResponse.kt index d51a5972d..dbe647461 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/ExchangeRateResponse.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/ExchangeRateResponse.kt @@ -17,12 +17,14 @@ package org.dash.wallet.integrations.maya.model +import com.google.gson.annotations.SerializedName + /** - * Response from api.exchangerates.host + * Response from https://v6.exchangerate-api.com/v6 */ data class ExchangeRateResponse( - val success: Boolean, - val base: String, - val date: String, - val rates: Map + val result: String, + @SerializedName("base_code") val baseCode: String, + @SerializedName("time_last_update_unix") val lastUpdate: Long, + @SerializedName("conversion_rates") val rates: Map ) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt new file mode 100644 index 000000000..e04cfe3be --- /dev/null +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Dash Core Group. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.dash.wallet.integrations.maya.model + +/** + * Response from https://api.freecurrencyapi.com/v1/latest + */ +class FreeCurrencyResponse( + val data: Map +) \ No newline at end of file From 50cfceaa7e6ed4d5d8ec1224ed430c7b1d5c5745 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 15:44:59 -0700 Subject: [PATCH 5/8] fix: add USK which was lost --- .../maya/payments/MayaCryptoCurrency.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/MayaCryptoCurrency.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/MayaCryptoCurrency.kt index 3ccd61c86..e083e4990 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/MayaCryptoCurrency.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/payments/MayaCryptoCurrency.kt @@ -116,7 +116,9 @@ open class MayaKujiraCryptoCurrency : MayaBitcoinCryptoCurrency() { class MayaKujiraTokenCryptoCurrency( override val code: String, override val name: String, - override val asset: String + override val asset: String, + override val codeId: Int, + override val nameId: Int ) : MayaKujiraCryptoCurrency() class MayaEthereumTokenCryptoCurrency( @@ -267,7 +269,14 @@ object MayaCurrencyList { ), MayaKujiraCryptoCurrency(), - MayaKujiraTokenCryptoCurrency("USK", "USK", "KUJI.USK"), + MayaKujiraTokenCryptoCurrency( + "USK", + "USK", + "KUJI.USK", + R.string.cryptocurrency_usk_code, + R.string.cryptocurrency_usk_network + ), + MayaRuneCryptoCurrency() ) currencyMap = currencyList.associateBy({ it.asset }, { it }) From 206be3469c8cc39c5444f876af1108ae85ba2168 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 13 Jun 2024 16:08:32 -0700 Subject: [PATCH 6/8] fix: update rates once per day --- .../maya/api/FiatExchangeRateApi.kt | 67 ++++++++++++------- .../integrations/maya/utils/MayaConfig.kt | 7 ++ 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt index 32073210e..46bb56029 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import org.dash.wallet.common.data.entity.ExchangeRate +import org.dash.wallet.integrations.maya.utils.MayaConfig import org.dash.wallet.integrations.maya.utils.MayaConstants import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -33,41 +34,61 @@ import javax.inject.Inject class FiatExchangeRateApiAggregator @Inject constructor( private val exchangeRateApi: ExchangeRateApi, private val currencyBeaconApi: CurrencyBeaconApi, - private val freeCurrencyApi: FreeCurrencyApi + private val freeCurrencyApi: FreeCurrencyApi, + private val mayaConfig: MayaConfig ) { companion object { val log: Logger = LoggerFactory.getLogger(FiatExchangeRateApiAggregator::class.java) } suspend fun getRate(currencyCode: String): ExchangeRate? { - val currencyBeaconResponse = currencyBeaconApi.getRates(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, currencyCode) - if (currencyBeaconResponse.isSuccessful) { - val response = currencyBeaconResponse.body() - val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 - log.info("exchange rate: {} {}", exchangeRate, currencyCode) - if (exchangeRate != 0.0) { - return ExchangeRate(currencyCode, exchangeRate.toString()) + val lastUpdate = mayaConfig.get(MayaConfig.EXCHANGE_RATE_LAST_UPDATE) + val lastCurrencyCode = mayaConfig.get(MayaConfig.EXCHANGE_RATE_CURRENCY_CODE) + if (lastCurrencyCode != currencyCode || lastUpdate == null || lastUpdate == 0L || + (System.currentTimeMillis() - lastUpdate) > MayaConfig.expirationDuration) { + val currencyBeaconResponse = + currencyBeaconApi.getRates(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, currencyCode) + if (currencyBeaconResponse.isSuccessful) { + val response = currencyBeaconResponse.body() + val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 + log.info("exchange rate: {} {}", exchangeRate, currencyCode) + if (exchangeRate != 0.0) { + return saveNewExchangeRate(exchangeRate, currencyCode) + } } - } - val freeCurrencyResponse = freeCurrencyApi.getRates(resultCurrencyCode = currencyCode) - if (freeCurrencyResponse.isSuccessful) { - val response = freeCurrencyResponse.body() - val exchangeRate = response?.data?.get(currencyCode) ?: 0.0 - log.info("exchange rate: {} {}", exchangeRate, currencyCode) - if (exchangeRate != 0.0) { - return ExchangeRate(currencyCode, exchangeRate.toString()) + val freeCurrencyResponse = freeCurrencyApi.getRates(resultCurrencyCode = currencyCode) + if (freeCurrencyResponse.isSuccessful) { + val response = freeCurrencyResponse.body() + val exchangeRate = response?.data?.get(currencyCode) ?: 0.0 + log.info("exchange rate: {} {}", exchangeRate, currencyCode) + if (exchangeRate != 0.0) { + return saveNewExchangeRate(exchangeRate, currencyCode) + } } - } - val response = exchangeRateApi.getRates().body() - val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 - log.info("exchange rate: {} {}", exchangeRate, currencyCode) - return if (exchangeRate != 0.0) { - ExchangeRate(currencyCode, exchangeRate.toString()) + val response = exchangeRateApi.getRates().body() + val exchangeRate = response?.rates?.get(currencyCode) ?: 0.0 + log.info("exchange rate: {} {}", exchangeRate, currencyCode) + return if (exchangeRate != 0.0) { + saveNewExchangeRate(exchangeRate, currencyCode) + } else { + null + } } else { - null + val lastValue = mayaConfig.get(MayaConfig.EXCHANGE_RATE_VALUE) ?: 0 + return ExchangeRate(lastCurrencyCode, lastValue.toString()) } } + + private suspend fun saveNewExchangeRate( + exchangeRate: Double, + currencyCode: String + ): ExchangeRate { + mayaConfig.set(MayaConfig.EXCHANGE_RATE_VALUE, exchangeRate) + mayaConfig.set(MayaConfig.EXCHANGE_RATE_CURRENCY_CODE, currencyCode) + mayaConfig.set(MayaConfig.EXCHANGE_RATE_LAST_UPDATE, System.currentTimeMillis()) + return ExchangeRate(currencyCode, exchangeRate.toString()) + } } interface FiatExchangeRateProvider { diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConfig.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConfig.kt index 560c54581..db3ee055f 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConfig.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConfig.kt @@ -18,9 +18,12 @@ package org.dash.wallet.integrations.maya.utils import android.content.Context +import androidx.datastore.preferences.core.doublePreferencesKey +import androidx.datastore.preferences.core.longPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import org.dash.wallet.common.WalletDataProvider import org.dash.wallet.common.data.BaseConfig +import java.util.concurrent.TimeUnit import javax.inject.Inject import javax.inject.Singleton @@ -33,5 +36,9 @@ open class MayaConfig @Inject constructor( const val PREFERENCES_NAME = "maya" val BACKGROUND_ERROR = stringPreferencesKey("error") + val expirationDuration = TimeUnit.DAYS.toMillis(1) + val EXCHANGE_RATE_LAST_UPDATE = longPreferencesKey("exchange_rate_last_update") + val EXCHANGE_RATE_VALUE = doublePreferencesKey("exchange_rate_value") + val EXCHANGE_RATE_CURRENCY_CODE = stringPreferencesKey("exchange_rate_currency_code") } } From b1cf7de91600168502bfbd3086c359f44643bfa3 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 20 Jun 2024 16:57:57 -0700 Subject: [PATCH 7/8] fix: fix many bugs with retrieving rates from FX services --- .../ui/recyclerview/IconifiedListAdapter.kt | 4 ++- .../maya/api/FiatExchangeRateApi.kt | 27 ++++++++----------- .../maya/ui/MayaAddressInputFragment.kt | 2 +- .../maya/ui/MayaConvertCryptoFragment.kt | 2 +- .../ui/MayaCryptoCurrencyPickerFragment.kt | 22 +++++++++++++-- .../maya/ui/MayaPortalFragment.kt | 2 +- .../integrations/maya/ui/MayaViewModel.kt | 13 +++++---- .../integrations/maya/utils/MayaConstants.kt | 16 ++++++++--- 8 files changed, 56 insertions(+), 32 deletions(-) diff --git a/common/src/main/java/org/dash/wallet/common/ui/recyclerview/IconifiedListAdapter.kt b/common/src/main/java/org/dash/wallet/common/ui/recyclerview/IconifiedListAdapter.kt index b347fc450..2a9e49928 100644 --- a/common/src/main/java/org/dash/wallet/common/ui/recyclerview/IconifiedListAdapter.kt +++ b/common/src/main/java/org/dash/wallet/common/ui/recyclerview/IconifiedListAdapter.kt @@ -20,6 +20,7 @@ package org.dash.wallet.common.ui.recyclerview import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.view.isVisible +import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import org.dash.wallet.common.R import org.dash.wallet.common.databinding.RadiobuttonRowBinding @@ -29,8 +30,9 @@ import org.dash.wallet.common.ui.radio_group.RadioGroupAdapter import org.dash.wallet.common.ui.setRoundedRippleBackground class IconifiedListAdapter( + diffCallback: DiffUtil.ItemCallback = RadioGroupAdapter.DiffCallback(), private val clickListener: (IconifiedViewItem, Int) -> Unit -): ListAdapter(RadioGroupAdapter.DiffCallback()) { +): ListAdapter(diffCallback) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IconifiedViewHolder { val inflater = LayoutInflater.from(parent.context) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt index 46bb56029..8b4acf5b8 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt @@ -45,6 +45,10 @@ class FiatExchangeRateApiAggregator @Inject constructor( val lastCurrencyCode = mayaConfig.get(MayaConfig.EXCHANGE_RATE_CURRENCY_CODE) if (lastCurrencyCode != currencyCode || lastUpdate == null || lastUpdate == 0L || (System.currentTimeMillis() - lastUpdate) > MayaConfig.expirationDuration) { + + if (currencyCode == MayaConstants.DEFAULT_EXCHANGE_CURRENCY) { + return ExchangeRate(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, "1.0") + } val currencyBeaconResponse = currencyBeaconApi.getRates(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, currencyCode) if (currencyBeaconResponse.isSuccessful) { @@ -72,7 +76,7 @@ class FiatExchangeRateApiAggregator @Inject constructor( return if (exchangeRate != 0.0) { saveNewExchangeRate(exchangeRate, currencyCode) } else { - null + ExchangeRate(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, "1.0") } } else { val lastValue = mayaConfig.get(MayaConfig.EXCHANGE_RATE_VALUE) ?: 0 @@ -101,7 +105,6 @@ class FiatExchangeRateAggregatedProvider @Inject constructor( ) : FiatExchangeRateProvider { companion object { private val log = LoggerFactory.getLogger(FiatExchangeRateApiAggregator::class.java) - private val UPDATE_FREQ_MS = TimeUnit.SECONDS.toMillis(30) } private val responseScope = CoroutineScope( @@ -111,31 +114,23 @@ class FiatExchangeRateAggregatedProvider @Inject constructor( override val fiatExchangeRate = MutableStateFlow(ExchangeRate(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, "1.0")) override fun observeFiatRate(currencyCode: String): Flow { - if (shouldRefresh()) { - refreshRates(currencyCode) - } + refreshRates(currencyCode) return fiatExchangeRate } private fun refreshRates(currencyCode: String) { - if (!shouldRefresh()) { - return - } - responseScope.launch { updateExchangeRates(currencyCode) poolListLastUpdated = System.currentTimeMillis() } } - private fun shouldRefresh(): Boolean { - val now = System.currentTimeMillis() - return poolListLastUpdated == 0L || now - poolListLastUpdated > UPDATE_FREQ_MS - } - private suspend fun updateExchangeRates(currencyCode: String) { - fiatExchangeRateApi.getRate(currencyCode)?.let { rate -> - fiatExchangeRate.value = rate + val newRate = fiatExchangeRateApi.getRate(currencyCode) + if (newRate != null) { + fiatExchangeRate.value = newRate + } else { + fiatExchangeRate.value = ExchangeRate(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, "1.0") } } } diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaAddressInputFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaAddressInputFragment.kt index b0594ae5d..7fc952c29 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaAddressInputFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaAddressInputFragment.kt @@ -39,7 +39,7 @@ import org.dash.wallet.integrations.maya.model.getMayaErrorString import org.dash.wallet.integrations.maya.model.getMayaErrorType class MayaAddressInputFragment : AddressInputFragment() { - private val mayaViewModel by viewModels() + private val mayaViewModel by mayaViewModels() private val mayaAddressInputViewModel by viewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaConvertCryptoFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaConvertCryptoFragment.kt index f38db150a..2aed5b6a5 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaConvertCryptoFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaConvertCryptoFragment.kt @@ -66,7 +66,7 @@ class MayaConvertCryptoFragment : Fragment(R.layout.fragment_maya_convert_crypto private val binding by viewBinding(FragmentMayaConvertCryptoBinding::bind) private val viewModel by viewModels() private val convertViewModel by mayaViewModels() - private val mayaViewModel by viewModels() + private val mayaViewModel by mayaViewModels() private val args by navArgs() private var loadingDialog: AdaptiveDialog? = null diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt index dca7709a7..233534322 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt @@ -25,6 +25,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController +import androidx.recyclerview.widget.DiffUtil import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import org.dash.wallet.common.ui.decorators.ListDividerDecorator @@ -40,14 +41,30 @@ import org.dash.wallet.integrations.maya.R import org.dash.wallet.integrations.maya.databinding.FragmentCurrencyPickerBinding import org.dash.wallet.integrations.maya.model.PoolInfo import org.dash.wallet.integrations.maya.payments.MayaCurrencyList +import org.slf4j.LoggerFactory @AndroidEntryPoint class MayaCryptoCurrencyPickerFragment : Fragment(R.layout.fragment_currency_picker) { + companion object { + private val log = LoggerFactory.getLogger(MayaCryptoCurrencyPickerFragment::class.java) + } private val binding by viewBinding(FragmentCurrencyPickerBinding::bind) - private val viewModel by viewModels() + private val viewModel by mayaViewModels() private var itemList = listOf() private lateinit var defaultItemMap: Map + class FullDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: IconifiedViewItem, newItem: IconifiedViewItem): Boolean { + return oldItem.title == newItem.title && + oldItem.iconRes == newItem.iconRes && + oldItem.additionalInfo == newItem.additionalInfo + } + + override fun areContentsTheSame(oldItem: IconifiedViewItem, newItem: IconifiedViewItem): Boolean { + return oldItem == newItem + } + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -55,7 +72,7 @@ class MayaCryptoCurrencyPickerFragment : Fragment(R.layout.fragment_currency_pic findNavController().popBackStack() } - val adapter = IconifiedListAdapter() { item, index -> + val adapter = IconifiedListAdapter(diffCallback = FullDiffCallback()) { item, _ -> viewModel.poolList.value.firstOrNull { it.asset == item.id }?.let { @@ -132,6 +149,7 @@ class MayaCryptoCurrencyPickerFragment : Fragment(R.layout.fragment_currency_pic ) } }.sortedBy { it.title } + log.info("exchange rate: updating itemList with {}", itemList[0].additionalInfo) adapter.submitList(itemList) } } diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt index e945f601c..b831c0169 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt @@ -34,7 +34,7 @@ import org.dash.wallet.integrations.maya.R class MayaPortalFragment : Fragment(R.layout.fragment_integration_portal) { private val binding by viewBinding(FragmentIntegrationPortalBinding::bind) - private val viewModel by viewModels() + private val viewModel by mayaViewModels() private var balanceAnimator: ObjectAnimator? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt index 580dc57a7..332b421dd 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt @@ -96,24 +96,23 @@ class MayaViewModel @Inject constructor( walletUIConfig.observe(WalletUIConfig.SELECTED_CURRENCY) .filterNotNull() - .onEach { log.info("selected currency: {}", it) } + .onEach { log.info("exchange rate selected currency: {}", it) } .flatMapLatest(fiatExchangeRateProvider::observeFiatRate) .onEach { it?.let { fiatRate -> - fiatFormat = fiatFormat.minDecimals(GenericUtils.getCurrencyDigits(it.currencyCode)) + fiatFormat = fiatFormat.minDecimals(GenericUtils.getCurrencyDigits(fiatRate.currencyCode)) fiatExchangeRate = fiatRate.fiat } log.info("exchange rate: $it") } .flatMapLatest { mayaApi.observePoolList(it!!.fiat) } - .onEach { + .onEach { newPoolList -> log.info("exchange rate in view model: {}", fiatExchangeRate?.toFriendlyString()) - log.info("Pool List: {}", it) - log.info("Pool List: {}", it.map { pool -> pool.assetPriceFiat }) - it.forEach { pool -> + newPoolList.forEach { pool -> pool.setAssetPrice(fiatExchangeRate!!) } - poolList.value = it + log.info("exchange rate Pool List: {}", newPoolList.map { pool -> pool.assetPriceFiat.toFriendlyString() }) + poolList.value = newPoolList } .launchIn(viewModelScope) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt index 321140a54..358d5885d 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt @@ -26,9 +26,19 @@ object MayaConstants { private const val MAINNET_BASE_URL = "https://mayanode.mayachain.info/mayachain/" /** - * https://exchangerate.host/#/docs + * https://www.exchangerate-api.com/docs/overview */ - const val EXCHANGERATE_BASE_URL = "https://api.exchangerate.host/" + const val EXCHANGERATE_BASE_URL = "https://v6.exchangerate-api.com/v6/cb83a189f4780ccfde2883d6/" + + /** + * https://currencybeacon.com/api-documentation + */ + const val CURRENCYBEACON_BASE_URL = "https://api.currencybeacon.com/v1/" + + /** + * https://freecurrencyapi.com/docs/ + */ + const val FREE_CURRENCY_API_BASE_URL = "https://api.freecurrencyapi.com/v1/" fun getBaseUrl(params: NetworkParameters): String { return MAINNET_BASE_URL @@ -43,4 +53,4 @@ object MayaConstants { const val ERROR_ID_2FA_REQUIRED = "two_factor_required" const val ERROR_MSG_INVALID_REQUEST = "That code was invalid" const val TRANSACTION_TYPE_SEND = "send" -} +} \ No newline at end of file From ae2cc6de38df3bce571bf1edc8aef0f90cbc32fc Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Thu, 20 Jun 2024 17:02:55 -0700 Subject: [PATCH 8/8] style: ktlint --- .../org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt | 1 - .../dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt | 5 ++--- .../java/org/dash/wallet/integrations/maya/di/MayaModule.kt | 4 ++-- .../wallet/integrations/maya/model/CurrencyBeaconResponse.kt | 2 +- .../wallet/integrations/maya/model/FreeCurrencyResponse.kt | 2 +- .../integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt | 5 ++--- .../dash/wallet/integrations/maya/ui/MayaPortalFragment.kt | 1 - .../org/dash/wallet/integrations/maya/ui/MayaViewModel.kt | 5 ++++- .../org/dash/wallet/integrations/maya/utils/MayaConstants.kt | 2 +- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt index 575398dd0..2a3d51c4f 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/ExchangeRateApi.kt @@ -22,7 +22,6 @@ import org.dash.wallet.integrations.maya.model.ExchangeRateResponse import org.dash.wallet.integrations.maya.model.FreeCurrencyResponse import retrofit2.Response import retrofit2.http.GET -import retrofit2.http.Header import retrofit2.http.Query /** diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt index 8b4acf5b8..03e19e952 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/api/FiatExchangeRateApi.kt @@ -28,7 +28,6 @@ import org.dash.wallet.integrations.maya.utils.MayaConstants import org.slf4j.Logger import org.slf4j.LoggerFactory import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit import javax.inject.Inject class FiatExchangeRateApiAggregator @Inject constructor( @@ -44,8 +43,8 @@ class FiatExchangeRateApiAggregator @Inject constructor( val lastUpdate = mayaConfig.get(MayaConfig.EXCHANGE_RATE_LAST_UPDATE) val lastCurrencyCode = mayaConfig.get(MayaConfig.EXCHANGE_RATE_CURRENCY_CODE) if (lastCurrencyCode != currencyCode || lastUpdate == null || lastUpdate == 0L || - (System.currentTimeMillis() - lastUpdate) > MayaConfig.expirationDuration) { - + (System.currentTimeMillis() - lastUpdate) > MayaConfig.expirationDuration + ) { if (currencyCode == MayaConstants.DEFAULT_EXCHANGE_CURRENCY) { return ExchangeRate(MayaConstants.DEFAULT_EXCHANGE_CURRENCY, "1.0") } diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt index a59cb1d15..9db9c3cbe 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/di/MayaModule.kt @@ -62,7 +62,7 @@ abstract class MayaModule { @Provides fun provideExchangeRateEndpoint( - remoteDataSource: RemoteDataSource, + remoteDataSource: RemoteDataSource ): ExchangeRateApi { val baseUrl = MayaConstants.EXCHANGERATE_BASE_URL return remoteDataSource.buildApi(ExchangeRateApi::class.java, baseUrl) @@ -78,7 +78,7 @@ abstract class MayaModule { @Provides fun provideFreeCurrencyApiEndpoint( - remoteDataSource: RemoteDataSource, + remoteDataSource: RemoteDataSource ): FreeCurrencyApi { val baseUrl = MayaConstants.FREE_CURRENCY_API_BASE_URL return remoteDataSource.buildApi(FreeCurrencyApi::class.java, baseUrl) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt index 823c4d4b8..f8f783027 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/CurrencyBeaconResponse.kt @@ -25,4 +25,4 @@ class CurrencyBeaconResponse( val base: String, val date: String, val rates: Map -) \ No newline at end of file +) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt index e04cfe3be..2cee7ec96 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/model/FreeCurrencyResponse.kt @@ -22,4 +22,4 @@ package org.dash.wallet.integrations.maya.model */ class FreeCurrencyResponse( val data: Map -) \ No newline at end of file +) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt index 233534322..dccc7c7f0 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaCryptoCurrencyPickerFragment.kt @@ -22,7 +22,6 @@ import android.view.View import androidx.core.content.ContextCompat import androidx.core.widget.doAfterTextChanged import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.DiffUtil @@ -56,8 +55,8 @@ class MayaCryptoCurrencyPickerFragment : Fragment(R.layout.fragment_currency_pic class FullDiffCallback : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: IconifiedViewItem, newItem: IconifiedViewItem): Boolean { return oldItem.title == newItem.title && - oldItem.iconRes == newItem.iconRes && - oldItem.additionalInfo == newItem.additionalInfo + oldItem.iconRes == newItem.iconRes && + oldItem.additionalInfo == newItem.additionalInfo } override fun areContentsTheSame(oldItem: IconifiedViewItem, newItem: IconifiedViewItem): Boolean { diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt index b831c0169..ade699d20 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaPortalFragment.kt @@ -22,7 +22,6 @@ import android.os.Bundle import android.view.View import androidx.core.view.isVisible import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import dagger.hilt.android.AndroidEntryPoint import org.dash.wallet.common.databinding.FragmentIntegrationPortalBinding diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt index 332b421dd..90b6297c8 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/ui/MayaViewModel.kt @@ -111,7 +111,10 @@ class MayaViewModel @Inject constructor( newPoolList.forEach { pool -> pool.setAssetPrice(fiatExchangeRate!!) } - log.info("exchange rate Pool List: {}", newPoolList.map { pool -> pool.assetPriceFiat.toFriendlyString() }) + log.info( + "exchange rate Pool List: {}", + newPoolList.map { pool -> pool.assetPriceFiat.toFriendlyString() } + ) poolList.value = newPoolList } .launchIn(viewModelScope) diff --git a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt index 358d5885d..1ccdc10b9 100644 --- a/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt +++ b/integrations/maya/src/main/java/org/dash/wallet/integrations/maya/utils/MayaConstants.kt @@ -53,4 +53,4 @@ object MayaConstants { const val ERROR_ID_2FA_REQUIRED = "two_factor_required" const val ERROR_MSG_INVALID_REQUEST = "That code was invalid" const val TRANSACTION_TYPE_SEND = "send" -} \ No newline at end of file +}