Skip to content

Commit d4073bd

Browse files
authored
Merge branch 'develop' into share-community-qr-17993
2 parents 78a87e6 + 54d9e5e commit d4073bd

File tree

23 files changed

+409
-125
lines changed

23 files changed

+409
-125
lines changed

modules/react-native-status/ios/RCTStatus/Utils.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ + (void) migrateKeystore:(NSString *)accountData
120120
return StatusgoCheckAddressChecksum(address);
121121
}
122122

123+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isAddress:(NSString *)address) {
124+
return StatusgoIsAddress(address);
125+
}
126+
123127
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(toChecksumAddress:(NSString *)address) {
124128
return StatusgoToChecksumAddress(address);
125129
}
126130

127-
128131
@end

src/legacy/status_im/mobile_sync_settings/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[(mailserver/process-next-messages-request)
3737
(bottom-sheet/hide-bottom-sheet-old)
3838
(wallet/restart-wallet-service nil)
39-
(add-new-contact/set-new-identity-reconnected)]
39+
#(add-new-contact/set-new-identity-reconnected %)]
4040

4141
logged-in?
4242
[(mailserver/process-next-messages-request)

src/legacy/status_im/profile/core.cljs

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@
8181
{:db (-> db
8282
(assoc :contacts/identity identity)
8383
(assoc :contacts/ens-name ens-name))
84-
:dispatch [:contacts/build-contact identity ens-name true]}
84+
:dispatch [:contacts/build-contact
85+
{:pubkey identity
86+
:ens ens-name
87+
:success-fn (fn [_]
88+
{:dispatch [:open-modal :profile]})}]}
8589
{:dispatch [:navigate-to :my-profile]})))

src/legacy/status_im/ui/screens/wallet/recipient/views.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
:on-change (fn [text]
5656
(re-frame/dispatch [:wallet-legacy/search-recipient-filter-changed text])
5757
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching])
58-
(debounce/debounce-and-dispatch [:contacts/set-new-identity text] 300))}]]))
58+
(debounce/debounce-and-dispatch [:contacts/set-new-identity {:input text}]
59+
300))}]]))
5960

6061
(defn section
6162
[_ _ _]

src/quo/components/wallet/account_permissions/schema.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
[:disabled? {:optional true} [:maybe :boolean]]
1919
[:on-change {:optional true} [:maybe fn?]]
2020
[:container-style {:optional true} [:maybe :map]]
21+
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
2122
[:theme :schema.common/theme]]]]
2223
:any])

src/quo/components/wallet/account_permissions/view.cljs

+10-7
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@
4242

4343
(defn- view-internal
4444
[{:keys
45-
[checked? disabled? on-change token-details keycard? theme container-style]
45+
[checked? disabled? on-change token-details keycard? theme container-style customization-color]
4646
{:keys
47-
[name address emoji customization-color]} :account}]
47+
[name address emoji]
48+
:as account} :account
49+
:or {customization-color :blue}}]
4850
[rn/view
4951
{:style (merge (style/container theme) container-style)
5052
:accessibility-label :wallet-account-permissions}
5153
[rn/view {:style style/row1}
5254
[account-avatar/view
5355
{:size 32
5456
:emoji emoji
55-
:customization-color customization-color}]
57+
:customization-color (:customization-color account)}]
5658
[rn/view {:style style/account-details}
5759
[rn/view {:style style/name-and-keycard}
5860
[text/text
@@ -67,10 +69,11 @@
6769
{:address address
6870
:format :short}]]
6971
[selectors/view
70-
{:type :checkbox
71-
:checked? checked?
72-
:disabled? disabled?
73-
:on-change on-change}]]
72+
{:type :checkbox
73+
:checked? checked?
74+
:customization-color customization-color
75+
:disabled? disabled?
76+
:on-change on-change}]]
7477

7578
[token-details-section token-details]])
7679

