* Add subscription to get preferred networks given an address * Fix preselected networks in receive screen * Improve subscription * Fix preselected networks in share screen * Update test to include oeth
This commit is contained in:
parent
ed88170c5d
commit
e1210e90c0
|
@ -19,11 +19,12 @@
|
||||||
(h/before-each
|
(h/before-each
|
||||||
(fn []
|
(fn []
|
||||||
(h/setup-subs {:dimensions/window-width 500
|
(h/setup-subs {:dimensions/window-width 500
|
||||||
:mediaserver/port 200
|
:mediaserver/port 200
|
||||||
:wallet/accounts [{:address "0x707f635951193ddafbb40971a0fcaab8a6415160"
|
:wallet/accounts [{:address "0x707f635951193ddafbb40971a0fcaab8a6415160"
|
||||||
:name "Wallet One"
|
:name "Wallet One"
|
||||||
:emoji "😆"
|
:emoji "😆"
|
||||||
:color :blue}]})))
|
:color :blue}]
|
||||||
|
:wallet/preferred-chain-names-for-address #{:eth :oeth :arb1}})))
|
||||||
|
|
||||||
(h/test "should display the wallet tab"
|
(h/test "should display the wallet tab"
|
||||||
(render-wallet-view)
|
(render-wallet-view)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.contexts.shell.share.style :as style]
|
[status-im.contexts.shell.share.style :as style]
|
||||||
[status-im.contexts.shell.share.wallet.style :as wallet-style]
|
[status-im.contexts.shell.share.wallet.style :as wallet-style]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
|
@ -51,9 +50,9 @@
|
||||||
chain-ids)))}])}]))
|
chain-ids)))}])}]))
|
||||||
|
|
||||||
(defn- wallet-qr-code-item
|
(defn- wallet-qr-code-item
|
||||||
[{:keys [account index]}]
|
[{:keys [account index preferred-chains]}]
|
||||||
(let [{window-width :width} (rn/get-window)
|
(let [{window-width :width} (rn/get-window)
|
||||||
selected-networks (reagent/atom constants/default-network-names)
|
selected-networks (reagent/atom preferred-chains)
|
||||||
wallet-type (reagent/atom :multichain)
|
wallet-type (reagent/atom :multichain)
|
||||||
on-settings-press #(open-preferences selected-networks account)
|
on-settings-press #(open-preferences selected-networks account)
|
||||||
on-legacy-press #(reset! wallet-type :legacy)
|
on-legacy-press #(reset! wallet-type :legacy)
|
||||||
|
@ -97,10 +96,11 @@
|
||||||
^{:key i} [indicator (= current-index i)])])
|
^{:key i} [indicator (= current-index i)])])
|
||||||
|
|
||||||
(defn render-item
|
(defn render-item
|
||||||
[item]
|
[{:keys [address] :as account}]
|
||||||
[wallet-qr-code-item
|
[wallet-qr-code-item
|
||||||
{:account item
|
{:account account
|
||||||
:index (:position item)}])
|
:index (:position account)
|
||||||
|
:preferred-chains (rf/sub [:wallet/preferred-chain-names-for-address address])}])
|
||||||
|
|
||||||
(defn- qr-code-visualized-index
|
(defn- qr-code-visualized-index
|
||||||
[offset qr-code-size num-qr-codes]
|
[offset qr-code-size num-qr-codes]
|
||||||
|
|
|
@ -47,13 +47,10 @@
|
||||||
:shell? true
|
:shell? true
|
||||||
:content sheet-content}])))
|
:content sheet-content}])))
|
||||||
|
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [padding-top (:top (safe-area/get-insets))
|
(let [padding-top (:top (safe-area/get-insets))
|
||||||
wallet-type (reagent/atom :legacy)
|
wallet-type (reagent/atom :legacy)
|
||||||
;; Design team is yet to confirm the default selected networks here. Should be the current
|
|
||||||
;; selected for the account or all the networks always
|
|
||||||
selected-networks (reagent/atom constants/default-network-names)
|
selected-networks (reagent/atom constants/default-network-names)
|
||||||
on-settings-press #(open-preferences selected-networks)
|
on-settings-press #(open-preferences selected-networks)
|
||||||
on-legacy-press #(reset! wallet-type :legacy)
|
on-legacy-press #(reset! wallet-type :legacy)
|
||||||
|
@ -61,11 +58,11 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [{:keys [address color emoji watch-only?]
|
(let [{:keys [address color emoji watch-only?]
|
||||||
:as account} (rf/sub [:wallet/current-viewing-account])
|
:as account} (rf/sub [:wallet/current-viewing-account])
|
||||||
|
preferred-networks (rf/sub [:wallet/preferred-chain-names-for-address address])
|
||||||
share-title (str (:name account) " " (i18n/label :t/address))
|
share-title (str (:name account) " " (i18n/label :t/address))
|
||||||
qr-url (utils/get-wallet-qr {:wallet-type @wallet-type
|
qr-url (utils/get-wallet-qr {:wallet-type @wallet-type
|
||||||
:selected-networks
|
:selected-networks @selected-networks
|
||||||
@selected-networks
|
:address address})
|
||||||
:address address})
|
|
||||||
qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
|
qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
|
||||||
{:url qr-url
|
{:url qr-url
|
||||||
:port (rf/sub [:mediaserver/port])
|
:port (rf/sub [:mediaserver/port])
|
||||||
|
@ -76,6 +73,9 @@
|
||||||
:share (i18n/label :t/share-address)
|
:share (i18n/label :t/share-address)
|
||||||
:receive (i18n/label :t/receive)
|
:receive (i18n/label :t/receive)
|
||||||
nil)]
|
nil)]
|
||||||
|
|
||||||
|
(rn/use-mount #(reset! selected-networks preferred-networks))
|
||||||
|
|
||||||
[quo/overlay {:type :shell}
|
[quo/overlay {:type :shell}
|
||||||
[rn/view
|
[rn/view
|
||||||
{:flex 1
|
{:flex 1
|
||||||
|
|
|
@ -408,6 +408,26 @@
|
||||||
(assoc account :customization-color color))
|
(assoc account :customization-color color))
|
||||||
accounts)))
|
accounts)))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/preferred-chains-for-address
|
||||||
|
:<- [:wallet/accounts]
|
||||||
|
:<- [:wallet/network-details]
|
||||||
|
:<- [:profile/test-networks-enabled?]
|
||||||
|
(fn [[accounts network-details test-networks-enabled?] [_ address]]
|
||||||
|
(let [preferred-chains-ids (some #(when (= (:address %) address)
|
||||||
|
(if test-networks-enabled?
|
||||||
|
(:test-preferred-chain-ids %)
|
||||||
|
(:prod-preferred-chain-ids %)))
|
||||||
|
accounts)]
|
||||||
|
(filter #(preferred-chains-ids (:chain-id %)) network-details))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/preferred-chain-names-for-address
|
||||||
|
(fn [[_ address]]
|
||||||
|
(rf/subscribe [:wallet/preferred-chains-for-address address]))
|
||||||
|
(fn [preferred-chains-for-address _]
|
||||||
|
(map :network-name preferred-chains-for-address)))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/transactions
|
:wallet/transactions
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
|
|
Loading…
Reference in New Issue