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: very small token values are being displayed in scientific format #19349

Merged
merged 1 commit into from
Mar 25, 2024
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
11 changes: 6 additions & 5 deletions src/status_im/subs/communities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -306,12 +306,13 @@
[checking-permissions?
token-images
{:keys [satisfied criteria]}]
(let [sym (:symbol criteria)
amount (:amount criteria)]
(let [sym (:symbol criteria)
amount-in-wei (: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 amount-in-wei decimals))
:img-src (get token-images sym)}))

(re-frame/reg-sub
Expand Down
30 changes: 17 additions & 13 deletions src/status_im/subs/communities_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down