src/status_im/common/home/top_nav/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
nil)]
3434
[quo/top-nav
3535
{:avatar-on-press #(rf/dispatch [:open-modal :settings])
36-
:scan-on-press #(js/alert "to be implemented")
36+
:scan-on-press #(rf/dispatch [:open-modal :shell-qr-reader])
3737
:activity-center-on-press #(rf/dispatch [:activity-center/open])
3838
:qr-code-on-press #(rf/dispatch [:open-modal :share-shell])
3939
:container-style (merge style/top-nav-container container-style)

src/status_im/common/router.cljs

+19-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@
2626

2727
(def web2-domain "status.app")
2828

29+
(def user-path "u#")
30+
(def user-with-data-path "u/")
31+
(def community-path "c#")
32+
(def community-with-data-path "c/")
33+
(def channel-path "cc/")
34+
2935
(def web-urls (map #(str % web2-domain "/") web-prefixes))
3036

37+
(defn path-urls
38+
[path]
39+
(map #(str % path) web-urls))
40+
3141
(def handled-schemes (set (into uri-schemes web-urls)))
3242

3343
(def group-chat-extractor
@@ -41,15 +51,15 @@
4151

4252
(def routes
4353
[""
44-
{handled-schemes {["c/" :community-data] :community
45-
["cc/" :community-data] :community-chat
46-
["p/" :chat-id] :private-chat
47-
["cr/" :community-id] :community-requests
48-
"g/" group-chat-extractor
49-
["wallet/" :account] :wallet-account
50-
["u/" :user-data] :user
51-
"c" :community
52-
"u" :user}
54+
{handled-schemes {[community-with-data-path :community-data] :community
55+
[channel-path :community-data] :community-chat
56+
["p/" :chat-id] :private-chat
57+
["cr/" :community-id] :community-requests
58+
"g/" group-chat-extractor
59+
["wallet/" :account] :wallet-account
60+
[user-with-data-path :user-data] :user
61+
"c" :community
62+
"u" :user}
5363
ethereum-scheme eip-extractor}])
5464

5565
(defn parse-query-params

src/status_im/contexts/chat/home/add_new_contact/events.cljs

+65-54
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
(ns status-im.contexts.chat.home.add-new-contact.events
22
(:require
33
[clojure.string :as string]
4+
[re-frame.core :as re-frame]
45
[status-im.common.validators :as validators]
56
[status-im.contexts.chat.contacts.events :as data-store.contacts]
67
status-im.contexts.chat.home.add-new-contact.effects
7-
[status-im.navigation.events :as navigation]
88
[utils.ens.stateofus :as stateofus]
99
[utils.ethereum.chain :as chain]
10-
[utils.re-frame :as rf]
1110
[utils.string :as utils.string]))
1211

1312
(defn init-contact
@@ -87,72 +86,64 @@
8786

8887
(def validate-contact (comp ->state ->type ->id))
8988

90-
(defn dispatcher [event input] (fn [arg] (rf/dispatch [event input arg])))
89+
(declare build-contact)
9190

92-
(rf/defn set-new-identity
93-
{:events [:contacts/set-new-identity]}
94-
[{:keys [db]} input scanned]
91+
(defn set-new-identity
92+
[{:keys [db]} [{:keys [input build-success-fn failure-fn]}]]
9593
(let [user-public-key (get-in db [:profile/profile :public-key])
9694
{:keys [input id ens state]
9795
:as contact} (-> {:user-public-key user-public-key
9896
:input input
99-
:scanned scanned}
97+
:scanned input}
10098
init-contact
10199
validate-contact)]
102100
(case state
103-
104101
:empty {:db (dissoc db :contacts/new-identity)}
105102
(:valid :invalid) {:db (assoc db :contacts/new-identity contact)}
106103
:decompress-key {:db (assoc db :contacts/new-identity contact)
107104
:serialization/decompress-public-key
108105
{:compressed-key id
109106
:on-success
110-
(dispatcher :contacts/set-new-identity-success input)
107+
#(re-frame/dispatch [:contacts/set-new-identity-success
108+
{:input input
109+
:pubkey %
110+
:build-success-fn build-success-fn}])
111111
:on-error
112-
(dispatcher :contacts/set-new-identity-error input)}}
112+
#(re-frame/dispatch [:contacts/set-new-identity-error
113+
{:input input
114+
:pubkey %
115+
:failure-fn failure-fn}])}}
113116
:resolve-ens {:db (assoc db :contacts/new-identity contact)
114117
:effects.contacts/resolve-public-key-from-ens
115118
{:chain-id (chain/chain-id db)
116119
:ens ens
117120
:on-success
118-
(dispatcher :contacts/set-new-identity-success input)
121+
#(re-frame/dispatch [:contacts/set-new-identity-success
122+
{:input input
123+
:pubkey %
124+
:build-success-fn build-success-fn}])
119125
:on-error
120-
(dispatcher :contacts/set-new-identity-error input)}})))
121-
126+
#(re-frame/dispatch [:contacts/set-new-identity-error
127+
{:input input
128+
:pubkey %
129+
:failure-fn failure-fn}])}})))
122130

