Skip to content

Commit

Permalink
Merge remote-tracking branch 'changelly-vip/feature/vip_codes' into f…
Browse files Browse the repository at this point in the history
…eature/vip_codes2

# Conflicts:
#	mbw/src/main/java/com/mycelium/wallet/external/changelly/model/ChangellyTransaction.kt
#	mbw/src/main/java/com/mycelium/wallet/external/changelly2/ExchangeFragment.kt
#	mbw/src/main/java/com/mycelium/wallet/external/changelly2/viewmodel/ExchangeResultViewModel.kt
  • Loading branch information
elvis committed Jun 25, 2024
2 parents 43dc340 + 4447b2b commit 1a0b0e7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ package com.mycelium.wallet.external.changelly.model
import java.io.Serializable
import java.math.BigDecimal


class ChangellyTransaction(val id: String,
val status: String,
val moneySent: String,
val amountExpectedFrom: BigDecimal? = null,
val amountExpectedTo: BigDecimal? = null,
val networkFee: BigDecimal? = null,
val currencyFrom: String,
val moneyReceived: String,
val currencyTo: String,
val payoutAddress:String,
val createdAt: Long
) : Serializable {

fun getExpectedAmount(): BigDecimal? = amountExpectedTo //?.minus(networkFee ?: BigDecimal.ZERO)
}
class ChangellyTransaction(
val id: String,
val status: String,
val moneySent: String,
val amountExpectedFrom: BigDecimal? = null,
val amountExpectedTo: BigDecimal? = null,
val networkFee: BigDecimal? = null,
val currencyFrom: String,
val moneyReceived: String,
val currencyTo: String,
val payoutAddress: String,
val createdAt: Long,
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,9 @@ class ExchangeFragment : Fragment(), BackListener {
val amount = viewModel.sellValue.value
val info = viewModel.exchangeInfo.value
val rate = info?.result
// val networkFee = info?.networkFee ?: BigDecimal.ZERO
viewModel.buyValue.value = if (amount?.isNotEmpty() == true && rate != null) {
try {
val result = amount.toBigDecimal() * rate //- networkFee
val result = amount.toBigDecimal() * rate
if (result <= BigDecimal.ZERO) null
else result
.setScale(viewModel.toCurrency.value?.friendlyDigits!!, RoundingMode.HALF_UP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class HistoryFragment : DialogFragment() {
TxItem(
it.id,
it.amountExpectedFrom.toString(),
it.getExpectedAmount().toString(),
it.amountExpectedTo.toString(),
it.fixedCurrencyFrom(),
it.fixedCurrencyTo(),
historyDateFormat.format(Date(it.createdAt * 1000L)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class ExchangeResultViewModel : ViewModel() {
fun setTransaction(result: ChangellyTransaction) {
txId.value = result.id
spendValue.value = "${result.amountExpectedFrom} ${result.currencyFrom.toUpperCase()}"
getValue.value = "${result.getExpectedAmount()} ${result.currencyTo.toUpperCase()}"
getValue.value = "${result.amountExpectedTo} ${result.currencyTo.toUpperCase()}"
date.value = DateFormat.getDateInstance(DateFormat.LONG).format(Date(result.createdAt / 1000L))
spendValueFiat.value = getFiatValue(result.amountExpectedFrom, result.currencyFrom)
getValueFiat.value = getFiatValue(result.getExpectedAmount(), result.currencyTo)
getValueFiat.value = getFiatValue(result.amountExpectedTo, result.currencyTo)
isExchangeComplete.value = result.status == "finished"
trackInProgress.value = result.status !in LINK_TEXT_LIST
trackLinkText.value =
Expand Down

0 comments on commit 1a0b0e7

Please sign in to comment.