mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Use max trade amount from offer at take offer view (allow backwards compatibility when we increase trade limits)
This commit is contained in:
parent
a25d089f55
commit
f61bf11c68
@ -314,7 +314,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
dataModel.initWithData(direction, tradeCurrency);
|
||||
if (dataModel.paymentAccount != null)
|
||||
btcValidator.setPaymentMethod(dataModel.paymentAccount.getPaymentMethod());
|
||||
btcValidator.setMaxTradeLimitInBitcoin(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimitInBitcoin());
|
||||
}
|
||||
|
||||
|
||||
@ -370,7 +370,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
}
|
||||
|
||||
public void onPaymentAccountSelected(PaymentAccount paymentAccount) {
|
||||
btcValidator.setPaymentMethod(paymentAccount.getPaymentMethod());
|
||||
btcValidator.setMaxTradeLimitInBitcoin(paymentAccount.getPaymentMethod().getMaxTradeLimitInBitcoin());
|
||||
dataModel.onPaymentAccountSelected(paymentAccount);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
offer.errorMessageProperty().addListener(offerErrorListener);
|
||||
errorMessage.set(offer.errorMessageProperty().get());
|
||||
|
||||
btcValidator.setPaymentMethod(dataModel.paymentAccount.getPaymentMethod());
|
||||
btcValidator.setMaxTradeLimitInBitcoin(offer.getAmount());
|
||||
}
|
||||
|
||||
|
||||
@ -183,8 +183,6 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
takeOfferSucceededHandler = resultHandler;
|
||||
takeOfferRequested = true;
|
||||
showTransactionPublishedScreen.set(false);
|
||||
//isTakeOfferSpinnerVisible.set(true);
|
||||
//takeOfferSpinnerInfoText.set(BSResources.get("takeOffer.fundsBox.takeOfferSpinnerInfo"));
|
||||
dataModel.onTakeOffer(trade -> {
|
||||
this.trade = trade;
|
||||
trade.stateProperty().addListener(tradeStateListener);
|
||||
@ -197,7 +195,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
|
||||
public void onPaymentAccountSelected(PaymentAccount paymentAccount) {
|
||||
dataModel.onPaymentAccountSelected(paymentAccount);
|
||||
btcValidator.setPaymentMethod(paymentAccount.getPaymentMethod());
|
||||
if (offer != null)
|
||||
btcValidator.setMaxTradeLimitInBitcoin(offer.getAmount());
|
||||
}
|
||||
|
||||
public void onShowPayFundsScreen() {
|
||||
|
@ -19,10 +19,9 @@ package io.bitsquare.gui.util.validation;
|
||||
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -30,16 +29,17 @@ public class BtcValidator extends NumberValidator {
|
||||
|
||||
private final BSFormatter formatter;
|
||||
|
||||
@NotNull
|
||||
private PaymentMethod paymentMethod;
|
||||
|
||||
@Nullable
|
||||
private Coin maxTradeLimitInBitcoin;
|
||||
|
||||
@Inject
|
||||
public BtcValidator(BSFormatter formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
public void setPaymentMethod(@NotNull PaymentMethod paymentMethod) {
|
||||
this.paymentMethod = paymentMethod;
|
||||
public void setMaxTradeLimitInBitcoin(Coin maxTradeLimitInBitcoin) {
|
||||
this.maxTradeLimitInBitcoin = maxTradeLimitInBitcoin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,8 +70,8 @@ public class BtcValidator extends NumberValidator {
|
||||
}
|
||||
|
||||
protected ValidationResult validateIfNotExceedsMaxBtcValue(String input) {
|
||||
if (paymentMethod != null && Coin.parseCoin(input).compareTo(paymentMethod.getMaxTradeLimitInBitcoin()) > 0)
|
||||
return new ValidationResult(false, BSResources.get("validation.btc.toLarge", formatter.formatCoinWithCode(paymentMethod.getMaxTradeLimitInBitcoin())));
|
||||
if (maxTradeLimitInBitcoin != null && Coin.parseCoin(input).compareTo(maxTradeLimitInBitcoin) > 0)
|
||||
return new ValidationResult(false, BSResources.get("validation.btc.toLarge", formatter.formatCoinWithCode(maxTradeLimitInBitcoin)));
|
||||
else
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user