Skip to content

Commit 78a87e6

Browse files
authored
Merge branch 'develop' into share-community-qr-17993
2 parents 5dce30d + 2e23dc7 commit 78a87e6

File tree

7 files changed

+46
-23
lines changed

7 files changed

+46
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
(ns status-im.contexts.wallet.add-address-to-watch.confirm-address.component-spec
22
(:require
33
[status-im.contexts.wallet.add-address-to-watch.confirm-address.view :as confirm-address]
4-
[test-helpers.component :as h]
5-
[utils.re-frame :as rf]))
4+
[test-helpers.component :as h]))
65

76
(h/describe "Add Watch Only Account Page"
87
(h/setup-restorable-re-frame)
98

109
(h/test "Create Account button is disabled while no account name exists"
11-
(let [callback (h/mock-fn)]
12-
(with-redefs [rf/dispatch #(callback)]
13-
(h/setup-subs {:profile/wallet-accounts []
14-
:get-screen-params {:address "0xmock-address"}})
15-
(h/render [confirm-address/view {}])
16-
(h/is-truthy (h/get-by-text "0xmock-address"))
17-
(h/was-not-called callback)
18-
(h/fire-event :change-text (h/get-by-label-text :profile-title-input) "NAME")
19-
(h/fire-event :press (h/get-by-translation-text :t/add-watched-address))
20-
(h/was-called callback)))))
10+
(h/setup-subs {:wallet/watch-only-accounts []
11+
:get-screen-params {:address "0xmock-address"}})
12+
(h/render [confirm-address/view])
13+
(h/is-truthy (h/get-by-text "0xmock-address"))
14+
(h/is-disabled (h/get-by-label-text :confirm-button-label))))

src/status_im/contexts/wallet/add_address_to_watch/confirm_address/view.cljs

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
(defn view
1616
[]
1717
(let [{:keys [address]} (rf/sub [:get-screen-params])
18-
number-of-accounts (count (rf/sub [:profile/wallet-accounts]))
19-
account-name (reagent/atom (i18n/label :t/default-account-name
20-
{:number (inc number-of-accounts)}))
18+
number-of-accounts (count (rf/sub [:wallet/watch-only-accounts]))
19+
account-name (reagent/atom "")
20+
placeholder (i18n/label :t/default-watched-address-placeholder
21+
{:number (inc number-of-accounts)})
2122
account-color (reagent/atom (rand-nth colors/account-colors))
2223
account-emoji (reagent/atom (emoji-picker.utils/random-emoji))
2324
on-change-name #(reset! account-name %)
@@ -31,6 +32,7 @@
3132
#(js/alert
3233
"Get info (to be
3334
implemented)")}]
35+
:placeholder placeholder
3436
:account-name @account-name
3537
:account-emoji @account-emoji
3638
:account-color @account-color
@@ -42,6 +44,7 @@
4244
:bottom-action-label :t/add-watched-address
4345
:bottom-action-props {:customization-color @account-color
4446
:disabled? (string/blank? @account-name)
47+
:accessibility-label :confirm-button-label
4548
:on-press #(rf/dispatch [:wallet/add-account
4649
{:sha3-pwd nil
4750
:type :watch

src/status_im/contexts/wallet/common/screen_base/create_or_edit_account/view.cljs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
[utils.re-frame :as rf]))
99

1010
(defn view
11-
[{:keys [margin-top? page-nav-right-side account-name account-color account-emoji on-change-name
11+
[{:keys [margin-top? page-nav-right-side placeholder account-name account-color account-emoji
12+
on-change-name
1213
on-change-color
1314
on-change-emoji on-focus on-blur section-label bottom-action?
1415
bottom-action-label bottom-action-props
@@ -45,10 +46,11 @@
4546
:container-style style/reaction-button-container}
4647
:i/reaction]]
4748
[quo/title-input
48-
{:placeholder (i18n/label :t/account-name-input-placeholder)
49+
{:placeholder placeholder
4950
:max-length constants/wallet-account-name-max-length
5051
:blur? true
5152
:default-value account-name
53+
:auto-focus true
5254
:on-change-text on-change-name
5355
:container-style style/title-input-container
5456
:on-focus on-focus

src/status_im/contexts/wallet/create_account/view.cljs

+9-4
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757
bottom (safe-area/get-bottom)
5858
account-color (reagent/atom (rand-nth colors/account-colors))
5959
emoji (reagent/atom (emoji-picker.utils/random-emoji))
60-
number-of-accounts (count (rf/sub [:wallet/accounts]))
61-
account-name (reagent/atom (i18n/label :t/default-account-name
62-
{:number (inc number-of-accounts)}))
60+
number-of-accounts (count (rf/sub [:wallet/accounts-without-watched-accounts]))
61+
account-name (reagent/atom "")
62+
placeholder (i18n/label :t/default-account-placeholder
63+
{:number (inc number-of-accounts)})
6364
derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts))
6465
{:keys [public-key]} (rf/sub [:profile/profile])
6566
on-change-text #(reset! account-name %)
@@ -96,11 +97,12 @@
9697
:container-style style/reaction-button-container} :i/reaction]]
9798
[quo/title-input
9899
{:customization-color @account-color
99-
:placeholder "Type something here"
100+
:placeholder placeholder
100101
:on-change-text on-change-text
101102
:max-length constants/wallet-account-name-max-length
102103
:blur? true
103104
:disabled? false
105+
:auto-focus true
104106
:default-value @account-name
105107
:container-style style/title-input-container}]
106108
[quo/divider-line]
@@ -133,6 +135,9 @@
133135
:path @derivation-path
134136
:account-name @account-name}]))
135137
:auth-button-label (i18n/label :t/confirm)
138+
;; TODO (@rende11) Add this property when sliding button issue will fixed
139+
;; https://github.com/status-im/status-mobile/pull/18683#issuecomment-1941564785
140+
;; :disabled? (empty? @account-name)
136141
:container-style (style/slide-button-container bottom)}]])))
137142

