Skip to content

Commit

Permalink
Fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rende11 committed Nov 16, 2023
1 parent 2717291 commit db00efd
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
(let [network-details (rf/sub [:wallet/network-details])
mainnet (first network-details)
layer-2-networks (rest network-details)
current-networks (->> network-details
(filter
#(contains? @network-preference-names-state (:network-name %))))]
current-networks (filter (fn [network]
(contains? @network-preference-names-state
(:network-name network)))
network-details)]
[:<>
[quo/drawer-top
{:title (i18n/label :t/network-preferences)
Expand Down Expand Up @@ -73,12 +74,12 @@
[quo/category
{:list-type :settings
:label (i18n/label :t/layer-2)
:data (mapv #(make-network-item %
{:color color
:network-preferences @network-preference-names-state
:on-change (fn [_]
(toggle-network (:network-name
%)))})
:data (mapv (fn [network]
(make-network-item network
{:color color
:network-preferences @network-preference-names-state
:on-change #(toggle-network (:network-name
network))}))
layer-2-networks)}]
[quo/bottom-actions
{:button-one-label (i18n/label :t/update)
Expand Down
12 changes: 9 additions & 3 deletions src/status_im2/contexts/wallet/edit_account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
[{:keys [theme type value account]}]
(let [edited-account-data (assoc account type value)
message (case type
:name :t/edit-wallet-account-name-updated-message
:color :t/edit-wallet-account-colour-updated-message
:emoji :t/edit-wallet-account-emoji-updated-message
:name
:t/edit-wallet-account-name-updated-message

:color
:t/edit-wallet-account-colour-updated-message

:emoji
:t/edit-wallet-account-emoji-updated-message

:prod-preferred-chain-ids
:t/edit-wallet-network-preferences-updated-message
nil)
Expand Down
19 changes: 9 additions & 10 deletions src/status_im2/subs/wallet/networks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
:wallet/network-details
:<- [:wallet/filtered-networks-by-mode false]
(fn [networks]
(->>
networks
(keep
(fn [{:keys [chain-id related-chain-id layer test?]}]
(let [network-details (get network-list (if test? related-chain-id chain-id))]
(assoc network-details
:chain-id chain-id
:related-chain-id related-chain-id
:layer layer))))
(sort-by (juxt :layer :short-name)))))
(->> networks
(keep
(fn [{:keys [chain-id related-chain-id layer test?]}]
(let [network-details (get network-list (if test? related-chain-id chain-id))]
(assoc network-details
:chain-id chain-id
:related-chain-id related-chain-id
:layer layer))))
(sort-by (juxt :layer :short-name)))))
3 changes: 2 additions & 1 deletion src/status_im2/subs/wallet/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
:<- [:wallet]
:<- [:wallet/network-details]
(fn [[wallet network-details]]
;; will get in follow up
;; TODO(@rende11): `testnet?` value would be relevant after this implementation,
;; https://github.com/status-im/status-mobile/issues/17826
(let [testnet? false]
(->> wallet
:accounts
Expand Down
88 changes: 44 additions & 44 deletions src/status_im2/subs/wallet/wallet_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@
(swap! rf-db/app-db #(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc :wallet/tokens tokens)))
(is (= [{:address "0x1"
:balance 3250}
{:address "0x2"
:balance 2100}]
(is (= '({:address "0x1"
:balance 3250}
{:address "0x2"
:balance 2100})
(rf/sub [sub-name])))))

(h/deftest-sub :wallet/accounts
Expand All @@ -134,46 +134,46 @@
(assoc :wallet/tokens tokens)
(assoc :wallet/networks network-data)))
(is
(= [{:path "m/44'/60'/0'/0/0"
:emoji "😃"
:key-uid "0x2f5ea39"
:address "0x1"
:wallet false
:name "Account One"
:type :generated
:chat false
:test-preferred-chain-ids #{5 420 421613}
:color :blue
:hidden false
:prod-preferred-chain-ids #{1 10 42161}
:network-preference-names #{:ethereum :arbitrum :optimism}
:position 0
:clock 1698945829328
:created-at 1698928839000
:operable "fully"
:mixedcase-address "0x7bcDfc75c431"
:public-key "0x04371e2d9d66b82f056bc128064"
:removed false}
{:path "m/44'/60'/0'/0/1"
:emoji "💎"
:key-uid "0x2f5ea39"
:address "0x2"
:wallet false
:name "Account Two"
:type :generated
:chat false
:test-preferred-chain-ids #{5 420 421613}
:color :purple
:hidden false
:prod-preferred-chain-ids #{1 10 42161}
:network-preference-names #{:ethereum :arbitrum :optimism}
:position 1
:clock 1698945829328
:created-at 1698928839000
:operable "fully"
:mixedcase-address "0x7bcDfc75c431"
:public-key "0x04371e2d9d66b82f056bc128064"
:removed false}]
(= '({:path "m/44'/60'/0'/0/0"
:emoji "😃"
:key-uid "0x2f5ea39"
:address "0x1"
:wallet false
:name "Account One"
:type :generated
:chat false
:test-preferred-chain-ids #{5 420 421613}
:color :blue
:hidden false
:prod-preferred-chain-ids #{1 10 42161}
:network-preference-names #{:ethereum :arbitrum :optimism}
:position 0
:clock 1698945829328
:created-at 1698928839000
:operable "fully"
:mixedcase-address "0x7bcDfc75c431"
:public-key "0x04371e2d9d66b82f056bc128064"
:removed false}
{:path "m/44'/60'/0'/0/1"
:emoji "💎"
:key-uid "0x2f5ea39"
:address "0x2"
:wallet false
:name "Account Two"
:type :generated
:chat false
:test-preferred-chain-ids #{5 420 421613}
:color :purple
:hidden false
:prod-preferred-chain-ids #{1 10 42161}
:network-preference-names #{:ethereum :arbitrum :optimism}
:position 1
:clock 1698945829328
:created-at 1698928839000
:operable "fully"
:mixedcase-address "0x7bcDfc75c431"
:public-key "0x04371e2d9d66b82f056bc128064"
:removed false})
(rf/sub [sub-name])))))

(h/deftest-sub :wallet/current-viewing-account-address
Expand Down

0 comments on commit db00efd

Please sign in to comment.