Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed Jan 3, 2024
1 parent a7b0668 commit e7346b6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/status_im/contexts/wallet/common/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@

(defn calc-max-crypto-decimals
[value]
(let [str-representation (str value)
decimal-part (second (clojure.string/split str-representation #"\."))
exponent (extract-exponent str-representation)
zeroes-count (count (take-while #(= \0 %) decimal-part))
max-decimals (or exponent zeroes-count)]
(let [first-non-zero-digit (first (filter #(not (= \0 %)) decimal-part))]
(if (= \1 first-non-zero-digit)
(inc max-decimals)
max-decimals))))
(let [str-representation (str value)
decimal-part (second (clojure.string/split str-representation #"\."))
exponent (extract-exponent str-representation)
zeroes-count (count (take-while #(= \0 %) decimal-part))
max-decimals (or exponent zeroes-count)
first-non-zero-digit (first (filter #(not (= \0 %)) decimal-part))]
(if (= \1 first-non-zero-digit)
(inc max-decimals)
max-decimals)))

(defn get-standard-crypto-format
"For full details: https://github.com/status-im/status-mobile/issues/18225"
[{:keys [market-values-per-currency]} token-units]
(let [price (get-in market-values-per-currency [:usd :price])
one-cent-value (if (pos? price) (/ 0.01 price) 0)
count (calc-max-crypto-decimals one-cent-value)]
decimals-count (calc-max-crypto-decimals one-cent-value)]
(if (< token-units one-cent-value)
(str "<" (.toFixed one-cent-value count))
(.toFixed token-units count))))
(str "<" (.toFixed one-cent-value decimals-count))
(.toFixed token-units decimals-count))))

(defn total-token-units-in-all-chains
[{:keys [balances-per-chain decimals] :as _token}]
Expand Down

0 comments on commit e7346b6

Please sign in to comment.