The network marks are not shown on the 'send to' page for accounts #19545 (#20365)

This commit is contained in:
mmilad75 2024-06-13 14:19:19 +02:00 committed by GitHub
parent 5f7d7254e7
commit d33648917a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 20 deletions

View File

@ -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]}]

View File

@ -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}]]))

View File

@ -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}]
[quo/account-item
{:account-props (assoc account :customization-color color)
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient account
:stack-id :screen/wallet.select-address}])}]))
other-accounts))))
[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
: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
[theme]

View File

@ -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)))

View File

@ -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]])))))