131+
(re-frame/reg-event-fx :contacts/set-new-identity set-new-identity)
123132

124-
(rf/defn build-contact
125-
{:events [:contacts/build-contact]}
126-
[_ pubkey ens open-profile-modal?]
127-
{:json-rpc/call [{:method "wakuext_buildContact"
128-
:params [{:publicKey pubkey
129-
:ENSName ens}]
130-
:js-response true
131-
:on-success #(rf/dispatch [:contacts/contact-built
132-
pubkey
133-
open-profile-modal?
134-
(data-store.contacts/<-rpc-js %)])}]})
135-
136-
(rf/defn contact-built
137-
{:events [:contacts/contact-built]}
138-
[{:keys [db]} pubkey open-profile-modal? contact]
139-
(merge {:db (assoc-in db [:contacts/contacts pubkey] contact)}
140-
(when open-profile-modal?
141-
{:dispatch [:open-modal :profile]})))
142-
143-
(rf/defn set-new-identity-success
144-
{:events [:contacts/set-new-identity-success]}
145-
[{:keys [db]} input pubkey]
133+
(defn- set-new-identity-success
134+
[{:keys [db]} [{:keys [input pubkey build-success-fn]}]]
146135
(let [contact (get-in db [:contacts/new-identity])]
147136
(when (= (:input contact) input)
148-
(rf/merge {:db (assoc db
149-
:contacts/new-identity
150-
(->state (assoc contact :public-key pubkey)))}
151-
(build-contact pubkey (:ens contact) false)))))
152-
153-
(rf/defn set-new-identity-error
154-
{:events [:contacts/set-new-identity-error]}
155-
[{:keys [db]} input err]
137+
{:db (assoc db :contacts/new-identity (->state (assoc contact :public-key pubkey)))
138+
:dispatch [:contacts/build-contact
139+
{:pubkey pubkey
140+
:ens (:ens contact)
141+
:success-fn build-success-fn}]})))
142+
143+
(re-frame/reg-event-fx :contacts/set-new-identity-success set-new-identity-success)
144+
145+
(defn- set-new-identity-error
146+
[{:keys [db]} [{:keys [input err failure-fn]}]]
156147
(let [contact (get-in db [:contacts/new-identity])]
157148
(when (= (:input contact) input)
158149
(let [state (cond
@@ -163,21 +154,41 @@
163154
(string/includes? (:message err) "no such host")))
164155
{:state :invalid :msg :t/lost-connection}
165156
:else {:state :invalid})]
166-
{:db (assoc db :contacts/new-identity (merge contact state))}))))
157+
(merge {:db (assoc db :contacts/new-identity (merge contact state))}
158+
(when failure-fn
159+
(failure-fn)))))))
160+
161+
(re-frame/reg-event-fx :contacts/set-new-identity-error set-new-identity-error)
167162

168-
(rf/defn clear-new-identity
169-
{:events [:contacts/clear-new-identity :contacts/new-chat-focus]}
163+
(defn- build-contact
164+
[_ [{:keys [pubkey ens success-fn]}]]
165+
{:json-rpc/call [{:method "wakuext_buildContact"
166+
:params [{:publicKey pubkey
167+
:ENSName ens}]
168+
:js-response true
169+
:on-success #(re-frame/dispatch [:contacts/build-contact-success
170+
{:pubkey pubkey
171+
:contact (data-store.contacts/<-rpc-js %)
172+
:success-fn success-fn}])}]})
173+
174+
(re-frame/reg-event-fx :contacts/build-contact build-contact)
175+
176+
(defn- build-contact-success
177+
[{:keys [db]} [{:keys [pubkey contact success-fn]}]]
178+
(merge {:db (assoc-in db [:contacts/contacts pubkey] contact)}
179+
(when success-fn
180+
(success-fn contact))))
181+
182+
(re-frame/reg-event-fx :contacts/build-contact-success build-contact-success)
183+
184+
(defn- clear-new-identity
170185
[{:keys [db]}]
171186
{:db (dissoc db :contacts/new-identity)})
172187

