parent
09c4e33834
commit
24f82f0b10
|
@ -7,6 +7,7 @@
|
||||||
[utils.number :as number]
|
[utils.number :as number]
|
||||||
[utils.string]))
|
[utils.string]))
|
||||||
|
|
||||||
|
(def missing-price-decimals 6) ; if we don't have the monetary value of the token, we default to 6 decimals
|
||||||
(defn get-first-name
|
(defn get-first-name
|
||||||
[full-name]
|
[full-name]
|
||||||
(first (string/split full-name #" ")))
|
(first (string/split full-name #" ")))
|
||||||
|
@ -66,16 +67,20 @@
|
||||||
(defn get-standard-crypto-format
|
(defn get-standard-crypto-format
|
||||||
"For full details: https://github.com/status-im/status-mobile/issues/18225"
|
"For full details: https://github.com/status-im/status-mobile/issues/18225"
|
||||||
[{:keys [market-values-per-currency]} token-units]
|
[{:keys [market-values-per-currency]} token-units]
|
||||||
(if (or (nil? token-units)
|
(cond (or (nil? token-units)
|
||||||
(nil? market-values-per-currency)
|
(money/equal-to token-units 0))
|
||||||
(money/equal-to token-units 0))
|
"0"
|
||||||
"0"
|
|
||||||
(let [price (-> market-values-per-currency :usd :price)
|
(nil? (-> market-values-per-currency :usd :price))
|
||||||
one-cent-value (if (pos? price) (/ 0.01 price) 0)
|
(number/remove-trailing-zeroes (.toFixed token-units missing-price-decimals))
|
||||||
decimals-count (calc-max-crypto-decimals one-cent-value)]
|
|
||||||
(if (< token-units one-cent-value)
|
:else
|
||||||
(str "<" (number/remove-trailing-zeroes (.toFixed one-cent-value decimals-count)))
|
(let [price (-> market-values-per-currency :usd :price)
|
||||||
(number/remove-trailing-zeroes (.toFixed token-units decimals-count))))))
|
one-cent-value (if (pos? price) (/ 0.01 price) 0)
|
||||||
|
decimals-count (calc-max-crypto-decimals one-cent-value)]
|
||||||
|
(if (< token-units one-cent-value)
|
||||||
|
(str "<" (number/remove-trailing-zeroes (.toFixed one-cent-value decimals-count)))
|
||||||
|
(number/remove-trailing-zeroes (.toFixed token-units decimals-count))))))
|
||||||
|
|
||||||
(defn get-market-value
|
(defn get-market-value
|
||||||
[currency {:keys [market-values-per-currency]}]
|
[currency {:keys [market-values-per-currency]}]
|
||||||
|
|
|
@ -64,6 +64,11 @@
|
||||||
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
|
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
|
||||||
token-units)
|
token-units)
|
||||||
"0.005")))
|
"0.005")))
|
||||||
|
(let [market-values-per-currency {:usd {:price nil}}
|
||||||
|
token-units (money/bignumber 0.0123456)]
|
||||||
|
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
|
||||||
|
token-units)
|
||||||
|
"0.012346")))
|
||||||
(let [market-values-per-currency {:usd {:price 0.005}}
|
(let [market-values-per-currency {:usd {:price 0.005}}
|
||||||
token-units (money/bignumber 0.01)]
|
token-units (money/bignumber 0.01)]
|
||||||
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
|
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "release/0.182.x",
|
"version": "release/0.182.x",
|
||||||
"commit-sha1": "dd787c982aac6cd2d376c9eb8c5a32a31c8f4405",
|
"commit-sha1": "da70d6f1b5f82e365014f3d18f03e0cfcd02d3c1",
|
||||||
"src-sha256": "0i5s7hdy27xjwb4vfg90w6b336149sdawq8x0xa9ynix0f7i6ixc"
|
"src-sha256": "03p7x3s9005ghi02x334077nxwdhwlkxmvhcnc07lsygfsnzkkzk"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue