This commit is contained in:
parent
5f7d7254e7
commit
d33648917a
|
@ -30,10 +30,7 @@
|
||||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))
|
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))
|
||||||
:container-style style/title-icon-container
|
:container-style style/title-icon-container
|
||||||
:accessibility-label :title-icon}])]
|
:accessibility-label :title-icon}])]
|
||||||
[address-text/view
|
[address-text/view (assoc account-props :format :short)]]])
|
||||||
{:networks (:networks account-props)
|
|
||||||
:address (:address account-props)
|
|
||||||
:format :short}]]])
|
|
||||||
|
|
||||||
(defn- balance-view
|
(defn- balance-view
|
||||||
[{:keys [balance-props type theme]}]
|
[{:keys [balance-props type theme]}]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- on-press
|
(defn- on-account-press
|
||||||
[address network-details]
|
[address network-details]
|
||||||
(rf/dispatch [:wallet/select-from-account
|
(rf/dispatch [:wallet/select-from-account
|
||||||
{:address address
|
{:address address
|
||||||
|
@ -22,15 +22,19 @@
|
||||||
(rf/dispatch [:navigate-back]))
|
(rf/dispatch [:navigate-back]))
|
||||||
|
|
||||||
(defn- render-fn
|
(defn- render-fn
|
||||||
[item]
|
[item _ _ {:keys [network-details]}]
|
||||||
(let [network-details (rf/sub [:wallet/network-details])]
|
(let [transformed-address (rf/sub [:wallet/account-address (:address item)
|
||||||
|
(:network-preferences-names item)])]
|
||||||
[quo/account-item
|
[quo/account-item
|
||||||
{:on-press #(on-press (:address item) network-details)
|
{:on-press #(on-account-press (:address item) network-details)
|
||||||
:account-props item}]))
|
:account-props (assoc item
|
||||||
|
:address transformed-address
|
||||||
|
:full-address? true)}]))
|
||||||
|
|
||||||
(defn view
|
(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
|
[floating-button-page/view
|
||||||
{:footer-container-padding 0
|
{:footer-container-padding 0
|
||||||
:header [account-switcher/view
|
:header [account-switcher/view
|
||||||
|
@ -45,5 +49,6 @@
|
||||||
{:style style/accounts-list
|
{:style style/accounts-list
|
||||||
:content-container-style style/accounts-list-container
|
:content-container-style style/accounts-list-container
|
||||||
:data accounts
|
:data accounts
|
||||||
|
:render-data {:network-details network-details}
|
||||||
:render-fn render-fn
|
:render-fn render-fn
|
||||||
:shows-horizontal-scroll-indicator false}]]))
|
:shows-horizontal-scroll-indicator false}]]))
|
||||||
|
|
|
@ -17,15 +17,21 @@
|
||||||
:description (i18n/label :t/here-is-a-cat-in-a-box-instead)
|
:description (i18n/label :t/here-is-a-cat-in-a-box-instead)
|
||||||
:image (resources/get-themed-image :cat-in-box theme)
|
:image (resources/get-themed-image :cat-in-box theme)
|
||||||
:container-style style/empty-container-style}]
|
:container-style style/empty-container-style}]
|
||||||
(into [rn/view {:style style/my-accounts-container}]
|
[rn/view {:style style/my-accounts-container}
|
||||||
(map (fn [{:keys [color address] :as account}]
|
(doall
|
||||||
[quo/account-item
|
(for [{:keys [color address] :as account} other-accounts]
|
||||||
{:account-props (assoc account :customization-color color)
|
^{:key (str address)}
|
||||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
(let [transformed-address (rf/sub [:wallet/account-address address
|
||||||
{:address address
|
(:network-preferences-names account)])]
|
||||||
:recipient account
|
[quo/account-item
|
||||||
:stack-id :screen/wallet.select-address}])}]))
|
{:account-props (assoc account
|
||||||
other-accounts))))
|
: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}])}])))])))
|
||||||
|
|
||||||
(defn- recent-transactions
|
(defn- recent-transactions
|
||||||
[theme]
|
[theme]
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
(ns status-im.subs.wallet.networks
|
(ns status-im.subs.wallet.networks
|
||||||
(:require [quo.foundations.resources :as resources]
|
(:require [quo.foundations.resources :as resources]
|
||||||
[re-frame.core :as re-frame]
|
[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
|
(re-frame/reg-sub
|
||||||
:wallet/networks
|
:wallet/networks
|
||||||
|
@ -88,3 +91,13 @@
|
||||||
(filter
|
(filter
|
||||||
#(contains? selected-networks (:network-name %))
|
#(contains? selected-networks (:network-name %))
|
||||||
network-details)))
|
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
|
:chain-id 10
|
||||||
:layer 2}}
|
:layer 2}}
|
||||||
(rf/sub [sub-name])))))
|
(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…
Reference in New Issue