Skip to content

Commit

Permalink
Merge pull request #3244 from bodymindarts/extract-ParsingUtils
Browse files Browse the repository at this point in the history
Extract helper classes from BSFormatter
  • Loading branch information
freimair authored Sep 12, 2019
2 parents eba6ab9 + 3b46f35 commit 2e72776
Show file tree
Hide file tree
Showing 67 changed files with 770 additions and 622 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/dao/state/DaoStateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import bisq.core.dao.state.model.governance.Issuance;
import bisq.core.dao.state.model.governance.IssuanceType;
import bisq.core.dao.state.model.governance.ParamChange;
import bisq.core.util.BSFormatter;
import bisq.core.util.BsqFormatter;
import bisq.core.util.ParsingUtils;

import org.bitcoinj.core.Coin;

Expand Down Expand Up @@ -924,7 +924,7 @@ public Coin getParamValueAsCoin(Param param, String paramValue) {
}

public double getParamValueAsPercentDouble(String paramValue) {
return BSFormatter.parsePercentStringToDouble(paramValue);
return ParsingUtils.parsePercentStringToDouble(paramValue);
}

public int getParamValueAsBlock(String paramValue) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/monetary/Altcoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.monetary;

import bisq.core.util.BSFormatter;
import bisq.core.util.ParsingUtils;

import org.bitcoinj.core.Monetary;
import org.bitcoinj.utils.MonetaryFormat;
Expand Down Expand Up @@ -89,7 +89,7 @@ public String getCurrencyCode() {
* @throws IllegalArgumentException if you try to specify fractional satoshis, or a value out of range.
*/
public static Altcoin parseAltcoin(final String currencyCode, String input) {
String cleaned = BSFormatter.convertCharsForNumber(input);
String cleaned = ParsingUtils.convertCharsForNumber(input);
try {
long val = new BigDecimal(cleaned).movePointRight(SMALLEST_UNIT_EXPONENT)
.toBigIntegerExact().longValue();
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/monetary/Price.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package bisq.core.monetary;

import bisq.core.locale.CurrencyUtil;
import bisq.core.util.BSFormatter;
import bisq.core.util.ParsingUtils;

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Monetary;
Expand Down Expand Up @@ -58,7 +58,7 @@ public Price(Monetary monetary) {
* @return The parsed Price.
*/
public static Price parse(String currencyCode, String input) {
String cleaned = BSFormatter.convertCharsForNumber(input);
String cleaned = ParsingUtils.convertCharsForNumber(input);
if (CurrencyUtil.isFiatCurrency(currencyCode))
return new Price(Fiat.parseFiat(currencyCode, cleaned));
else
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/monetary/Volume.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package bisq.core.monetary;

import bisq.core.locale.CurrencyUtil;
import bisq.core.util.BSFormatter;
import bisq.core.util.ParsingUtils;

import org.bitcoinj.core.Monetary;
import org.bitcoinj.utils.Fiat;
Expand All @@ -36,7 +36,7 @@ public Volume(Monetary monetary) {
}

public static Volume parse(String input, String currencyCode) {
String cleaned = BSFormatter.convertCharsForNumber(input);
String cleaned = ParsingUtils.convertCharsForNumber(input);
if (CurrencyUtil.isFiatCurrency(currencyCode))
return new Volume(Fiat.parseFiat(currencyCode, cleaned));
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ else if (!isFiatCurrency && !isSellOffer)
String msg = Res.get("account.notifications.marketAlert.message.msg",
direction,
BSFormatter.getCurrencyPair(currencyCode),
formatter.formatPrice(offerPrice),
BSFormatter.formatPrice(offerPrice),
BSFormatter.formatToPercentWithSymbol(ratio / 10000d),
marketDir,
Res.get(offer.getPaymentMethod().getId()),
Expand Down
11 changes: 0 additions & 11 deletions core/src/main/java/bisq/core/offer/OfferUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,6 @@ public static Optional<Volume> getFeeInUserFiatCurrency(Coin makerFee, boolean i
}
}

public static String getFeeWithFiatAmount(Coin makerFeeAsCoin, Optional<Volume> optionalFeeInFiat, BSFormatter formatter) {
String fee = makerFeeAsCoin != null ? formatter.formatCoinWithCode(makerFeeAsCoin) : Res.get("shared.na");
String feeInFiatAsString;
if (optionalFeeInFiat != null && optionalFeeInFiat.isPresent()) {
feeInFiatAsString = formatter.formatVolumeWithCode(optionalFeeInFiat.get());
} else {
feeInFiatAsString = Res.get("shared.na");
}
return Res.get("feeOptionWindow.fee", fee, feeInFiatAsString);
}


public static Map<String, String> getExtraDataMap(AccountAgeWitnessService accountAgeWitnessService,
ReferralIdService referralIdService,
Expand Down
Loading

0 comments on commit 2e72776

Please sign in to comment.