173-
(rf/defn qr-code-scanned
174-
{:events [:contacts/qr-code-scanned]}
175-
[{:keys [db] :as cofx} scanned]
176-
(rf/merge cofx
177-
(set-new-identity scanned scanned)
178-
(navigation/navigate-back)))
188+
(re-frame/reg-event-fx :contacts/clear-new-identity clear-new-identity)
179189

180-
(rf/defn set-new-identity-reconnected
190+
(defn set-new-identity-reconnected
181191
[{:keys [db]}]
182192
(let [input (get-in db [:contacts/new-identity :input])]
183-
(rf/dispatch [:contacts/set-new-identity input])))
193+
(re-frame/dispatch [:contacts/set-new-identity {:input input}])))
194+

src/status_im/contexts/chat/home/add_new_contact/events_test.cljs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require
33
[cljs.test :refer-macros [deftest are]]
44
matcher-combinators.test
5+
[re-frame.core :as re-frame]
56
[status-im.contexts.chat.home.add-new-contact.events :as events]))
67

78
(def user-ukey
@@ -90,8 +91,8 @@
9091
:config {:NetworkId 1}}}})
9192

9293
(deftest set-new-identity-test
93-
(with-redefs [events/dispatcher (fn [& args] args)]
94-
(are [i edb] (match? (events/set-new-identity {:db db} i nil) edb)
94+
(with-redefs [re-frame/dispatch (fn [& args] args)]
95+
(are [i edb] (match? (events/set-new-identity {:db db} [{:input i}]) edb)
9596

9697
"" {:db db}
9798

@@ -103,6 +104,7 @@
103104
:id ukey
104105
:type :public-key
105106
:public-key ukey
107+
:scanned ukey
106108
:state :invalid
107109
:msg :t/not-a-chatkey}))}
108110

@@ -115,6 +117,7 @@
115117
:type :ens
116118
:ens ens-stateofus-eth
117119
:public-key nil ; not yet...
120+
:scanned ens
118121
:state :resolve-ens}))
119122
:effects.contacts/resolve-public-key-from-ens
120123
{:chain-id 1
@@ -131,6 +134,7 @@
131134
:id user-ckey
132135
:type :compressed-key
133136
:public-key nil ; not yet...
137+
:scanned user-ckey
134138
:state :decompress-key}))
135139
:serialization/decompress-public-key
136140
{:compressed-key user-ckey

src/status_im/contexts/chat/home/add_new_contact/scan/scan_profile_qr_page.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
(rn/dismiss-keyboard!))
1414
[scan-qr-code/view
1515
{:title (i18n/label :t/scan-qr)
16-
:on-success-scan #(debounce/debounce-and-dispatch [:contacts/set-new-identity % %] 300)}]]))
16+
:on-success-scan #(debounce/debounce-and-dispatch [:contacts/set-new-identity {:input %}]
17+
300)}]]))
1718

1819
(defn view
1920
[]

src/status_im/contexts/chat/home/add_new_contact/views.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
paste-on-input #(clipboard/get-string
6060
(fn [clipboard-text]
6161
(reset! input-value clipboard-text)
62-
(rf/dispatch [:contacts/set-new-identity clipboard-text nil])))]
62+
(rf/dispatch [:contacts/set-new-identity
63+
{:input clipboard-text}])))]
6364
(let [{:keys [scanned]} (rf/sub [:contacts/new-identity])
6465
empty-input? (and (string/blank? @input-value)
6566
(string/blank? scanned))]
@@ -86,7 +87,7 @@
8687
:value (or scanned @input-value)
8788
:on-change-text (fn [new-text]
8889
(reset! input-value new-text)
89-
(as-> [:contacts/set-new-identity new-text nil] $
90+
(as-> [:contacts/set-new-identity {:input new-text}] $
9091
(if (string/blank? scanned)
9192
(debounce/debounce-and-dispatch $ 600)
9293
(rf/dispatch-sync $))))}]

0 commit comments

Comments
 (0)