diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 15c2b32290c..c0ec36e2665 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -619,7 +619,7 @@ private void onRemoveOpenOffer(Offer offer) { if (model.isBootstrappedOrShowPopup()) { String key = "RemoveOfferWarning"; if (DontShowAgainLookup.showAgain(key)) { - new Popup<>().warning(Res.get("popup.warning.removeOffer", model.formatter.formatCoinWithCode(offer.getMakerFee()))) + new Popup<>().warning(Res.get("popup.warning.removeOffer", model.getMakerFeeAsString(offer))) .actionButtonText(Res.get("shared.removeOffer")) .onAction(() -> doRemoveOffer(offer)) .closeButtonText(Res.get("shared.dontRemoveOffer")) diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index 063820316fe..dc7983f8e1c 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -48,6 +48,7 @@ import bisq.core.user.Preferences; import bisq.core.user.User; import bisq.core.util.BSFormatter; +import bisq.core.util.BsqFormatter; import bisq.network.p2p.NodeAddress; import bisq.network.p2p.P2PService; @@ -101,7 +102,8 @@ class OfferBookViewModel extends ActivatableViewModel { private final FilterManager filterManager; final AccountAgeWitnessService accountAgeWitnessService; private final Navigation navigation; - final BSFormatter formatter; + private final BSFormatter btcFormatter; + private final BsqFormatter bsqFormatter; final ObjectProperty priceSortTypeProperty = new SimpleObjectProperty<>(); @@ -143,7 +145,8 @@ public OfferBookViewModel(User user, FilterManager filterManager, AccountAgeWitnessService accountAgeWitnessService, Navigation navigation, - BSFormatter formatter) { + BSFormatter btcFormatter, + BsqFormatter bsqFormatter) { super(); this.openOfferManager = openOfferManager; @@ -156,7 +159,8 @@ public OfferBookViewModel(User user, this.filterManager = filterManager; this.accountAgeWitnessService = accountAgeWitnessService; this.navigation = navigation; - this.formatter = formatter; + this.btcFormatter = btcFormatter; + this.bsqFormatter = bsqFormatter; this.filteredItems = new FilteredList<>(offerBook.getOfferBookListItems()); this.sortedItems = new SortedList<>(filteredItems); @@ -343,7 +347,7 @@ String getAmount(OfferBookListItem item) { } private String formatAmount(Offer offer, boolean decimalAligned) { - return DisplayUtils.formatAmount(offer, GUIUtil.AMOUNT_DECIMALS, decimalAligned, maxPlacesForAmount.get(), formatter); + return DisplayUtils.formatAmount(offer, GUIUtil.AMOUNT_DECIMALS, decimalAligned, maxPlacesForAmount.get(), btcFormatter); } @@ -625,4 +629,10 @@ public boolean hasSelectionAccountSigning() { } return true; } + + public String getMakerFeeAsString(Offer offer) { + return offer.isCurrencyForMakerFeeBtc() ? + btcFormatter.formatCoinWithCode(offer.getMakerFee()) : + bsqFormatter.formatCoinWithCode(offer.getMakerFee()); + } } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java index 5ae125f56d9..5ced8ba8d40 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java @@ -169,7 +169,7 @@ private void onRemoveOpenOffer(OpenOffer openOffer) { if (model.isBootstrappedOrShowPopup()) { String key = "RemoveOfferWarning"; if (DontShowAgainLookup.showAgain(key)) { - new Popup<>().warning(Res.get("popup.warning.removeOffer", model.formatter.formatCoinWithCode(openOffer.getOffer().getMakerFee()))) + new Popup<>().warning(Res.get("popup.warning.removeOffer", model.getMakerFeeAsString(openOffer))) .actionButtonText(Res.get("shared.removeOffer")) .onAction(() -> doRemoveOpenOffer(openOffer)) .closeButtonText(Res.get("shared.dontRemoveOffer")) diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersViewModel.java index 32fa03680cc..c362c8a10be 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersViewModel.java @@ -27,6 +27,7 @@ import bisq.core.offer.Offer; import bisq.core.offer.OpenOffer; import bisq.core.util.BSFormatter; +import bisq.core.util.BsqFormatter; import bisq.network.p2p.P2PService; @@ -39,17 +40,20 @@ class OpenOffersViewModel extends ActivatableWithDataModel implements ViewModel { private final P2PService p2PService; - final BSFormatter formatter; + private final BSFormatter btcFormatter; + private final BsqFormatter bsqFormatter; @Inject public OpenOffersViewModel(OpenOffersDataModel dataModel, P2PService p2PService, - BSFormatter formatter) { + BSFormatter btcFormatter, + BsqFormatter bsqFormatter) { super(dataModel); this.p2PService = p2PService; - this.formatter = formatter; + this.btcFormatter = btcFormatter; + this.bsqFormatter = bsqFormatter; } void onActivateOpenOffer(OpenOffer openOffer, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { @@ -73,7 +77,7 @@ String getTradeId(OpenOfferListItem item) { } String getAmount(OpenOfferListItem item) { - return (item != null) ? DisplayUtils.formatAmount(item.getOffer(), formatter) : ""; + return (item != null) ? DisplayUtils.formatAmount(item.getOffer(), btcFormatter) : ""; } String getPrice(OpenOfferListItem item) { @@ -121,4 +125,11 @@ boolean isDeactivated(OpenOfferListItem item) { boolean isBootstrappedOrShowPopup() { return GUIUtil.isBootstrappedOrShowPopup(p2PService); } + + public String getMakerFeeAsString(OpenOffer openOffer) { + Offer offer = openOffer.getOffer(); + return offer.isCurrencyForMakerFeeBtc() ? + btcFormatter.formatCoinWithCode(offer.getMakerFee()) : + bsqFormatter.formatCoinWithCode(offer.getMakerFee()); + } } diff --git a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java index d0224d29774..a4efee143f9 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java @@ -42,6 +42,7 @@ import bisq.core.provider.price.MarketPrice; import bisq.core.provider.price.PriceFeedService; import bisq.core.util.BSFormatter; +import bisq.core.util.BsqFormatter; import javafx.beans.property.SimpleIntegerProperty; @@ -225,7 +226,7 @@ public void testMaxCharactersForAmountWithNoOffes() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); assertEquals(0, model.maxPlacesForAmount.intValue()); } @@ -239,7 +240,7 @@ public void testMaxCharactersForAmount() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(6, model.maxPlacesForAmount.intValue()); @@ -257,7 +258,7 @@ public void testMaxCharactersForAmountRange() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(15, model.maxPlacesForAmount.intValue()); @@ -276,7 +277,7 @@ public void testMaxCharactersForVolumeWithNoOffes() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); assertEquals(0, model.maxPlacesForVolume.intValue()); } @@ -290,7 +291,7 @@ public void testMaxCharactersForVolume() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(8, model.maxPlacesForVolume.intValue()); @@ -308,7 +309,7 @@ public void testMaxCharactersForVolumeRange() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(15, model.maxPlacesForVolume.intValue()); @@ -327,7 +328,7 @@ public void testMaxCharactersForPriceWithNoOffers() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); assertEquals(0, model.maxPlacesForPrice.intValue()); } @@ -341,7 +342,7 @@ public void testMaxCharactersForPrice() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(7, model.maxPlacesForPrice.intValue()); @@ -359,7 +360,7 @@ public void testMaxCharactersForPriceDistanceWithNoOffers() { when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue()); } @@ -387,7 +388,7 @@ public void testMaxCharactersForPriceDistance() { offerBookListItems.addAll(item1, item2); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, priceFeedService, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); model.activate(); assertEquals(8, model.maxPlacesForMarketPriceMargin.intValue()); //" (1.97%)" @@ -408,7 +409,7 @@ public void testGetPrice() { when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true)); final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, - null, null, null, null, new BSFormatter()); + null, null, null, null, new BSFormatter(), new BsqFormatter()); final OfferBookListItem item = make(btcBuyItem.but( with(useMarketBasedPrice, true),