Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with wrong base currency #1913

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions core/src/main/java/bisq/core/offer/OfferPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package bisq.core.offer;

import bisq.core.locale.CurrencyUtil;

import bisq.network.p2p.NodeAddress;
import bisq.network.p2p.storage.payload.ExpirablePayload;
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
Expand Down Expand Up @@ -372,7 +370,7 @@ public PublicKey getOwnerPubKey() {
// The rest of the app does not support yet that concept of base currency and counter currencies
// so we map here for convenience
public String getCurrencyCode() {
return CurrencyUtil.isCryptoCurrency(getBaseCurrencyCode()) ? getBaseCurrencyCode() : getCounterCurrencyCode();
return getBaseCurrencyCode().equals("BTC") ? getCounterCurrencyCode() : getBaseCurrencyCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void onAllServicesInitialized() {

Map<String, Tuple2<Long, Integer>> tradeStatMap = new HashMap<>();
tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
.filter(e -> !e.getBaseCurrency().equals("BTC"))
.filter(e -> CurrencyUtil.isCryptoCurrency(e.getBaseCurrency()))
.filter(e -> e.getTradeDate().getTime() > compareDate.getTime())
.forEach(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package bisq.core.trade.statistics;

import bisq.core.locale.CurrencyUtil;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.AltcoinExchangeRate;
import bisq.core.monetary.Price;
Expand Down Expand Up @@ -223,7 +222,7 @@ public Price getTradePrice() {
}

public String getCurrencyCode() {
return CurrencyUtil.isCryptoCurrency(baseCurrency) ? baseCurrency : counterCurrency;
return baseCurrency.equals("BTC") ? counterCurrency : baseCurrency;
}

public Coin getTradeAmount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package bisq.core.trade.statistics;

import bisq.core.locale.CurrencyUtil;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.AltcoinExchangeRate;
import bisq.core.monetary.Price;
Expand Down Expand Up @@ -248,7 +247,7 @@ public Price getTradePrice() {
}

public String getCurrencyCode() {
return CurrencyUtil.isCryptoCurrency(baseCurrency) ? baseCurrency : counterCurrency;
return baseCurrency.equals("BTC") ? counterCurrency : baseCurrency;
}

public Coin getTradeAmount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public void testMaxCharactersForFiatBuyPrice() {
model.activate();
assertEquals(7, model.maxPlacesForBuyPrice.intValue());
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.price, 94016475L))));
assertEquals(7, model.maxPlacesForBuyPrice.intValue());
assertEquals(9, model.maxPlacesForBuyPrice.intValue()); // 9401.6475
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.price, 101016475L))));
assertEquals(7, model.maxPlacesForBuyPrice.intValue());
assertEquals(10, model.maxPlacesForBuyPrice.intValue()); //10101.6475
}

@Test
Expand All @@ -132,9 +132,9 @@ public void testMaxCharactersForFiatBuyVolume() {
model.activate();
assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //0.01
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //10.00
assertEquals(5, model.maxPlacesForBuyVolume.intValue()); //10.00
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //2212.86
assertEquals(7, model.maxPlacesForBuyVolume.intValue()); //2212.86
}

@Test
Expand Down Expand Up @@ -179,11 +179,11 @@ public void testMaxCharactersForFiatSellPrice() {

final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, null, new BSFormatter());
model.activate();
assertEquals(7, model.maxPlacesForSellPrice.intValue());
assertEquals(7, model.maxPlacesForSellPrice.intValue()); // 10.0000 default price
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 94016475L))));
assertEquals(7, model.maxPlacesForSellPrice.intValue());
assertEquals(9, model.maxPlacesForSellPrice.intValue()); // 9401.6475
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.price, 101016475L))));
assertEquals(7, model.maxPlacesForSellPrice.intValue());
assertEquals(10, model.maxPlacesForSellPrice.intValue()); // 10101.6475
}

@Test
Expand All @@ -210,8 +210,8 @@ public void testMaxCharactersForFiatSellVolume() {
model.activate();
assertEquals(4, model.maxPlacesForSellVolume.intValue()); //0.01
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
assertEquals(4, model.maxPlacesForSellVolume.intValue()); //10.00
assertEquals(5, model.maxPlacesForSellVolume.intValue()); //10.00
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
assertEquals(4, model.maxPlacesForSellVolume.intValue()); //2212.86
assertEquals(7, model.maxPlacesForSellVolume.intValue()); //2212.86
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void testFormatCoin() {

@Test
public void testFormatVolume() {
assertEquals("0.01", formatter.formatVolume(make(btcUsdOffer), true, 4));
assertEquals("1.00", formatter.formatVolume(make(btcUsdOffer), true, 4));
assertEquals("100.00", formatter.formatVolume(make(usdVolume)));
assertEquals("1774.62", formatter.formatVolume(make(usdVolume.but(with(volumeString, "1774.62")))));
}
Expand Down