From 55ba6b8078b2a41987ff4816e66b37d79df51dba Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Thu, 25 Apr 2024 12:13:12 +0700 Subject: [PATCH] Add asBsqFromValue method to Coin Format BSQ display --- .../user/reputation/list/ReputationListView.java | 4 +++- .../src/main/java/bisq/common/monetary/Coin.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/user/reputation/list/ReputationListView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/user/reputation/list/ReputationListView.java index 2b9f94c63d..3506b9a32c 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/user/reputation/list/ReputationListView.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/user/reputation/list/ReputationListView.java @@ -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; @@ -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; @@ -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: diff --git a/common/src/main/java/bisq/common/monetary/Coin.java b/common/src/main/java/bisq/common/monetary/Coin.java index 5b195f9517..a453c59107 100644 --- a/common/src/main/java/bisq/common/monetary/Coin.java +++ b/common/src/main/java/bisq/common/monetary/Coin.java @@ -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. */