Skip to content

Commit

Permalink
Add asBsqFromValue method to Coin
Browse files Browse the repository at this point in the history
Format BSQ display
  • Loading branch information
HenrikJannsen committed Apr 25, 2024
1 parent a43207d commit 55ba6b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.desktop.main.content.user.reputation.list;

import bisq.common.monetary.Coin;
import bisq.desktop.common.threading.UIThread;
import bisq.desktop.common.view.View;
import bisq.desktop.components.table.BisqTableColumn;
Expand All @@ -25,6 +26,7 @@
import bisq.desktop.main.content.components.ReputationScoreDisplay;
import bisq.desktop.main.content.components.UserProfileIcon;
import bisq.i18n.Res;
import bisq.presentation.formatters.AmountFormatter;
import bisq.presentation.formatters.TimeFormatter;
import bisq.user.profile.UserProfile;
import bisq.user.reputation.ReputationScore;
Expand Down Expand Up @@ -268,7 +270,7 @@ void applyReputationScore(String userProfileId) {
switch (selectedReputationSource.get()) {
case BURNED_BSQ:
case BSQ_BOND:
valueProperty.set(String.valueOf(value));
valueProperty.set(AmountFormatter.formatAmount(Coin.asBsqFromValue(value)));
break;
case PROFILE_AGE:
case BISQ1_ACCOUNT_AGE:
Expand Down
15 changes: 15 additions & 0 deletions common/src/main/java/bisq/common/monetary/Coin.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ public static Coin asBtcFromFaceValue(double faceValue) {
return new Coin(faceValue, "BTC", 8);
}

/**
* @param value Value as smallest unit the Coin object can represent.
*/
public static Coin asBsqFromValue(long value) {
return new Coin(value, "BSQ", 2);
}

/**
* @param faceValue Coin value as face value. E.g. 1.123456789012 XMR
*/
public static Coin asBsqFromFaceValue(double faceValue) {
return new Coin(faceValue, "BSQ", 2);
}


/**
* @param value Value as smallest unit the Coin object can represent.
*/
Expand Down

0 comments on commit 55ba6b8

Please sign in to comment.