Adjust cli module to OfferInfo.price field change to string type

This commit is contained in:
ghubstan 2022-02-17 17:57:45 -03:00
parent 461edff631
commit 3405dbf5c3
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
3 changed files with 11 additions and 19 deletions

View File

@ -123,6 +123,7 @@ public class CurrencyFormat {
return FRIENDLY_NUMBER_FORMAT.format(price);
}
// TODO Deprecate after triggerPrice field type is changed to string.
public static String formatPrice(long price) {
FRIENDLY_NUMBER_FORMAT.setMinimumFractionDigits(4);
FRIENDLY_NUMBER_FORMAT.setMaximumFractionDigits(4);

View File

@ -29,11 +29,8 @@ import bisq.proto.grpc.GetOfferRequest;
import bisq.proto.grpc.GetOffersRequest;
import bisq.proto.grpc.OfferInfo;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import static bisq.cli.CryptoCurrencyUtil.apiDoesSupportCryptoCurrency;
import static bisq.proto.grpc.EditOfferRequest.EditType.ACTIVATION_STATE_ONLY;
@ -52,12 +49,6 @@ import bisq.cli.GrpcStubs;
public class OffersServiceRequest {
private final Function<Long, String> scaledPriceStringRequestFormat = (price) -> {
BigDecimal factor = new BigDecimal(10).pow(4);
//noinspection BigDecimalMethodWithoutRoundingCalled
return new BigDecimal(price).divide(factor).toPlainString();
};
private final GrpcStubs grpcStubs;
public OffersServiceRequest(GrpcStubs grpcStubs) {
@ -159,11 +150,11 @@ public class OffersServiceRequest {
public void editOfferActivationState(String offerId, int enable) {
var offer = getMyOffer(offerId);
var scaledPriceString = offer.getUseMarketBasedPrice()
var offerPrice = offer.getUseMarketBasedPrice()
? "0.00"
: scaledPriceStringRequestFormat.apply(offer.getPrice());
: offer.getPrice();
editOffer(offerId,
scaledPriceString,
offerPrice,
offer.getUseMarketBasedPrice(),
offer.getMarketPriceMargin(),
offer.getTriggerPrice(),

View File

@ -80,7 +80,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
public Table buildFiatOfferTable(List<OfferInfo> offers) {
@Nullable
Column<String> colEnabled = enabledColumn.get(); // Not boolean: YES, NO, or PENDING
Column<Long> colFiatPrice = new FiatColumn(format(COL_HEADER_DETAILED_PRICE, fiatTradeCurrency.get()));
Column<String> colFiatPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE, fiatTradeCurrency.get()), RIGHT);
Column<Long> colFiatVolume = new FiatColumn(format("Temp Volume (%s)", fiatTradeCurrency.get()), NONE, VOLUME);
Column<Long> colMinFiatVolume = new FiatColumn(format("Temp Min Volume (%s)", fiatTradeCurrency.get()), NONE, VOLUME);
@Nullable
@ -121,7 +121,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
if (isShowingMyOffers.get()) {
return new Table(colEnabled.asStringColumn(),
colDirection,
colFiatPrice.asStringColumn(),
colFiatPrice.justify(),
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
colTriggerPrice.asStringColumn(),
@ -130,7 +130,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
colOfferId);
} else {
return new Table(colDirection,
colFiatPrice.asStringColumn(),
colFiatPrice.justify(),
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
colPaymentMethod,
@ -143,7 +143,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
public Table buildCryptoCurrencyOfferTable(List<OfferInfo> offers) {
@Nullable
Column<String> colEnabled = enabledColumn.get(); // Not boolean: YES, NO, or PENDING
Column<Long> colBtcPrice = new SatoshiColumn(format(COL_HEADER_DETAILED_PRICE_OF_ALTCOIN, altcoinTradeCurrency.get()));
Column<String> colBtcPrice = new StringColumn(format(COL_HEADER_DETAILED_PRICE_OF_ALTCOIN, altcoinTradeCurrency.get()), RIGHT);
Column<Long> colBtcVolume = new AltcoinColumn(format("Temp Volume (%s)", altcoinTradeCurrency.get()),
NONE,
ALTCOIN_OFFER_VOLUME);
@ -189,7 +189,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
if (isShowingBsqOffers.get()) {
return new Table(colEnabled.asStringColumn(),
colDirection,
colBtcPrice.asStringColumn(),
colBtcPrice.justify(),
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
colPaymentMethod,
@ -198,7 +198,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
} else {
return new Table(colEnabled.asStringColumn(),
colDirection,
colBtcPrice.asStringColumn(),
colBtcPrice.justify(),
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
colTriggerPrice.asStringColumn(),
@ -208,7 +208,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
}
} else {
return new Table(colDirection,
colBtcPrice.asStringColumn(),
colBtcPrice.justify(),
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
colPaymentMethod,