Fix: Asset decimals on select asset screen (#18427)
* fix: assets decimals
This commit is contained in:
parent
623d4a1476
commit
ec2b95c370
|
@ -0,0 +1,5 @@
|
||||||
|
{:lint-as
|
||||||
|
{rewrite-clj.zip/subedit-> clojure.core/->
|
||||||
|
rewrite-clj.zip/subedit->> clojure.core/->>
|
||||||
|
rewrite-clj.zip/edit-> clojure.core/->
|
||||||
|
rewrite-clj.zip/edit->> clojure.core/->>}}
|
|
@ -0,0 +1 @@
|
||||||
|
{:hooks {:analyze-call {taoensso.encore/defalias taoensso.encore/defalias}}}
|
|
@ -0,0 +1,16 @@
|
||||||
|
(ns taoensso.encore
|
||||||
|
(:require
|
||||||
|
[clj-kondo.hooks-api :as hooks]))
|
||||||
|
|
||||||
|
(defn defalias [{:keys [node]}]
|
||||||
|
(let [[sym-raw src-raw] (rest (:children node))
|
||||||
|
src (if src-raw src-raw sym-raw)
|
||||||
|
sym (if src-raw
|
||||||
|
sym-raw
|
||||||
|
(symbol (name (hooks/sexpr src))))]
|
||||||
|
{:node (with-meta
|
||||||
|
(hooks/list-node
|
||||||
|
[(hooks/token-node 'def)
|
||||||
|
(hooks/token-node (hooks/sexpr sym))
|
||||||
|
(hooks/token-node (hooks/sexpr src))])
|
||||||
|
(meta src))}))
|
|
@ -27,7 +27,7 @@
|
||||||
(def info
|
(def info
|
||||||
{:flex-direction :row
|
{:flex-direction :row
|
||||||
:align-items :center
|
:align-items :center
|
||||||
:width "70%"})
|
:width "60%"})
|
||||||
|
|
||||||
(def token-info
|
(def token-info
|
||||||
{:height 40
|
{:height 40
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
(def values-container
|
(def values-container
|
||||||
{:align-items :flex-end
|
{:align-items :flex-end
|
||||||
:max-width "30%"})
|
:max-width "40%"})
|
||||||
|
|
||||||
(defn fiat-value
|
(defn fiat-value
|
||||||
[theme]
|
[theme]
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn token-value-drawer
|
(defn token-value-drawer
|
||||||
[]
|
[token]
|
||||||
|
(let [token-data (first (rf/sub [:wallet/tokens-filtered (:token token)]))]
|
||||||
[:<>
|
[:<>
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[{:icon :i/buy
|
[[{:icon :i/buy
|
||||||
|
@ -14,20 +15,28 @@
|
||||||
:right-icon :i/external}
|
:right-icon :i/external}
|
||||||
{:icon :i/send
|
{:icon :i/send
|
||||||
:accessibility-label :send
|
:accessibility-label :send
|
||||||
:label (i18n/label :t/send)}
|
:label (i18n/label :t/send)
|
||||||
|
:on-press (fn []
|
||||||
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
(rf/dispatch [:wallet/send-select-token-drawer {:token token-data}])
|
||||||
|
(rf/dispatch [:open-modal :wallet-select-address]))}
|
||||||
{:icon :i/receive
|
{:icon :i/receive
|
||||||
:accessibility-label :receive
|
:accessibility-label :receive
|
||||||
:label (i18n/label :t/receive)}
|
:label (i18n/label :t/receive)
|
||||||
|
:on-press #(js/alert "to be implemented")}
|
||||||
{:icon :i/bridge
|
{:icon :i/bridge
|
||||||
:accessibility-label :bridge
|
:accessibility-label :bridge
|
||||||
:label (i18n/label :t/bridge)}
|
:label (i18n/label :t/bridge)
|
||||||
|
:on-press #(js/alert "to be implemented")}
|
||||||
{:icon :i/settings
|
{:icon :i/settings
|
||||||
:accessibility-label :settings
|
:accessibility-label :settings
|
||||||
:label (i18n/label :t/manage-tokens)
|
:label (i18n/label :t/manage-tokens)
|
||||||
|
:on-press #(js/alert "to be implemented")
|
||||||
:add-divider? true}
|
:add-divider? true}
|
||||||
{:icon :i/hide
|
{:icon :i/hide
|
||||||
:accessibility-label :hide
|
:accessibility-label :hide
|
||||||
:label (i18n/label :t/hide)}]]]])
|
:label (i18n/label :t/hide)
|
||||||
|
:on-press #(js/alert "to be implemented")}]]]]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[item]
|
[item]
|
||||||
|
@ -36,5 +45,5 @@
|
||||||
{:on-long-press
|
{:on-long-press
|
||||||
#(rf/dispatch
|
#(rf/dispatch
|
||||||
[:show-bottom-sheet
|
[:show-bottom-sheet
|
||||||
{:content token-value-drawer
|
{:content (fn [] [token-value-drawer item])
|
||||||
:selected-item (fn [] [quo/token-value item])}])})])
|
:selected-item (fn [] [quo/token-value item])}])})])
|
||||||
|
|
|
@ -173,6 +173,12 @@
|
||||||
constants/optimism-chain-id :optimism
|
constants/optimism-chain-id :optimism
|
||||||
constants/arbitrum-chain-id :arbitrum})
|
constants/arbitrum-chain-id :arbitrum})
|
||||||
|
|
||||||
|
(defn get-standard-fiat-format
|
||||||
|
[crypto-value currency-symbol fiat-value]
|
||||||
|
(if (string/includes? crypto-value "<")
|
||||||
|
"<$0.01"
|
||||||
|
(prettify-balance currency-symbol fiat-value)))
|
||||||
|
|
||||||
(defn calculate-token-value
|
(defn calculate-token-value
|
||||||
"This function returns token values in the props of token-value (quo) component"
|
"This function returns token values in the props of token-value (quo) component"
|
||||||
[{:keys [token color currency currency-symbol]}]
|
[{:keys [token color currency currency-symbol]}]
|
||||||
|
@ -184,9 +190,7 @@
|
||||||
constants/profile-default-currency]))
|
constants/profile-default-currency]))
|
||||||
{:keys [change-pct-24hour]} market-values
|
{:keys [change-pct-24hour]} market-values
|
||||||
crypto-value (get-standard-crypto-format token token-units)
|
crypto-value (get-standard-crypto-format token token-units)
|
||||||
fiat-value (if (string/includes? crypto-value "<")
|
fiat-value (get-standard-fiat-format crypto-value currency-symbol fiat-value)]
|
||||||
"<$0.01"
|
|
||||||
(prettify-balance currency-symbol fiat-value))]
|
|
||||||
{:token (:symbol token)
|
{:token (:symbol token)
|
||||||
:token-name (:name token)
|
:token-name (:name token)
|
||||||
:state :default
|
:state :default
|
||||||
|
|
|
@ -47,18 +47,24 @@
|
||||||
(update-in [:wallet :ui :send] dissoc :to-address))
|
(update-in [:wallet :ui :send] dissoc :to-address))
|
||||||
:fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]}))
|
:fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/select-send-address
|
(fn [{:keys [db]} [{:keys [address token stack-id]}]]
|
||||||
(fn [{:keys [db]} [{:keys [address stack-id]}]]
|
{:db (assoc-in db [:wallet :ui :send :to-address] address)
|
||||||
{:db (-> db
|
:fx [[:navigate-to-within-stack
|
||||||
(assoc-in [:wallet :ui :send :to-address] address)
|
(if token [:wallet-send-input-amount stack-id] [:wallet-select-asset stack-id])]]})
|
||||||
(update-in [:wallet :ui :send] dissoc :send-account-address))
|
|
||||||
:fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/send-select-token
|
(rf/reg-event-fx :wallet/send-select-token
|
||||||
(fn [{:keys [db]} [{:keys [token stack-id]}]]
|
(fn [{:keys [db]} [{:keys [token stack-id]}]]
|
||||||
{:db (assoc-in db [:wallet :ui :send :token] token)
|
{:db (assoc-in db [:wallet :ui :send :token] token)
|
||||||
:fx [[:navigate-to-within-stack [:wallet-send-input-amount stack-id]]]}))
|
:fx [[:navigate-to-within-stack [:wallet-send-input-amount stack-id]]]}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :wallet/send-select-token-drawer
|
||||||
|
(fn [{:keys [db]} [{:keys [token]}]]
|
||||||
|
{:db (assoc-in db [:wallet :ui :send :token] token)}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :wallet/clean-selected-token
|
||||||
|
(fn [{:keys [db]}]
|
||||||
|
{:db (assoc-in db [:wallet :ui :send :token] nil)}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/send-select-amount
|
(rf/reg-event-fx :wallet/send-select-amount
|
||||||
(fn [{:keys [db]} [{:keys [amount stack-id]}]]
|
(fn [{:keys [db]} [{:keys [amount stack-id]}]]
|
||||||
{:db (assoc-in db [:wallet :ui :send :amount] amount)
|
{:db (assoc-in db [:wallet :ui :send :amount] amount)
|
||||||
|
|
|
@ -155,7 +155,9 @@
|
||||||
:left-action :dot
|
:left-action :dot
|
||||||
:delete-key? true
|
:delete-key? true
|
||||||
:on-press handle-keyboard-press
|
:on-press handle-keyboard-press
|
||||||
:on-delete handle-delete}]]))))
|
:on-delete handle-delete}]
|
||||||
|
]
|
||||||
|
))))
|
||||||
|
|
||||||
(defn- view-internal
|
(defn- view-internal
|
||||||
[props]
|
[props]
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[react-native.safe-area :as safe-area]
|
[react-native.safe-area :as safe-area]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||||
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.send.select-asset.style :as style]
|
[status-im.contexts.wallet.send.select-asset.style :as style]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
@ -16,27 +17,32 @@
|
||||||
|
|
||||||
(defn- asset-component
|
(defn- asset-component
|
||||||
[]
|
[]
|
||||||
(fn [token _ _ _]
|
(fn [token _ _ {:keys [currency currency-symbol]}]
|
||||||
(let [on-press
|
(let [on-press
|
||||||
#(rf/dispatch [:wallet/send-select-token
|
#(rf/dispatch [:wallet/send-select-token
|
||||||
{:token token
|
{:token token
|
||||||
:stack-id :wallet-select-asset}])
|
:stack-id :wallet-select-asset}])
|
||||||
total-balance-formatted (.toFixed (:total-balance token) 2)
|
token-units (utils/total-token-units-in-all-chains token)
|
||||||
balance-fiat-formatted (.toFixed (:total-balance-fiat token) 2)
|
crypto-formatted (utils/get-standard-crypto-format token token-units)
|
||||||
currency-symbol (rf/sub [:profile/currency-symbol])]
|
fiat-value (utils/total-token-fiat-value currency token)
|
||||||
|
fiat-formatted (utils/get-standard-fiat-format crypto-formatted currency-symbol fiat-value)]
|
||||||
[quo/token-network
|
[quo/token-network
|
||||||
{:token (:symbol token)
|
{:token (:symbol token)
|
||||||
:label (:name token)
|
:label (:name token)
|
||||||
:token-value (str total-balance-formatted " " (:symbol token))
|
:token-value (str crypto-formatted " " (:symbol token))
|
||||||
:fiat-value (str currency-symbol balance-fiat-formatted)
|
:fiat-value fiat-formatted
|
||||||
:networks (:networks token)
|
:networks (:networks token)
|
||||||
:on-press on-press}])))
|
:on-press on-press}])))
|
||||||
|
|
||||||
(defn- asset-list
|
(defn- asset-list
|
||||||
[search-text]
|
[search-text]
|
||||||
(let [filtered-tokens (rf/sub [:wallet/tokens-filtered search-text])]
|
(let [filtered-tokens (rf/sub [:wallet/tokens-filtered search-text])
|
||||||
|
currency (rf/sub [:profile/currency])
|
||||||
|
currency-symbol (rf/sub [:profile/currency-symbol])]
|
||||||
[rn/flat-list
|
[rn/flat-list
|
||||||
{:data filtered-tokens
|
{:data filtered-tokens
|
||||||
|
:render-data {:currency currency
|
||||||
|
:currency-symbol currency-symbol}
|
||||||
:style {:flex 1}
|
:style {:flex 1}
|
||||||
:content-container-style {:padding-horizontal 8}
|
:content-container-style {:padding-horizontal 8}
|
||||||
:keyboard-should-persist-taps :handled
|
:keyboard-should-persist-taps :handled
|
||||||
|
|
Loading…
Reference in New Issue