mirror of
https://github.com/status-im/status-react.git
synced 2025-02-24 08:38:28 +00:00
This commit is contained in:
parent
5f7d7254e7
commit
d33648917a
@ -30,10 +30,7 @@
|
||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))
|
||||
:container-style style/title-icon-container
|
||||
:accessibility-label :title-icon}])]
|
||||
[address-text/view
|
||||
{:networks (:networks account-props)
|
||||
:address (:address account-props)
|
||||
:format :short}]]])
|
||||
[address-text/view (assoc account-props :format :short)]]])
|
||||
|
||||
(defn- balance-view
|
||||
[{:keys [balance-props type theme]}]
|
||||
|
@ -9,7 +9,7 @@
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- on-press
|
||||
(defn- on-account-press
|
||||
[address network-details]
|
||||
(rf/dispatch [:wallet/select-from-account
|
||||
{:address address
|
||||
@ -22,15 +22,19 @@
|
||||
(rf/dispatch [:navigate-back]))
|
||||
|
||||
(defn- render-fn
|
||||
[item]
|
||||
(let [network-details (rf/sub [:wallet/network-details])]
|
||||
[item _ _ {:keys [network-details]}]
|
||||
(let [transformed-address (rf/sub [:wallet/account-address (:address item)
|
||||
(:network-preferences-names item)])]
|
||||
[quo/account-item
|
||||
{:on-press #(on-press (:address item) network-details)
|
||||
:account-props item}]))
|
||||
{:on-press #(on-account-press (:address item) network-details)
|
||||
:account-props (assoc item
|
||||
:address transformed-address
|
||||
:full-address? true)}]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])]
|
||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])
|
||||
network-details (rf/sub [:wallet/network-details])]
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:header [account-switcher/view
|
||||
@ -45,5 +49,6 @@
|
||||
{:style style/accounts-list
|
||||
:content-container-style style/accounts-list-container
|
||||
:data accounts
|
||||
:render-data {:network-details network-details}
|
||||
:render-fn render-fn
|
||||
:shows-horizontal-scroll-indicator false}]]))
|
||||
|
@ -17,15 +17,21 @@
|
||||
:description (i18n/label :t/here-is-a-cat-in-a-box-instead)
|
||||
:image (resources/get-themed-image :cat-in-box theme)
|
||||
:container-style style/empty-container-style}]
|
||||
(into [rn/view {:style style/my-accounts-container}]
|
||||
(map (fn [{:keys [color address] :as account}]
|
||||
[rn/view {:style style/my-accounts-container}
|
||||
(doall
|
||||
(for [{:keys [color address] :as account} other-accounts]
|
||||
^{:key (str address)}
|
||||
(let [transformed-address (rf/sub [:wallet/account-address address
|
||||
(:network-preferences-names account)])]
|
||||
[quo/account-item
|
||||
{:account-props (assoc account :customization-color color)
|
||||
{:account-props (assoc account
|
||||
:customization-color color
|
||||
:address transformed-address
|
||||
:full-address? true)
|
||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient account
|
||||
:stack-id :screen/wallet.select-address}])}]))
|
||||
other-accounts))))
|
||||
:stack-id :screen/wallet.select-address}])}])))])))
|
||||
|
||||
(defn- recent-transactions
|
||||
[theme]
|
||||
|
@ -1,7 +1,10 @@
|
||||
(ns status-im.subs.wallet.networks
|
||||
(:require [quo.foundations.resources :as resources]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]))
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]))
|
||||
|
||||
(def max-network-prefixes 2)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/networks
|
||||
@ -88,3 +91,13 @@
|
||||
(filter
|
||||
#(contains? selected-networks (:network-name %))
|
||||
network-details)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet/account-address
|
||||
(fn [_ [_ address network-preferences]]
|
||||
(let [short-names (map network-utils/network->short-name network-preferences)
|
||||
prefix (when (<= (count short-names) max-network-prefixes)
|
||||
(network-utils/short-names->network-preference-prefix
|
||||
short-names))
|
||||
transformed-address (str prefix address)]
|
||||
transformed-address)))
|
||||
|
@ -82,3 +82,14 @@
|
||||
:chain-id 10
|
||||
:layer 2}}
|
||||
(rf/sub [sub-name])))))
|
||||
|
||||
(h/deftest-sub :wallet/account-address
|
||||
[sub-name]
|
||||
(testing
|
||||
"returns the address with prefixes when an address and less than 3 network preferences are passed"
|
||||
(is
|
||||
(match? "eth:0x01" (rf/sub [sub-name "0x01" [:ethereum]]))))
|
||||
(testing
|
||||
"returns the address without the prefixes when an address and equal or more than 3 network preferences are passed"
|
||||
(is
|
||||
(match? "0x01" (rf/sub [sub-name "0x01" [:ethereum :optimism :arbitrum]])))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user