mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 18:46:19 +00:00
Truncate decimal values beyond 6 decimal places in signing sheet
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
f4d5beced7
commit
76296870d1
@ -21,7 +21,8 @@
|
|||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[status-im.ui.screens.signing.styles :as styles]
|
[status-im.ui.screens.signing.styles :as styles]
|
||||||
[status-im.react-native.resources :as resources]
|
[status-im.react-native.resources :as resources]
|
||||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]))
|
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||||
|
[status-im.utils.utils :as utils]))
|
||||||
|
|
||||||
(defn hide-panel-anim
|
(defn hide-panel-anim
|
||||||
[bottom-anim-value alpha-value window-height]
|
[bottom-anim-value alpha-value window-height]
|
||||||
@ -229,7 +230,7 @@
|
|||||||
:title :t/send-request-amount
|
:title :t/send-request-amount
|
||||||
:error amount-error
|
:error amount-error
|
||||||
:accessories [[react/nested-text {:style {:color colors/gray}}
|
:accessories [[react/nested-text {:style {:color colors/gray}}
|
||||||
[{:style {:color colors/black}} (str (or amount 0))]
|
[{:style {:color colors/black}} (utils/format-decimals amount 6)]
|
||||||
" "
|
" "
|
||||||
(or display-symbol fee-display-symbol)
|
(or display-symbol fee-display-symbol)
|
||||||
" • "
|
" • "
|
||||||
@ -249,7 +250,7 @@
|
|||||||
:title :t/network-fee
|
:title :t/network-fee
|
||||||
:error gas-error
|
:error gas-error
|
||||||
:accessories [[react/nested-text {:style {:color colors/gray}}
|
:accessories [[react/nested-text {:style {:color colors/gray}}
|
||||||
[{:style {:color colors/black}} fee]
|
[{:style {:color colors/black}} (utils/format-decimals fee 6)]
|
||||||
" "
|
" "
|
||||||
fee-display-symbol
|
fee-display-symbol
|
||||||
" • "
|
" • "
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
(ns status-im.utils.utils
|
(ns status-im.utils.utils
|
||||||
(:require [status-im.i18n :as i18n]
|
(:require [clojure.string :as string]
|
||||||
|
[goog.string :as gstring]
|
||||||
|
[goog.string.format]
|
||||||
|
[status-im.i18n :as i18n]
|
||||||
[status-im.react-native.js-dependencies :as rn-dependencies]
|
[status-im.react-native.js-dependencies :as rn-dependencies]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
@ -151,3 +154,9 @@
|
|||||||
(if platform/desktop?
|
(if platform/desktop?
|
||||||
(js/clearInterval id)
|
(js/clearInterval id)
|
||||||
(.clearInterval rn-dependencies/background-timer id)))
|
(.clearInterval rn-dependencies/background-timer id)))
|
||||||
|
|
||||||
|
(defn format-decimals [amount places]
|
||||||
|
(let [decimal-part (get (string/split (str amount) ".") 1)]
|
||||||
|
(if (> (count decimal-part) places)
|
||||||
|
(gstring/format (str "%." places "f") amount)
|
||||||
|
(or (str amount) 0))))
|
@ -49,3 +49,9 @@
|
|||||||
(is (= {:a 1 :b 2} (u/deep-merge {:a 1} {:b 2})))
|
(is (= {:a 1 :b 2} (u/deep-merge {:a 1} {:b 2})))
|
||||||
(is (= {:a {:b 1 :c 2}} (u/deep-merge {:a {:b 1 :c 1}} {:a {:c 2}})))
|
(is (= {:a {:b 1 :c 2}} (u/deep-merge {:a {:b 1 :c 1}} {:a {:c 2}})))
|
||||||
(is (= {:a {:b {:c 2}} :d 1} (u/deep-merge {:a {:b {:c 1}} :d 1} {:a {:b {:c 2}}}))))
|
(is (= {:a {:b {:c 2}} :d 1} (u/deep-merge {:a {:b {:c 1}} :d 1} {:a {:b {:c 2}}}))))
|
||||||
|
|
||||||
|
(deftest format-decimals-test
|
||||||
|
(is (= "1" (uu/format-decimals 1 5)))
|
||||||
|
(is (= "1.1" (uu/format-decimals 1.1 5)))
|
||||||
|
(is (= "1.111111" (uu/format-decimals 1.111111 7)))
|
||||||
|
(is (= "1.1" (uu/format-decimals 1.111 1))))
|
Loading…
x
Reference in New Issue
Block a user