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
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:width "70%"})
|
||||
:width "60%"})
|
||||
|
||||
(def token-info
|
||||
{:height 40
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
(def values-container
|
||||
{:align-items :flex-end
|
||||
:max-width "30%"})
|
||||
:max-width "40%"})
|
||||
|
||||
(defn fiat-value
|
||||
[theme]
|
||||
|
|
|
@ -4,30 +4,39 @@
|
|||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn token-value-drawer
|
||||
[]
|
||||
[:<>
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/buy
|
||||
:accessibility-label :buy
|
||||
:label (i18n/label :t/buy)
|
||||
:on-press #(js/alert "to be implemented")
|
||||
:right-icon :i/external}
|
||||
{:icon :i/send
|
||||
:accessibility-label :send
|
||||
:label (i18n/label :t/send)}
|
||||
{:icon :i/receive
|
||||
:accessibility-label :receive
|
||||
:label (i18n/label :t/receive)}
|
||||
{:icon :i/bridge
|
||||
:accessibility-label :bridge
|
||||
:label (i18n/label :t/bridge)}
|
||||
{:icon :i/settings
|
||||
:accessibility-label :settings
|
||||
:label (i18n/label :t/manage-tokens)
|
||||
:add-divider? true}
|
||||
{:icon :i/hide
|
||||
:accessibility-label :hide
|
||||
:label (i18n/label :t/hide)}]]]])
|
||||
[token]
|
||||
(let [token-data (first (rf/sub [:wallet/tokens-filtered (:token token)]))]
|
||||
[:<>
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/buy
|
||||
:accessibility-label :buy
|
||||
:label (i18n/label :t/buy)
|
||||
:on-press #(js/alert "to be implemented")
|
||||
:right-icon :i/external}
|
||||
{:icon :i/send
|
||||
:accessibility-label :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
|
||||
:accessibility-label :receive
|
||||
:label (i18n/label :t/receive)
|
||||
:on-press #(js/alert "to be implemented")}
|
||||
{:icon :i/bridge
|
||||
:accessibility-label :bridge
|
||||
:label (i18n/label :t/bridge)
|
||||
:on-press #(js/alert "to be implemented")}
|
||||
{:icon :i/settings
|
||||
:accessibility-label :settings
|
||||
:label (i18n/label :t/manage-tokens)
|
||||
:on-press #(js/alert "to be implemented")
|
||||
:add-divider? true}
|
||||
{:icon :i/hide
|
||||
:accessibility-label :hide
|
||||
:label (i18n/label :t/hide)
|
||||
:on-press #(js/alert "to be implemented")}]]]]))
|
||||
|
||||
(defn view
|
||||
[item]
|
||||
|
@ -36,5 +45,5 @@
|
|||
{:on-long-press
|
||||
#(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content token-value-drawer
|
||||
{:content (fn [] [token-value-drawer item])
|
||||
:selected-item (fn [] [quo/token-value item])}])})])
|
||||
|
|
|
@ -173,6 +173,12 @@
|
|||
constants/optimism-chain-id :optimism
|
||||
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
|
||||
"This function returns token values in the props of token-value (quo) component"
|
||||
[{:keys [token color currency currency-symbol]}]
|
||||
|
@ -184,9 +190,7 @@
|
|||
constants/profile-default-currency]))
|
||||
{:keys [change-pct-24hour]} market-values
|
||||
crypto-value (get-standard-crypto-format token token-units)
|
||||
fiat-value (if (string/includes? crypto-value "<")
|
||||
"<$0.01"
|
||||
(prettify-balance currency-symbol fiat-value))]
|
||||
fiat-value (get-standard-fiat-format crypto-value currency-symbol fiat-value)]
|
||||
{:token (:symbol token)
|
||||
:token-name (:name token)
|
||||
:state :default
|
||||
|
|
|
@ -47,18 +47,24 @@
|
|||
(update-in [:wallet :ui :send] dissoc :to-address))
|
||||
:fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/select-send-address
|
||||
(fn [{:keys [db]} [{:keys [address stack-id]}]]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :to-address] address)
|
||||
(update-in [:wallet :ui :send] dissoc :send-account-address))
|
||||
:fx [[:navigate-to-within-stack [:wallet-select-asset stack-id]]]}))
|
||||
(fn [{:keys [db]} [{:keys [address token stack-id]}]]
|
||||
{:db (assoc-in db [:wallet :ui :send :to-address] address)
|
||||
:fx [[:navigate-to-within-stack
|
||||
(if token [:wallet-send-input-amount stack-id] [:wallet-select-asset stack-id])]]})
|
||||
|
||||
(rf/reg-event-fx :wallet/send-select-token
|
||||
(fn [{:keys [db]} [{:keys [token stack-id]}]]
|
||||
{:db (assoc-in db [:wallet :ui :send :token] token)
|
||||
: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
|
||||
(fn [{:keys [db]} [{:keys [amount stack-id]}]]
|
||||
{:db (assoc-in db [:wallet :ui :send :amount] amount)
|
||||
|
|
|
@ -155,7 +155,9 @@
|
|||
:left-action :dot
|
||||
:delete-key? true
|
||||
:on-press handle-keyboard-press
|
||||
:on-delete handle-delete}]]))))
|
||||
:on-delete handle-delete}]
|
||||
]
|
||||
))))
|
||||
|
||||
(defn- view-internal
|
||||
[props]
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[react-native.safe-area :as safe-area]
|
||||
[reagent.core :as reagent]
|
||||
[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]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -16,27 +17,32 @@
|
|||
|
||||
(defn- asset-component
|
||||
[]
|
||||
(fn [token _ _ _]
|
||||
(fn [token _ _ {:keys [currency currency-symbol]}]
|
||||
(let [on-press
|
||||
#(rf/dispatch [:wallet/send-select-token
|
||||
{:token token
|
||||
:stack-id :wallet-select-asset}])
|
||||
total-balance-formatted (.toFixed (:total-balance token) 2)
|
||||
balance-fiat-formatted (.toFixed (:total-balance-fiat token) 2)
|
||||
currency-symbol (rf/sub [:profile/currency-symbol])]
|
||||
token-units (utils/total-token-units-in-all-chains token)
|
||||
crypto-formatted (utils/get-standard-crypto-format token token-units)
|
||||
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
|
||||
{:token (:symbol token)
|
||||
:label (:name token)
|
||||
:token-value (str total-balance-formatted " " (:symbol token))
|
||||
:fiat-value (str currency-symbol balance-fiat-formatted)
|
||||
:token-value (str crypto-formatted " " (:symbol token))
|
||||
:fiat-value fiat-formatted
|
||||
:networks (:networks token)
|
||||
:on-press on-press}])))
|
||||
|
||||
(defn- asset-list
|
||||
[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
|
||||
{:data filtered-tokens
|
||||
:render-data {:currency currency
|
||||
:currency-symbol currency-symbol}
|
||||
:style {:flex 1}
|
||||
:content-container-style {:padding-horizontal 8}
|
||||
:keyboard-should-persist-taps :handled
|
||||
|
|
Loading…
Reference in New Issue