Move Offer.Direction one level up and rename to OfferDirection

This commit is contained in:
chimp1984 2021-10-20 12:51:41 +02:00
parent d1d1706a7f
commit dfbc746d5b
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
44 changed files with 226 additions and 200 deletions

View File

@ -24,7 +24,7 @@ import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferRestrictions;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.AssetAccount;
import bisq.core.payment.ChargeBackRisk;
import bisq.core.payment.PaymentAccount;
@ -421,11 +421,11 @@ public class AccountAgeWitnessService {
String currencyCode,
AccountAgeWitness accountAgeWitness,
AccountAge accountAgeCategory,
OfferPayload.Direction direction,
OfferDirection direction,
PaymentMethod paymentMethod) {
if (CurrencyUtil.isCryptoCurrency(currencyCode) ||
!PaymentMethod.hasChargebackRisk(paymentMethod, currencyCode) ||
direction == OfferPayload.Direction.SELL) {
direction == OfferDirection.SELL) {
return maxTradeLimit.value;
}
@ -500,7 +500,7 @@ public class AccountAgeWitnessService {
return getAccountAge(getMyWitness(paymentAccountPayload), new Date());
}
public long getMyTradeLimit(PaymentAccount paymentAccount, String currencyCode, OfferPayload.Direction direction) {
public long getMyTradeLimit(PaymentAccount paymentAccount, String currencyCode, OfferDirection direction) {
if (paymentAccount == null)
return 0;
@ -647,7 +647,7 @@ public class AccountAgeWitnessService {
if (!hasTradeLimitException(peersWitness)) {
final long accountSignAge = getWitnessSignAge(peersWitness, peersCurrentDate);
AccountAge accountAgeCategory = getPeersAccountAgeCategory(accountSignAge);
OfferPayload.Direction direction = offer.isMyOffer(keyRing) ?
OfferDirection direction = offer.isMyOffer(keyRing) ?
offer.getMirroredDirection() : offer.getDirection();
peersCurrentTradeLimit = getTradeLimit(defaultMaxTradeLimit, currencyCode, peersWitness,
accountAgeCategory, direction, offer.getPaymentMethod());

View File

@ -27,6 +27,7 @@ import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.MutableOfferPayloadFields;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.payment.PaymentAccount;
import bisq.core.provider.price.PriceFeedService;
@ -59,8 +60,7 @@ import static bisq.core.locale.CurrencyUtil.isCryptoCurrency;
import static bisq.core.offer.Offer.State;
import static bisq.core.offer.OpenOffer.State.AVAILABLE;
import static bisq.core.offer.OpenOffer.State.DEACTIVATED;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction.BUY;
import static bisq.core.offer.bisq_v1.OfferDirection.BUY;
import static bisq.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer;
import static bisq.proto.grpc.EditOfferRequest.EditType;
import static bisq.proto.grpc.EditOfferRequest.EditType.*;
@ -184,7 +184,7 @@ class CoreOffersService {
String upperCaseCurrencyCode = currencyCode.toUpperCase();
String offerId = createOfferService.getRandomOfferId();
Direction direction = Direction.valueOf(directionAsString.toUpperCase());
OfferDirection direction = OfferDirection.valueOf(directionAsString.toUpperCase());
Price price = Price.valueOf(upperCaseCurrencyCode, priceStringToLong(priceAsString, upperCaseCurrencyCode));
Coin amount = Coin.valueOf(amountAsLong);
Coin minAmount = Coin.valueOf(minAmountAsLong);

View File

@ -26,7 +26,7 @@ import bisq.core.notifications.MobileMessageType;
import bisq.core.notifications.MobileNotificationService;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferBookService;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.user.User;
@ -119,7 +119,7 @@ public class MarketAlerts {
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode);
Price offerPrice = offer.getPrice();
if (marketPrice != null && offerPrice != null) {
boolean isSellOffer = offer.getDirection() == OfferPayload.Direction.SELL;
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
String shortOfferId = offer.getShortId();
boolean isFiatCurrency = CurrencyUtil.isFiatCurrency(currencyCode);
String alertId = getAlertId(offer);

View File

@ -25,6 +25,7 @@ import bisq.core.monetary.Volume;
import bisq.core.offer.availability.OfferAvailabilityModel;
import bisq.core.offer.availability.OfferAvailabilityProtocol;
import bisq.core.offer.bisq_v1.MarketPriceNotAvailableException;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.price.MarketPrice;
@ -175,10 +176,10 @@ public class Offer implements NetworkPayload, PersistablePayload {
double factor;
double marketPriceMargin = offerPayload.getMarketPriceMargin();
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
factor = getDirection() == OfferPayload.Direction.SELL ?
factor = getDirection() == OfferDirection.SELL ?
1 - marketPriceMargin : 1 + marketPriceMargin;
} else {
factor = getDirection() == OfferPayload.Direction.BUY ?
factor = getDirection() == OfferDirection.BUY ?
1 - marketPriceMargin : 1 + marketPriceMargin;
}
double marketPriceAsDouble = marketPrice.getPrice();
@ -344,11 +345,11 @@ public class Offer implements NetworkPayload, PersistablePayload {
}
public boolean isBuyOffer() {
return getDirection() == OfferPayload.Direction.BUY;
return getDirection() == OfferDirection.BUY;
}
public OfferPayload.Direction getMirroredDirection() {
return getDirection() == OfferPayload.Direction.BUY ? OfferPayload.Direction.SELL : OfferPayload.Direction.BUY;
public OfferDirection getMirroredDirection() {
return getDirection() == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
}
public boolean isMyOffer(KeyRing keyRing) {
@ -405,7 +406,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
// Delegate Getter (boilerplate code generated via IntelliJ generate delegate feature)
///////////////////////////////////////////////////////////////////////////////////////////
public OfferPayload.Direction getDirection() {
public OfferDirection getDirection() {
return offerPayload.getDirection();
}

View File

@ -21,7 +21,7 @@ import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.payload.PaymentMethod;
import bisq.common.util.MathUtils;
@ -41,7 +41,7 @@ import javax.annotation.Nullable;
public class OfferForJson {
private static final Logger log = LoggerFactory.getLogger(OfferForJson.class);
public final OfferPayload.Direction direction;
public final OfferDirection direction;
public final String currencyCode;
public final long minAmount;
public final long amount;
@ -54,7 +54,7 @@ public class OfferForJson {
// primaryMarket fields are based on industry standard where primaryMarket is always in the focus (in the app BTC is always in the focus - will be changed in a larger refactoring once)
public String currencyPair;
public OfferPayload.Direction primaryMarketDirection;
public OfferDirection primaryMarketDirection;
public String priceDisplayString;
public String primaryMarketAmountDisplayString;
@ -76,7 +76,7 @@ public class OfferForJson {
transient private final MonetaryFormat coinFormat = MonetaryFormat.BTC;
public OfferForJson(OfferPayload.Direction direction,
public OfferForJson(OfferDirection direction,
String currencyCode,
Coin minAmount,
Coin amount,
@ -105,7 +105,7 @@ public class OfferForJson {
try {
final Price price = getPrice();
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
primaryMarketDirection = direction == OfferPayload.Direction.BUY ? OfferPayload.Direction.SELL : OfferPayload.Direction.BUY;
primaryMarketDirection = direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
currencyPair = currencyCode + "/" + Res.getBaseCurrencyCode();
// int precision = 8;

View File

@ -26,6 +26,7 @@ import bisq.core.locale.Res;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.bisq_v1.MutableOfferPayloadFields;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.payment.CashByMailAccount;
import bisq.core.payment.F2FAccount;
@ -134,13 +135,13 @@ public class OfferUtil {
* @return {@code true} for an offer to buy BTC from the taker, {@code false} for an
* offer to sell BTC to the taker
*/
public boolean isBuyOffer(Direction direction) {
return direction == Direction.BUY;
public boolean isBuyOffer(OfferDirection direction) {
return direction == OfferDirection.BUY;
}
public long getMaxTradeLimit(PaymentAccount paymentAccount,
String currencyCode,
Direction direction) {
OfferDirection direction) {
return paymentAccount != null
? accountAgeWitnessService.getMyTradeLimit(paymentAccount, currencyCode, direction)
: 0;
@ -315,7 +316,7 @@ public class OfferUtil {
public Map<String, String> getExtraDataMap(PaymentAccount paymentAccount,
String currencyCode,
Direction direction) {
OfferDirection direction) {
Map<String, String> extraDataMap = new HashMap<>();
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
String myWitnessHashAsHex = accountAgeWitnessService
@ -338,7 +339,7 @@ public class OfferUtil {
extraDataMap.put(CAPABILITIES, Capabilities.app.toStringList());
if (currencyCode.equals("XMR") && direction == Direction.SELL) {
if (currencyCode.equals("XMR") && direction == OfferDirection.SELL) {
preferences.getAutoConfirmSettingsList().stream()
.filter(e -> e.getCurrencyCode().equals("XMR"))
.filter(AutoConfirmSettings::isEnabled)

View File

@ -103,7 +103,7 @@ public class CreateOfferService {
}
public Offer createAndGetOffer(String offerId,
OfferPayload.Direction direction,
OfferDirection direction,
String currencyCode,
Coin amount,
Coin minAmount,
@ -190,7 +190,7 @@ public class CreateOfferService {
creationTime,
makerAddress,
pubKeyRing,
OfferPayload.Direction.valueOf(direction.name()),
OfferDirection.valueOf(direction.name()),
priceAsLong,
marketPriceMarginParam,
useMarketBasedPriceValue,
@ -230,7 +230,7 @@ public class CreateOfferService {
}
public Tuple2<Coin, Integer> getEstimatedFeeAndTxVsize(Coin amount,
OfferPayload.Direction direction,
OfferDirection direction,
double buyerSecurityDeposit,
double sellerSecurityDeposit) {
Coin reservedFundsForOffer = getReservedFundsForOffer(direction,
@ -241,7 +241,7 @@ public class CreateOfferService {
offerUtil.getMakerFee(amount));
}
public Coin getReservedFundsForOffer(OfferPayload.Direction direction,
public Coin getReservedFundsForOffer(OfferDirection direction,
Coin amount,
double buyerSecurityDeposit,
double sellerSecurityDeposit) {
@ -256,7 +256,7 @@ public class CreateOfferService {
return reservedFundsForOffer;
}
public Coin getSecurityDeposit(OfferPayload.Direction direction,
public Coin getSecurityDeposit(OfferDirection direction,
Coin amount,
double buyerSecurityDeposit,
double sellerSecurityDeposit) {

View File

@ -0,0 +1,33 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq 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 Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.core.offer.bisq_v1;
import bisq.common.proto.ProtoUtil;
public enum OfferDirection {
BUY,
SELL;
public static OfferDirection fromProto(protobuf.OfferPayload.Direction direction) {
return ProtoUtil.enumFromProto(OfferDirection.class, direction.name());
}
public static protobuf.OfferPayload.Direction toProtoMessage(OfferDirection direction) {
return protobuf.OfferPayload.Direction.valueOf(direction.name());
}
}

View File

@ -63,19 +63,6 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
// Enum
///////////////////////////////////////////////////////////////////////////////////////////
public enum Direction {
BUY,
SELL;
public static OfferPayload.Direction fromProto(protobuf.OfferPayload.Direction direction) {
return ProtoUtil.enumFromProto(OfferPayload.Direction.class, direction.name());
}
public static protobuf.OfferPayload.Direction toProtoMessage(Direction direction) {
return protobuf.OfferPayload.Direction.valueOf(direction.name());
}
}
// Keys for extra map
// Only set for fiat offers
public static final String ACCOUNT_AGE_WITNESS_HASH = "accountAgeWitnessHash";
@ -103,7 +90,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
private final NodeAddress ownerNodeAddress;
@JsonExclude
private final PubKeyRing pubKeyRing;
private final Direction direction;
private final OfferDirection direction;
// price if fixed price is used (usePercentageBasedPrice = false), otherwise 0
private final long price;
// Distance form market price if percentage based price is used (usePercentageBasedPrice = true), otherwise 0.
@ -190,7 +177,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
long date,
NodeAddress ownerNodeAddress,
PubKeyRing pubKeyRing,
Direction direction,
OfferDirection direction,
long price,
double marketPriceMargin,
boolean useMarketBasedPrice,
@ -286,7 +273,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
.setDate(date)
.setOwnerNodeAddress(ownerNodeAddress.toProtoMessage())
.setPubKeyRing(pubKeyRing.toProtoMessage())
.setDirection(Direction.toProtoMessage(direction))
.setDirection(OfferDirection.toProtoMessage(direction))
.setPrice(price)
.setMarketPriceMargin(marketPriceMargin)
.setUseMarketBasedPrice(useMarketBasedPrice)
@ -345,7 +332,7 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
proto.getDate(),
NodeAddress.fromProto(proto.getOwnerNodeAddress()),
PubKeyRing.fromProto(proto.getPubKeyRing()),
OfferPayload.Direction.fromProto(proto.getDirection()),
OfferDirection.fromProto(proto.getDirection()),
proto.getPrice(),
proto.getMarketPriceMargin(),
proto.getUseMarketBasedPrice(),

View File

@ -46,7 +46,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import static bisq.core.btc.model.AddressEntry.Context.OFFER_FUNDING;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction.SELL;
import static bisq.core.offer.bisq_v1.OfferDirection.SELL;
import static bisq.core.util.VolumeUtil.getAdjustedVolumeForHalCash;
import static bisq.core.util.VolumeUtil.getRoundedFiatVolume;
import static bisq.core.util.coin.CoinUtil.minCoin;

View File

@ -129,8 +129,8 @@ public class TriggerPriceService {
return false;
}
OfferPayload.Direction direction = openOffer.getOffer().getDirection();
boolean isSellOffer = direction == OfferPayload.Direction.SELL;
OfferDirection direction = openOffer.getOffer().getDirection();
boolean isSellOffer = direction == OfferDirection.SELL;
boolean condition = isSellOffer && !cryptoCurrency || !isSellOffer && cryptoCurrency;
return condition ?
marketPriceAsLong < triggerPrice :

View File

@ -21,7 +21,7 @@ import bisq.core.btc.model.AddressEntry;
import bisq.core.offer.Offer;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.availability.AvailabilityResult;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.support.dispute.DisputeResult;
import bisq.core.trade.model.bisq_v1.Trade;
@ -81,8 +81,8 @@ public class ProtoDevUtil {
sb.append(" enum Direction {\n");
sb.append(" PB_ERROR = 0;\n");
for (int i = 0; i < OfferPayload.Direction.values().length; i++) {
OfferPayload.Direction s = OfferPayload.Direction.values()[i];
for (int i = 0; i < OfferDirection.values().length; i++) {
OfferDirection s = OfferDirection.values()[i];
sb.append(" ");
sb.append(s.toString());
sb.append(" = ");

View File

@ -26,7 +26,7 @@ import bisq.core.offer.Offer;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.availability.OfferAvailabilityModel;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.support.dispute.mediation.mediator.MediatorManager;
@ -715,7 +715,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
if (isMyOffer(offer))
return offer.isBuyOffer();
else
return offer.getDirection() == OfferPayload.Direction.SELL;
return offer.getDirection() == OfferDirection.SELL;
}
public Optional<Trade> getTradeById(String tradeId) {

View File

@ -22,6 +22,7 @@ import bisq.core.monetary.AltcoinExchangeRate;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.trade.model.bisq_v1.Trade;
import bisq.core.util.VolumeUtil;
@ -106,7 +107,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
@SuppressWarnings("SpellCheckingInspection")
public static final String REFUND_AGENT_ADDRESS = "refAddr";
private final OfferPayload.Direction direction;
private final OfferDirection direction;
private final String baseCurrency;
private final String counterCurrency;
private final String offerPaymentMethod;
@ -165,7 +166,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////
public TradeStatistics2(OfferPayload.Direction direction,
public TradeStatistics2(OfferDirection direction,
String baseCurrency,
String counterCurrency,
String offerPaymentMethod,
@ -209,7 +210,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
private protobuf.TradeStatistics2.Builder getBuilder() {
final protobuf.TradeStatistics2.Builder builder = protobuf.TradeStatistics2.newBuilder()
.setDirection(OfferPayload.Direction.toProtoMessage(direction))
.setDirection(OfferDirection.toProtoMessage(direction))
.setBaseCurrency(baseCurrency)
.setCounterCurrency(counterCurrency)
.setPaymentMethodId(offerPaymentMethod)
@ -239,7 +240,7 @@ public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayl
public static TradeStatistics2 fromProto(protobuf.TradeStatistics2 proto) {
return new TradeStatistics2(
OfferPayload.Direction.fromProto(proto.getDirection()),
OfferDirection.fromProto(proto.getDirection()),
proto.getBaseCurrency(),
proto.getCounterCurrency(),
proto.getPaymentMethodId(),

View File

@ -17,6 +17,7 @@
package bisq.core.offer;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import com.natpryce.makeiteasy.Instantiator;
@ -32,7 +33,7 @@ public class OfferMaker {
public static final Property<Offer, Long> amount = new Property<>();
public static final Property<Offer, String> baseCurrencyCode = new Property<>();
public static final Property<Offer, String> counterCurrencyCode = new Property<>();
public static final Property<Offer, OfferPayload.Direction> direction = new Property<>();
public static final Property<Offer, OfferDirection> direction = new Property<>();
public static final Property<Offer, Boolean> useMarketBasedPrice = new Property<>();
public static final Property<Offer, Double> marketPriceMargin = new Property<>();
public static final Property<Offer, String> id = new Property<>();
@ -42,7 +43,7 @@ public class OfferMaker {
0L,
null,
null,
lookup.valueOf(direction, OfferPayload.Direction.BUY),
lookup.valueOf(direction, OfferDirection.BUY),
lookup.valueOf(price, 100000L),
lookup.valueOf(marketPriceMargin, 0.0),
lookup.valueOf(useMarketBasedPrice, false),

View File

@ -34,7 +34,7 @@ import bisq.core.locale.FiatCurrency;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.AssetAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
@ -187,14 +187,14 @@ public abstract class PaymentMethodForm {
Res.get("payment.maxPeriodAndLimitCrypto",
getTimeText(hours),
formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(
paymentAccount, tradeCurrency.getCode(), OfferPayload.Direction.BUY))))
paymentAccount, tradeCurrency.getCode(), OfferDirection.BUY))))
:
Res.get("payment.maxPeriodAndLimit",
getTimeText(hours),
formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(
paymentAccount, tradeCurrency.getCode(), OfferPayload.Direction.BUY))),
paymentAccount, tradeCurrency.getCode(), OfferDirection.BUY))),
formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(
paymentAccount, tradeCurrency.getCode(), OfferPayload.Direction.SELL))),
paymentAccount, tradeCurrency.getCode(), OfferDirection.SELL))),
DisplayUtils.formatAccountAge(accountAge));
return limitationsText;
}

View File

@ -26,7 +26,7 @@ import bisq.core.locale.Res;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.TradeStatisticsManager;
@ -139,7 +139,7 @@ public class PriceUtil {
}
public Optional<Double> getMarketBasedPrice(Offer offer,
OfferPayload.Direction direction) {
OfferDirection direction) {
if (offer.isUseMarketBasedPrice()) {
return Optional.of(offer.getMarketPriceMargin());
}
@ -169,7 +169,7 @@ public class PriceUtil {
public Optional<Double> calculatePercentage(Offer offer,
double marketPrice,
OfferPayload.Direction direction) {
OfferDirection direction) {
// If the offer did not use % price we calculate % from current market price
String currencyCode = offer.getCurrencyCode();
Price price = offer.getPrice();
@ -179,7 +179,7 @@ public class PriceUtil {
long priceAsLong = checkNotNull(price).getValue();
double scaled = MathUtils.scaleDownByPowerOf10(priceAsLong, precision);
double value;
if (direction == OfferPayload.Direction.SELL) {
if (direction == OfferDirection.SELL) {
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
if (marketPrice == 0) {
return Optional.empty();

View File

@ -37,7 +37,7 @@ import bisq.desktop.util.GUIUtil;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.util.FormattingUtils;
import bisq.core.util.VolumeUtil;
import bisq.core.util.coin.CoinFormatter;
@ -164,8 +164,8 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
VBox.setMargin(chartPane, new Insets(0, 0, 5, 0));
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferPayload.Direction.BUY);
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferPayload.Direction.SELL);
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferDirection.BUY);
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferDirection.SELL);
buyOfferTableView = tupleBuy.first;
sellOfferTableView = tupleSell.first;
@ -181,8 +181,8 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
VBox.setMargin(bottomHBox, new Insets(-5, 0, 0, 0));
HBox.setHgrow(tupleBuy.second, Priority.ALWAYS);
HBox.setHgrow(tupleSell.second, Priority.ALWAYS);
tupleBuy.second.setUserData(OfferPayload.Direction.BUY.name());
tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
tupleBuy.second.setUserData(OfferDirection.BUY.name());
tupleSell.second.setUserData(OfferDirection.SELL.name());
bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
root.getChildren().addAll(currencyComboBoxTuple.first, chartPane, bottomHBox);
@ -250,7 +250,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
});
if (CurrencyUtil.isCryptoCurrency(code)) {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferPayload.Direction.BUY.name())) {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferDirection.BUY.name())) {
bottomHBox.getChildren().get(0).toFront();
reverseTableColumns();
}
@ -263,7 +263,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
priceColumnLabel.set(Res.get("shared.priceWithCur", Res.getBaseCurrencyCode()));
} else {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferPayload.Direction.SELL.name())) {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferDirection.SELL.name())) {
bottomHBox.getChildren().get(0).toFront();
reverseTableColumns();
}
@ -459,7 +459,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
.collect(Collectors.toList());
}
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferDirection direction) {
TableView<OfferListItem> tableView = new TableView<>();
tableView.setMinHeight(initialOfferTableViewHeight);
tableView.setPrefHeight(initialOfferTableViewHeight);
@ -605,7 +605,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
}
});
boolean isSellOffer = direction == OfferPayload.Direction.SELL;
boolean isSellOffer = direction == OfferDirection.SELL;
// trader avatar
TableColumn<OfferListItem, OfferListItem> avatarColumn = new AutoTooltipTableColumn<>(isSellOffer ?

View File

@ -35,7 +35,7 @@ import bisq.core.locale.GlobalSettings;
import bisq.core.locale.TradeCurrency;
import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.user.Preferences;
import bisq.core.util.VolumeUtil;
@ -308,7 +308,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
List<Offer> allBuyOffers = offerBookListItems.stream()
.map(OfferBookListItem::getOffer)
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
&& e.getDirection().equals(OfferPayload.Direction.BUY))
&& e.getDirection().equals(OfferDirection.BUY))
.sorted(buyOfferSortComparator)
.collect(Collectors.toList());
@ -332,12 +332,12 @@ class OfferBookChartViewModel extends ActivatableViewModel {
maxPlacesForBuyVolume.set(formatVolume(offer, false).length());
}
buildChartAndTableEntries(allBuyOffers, OfferPayload.Direction.BUY, buyData, topBuyOfferList);
buildChartAndTableEntries(allBuyOffers, OfferDirection.BUY, buyData, topBuyOfferList);
List<Offer> allSellOffers = offerBookListItems.stream()
.map(OfferBookListItem::getOffer)
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
&& e.getDirection().equals(OfferPayload.Direction.SELL))
&& e.getDirection().equals(OfferDirection.SELL))
.sorted(sellOfferSortComparator)
.collect(Collectors.toList());
@ -359,11 +359,11 @@ class OfferBookChartViewModel extends ActivatableViewModel {
maxPlacesForSellVolume.set(formatVolume(offer, false).length());
}
buildChartAndTableEntries(allSellOffers, OfferPayload.Direction.SELL, sellData, topSellOfferList);
buildChartAndTableEntries(allSellOffers, OfferDirection.SELL, sellData, topSellOfferList);
}
private void buildChartAndTableEntries(List<Offer> sortedList,
OfferPayload.Direction direction,
OfferDirection direction,
List<XYChart.Data<Number, Number>> data,
ObservableList<OfferListItem> offerTableList) {
data.clear();
@ -378,12 +378,12 @@ class OfferBookChartViewModel extends ActivatableViewModel {
double priceAsDouble = (double) price.getValue() / LongMath.pow(10, price.smallestUnitExponent());
if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) {
if (direction.equals(OfferPayload.Direction.SELL))
if (direction.equals(OfferDirection.SELL))
data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount));
else
data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount));
} else {
if (direction.equals(OfferPayload.Direction.BUY))
if (direction.equals(OfferDirection.BUY))
data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount));
else
data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount));

View File

@ -27,7 +27,7 @@ import bisq.core.locale.Res;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.util.FormattingUtils;
@ -145,7 +145,7 @@ class SpreadViewModel extends ActivatableViewModel {
List<Offer> buyOffers = uniqueOffers
.stream()
.filter(e -> e.getDirection().equals(OfferPayload.Direction.BUY))
.filter(e -> e.getDirection().equals(OfferDirection.BUY))
.sorted((o1, o2) -> {
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;
@ -162,7 +162,7 @@ class SpreadViewModel extends ActivatableViewModel {
List<Offer> sellOffers = uniqueOffers
.stream()
.filter(e -> e.getDirection().equals(OfferPayload.Direction.SELL))
.filter(e -> e.getDirection().equals(OfferDirection.SELL))
.sorted((o1, o2) -> {
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;

View File

@ -21,7 +21,7 @@ import bisq.desktop.Navigation;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.common.view.ViewLoader;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
@ -46,6 +46,6 @@ public class BuyOfferView extends OfferView {
arbitratorManager,
user,
p2PService,
OfferPayload.Direction.BUY);
OfferDirection.BUY);
}
}

View File

@ -34,7 +34,7 @@ import bisq.core.locale.LanguageUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
@ -66,7 +66,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
private final Preferences preferences;
private final User user;
private final P2PService p2PService;
private final OfferPayload.Direction direction;
private final OfferDirection direction;
private final ArbitratorManager arbitratorManager;
private Offer offer;
@ -82,7 +82,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
ArbitratorManager arbitratorManager,
User user,
P2PService p2PService,
OfferPayload.Direction direction) {
OfferDirection direction) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.preferences = preferences;
@ -132,7 +132,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
@Override
protected void activate() {
Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferPayload.Direction.SELL) ?
Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferDirection.SELL) ?
CurrencyUtil.getTradeCurrency(preferences.getSellScreenCurrencyCode()) :
CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCurrencyCode());
tradeCurrency = tradeCurrencyOptional.orElseGet(GlobalSettings::getDefaultTradeCurrency);
@ -162,7 +162,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
TabPane tabPane = root;
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS);
View view;
boolean isBuy = direction == OfferPayload.Direction.BUY;
boolean isBuy = direction == OfferDirection.BUY;
if (viewClass == OfferBookView.class && offerBookView == null) {
view = viewLoader.load(viewClass);

View File

@ -21,7 +21,7 @@ import bisq.desktop.Navigation;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.common.view.ViewLoader;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
@ -46,6 +46,6 @@ public class SellOfferView extends OfferView {
arbitratorManager,
user,
p2PService,
OfferPayload.Direction.SELL);
OfferDirection.SELL);
}
}

View File

@ -37,7 +37,7 @@ import bisq.core.offer.Offer;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.PriceFeedService;
@ -111,7 +111,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
private final BalanceListener btcBalanceListener;
private final SetChangeListener<PaymentAccount> paymentAccountsChangeListener;
protected OfferPayload.Direction direction;
protected OfferDirection direction;
protected TradeCurrency tradeCurrency;
protected final StringProperty tradeCurrencyCode = new SimpleStringProperty();
protected final BooleanProperty useMarketBasedPrice = new SimpleBooleanProperty();
@ -226,7 +226,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
///////////////////////////////////////////////////////////////////////////////////////////
// called before activate()
public boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
public boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
this.direction = direction;
this.tradeCurrency = tradeCurrency;
@ -468,16 +468,16 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
return true;
}
OfferPayload.Direction getDirection() {
OfferDirection getDirection() {
return direction;
}
boolean isSellOffer() {
return direction == OfferPayload.Direction.SELL;
return direction == OfferDirection.SELL;
}
boolean isBuyOffer() {
return direction == OfferPayload.Direction.BUY;
return direction == OfferDirection.BUY;
}
AddressEntry getAddressEntry() {

View File

@ -49,7 +49,7 @@ import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.FasterPaymentsAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
@ -300,7 +300,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
model.getDataModel().onTabSelected(isSelected);
}
public void initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
public void initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
boolean result = model.initWithData(direction, tradeCurrency);
if (!result) {
@ -313,7 +313,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
}).show();
}
if (direction == OfferPayload.Direction.BUY) {
if (direction == OfferDirection.BUY) {
placeOfferButton.setId("buy-button-big");
placeOfferButton.updateText(Res.get("createOffer.placeOfferButton", Res.get("shared.buy")));
} else {

View File

@ -47,7 +47,7 @@ import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferRestrictions;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
@ -266,7 +266,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
}
private void addBindings() {
if (dataModel.getDirection() == OfferPayload.Direction.BUY) {
if (dataModel.getDirection() == OfferDirection.BUY) {
volumeDescriptionLabel.bind(createStringBinding(
() -> Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getTradeCurrencyCode().get()),
dataModel.getTradeCurrencyCode()));
@ -335,9 +335,9 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
try {
double priceAsDouble = ParsingUtils.parseNumberStringToDouble(price.get());
double relation = priceAsDouble / marketPriceAsDouble;
final OfferPayload.Direction compareDirection = CurrencyUtil.isCryptoCurrency(currencyCode) ?
OfferPayload.Direction.SELL :
OfferPayload.Direction.BUY;
final OfferDirection compareDirection = CurrencyUtil.isCryptoCurrency(currencyCode) ?
OfferDirection.SELL :
OfferDirection.BUY;
double percentage = dataModel.getDirection() == compareDirection ? 1 - relation : relation - 1;
percentage = MathUtils.roundDouble(percentage, 4);
dataModel.setMarketPriceMargin(percentage);
@ -371,9 +371,9 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
percentage = MathUtils.roundDouble(percentage, 4);
double marketPriceAsDouble = marketPrice.getPrice();
final boolean isCryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
final OfferPayload.Direction compareDirection = isCryptoCurrency ?
OfferPayload.Direction.SELL :
OfferPayload.Direction.BUY;
final OfferDirection compareDirection = isCryptoCurrency ?
OfferDirection.SELL :
OfferDirection.BUY;
double factor = dataModel.getDirection() == compareDirection ?
1 - percentage :
1 + percentage;
@ -581,14 +581,14 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
// API
///////////////////////////////////////////////////////////////////////////////////////////
boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
boolean result = dataModel.initWithData(direction, tradeCurrency);
if (dataModel.paymentAccount != null)
btcValidator.setMaxValue(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimitAsCoin(dataModel.getTradeCurrencyCode().get()));
btcValidator.setMaxTradeLimit(Coin.valueOf(dataModel.getMaxTradeLimit()));
btcValidator.setMinValue(Restrictions.getMinTradeAmount());
final boolean isBuy = dataModel.getDirection() == OfferPayload.Direction.BUY;
final boolean isBuy = dataModel.getDirection() == OfferDirection.BUY;
amountDescription = Res.get("createOffer.amountPriceBox.amountDescription",
isBuy ? Res.get("shared.buy") : Res.get("shared.sell"));
@ -981,7 +981,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
}
public boolean isSellOffer() {
return dataModel.getDirection() == OfferPayload.Direction.SELL;
return dataModel.getDirection() == OfferDirection.SELL;
}
public TradeCurrency getTradeCurrency() {
@ -1233,7 +1233,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
private void maybeShowMakeOfferToUnsignedAccountWarning() {
if (!makeOfferFromUnsignedAccountWarningDisplayed &&
dataModel.getDirection() == OfferPayload.Direction.SELL &&
dataModel.getDirection() == OfferDirection.SELL &&
PaymentMethod.hasChargebackRisk(dataModel.getPaymentAccount().getPaymentMethod(), dataModel.getTradeCurrency().getCode())) {
Coin checkAmount = dataModel.getMinAmount().get() == null ? dataModel.getAmount().get() : dataModel.getMinAmount().get();
if (checkAmount != null && !checkAmount.isGreaterThan(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT)) {

View File

@ -37,7 +37,7 @@ import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountUtil;
import bisq.core.payment.payload.PaymentMethod;
@ -217,7 +217,7 @@ class TakeOfferDataModel extends OfferDataModel {
this.amount.set(Coin.valueOf(Math.min(offer.getAmount().value, getMaxTradeLimit())));
securityDeposit = offer.getDirection() == OfferPayload.Direction.SELL ?
securityDeposit = offer.getDirection() == OfferDirection.SELL ?
getBuyerSecurityDeposit() :
getSellerSecurityDeposit();
@ -421,7 +421,7 @@ class TakeOfferDataModel extends OfferDataModel {
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
OfferPayload.Direction getDirection() {
OfferDirection getDirection() {
return offer.getDirection();
}
@ -525,11 +525,11 @@ class TakeOfferDataModel extends OfferDataModel {
}
boolean isBuyOffer() {
return getDirection() == OfferPayload.Direction.BUY;
return getDirection() == OfferDirection.BUY;
}
boolean isSellOffer() {
return getDirection() == OfferPayload.Direction.SELL;
return getDirection() == OfferDirection.SELL;
}
boolean isCryptoCurrency() {

View File

@ -52,7 +52,7 @@ import bisq.desktop.util.Transitions;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.FasterPaymentsAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
@ -354,7 +354,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
model.initWithData(offer);
priceAsPercentageInputBox.setVisible(offer.isUseMarketBasedPrice());
if (model.getOffer().getDirection() == OfferPayload.Direction.SELL) {
if (model.getOffer().getDirection() == OfferDirection.SELL) {
takeOfferButton.setId("buy-button-big");
takeOfferButton.updateText(Res.get("takeOffer.takeOfferButton", Res.get("shared.buy")));
nextButton.setId("buy-button");

View File

@ -37,7 +37,7 @@ import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferRestrictions;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
@ -348,7 +348,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
amountValidationResult.set(new InputValidator.ValidationResult(false,
Res.get("takeOffer.validation.amountLargerThanOfferAmountMinusFee")));
} else if (btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().value == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.value) {
if (dataModel.getDirection() == OfferPayload.Direction.BUY) {
if (dataModel.getDirection() == OfferDirection.BUY) {
new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.seller",
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT),
Res.get("offerbook.warning.newVersionAnnouncement")))
@ -478,7 +478,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
private void addBindings() {
volume.bind(createStringBinding(() -> VolumeUtil.formatVolume(dataModel.volume.get()), dataModel.volume));
if (dataModel.getDirection() == OfferPayload.Direction.SELL) {
if (dataModel.getDirection() == OfferDirection.SELL) {
volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getCurrencyCode()));
} else {
volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.sell.volumeDescription", dataModel.getCurrencyCode()));
@ -642,11 +642,11 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
}
boolean isSeller() {
return dataModel.getDirection() == OfferPayload.Direction.BUY;
return dataModel.getDirection() == OfferDirection.BUY;
}
public boolean isSellingToAnUnsignedAccount(Offer offer) {
if (offer.getDirection() == OfferPayload.Direction.BUY &&
if (offer.getDirection() == OfferDirection.BUY &&
PaymentMethod.hasChargebackRisk(offer.getPaymentMethod(), offer.getCurrencyCode())) {
// considered risky when either UNSIGNED, PEER_INITIAL, or BANNED (see #5343)
return accountAgeWitnessService.getSignState(offer) == AccountAgeWitnessService.SignState.UNSIGNED ||

View File

@ -39,7 +39,7 @@ import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction.BUY;
import static bisq.core.offer.bisq_v1.OfferDirection.BUY;
/**
* Holds and manages the unsorted and unfiltered offerbook list (except for banned offers) of both buy and sell offers.

View File

@ -55,7 +55,7 @@ import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferFilterService;
import bisq.core.offer.OfferRestrictions;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.user.DontShowAgainLookup;
@ -265,7 +265,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
if (price2 == null || price1 == null) {
return 0;
}
if (model.getDirection() == OfferPayload.Direction.SELL) {
if (model.getDirection() == OfferDirection.SELL) {
return price1.compareTo(price2);
} else {
return price2.compareTo(price1);
@ -277,7 +277,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
paymentMethodColumn.setComparator(Comparator.comparing(o -> Res.get(o.getOffer().getPaymentMethod().getId())));
avatarColumn.setComparator(Comparator.comparing(o -> model.getNumTrades(o.getOffer())));
depositColumn.setComparator(Comparator.comparing(item -> {
boolean isSellOffer = item.getOffer().getDirection() == OfferPayload.Direction.SELL;
boolean isSellOffer = item.getOffer().getDirection() == OfferDirection.SELL;
Coin deposit = isSellOffer ?
item.getOffer().getBuyerSecurityDeposit() :
item.getOffer().getSellerSecurityDeposit();
@ -314,7 +314,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
protected void activate() {
currencyComboBox.setCellFactory(GUIUtil.getTradeCurrencyCellFactory(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"),
(model.getDirection() == OfferPayload.Direction.BUY ? model.getSellOfferCounts() : model.getBuyOfferCounts())));
(model.getDirection() == OfferDirection.BUY ? model.getSellOfferCounts() : model.getBuyOfferCounts())));
currencyComboBox.setConverter(new CurrencyStringConverter(currencyComboBox));
currencyComboBox.getEditor().getStyleClass().add("combo-box-editor-bold");
@ -536,38 +536,38 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
createOfferButton.setDisable(false);
}
public void setDirection(OfferPayload.Direction direction) {
public void setDirection(OfferDirection direction) {
model.initWithDirection(direction);
ImageView iconView = new ImageView();
createOfferButton.setGraphic(iconView);
iconView.setId(direction == OfferPayload.Direction.SELL ? "image-sell-white" : "image-buy-white");
createOfferButton.setId(direction == OfferPayload.Direction.SELL ? "sell-button-big" : "buy-button-big");
avatarColumn.setTitle(direction == OfferPayload.Direction.SELL ? Res.get("shared.buyerUpperCase") : Res.get("shared.sellerUpperCase"));
iconView.setId(direction == OfferDirection.SELL ? "image-sell-white" : "image-buy-white");
createOfferButton.setId(direction == OfferDirection.SELL ? "sell-button-big" : "buy-button-big");
avatarColumn.setTitle(direction == OfferDirection.SELL ? Res.get("shared.buyerUpperCase") : Res.get("shared.sellerUpperCase"));
setDirectionTitles();
}
private void setDirectionTitles() {
TradeCurrency selectedTradeCurrency = model.getSelectedTradeCurrency();
if (selectedTradeCurrency != null) {
OfferPayload.Direction direction = model.getDirection();
OfferDirection direction = model.getDirection();
String offerButtonText;
String code = selectedTradeCurrency.getCode();
if (model.showAllTradeCurrenciesProperty.get()) {
offerButtonText = direction == OfferPayload.Direction.BUY ?
offerButtonText = direction == OfferDirection.BUY ?
Res.get("offerbook.createOfferToBuy",
Res.getBaseCurrencyCode()) :
Res.get("offerbook.createOfferToSell",
Res.getBaseCurrencyCode());
} else if (selectedTradeCurrency instanceof FiatCurrency) {
offerButtonText = direction == OfferPayload.Direction.BUY ?
offerButtonText = direction == OfferDirection.BUY ?
Res.get("offerbook.createOfferToBuy.withFiat",
Res.getBaseCurrencyCode(), code) :
Res.get("offerbook.createOfferToSell.forFiat", Res.getBaseCurrencyCode(), code);
} else {
offerButtonText = direction == OfferPayload.Direction.BUY ?
offerButtonText = direction == OfferDirection.BUY ?
Res.get("offerbook.createOfferToBuy.withCrypto",
code, Res.getBaseCurrencyCode()) :
Res.get("offerbook.createOfferToSell.forCrypto", code, Res.getBaseCurrencyCode());
@ -673,7 +673,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
private void onTakeOffer(Offer offer) {
if (model.canCreateOrTakeOffer()) {
if (offer.getDirection() == OfferPayload.Direction.SELL &&
if (offer.getDirection() == OfferDirection.SELL &&
offer.getPaymentMethod().getId().equals(PaymentMethod.CASH_DEPOSIT.getId())) {
new Popup().confirmation(Res.get("popup.info.cashDepositInfo", offer.getBankId()))
.actionButtonText(Res.get("popup.info.cashDepositInfo.confirm"))
@ -981,7 +981,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
public void updateItem(final OfferBookListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
var isSellOffer = item.getOffer().getDirection() == OfferPayload.Direction.SELL;
var isSellOffer = item.getOffer().getDirection() == OfferDirection.SELL;
var deposit = isSellOffer ? item.getOffer().getBuyerSecurityDeposit() :
item.getOffer().getSellerSecurityDeposit();
if (deposit == null) {
@ -1070,7 +1070,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
button.setStyle(CssTheme.isDarkTheme() ? "-fx-text-fill: white" : "-fx-text-fill: #444444");
button.setOnAction(e -> onRemoveOpenOffer(offer));
} else {
boolean isSellOffer = offer.getDirection() == OfferPayload.Direction.SELL;
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
button.setId(isSellOffer ? "buy-button" : "sell-button");
button.setStyle("-fx-text-fill: white");

View File

@ -40,7 +40,7 @@ import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferFilterService;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.PaymentAccountUtil;
import bisq.core.payment.payload.PaymentMethod;
@ -117,7 +117,7 @@ class OfferBookViewModel extends ActivatableViewModel {
private TradeCurrency selectedTradeCurrency;
private final ObservableList<TradeCurrency> allTradeCurrencies = FXCollections.observableArrayList();
private OfferPayload.Direction direction;
private OfferDirection direction;
final StringProperty tradeCurrencyCode = new SimpleStringProperty();
@ -215,7 +215,7 @@ class OfferBookViewModel extends ActivatableViewModel {
protected void activate() {
filteredItems.addListener(filterItemsListener);
String code = direction == OfferPayload.Direction.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
String code = direction == OfferDirection.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
if (code != null && !code.isEmpty() && !isShowAllEntry(code) &&
CurrencyUtil.getTradeCurrency(code).isPresent()) {
showAllTradeCurrenciesProperty.set(false);
@ -251,7 +251,7 @@ class OfferBookViewModel extends ActivatableViewModel {
// API
///////////////////////////////////////////////////////////////////////////////////////////
void initWithDirection(OfferPayload.Direction direction) {
void initWithDirection(OfferDirection direction) {
this.direction = direction;
}
@ -279,7 +279,7 @@ class OfferBookViewModel extends ActivatableViewModel {
setMarketPriceFeedCurrency();
filterOffers();
if (direction == OfferPayload.Direction.BUY)
if (direction == OfferDirection.BUY)
preferences.setBuyScreenCurrencyCode(code);
else
preferences.setSellScreenCurrencyCode(code);
@ -341,7 +341,7 @@ class OfferBookViewModel extends ActivatableViewModel {
return openOfferManager.isMyOffer(offer);
}
OfferPayload.Direction getDirection() {
OfferDirection getDirection() {
return direction;
}
@ -647,11 +647,11 @@ class OfferBookViewModel extends ActivatableViewModel {
bsqFormatter.formatCoinWithCode(offer.getMakerFee());
}
private static String getDirectionWithCodeDetailed(OfferPayload.Direction direction, String currencyCode) {
private static String getDirectionWithCodeDetailed(OfferDirection direction, String currencyCode) {
if (CurrencyUtil.isFiatCurrency(currencyCode))
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyingBTCWith", currencyCode) : Res.get("shared.sellingBTCFor", currencyCode);
return (direction == OfferDirection.BUY) ? Res.get("shared.buyingBTCWith", currencyCode) : Res.get("shared.sellingBTCFor", currencyCode);
else
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyingCurrency", currencyCode) : Res.get("shared.sellingCurrency", currencyCode);
return (direction == OfferDirection.SELL) ? Res.get("shared.buyingCurrency", currencyCode) : Res.get("shared.sellingCurrency", currencyCode);
}
public String formatDepositString(Coin deposit, long amount) {

View File

@ -33,7 +33,7 @@ import bisq.core.locale.Res;
import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.user.User;
@ -175,7 +175,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
if (isF2F)
rows++;
boolean showXmrAutoConf = offer.isXmr() && offer.getDirection() == OfferPayload.Direction.SELL;
boolean showXmrAutoConf = offer.isXmr() && offer.getDirection() == OfferDirection.SELL;
if (showXmrAutoConf) {
rows++;
}
@ -184,7 +184,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
String fiatDirectionInfo = "";
String btcDirectionInfo = "";
OfferPayload.Direction direction = offer.getDirection();
OfferDirection direction = offer.getDirection();
String currencyCode = offer.getCurrencyCode();
String offerTypeLabel = Res.get("shared.offerType");
String toReceive = " " + Res.get("shared.toReceive");
@ -193,13 +193,13 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
if (takeOfferHandlerOptional.isPresent()) {
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
DisplayUtils.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
fiatDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
btcDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
fiatDirectionInfo = direction == OfferDirection.BUY ? toReceive : toSpend;
btcDirectionInfo = direction == OfferDirection.SELL ? toReceive : toSpend;
} else if (placeOfferHandlerOptional.isPresent()) {
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
DisplayUtils.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
fiatDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
btcDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
fiatDirectionInfo = direction == OfferDirection.SELL ? toReceive : toSpend;
btcDirectionInfo = direction == OfferDirection.BUY ? toReceive : toSpend;
} else {
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
DisplayUtils.getDirectionBothSides(direction, currencyCode), firstRowDistance);

View File

@ -23,7 +23,7 @@ import bisq.desktop.main.PriceUtil;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.bisq_v1.ClosedTradableManager;
@ -91,7 +91,7 @@ class ClosedTradesDataModel extends ActivatableDataModel {
.map(ClosedTradableListItem::getTradable)
.collect(Collectors.toList());
public OfferPayload.Direction getDirection(Offer offer) {
public OfferDirection getDirection(Offer offer) {
return closedTradableManager.wasMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -33,6 +33,7 @@ import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.MutableOfferPayloadFields;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.payment.PaymentAccount;
import bisq.core.proto.persistable.CorePersistenceProtoResolver;
@ -147,7 +148,7 @@ class EditOfferDataModel extends MutableOfferDataModel {
}
@Override
public boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
public boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
try {
return super.initWithData(direction, tradeCurrency);
} catch (NullPointerException e) {

View File

@ -20,7 +20,7 @@ package bisq.desktop.main.portfolio.failedtrades;
import bisq.desktop.common.model.ActivatableDataModel;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.trade.TradeManager;
import bisq.core.trade.bisq_v1.FailedTradesManager;
import bisq.core.trade.model.bisq_v1.Trade;
@ -77,7 +77,7 @@ class FailedTradesDataModel extends ActivatableDataModel {
return list;
}
public OfferPayload.Direction getDirection(Offer offer) {
public OfferDirection getDirection(Offer offer) {
return failedTradesManager.wasMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -22,7 +22,7 @@ import bisq.desktop.common.model.ActivatableDataModel;
import bisq.core.offer.Offer;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.OpenOfferManager;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.TriggerPriceService;
import bisq.core.provider.price.PriceFeedService;
@ -86,7 +86,7 @@ class OpenOffersDataModel extends ActivatableDataModel {
return list;
}
public OfferPayload.Direction getDirection(Offer offer) {
public OfferDirection getDirection(Offer offer) {
return openOfferManager.isMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
}

View File

@ -35,7 +35,7 @@ import bisq.core.dao.DaoFacade;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.support.SupportType;
import bisq.core.support.dispute.Dispute;
@ -534,7 +534,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
Dispute dispute = new Dispute(new Date().getTime(),
trade.getId(),
pubKeyRing.hashCode(), // traderId
(offer.getDirection() == OfferPayload.Direction.BUY) == isMaker,
(offer.getDirection() == OfferDirection.BUY) == isMaker,
isMaker,
pubKeyRing,
trade.getDate().getTime(),
@ -595,7 +595,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
Dispute dispute = new Dispute(new Date().getTime(),
trade.getId(),
pubKeyRing.hashCode(), // traderId
(offer.getDirection() == OfferPayload.Direction.BUY) == isMaker,
(offer.getDirection() == OfferDirection.BUY) == isMaker,
isMaker,
pubKeyRing,
trade.getDate().getTime(),

View File

@ -6,7 +6,7 @@ import bisq.core.locale.Res;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.util.FormattingUtils;
import bisq.core.util.ParsingUtils;
import bisq.core.util.VolumeUtil;
@ -89,21 +89,21 @@ public class DisplayUtils {
// Offer direction
///////////////////////////////////////////////////////////////////////////////////////////
public static String getDirectionWithCode(OfferPayload.Direction direction, String currencyCode) {
public static String getDirectionWithCode(OfferDirection direction, String currencyCode) {
if (CurrencyUtil.isFiatCurrency(currencyCode))
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyCurrency", Res.getBaseCurrencyCode()) : Res.get("shared.sellCurrency", Res.getBaseCurrencyCode());
return (direction == OfferDirection.BUY) ? Res.get("shared.buyCurrency", Res.getBaseCurrencyCode()) : Res.get("shared.sellCurrency", Res.getBaseCurrencyCode());
else
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
return (direction == OfferDirection.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
}
public static String getDirectionBothSides(OfferPayload.Direction direction, String currencyCode) {
public static String getDirectionBothSides(OfferDirection direction, String currencyCode) {
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
currencyCode = Res.getBaseCurrencyCode();
return direction == OfferPayload.Direction.BUY ?
return direction == OfferDirection.BUY ?
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
} else {
return direction == OfferPayload.Direction.SELL ?
return direction == OfferDirection.SELL ?
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
}
@ -135,28 +135,28 @@ public class DisplayUtils {
}
}
public static String getDirectionForTakeOffer(OfferPayload.Direction direction, String currencyCode) {
public static String getDirectionForTakeOffer(OfferDirection direction, String currencyCode) {
String baseCurrencyCode = Res.getBaseCurrencyCode();
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
return direction == OfferPayload.Direction.BUY ?
return direction == OfferDirection.BUY ?
Res.get("formatter.youAre", Res.get("shared.selling"), baseCurrencyCode, Res.get("shared.buying"), currencyCode) :
Res.get("formatter.youAre", Res.get("shared.buying"), baseCurrencyCode, Res.get("shared.selling"), currencyCode);
} else {
return direction == OfferPayload.Direction.SELL ?
return direction == OfferDirection.SELL ?
Res.get("formatter.youAre", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), baseCurrencyCode) :
Res.get("formatter.youAre", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), baseCurrencyCode);
}
}
public static String getOfferDirectionForCreateOffer(OfferPayload.Direction direction, String currencyCode) {
public static String getOfferDirectionForCreateOffer(OfferDirection direction, String currencyCode) {
String baseCurrencyCode = Res.getBaseCurrencyCode();
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
return direction == OfferPayload.Direction.BUY ?
return direction == OfferDirection.BUY ?
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.buy"), baseCurrencyCode) :
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.sell"), baseCurrencyCode);
} else {
return direction == OfferPayload.Direction.SELL ?
return direction == OfferDirection.SELL ?
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.buy"), currencyCode, Res.get("shared.selling"), baseCurrencyCode) :
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.sell"), currencyCode, Res.get("shared.buying"), baseCurrencyCode);
}

View File

@ -10,6 +10,7 @@ import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.ClearXchangeAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.RevolutAccount;
@ -29,7 +30,6 @@ import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
@ -99,7 +99,7 @@ public class CreateOfferDataModelTest {
when(preferences.getSelectedPaymentAccountForCreateOffer()).thenReturn(revolutAccount);
when(offerUtil.getMakerFee(any())).thenReturn(Coin.ZERO);
model.initWithData(Direction.BUY, new FiatCurrency("USD"));
model.initWithData(OfferDirection.BUY, new FiatCurrency("USD"));
assertEquals("USD", model.getTradeCurrencyCode().get());
}
@ -121,7 +121,7 @@ public class CreateOfferDataModelTest {
when(preferences.getSelectedPaymentAccountForCreateOffer()).thenReturn(revolutAccount);
when(offerUtil.getMakerFee(any())).thenReturn(Coin.ZERO);
model.initWithData(Direction.BUY, new FiatCurrency("USD"));
model.initWithData(OfferDirection.BUY, new FiatCurrency("USD"));
assertEquals("USD", model.getTradeCurrencyCode().get());
}
}

View File

@ -34,6 +34,7 @@ import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
@ -62,7 +63,6 @@ import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import static bisq.core.offer.bisq_v1.OfferPayload.Direction;
import static bisq.desktop.maker.PreferenceMakers.empty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@ -137,7 +137,7 @@ public class CreateOfferViewModelTest {
coinFormatter,
tradeStats,
null);
dataModel.initWithData(Direction.BUY, new CryptoCurrency("BTC", "bitcoin"));
dataModel.initWithData(OfferDirection.BUY, new CryptoCurrency("BTC", "bitcoin"));
dataModel.activate();
model = new CreateOfferViewModel(dataModel,

View File

@ -19,7 +19,7 @@ package bisq.desktop.main.offer.offerbook;
import bisq.desktop.maker.OfferMaker;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.MakeItEasy;
@ -37,7 +37,7 @@ public class OfferBookListItemMaker {
public static final Property<OfferBookListItem, Long> price = new Property<>();
public static final Property<OfferBookListItem, Long> amount = new Property<>();
public static final Property<OfferBookListItem, Long> minAmount = new Property<>();
public static final Property<OfferBookListItem, OfferPayload.Direction> direction = new Property<>();
public static final Property<OfferBookListItem, OfferDirection> direction = new Property<>();
public static final Property<OfferBookListItem, Boolean> useMarketBasedPrice = new Property<>();
public static final Property<OfferBookListItem, Double> marketPriceMargin = new Property<>();
public static final Property<OfferBookListItem, String> baseCurrencyCode = new Property<>();
@ -48,7 +48,7 @@ public class OfferBookListItemMaker {
MakeItEasy.with(OfferMaker.price, lookup.valueOf(price, 100000L)),
with(OfferMaker.amount, lookup.valueOf(amount, 100000L)),
with(OfferMaker.minAmount, lookup.valueOf(amount, 100000L)),
with(OfferMaker.direction, lookup.valueOf(direction, OfferPayload.Direction.BUY)),
with(OfferMaker.direction, lookup.valueOf(direction, OfferDirection.BUY)),
with(OfferMaker.useMarketBasedPrice, lookup.valueOf(useMarketBasedPrice, false)),
with(OfferMaker.marketPriceMargin, lookup.valueOf(marketPriceMargin, 0.0)),
with(OfferMaker.baseCurrencyCode, lookup.valueOf(baseCurrencyCode, "BTC")),
@ -63,7 +63,7 @@ public class OfferBookListItemMaker {
with(OfferMaker.amount, lookup.valueOf(amount, 200000L)))));
public static final Maker<OfferBookListItem> btcBuyItem = a(OfferBookListItem);
public static final Maker<OfferBookListItem> btcSellItem = a(OfferBookListItem, with(direction, OfferPayload.Direction.SELL));
public static final Maker<OfferBookListItem> btcSellItem = a(OfferBookListItem, with(direction, OfferDirection.SELL));
public static final Maker<OfferBookListItem> btcItemWithRange = a(OfferBookListItemWithRange);
}

View File

@ -13,7 +13,7 @@ import bisq.core.locale.Res;
import bisq.core.offer.OfferUtil;
import bisq.core.offer.OpenOffer;
import bisq.core.offer.bisq_v1.CreateOfferService;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.payment.CryptoCurrencyAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.provider.fee.FeeService;
@ -129,6 +129,6 @@ public class EditOfferDataModelTest {
@Test
public void testInitializeEditOfferWithRemovedAsset() {
exception.expect(IllegalArgumentException.class);
model.initWithData(OfferPayload.Direction.BUY, null);
model.initWithData(OfferDirection.BUY, null);
}
}

View File

@ -18,6 +18,7 @@
package bisq.desktop.maker;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferDirection;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.network.p2p.NodeAddress;
@ -56,7 +57,7 @@ public class OfferMaker {
public static final Property<Offer, Long> amount = newProperty();
public static final Property<Offer, String> baseCurrencyCode = newProperty();
public static final Property<Offer, String> counterCurrencyCode = newProperty();
public static final Property<Offer, OfferPayload.Direction> direction = newProperty();
public static final Property<Offer, OfferDirection> direction = newProperty();
public static final Property<Offer, Boolean> useMarketBasedPrice = newProperty();
public static final Property<Offer, Double> marketPriceMargin = newProperty();
public static final Property<Offer, NodeAddress> nodeAddress = newProperty();
@ -78,7 +79,7 @@ public class OfferMaker {
lookup.valueOf(date, currentTimeMillis()),
lookup.valueOf(nodeAddress, getLocalHostNodeWithPort(10000)),
lookup.valueOf(pubKeyRing, genPubKeyRing()),
lookup.valueOf(direction, OfferPayload.Direction.BUY),
lookup.valueOf(direction, OfferDirection.BUY),
lookup.valueOf(price, 100000L),
lookup.valueOf(marketPriceMargin, 0.0),
lookup.valueOf(useMarketBasedPrice, false),