From e0ab6feec6e2b797316dead65401334acd1160d5 Mon Sep 17 00:00:00 2001 From: Ajay Sivan Date: Thu, 21 Mar 2024 17:33:26 +0530 Subject: [PATCH] fix: very small token values are being displayed in scientific format --- src/status_im/subs/communities.cljs | 15 ++++++------ src/status_im/subs/communities_test.cljs | 30 ++++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/status_im/subs/communities.cljs b/src/status_im/subs/communities.cljs index 9fcabd10347a..cb99715a0df0 100644 --- a/src/status_im/subs/communities.cljs +++ b/src/status_im/subs/communities.cljs @@ -4,8 +4,8 @@ [legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] [re-frame.core :as re-frame] [status-im.constants :as constants] - [status-im.contexts.wallet.common.utils :as wallet.utils] - [utils.i18n :as i18n])) + [utils.i18n :as i18n] + [utils.money :as money])) (re-frame/reg-sub :communities/fetching-community @@ -266,8 +266,8 @@ :position position :mentions-count (or unviewed-mentions-count 0) :can-post? can-post? - ;; NOTE: this is a troolean nil->no permissions, true->no access, false -> - ;; has access + ;; NOTE: this is a troolean nil->no permissions, true->no access, false + ;; -> has access :locked? (when token-gated? (and (not can-view?) (not can-post?))) @@ -306,12 +306,13 @@ [checking-permissions? token-images {:keys [satisfied criteria]}] - (let [sym (:symbol criteria) - amount (:amount criteria)] + (let [sym (:symbol criteria) + amountInWei (:amountInWei criteria) + decimals (:decimals criteria)] {:symbol sym :sufficient? satisfied :loading? checking-permissions? - :amount (wallet.utils/remove-trailing-zeroes amount) + :amount (money/to-fixed (money/token->unit amountInWei decimals)) :img-src (get token-images sym)})) (re-frame/reg-sub diff --git a/src/status_im/subs/communities_test.cljs b/src/status_im/subs/communities_test.cljs index 48b131d659a1..ad3f6359d1e6 100644 --- a/src/status_im/subs/communities_test.cljs +++ b/src/status_im/subs/communities_test.cljs @@ -289,19 +289,23 @@ checks {:checking? checking-permissions? :check {:satisfied true - :highestRole {:type constants/community-token-permission-become-admin - :criteria [{:tokenRequirement [{:satisfied true - :criteria {:contract_addresses - {:5 "0x0"} - :type 1 - :symbol "DAI" - :amount "5.0" - :decimals 18}}]} - {:tokenRequirement [{:satisfied false - :criteria {:type 1 - :symbol "ETH" - :amount "0.002" - :decimals 18}}]}]} + :highestRole + {:type constants/community-token-permission-become-admin + :criteria [{:tokenRequirement [{:satisfied true + :criteria {:contract_addresses + {:5 "0x0"} + :type 1 + :symbol "DAI" + :amountInWei + "5000000000000000000" + :amount "5.0" + :decimals 18}}]} + {:tokenRequirement [{:satisfied false + :criteria {:type 1 + :symbol "ETH" + :amountInWei "2000000000000000" + :amount "0.002" + :decimals 18}}]}]} :permissions {:a3dd5b6b-d93b-452c-b22a-09a8f42ec566 {:criteria [true false