Skip to content

Commit

Permalink
style: ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Mar 7, 2024
1 parent 91aa743 commit 4d4a52f
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,24 @@ open class MayaWebApi @Inject constructor(
suspend fun getInboundAddresses(): List<InboundAddress> {
return listOf(
InboundAddress(
address = "XsPKvvrZqQB931M8EbFpB12W88QxjW9WnX",
chain = "DASH",
chain_lp_actions_paused = false,
chain_trading_paused = false,
dust_threshold = "10000",
gas_rate = "12",
gas_rate_units = "satsperbyte",
global_trading_paused = false,
halted = false,
outbound_fee = "5412",
outbound_tx_size = "451",
pub_key = "mayapub1addwnpepq255x4s5ag6qu0s2hrj9kwnlqpuy5r33d5t50p9r00wgr2842zhvz74muvu"
address = "XsPKvvrZqQB931M8EbFpB12W88QxjW9WnX",
chain = "DASH",
chain_lp_actions_paused = false,
chain_trading_paused = false,
dust_threshold = "10000",
gas_rate = "12",
gas_rate_units = "satsperbyte",
global_trading_paused = false,
halted = false,
outbound_fee = "5412",
outbound_tx_size = "451",
pub_key = "mayapub1addwnpepq255x4s5ag6qu0s2hrj9kwnlqpuy5r33d5t50p9r00wgr2842zhvz74muvu"
)
)
// return try {
// val response = endpoint.getInboundAddresses()
// log.info("maya: response: {}", response)
//
//
// return if (response.isSuccessful && response.body()?.isNotEmpty() == true) {
// response.body()!!.toList()
// } else {
Expand All @@ -107,11 +107,11 @@ open class MayaWebApi @Inject constructor(
// }
// } catch (ex: Exception) {
// log.error("Error in getInboundAddresses: $ex")
//
//
// if (ex !is IOException) {
// analyticsService.logError(ex)
// }
//
//
// listOf()
// }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.dash.wallet.common.util.toFormattedString
import java.math.BigDecimal
import java.math.RoundingMode


@Parcelize
data class AccountDataUIModel(
override val coinbaseAccount: Account,
Expand All @@ -31,7 +30,7 @@ fun AccountDataUIModel.getCoinBaseExchangeRateConversion(
): Pair<String, Coin> {
val cleanedValue =
this.coinbaseAccount.availableBalance.value.toBigDecimal() /
this.currencyToCryptoCurrencyExchangeRate
this.currencyToCryptoCurrencyExchangeRate
val bd = cleanedValue.setScale(8, RoundingMode.HALF_UP)

val currencyRate = org.bitcoinj.utils.ExchangeRate(Coin.COIN, currentExchangeRate.fiat)
Expand All @@ -46,12 +45,12 @@ open class ToDashExchangeRateUIModel(
open val coinbaseAccount: Account,
open val currencyToDashExchangeRate: BigDecimal,
open val currencyToUSDExchangeRate: BigDecimal
): Parcelable {
) : Parcelable {
companion object {
val EMPTY = ToDashExchangeRateUIModel(
Account.EMPTY,
BigDecimal.ZERO,
BigDecimal.ZERO
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class Account(
val active: Boolean,
val type: String,
val ready: Boolean
): Parcelable {
) : Parcelable {
companion object {
val EMPTY = Account(
UUID.randomUUID(),
Expand All @@ -35,4 +35,4 @@ data class Account(
data class Balance(
val value: String,
val currency: String
): Parcelable
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package org.dash.wallet.integrations.maya.model
import java.math.BigDecimal

/**
holds an amount in terms of dash, a fiat currency and another crypto currency. When exchange rates are changed
dash is used as the anchor to recalculate the fiat and crypto values.
holds an amount in terms of dash, a fiat currency and another crypto currency. When exchange rates are changed
dash is used as the anchor to recalculate the fiat and crypto values.
*/
data class Amount(
private var _dash: BigDecimal = BigDecimal.ZERO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ data class SwapTradeUIModel(
val feeCurrency: String = "",
var assetsBaseID: Pair<String, String>? = null,
var inputCurrencyName: String = "",
var outputCurrencyName: String = "",
var outputCurrencyName: String = ""
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.bitcoinj.core.Coin
import org.dash.wallet.common.data.ResponseResource
import org.dash.wallet.common.data.WalletUIConfig
import org.dash.wallet.common.services.NetworkStateInt
import org.dash.wallet.common.services.analytics.AnalyticsService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ class MayaConvertCryptoFragment : Fragment(R.layout.fragment_maya_convert_crypto
"Wallet",
true
),
BigDecimal.ONE.setScale(16, RoundingMode.HALF_UP) / (poolInfo?.assetPriceFiat?.toBigDecimal() ?: BigDecimal.ONE),
BigDecimal.ONE.setScale(16, RoundingMode.HALF_UP) / (dashPoolInfo?.assetPriceFiat?.toBigDecimal() ?: BigDecimal.ONE),
BigDecimal.ONE.setScale(16, RoundingMode.HALF_UP) /
(poolInfo?.assetPriceFiat?.toBigDecimal() ?: BigDecimal.ONE),
BigDecimal.ONE.setScale(16, RoundingMode.HALF_UP) /
(dashPoolInfo?.assetPriceFiat?.toBigDecimal() ?: BigDecimal.ONE),
BigDecimal.ONE.setScale(16, RoundingMode.HALF_UP)
)
)
Expand Down Expand Up @@ -485,7 +487,6 @@ class MayaConvertCryptoFragment : Fragment(R.layout.fragment_maya_convert_crypto
binding.convertView.layoutParams = params
}


private fun showProgress(messageResId: Int) {
if (loadingDialog != null && loadingDialog?.isAdded == true) {
loadingDialog?.dismissAllowingStateLoss()
Expand All @@ -506,7 +507,7 @@ class MayaConvertCryptoFragment : Fragment(R.layout.fragment_maya_convert_crypto
getString(R.string.we_didnt_find_any_assets),
getString(R.string.you_dont_own_any_crypto),
getString(R.string.button_close),
getString(R.string.buy_crypto_on_coinbase),
getString(R.string.buy_crypto_on_coinbase)
).show(requireActivity()) { buyOnCoinbase ->
if (buyOnCoinbase == true) {
viewModel.logEvent(AnalyticsConstants.Coinbase.CONVERT_BUY_ON_COINBASE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
Expand All @@ -41,9 +40,9 @@ import org.dash.wallet.common.services.analytics.AnalyticsConstants
import org.dash.wallet.common.services.analytics.AnalyticsService
import org.dash.wallet.common.util.Constants
import org.dash.wallet.common.util.toFormattedStringNoCode
import org.dash.wallet.integrations.maya.model.CoinbaseErrorResponse
import org.dash.wallet.integrations.maya.api.MayaWebApi
import org.dash.wallet.integrations.maya.model.AccountDataUIModel
import org.dash.wallet.integrations.maya.model.CoinbaseErrorResponse
import org.dash.wallet.integrations.maya.model.SwapTradeResponse
import org.dash.wallet.integrations.maya.model.SwapTradeUIModel
import org.dash.wallet.integrations.maya.model.TradesRequest
Expand Down Expand Up @@ -82,7 +81,7 @@ class MayaConvertCryptoViewModel @Inject constructor(
setDashWalletBalance()
}

fun setBaseIdForFaitModelCoinBase(list:List<BaseIdForUSDData>) {
fun setBaseIdForFaitModelCoinBase(list: List<BaseIdForUSDData>) {
_baseIdForFaitModelCoinBase.value = list
}

Expand Down Expand Up @@ -196,8 +195,8 @@ class MayaConvertCryptoViewModel @Inject constructor(

suspend fun isInputGreaterThanLimit(amountInDash: Coin): Boolean {
return false
//val withdrawalLimitInDash = coinBaseRepository.getWithdrawalLimitInDash()
//return amountInDash.toPlainString().toDoubleOrZero.compareTo(withdrawalLimitInDash) > 0
// val withdrawalLimitInDash = coinBaseRepository.getWithdrawalLimitInDash()
// return amountInDash.toPlainString().toDoubleOrZero.compareTo(withdrawalLimitInDash) > 0
}

fun getUpdatedPaymentIntent(amountInDash: Coin, destination: Address): PaymentIntent? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ class ConvertViewViewModel @Inject constructor(
selectedLocalCurrencyCode -> amount.fiat
selectedCryptoCurrencyAccount.value!!.coinbaseAccount.currency -> amount.crypto
else -> throw IllegalArgumentException(
"Currency code $currencyCode is not found (DASH, $selectedLocalCurrencyCode, $selectedCryptoCurrencyAccount.value!!.coinbaseAccount.currency)"
"Currency code $currencyCode is not found (DASH, $selectedLocalCurrencyCode," +
"$selectedCryptoCurrencyAccount.value!!.coinbaseAccount.currency)"
)
}.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import org.bitcoinj.core.Coin
import org.bitcoinj.utils.ExchangeRate
Expand Down Expand Up @@ -144,7 +143,7 @@ class ConverterView(context: Context, attrs: AttributeSet) : ConstraintLayout(co

if (dashInput != null && fiatInput != null) {
binding.convertFromBtn.setConvertItemAmounts(
"${dashFormat.minDecimals(2).optionalDecimals(2,4).format(dashInput?: Coin.ZERO)}",
"${dashFormat.minDecimals(2).optionalDecimals(2,4).format(dashInput ?: Coin.ZERO)}",
"${Constants.PREFIX_ALMOST_EQUAL_TO} ${ (fiatInput ?: Fiat.valueOf("USD", 0)).toFormattedString() }"
)
}
Expand All @@ -156,10 +155,10 @@ class ConverterView(context: Context, attrs: AttributeSet) : ConstraintLayout(co
// "${dashFormat.minDecimals(2).optionalDecimals(2,4).format(dash)}",
// "${Constants.PREFIX_ALMOST_EQUAL_TO} $fiatAmount"
// )
//// binding.convertFromDashBalance.text = "${dashFormat.minDecimals(0)
//// .optionalDecimals(0,8).format(dash)} DASH"
////
//// binding.convertFromDashFiatAmount.text = "${Constants.PREFIX_ALMOST_EQUAL_TO} $fiatAmount"
// // binding.convertFromDashBalance.text = "${dashFormat.minDecimals(0)
// // .optionalDecimals(0,8).format(dash)} DASH"
// //
// // binding.convertFromDashFiatAmount.text = "${Constants.PREFIX_ALMOST_EQUAL_TO} $fiatAmount"
// }
// }
} else {
Expand Down Expand Up @@ -222,7 +221,7 @@ class ConverterView(context: Context, attrs: AttributeSet) : ConstraintLayout(co
}

// exchangeRate?.let { currentExchangeRate ->
// dashInput?.let { dash ->
// dashInput?.let { dash ->
// val currencyRate = ExchangeRate(Coin.COIN, currentExchangeRate.fiat)
// val fiatAmount = currencyRate.coinToFiat(dash).toFormattedString()
// binding.convertFromBtn.setConvertItemAmounts("${dashFormat.minDecimals(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.withStyledAttributes
import androidx.core.view.isVisible
import androidx.core.view.marginEnd
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import coil.load
Expand Down Expand Up @@ -96,11 +95,15 @@ class CryptoCurrencyItem @JvmOverloads constructor(
if (GenericUtils.isCurrencySymbolFirst()) {
binding.dashIconBack.isVisible = false
binding.dashIconFront.isVisible = binding.amountFiat.text.isNotEmpty()
binding.amountCrypto.updatePadding(right = resources.getDimensionPixelOffset(R.dimen.default_horizontal_padding))
binding.amountCrypto.updatePadding(
right = resources.getDimensionPixelOffset(R.dimen.default_horizontal_padding)
)
} else {
binding.dashIconBack.isVisible = binding.amountFiat.text.isNotEmpty()
binding.dashIconFront.isVisible = false
binding.amountCrypto.updatePadding(right = resources.getDimensionPixelOffset(R.dimen.default_vertical_padding))
binding.amountCrypto.updatePadding(
right = resources.getDimensionPixelOffset(R.dimen.default_vertical_padding)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import androidx.core.view.setPadding
import org.bitcoinj.core.Coin
import org.bitcoinj.utils.ExchangeRate
import org.bitcoinj.utils.MonetaryFormat
import org.dash.wallet.common.util.Constants
import org.dash.wallet.common.util.GenericUtils
import org.dash.wallet.common.util.toFormattedString
import org.dash.wallet.integrations.maya.R
import org.dash.wallet.integrations.maya.databinding.ConverterViewBinding
import org.dash.wallet.integrations.maya.ui.convert_currency.model.BaseServiceWallet
Expand All @@ -54,7 +52,7 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con

var walletToCoinbase: Boolean = false
set(value) {
if (field != value){
if (field != value) {
field = value
updateSymbols(isDeviceConnectedToInternet)
updateAmount()
Expand All @@ -70,24 +68,43 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con
}

private fun updateSymbols(isOnline: Boolean) {
if (walletToCoinbase){
if (walletToCoinbase) {
binding.convertFromBtn.setConvertItemTitle(R.string.dash_wallet_name)
binding.convertToBtn.setConvertItemTitle(R.string.maya_service_name)
ContextCompat.getDrawable(context,
if (isOnline)
R.drawable.ic_dash_blue_filled else org.dash.wallet.common.R.drawable.ic_dash_saturated)
ContextCompat.getDrawable(
context,
if (isOnline) {
R.drawable.ic_dash_blue_filled
} else {
org.dash.wallet.common.R.drawable.ic_dash_saturated
}
)
?.let { binding.convertFromBtn.setConvertItemIcon(it) }
ContextCompat.getDrawable(context, if (isOnline)
R.drawable.ic_maya_logo else R.drawable.ic_maya_logo) // saturated?
ContextCompat.getDrawable(
context,
if (isOnline) {
R.drawable.ic_maya_logo
} else {
R.drawable.ic_maya_logo
}
) // saturated?
?.let { binding.convertToBtn.setConvertItemIcon(it) }
} else {
binding.convertFromBtn.setConvertItemTitle(R.string.maya_service_name)
binding.convertToBtn.setConvertItemTitle(R.string.dash_wallet_name)
ContextCompat.getDrawable(context, if (isOnline)
R.drawable.ic_maya_logo else R.drawable.ic_maya_logo) // saturated
ContextCompat.getDrawable(
context,
if (isOnline) {
R.drawable.ic_maya_logo
} else {
R.drawable.ic_maya_logo
}
) // saturated
?.let { binding.convertFromBtn.setConvertItemIcon(it) }
ContextCompat.getDrawable(context,
if (isOnline) R.drawable.ic_dash_blue_filled else org.dash.wallet.common.R.drawable.ic_dash_saturated)
ContextCompat.getDrawable(
context,
if (isOnline) R.drawable.ic_dash_blue_filled else org.dash.wallet.common.R.drawable.ic_dash_saturated
)
?.let { binding.convertToBtn.setConvertItemIcon(it) }
}
}
Expand All @@ -101,7 +118,7 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con
}
}

fun setOnTransferDirectionBtnClicked(listener: () -> Unit){
fun setOnTransferDirectionBtnClicked(listener: () -> Unit) {
onTransferDirectionBtnClicked = listener
}

Expand All @@ -116,7 +133,7 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con
}
}

private fun initUI(){
private fun initUI() {
binding.convertFromBtn.setCryptoItemGroupVisibility(true)
binding.convertToBtn.setCryptoItemGroupVisibility(true)
binding.convertFromBtn.setSyncingVisibility(false)
Expand Down Expand Up @@ -158,8 +175,8 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con
}
} else {
balanceOnCoinbase?.let {
val balance = it.balance?: ""
if (balance.isNotEmpty() && balance != MayaConstants.VALUE_ZERO){
val balance = it.balance ?: ""
if (balance.isNotEmpty() && balance != MayaConstants.VALUE_ZERO) {
val formattedAmount = GenericUtils.formatFiatWithoutComma(balance)
val coin = try {
Coin.parseCoin(formattedAmount)
Expand All @@ -176,9 +193,8 @@ class TransferView(context: Context, attrs: AttributeSet) : ConstraintLayout(con
// binding.convertFromDashFiatAmount.isVisible = true
//
// binding.walletIcon.isVisible = balance.isNotEmpty()

}
}
}
}
}
}
Loading

0 comments on commit 4d4a52f

Please sign in to comment.