Skip to content

Commit

Permalink
merge wtih master
Browse files Browse the repository at this point in the history
  • Loading branch information
elvis committed Mar 18, 2024
1 parent e3d4069 commit c78427f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ interface ChangellyAPIService {
): Response<ChangellyResponse<List<ChangellyTransaction>>>


@TestOnly
@POST("getFixRate")
suspend fun getFixRate(@Query("from") from: String,
@Query("to") to: String): Response<ChangellyResponse<FixRateForAmount>>
// @TestOnly
// @POST("getFixRate")
// suspend fun getFixRateTest(@Query("from") from: String,
// @Query("to") to: String): Response<ChangellyResponse<FixRateForAmount>>


companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ public GetOfferCallback(double amountFrom) {
public void onResponse(@NonNull Call<ChangellyResponse<ChangellyTransactionOffer>> call,
@NonNull Response<ChangellyResponse<ChangellyTransactionOffer>> response) {
ChangellyResponse<ChangellyTransactionOffer> result = response.body();
if(result != null && !result.getResult().isEmpty()) {
if(result != null && result.getResult() != null) {
progressDialog.dismiss();
// if the amount changed after the offer was requested but before the offer was
// received, we reset the amount to the requested amount instead of ignoring the
// offer.
// If the user requested a new offer meanwhile, the new amount will return with
// the new offer, too.
amount = amountFrom;
offer = result.getResult().get(0);
offer = result.getResult();
sendOrderToService(getOrder());
updateUI();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.mycelium.wallet.databinding.FragmentChangelly2ExchangeBinding
import com.mycelium.wallet.event.*
import com.mycelium.wallet.external.changelly.model.ChangellyResponse
import com.mycelium.wallet.external.changelly.model.ChangellyTransactionOffer
import com.mycelium.wallet.external.changelly.model.FixRate
import com.mycelium.wallet.external.changelly2.remote.Changelly2Repository
import com.mycelium.wallet.external.changelly2.viewmodel.ExchangeViewModel
import com.mycelium.wallet.external.partner.openLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class ExchangeResultFragment : DialogFragment() {
Changelly2Repository.getTransaction(lifecycleScope, txId,
{ response ->
response?.result?.first()?.let { result ->
binding?.toolbar?.title = result.first().getReadableStatus("exchange")
viewModel.setTransaction(result.first())
binding?.toolbar?.title = result.getReadableStatus("exchange")
viewModel.setTransaction(result)
} ?: let {
AlertDialog.Builder(requireContext())
.setMessage(response?.error?.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ class HistoryFragment : DialogFragment() {
Changelly2Repository.getTransactions(lifecycleScope, txIds,
{
it?.result?.first()?.let {
adapter.submitList(it.map {
adapter.submitList(listOf(
TxItem(it.id,
it.amountExpectedFrom.toString(), it.getExpectedAmount().toString(),
it.fixedCurrencyFrom(), it.fixedCurrencyTo(),
DateFormat.getDateInstance(DateFormat.LONG).format(Date(it.createdAt * 1000L)),
it.getReadableStatus())
})
it.getReadableStatus()))
)
}
},
{ _, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.mycelium.wallet.WalletApplication
import com.mycelium.wallet.activity.util.toStringFriendlyWithUnit
import com.mycelium.wallet.activity.util.toStringWithUnit
import com.mycelium.wallet.external.changelly.model.FixRate
import com.mycelium.wallet.external.changelly.model.FixRateForAmount
import com.mycelium.wapi.wallet.Address
import com.mycelium.wapi.wallet.Transaction
import com.mycelium.wapi.wallet.Util
Expand All @@ -35,7 +34,7 @@ class ExchangeViewModel(application: Application) : AndroidViewModel(application
val mbwManager = MbwManager.getInstance(WalletApplication.getInstance())
var currencies = setOf("BTC", "ETH")
val fromAccount = MutableLiveData<WalletAccount<*>>()
val exchangeInfo = MutableLiveData<FixRateForAmount>()
val exchangeInfo = MutableLiveData<FixRate>()
val sellValue = object : MutableLiveData<String>() {
override fun setValue(value: String?) {
if (this.value != value) {
Expand Down Expand Up @@ -152,7 +151,7 @@ class ExchangeViewModel(application: Application) : AndroidViewModel(application
}

val exchangeRateToValue = Transformations.map(exchangeInfo) {
it.getExpectedValue().toPlainString()
it.result.toPlainString()
}

val exchangeRateToCurrency = Transformations.map(exchangeInfo) {
Expand Down

0 comments on commit c78427f

Please sign in to comment.