138143
(def view (quo.theme/with-theme view-internal))

src/status_im/subs/wallet/wallet.cljs

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@
100100
(map #(assoc-network-preferences-names network-details % test-networks-enabled?))
101101
(sort-by :position))))
102102

103+
(rf/reg-sub
104+
:wallet/watch-only-accounts
105+
:<- [:wallet/accounts]
106+
(fn [accounts]
107+
(filter :watch-only? accounts)))
108+
103109
(rf/reg-sub
104110
:wallet/addresses
105111
:<- [:wallet]

src/status_im/subs/wallet/wallet_test.cljs

+13
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,16 @@
484484
(assoc :customization-color :magenta)
485485
(assoc :network-preferences-names #{}))]
486486
(rf/sub [sub-name])))))
487+
488+
(h/deftest-sub :wallet/watch-only-accounts
489+
[sub-name]
490+
(testing "returns only active (not watch-only?) accounts"
491+
(swap! rf-db/app-db
492+
#(-> %
493+
(assoc-in [:wallet :accounts] accounts)
494+
(assoc-in [:wallet :networks] network-data)))
495+
(is
496+
(= [(-> accounts
497+
(get "0x3")
498+
(assoc :network-preferences-names #{}))]
499+
(rf/sub [sub-name])))))

translations/en.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@
444444
"decline": "Decline",
445445
"decryption-failed-content": "An error occured decrypting your data. You might need to erase your old data and generate a new account. Tap “Apply” to erase or “Cancel” to try again",
446446
"default": "Default",
447-
"default-account-name": "Account {{number}}",
447+
"default-account-placeholder": "Account {{number}}",
448+
"default-watched-address-placeholder": "Watched address {{number}}",
448449
"delete": "Delete",
449450
"delete-and-leave-group": "Delete and leave group",
450451
"delete-bootnode": "Delete bootnode",
@@ -2404,7 +2405,6 @@
24042405
"moonpay-description": "The new standard for fiat to crypto, supports Apple Pay.",
24052406
"latamex-description": "Easily buy crypto in Argentina, Mexico and Brazil.",
24062407
"account-info": "Account info",
2407-
"account-name-input-placeholder": "Account name",
24082408
"network-preferences": "Network preferences",
24092409
"network-preferences-desc-1": "Select which networks this address is happy to receive funds on",
24102410
"network-preferences-desc-2": "Select which networks to receive funds on",

0 commit comments

Comments
 (0)