Skip to content

Commit b41760e

Browse files
authored
Merge branch 'develop' into 17433-composer-expanded-on-cancel
2 parents 97e7d46 + ec4046e commit b41760e

18 files changed

+242
-130
lines changed

Makefile

+6-5
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,14 @@ endef
311311
lint: export TARGET := clojure
312312
lint: export CLJ_LINTER_PRINT_WARNINGS ?= false
313313
lint: ##@test Run code style checks
314-
@sh scripts/lint-re-frame-in-quo-components.sh && \
315-
sh scripts/lint-direct-require-component-outside-quo.sh && \
314+
@sh scripts/lint/re-frame-in-quo-components.sh && \
315+
sh scripts/lint/direct-require-component-outside-quo.sh && \
316+
sh scripts/lint/require-i18n-resource-first.sh && \
316317
clj-kondo --config .clj-kondo/config.edn --cache false --fail-level error --lint src $(if $(filter $(CLJ_LINTER_PRINT_WARNINGS),true),,| grep -v ': warning: ') && \
317318
ALL_CLOJURE_FILES=$(call find_all_clojure_files) && \
318-
scripts/lint_translations.clj && \
319+
scripts/lint/translations.clj && \
319320
zprint '{:search-config? true}' -sfc $$ALL_CLOJURE_FILES && \
320-
sh scripts/lint-trailing-newline.sh && \
321+
sh scripts/lint/trailing-newline.sh && \
321322
node_modules/.bin/prettier --write .
322323

323324
# NOTE: We run the linter twice because of https://github.com/kkinnear/zprint/issues/271
@@ -327,7 +328,7 @@ lint-fix: ##@test Run code style checks and fix issues
327328
zprint '{:search-config? true}' -sw $$ALL_CLOJURE_FILES && \
328329
zprint '{:search-config? true}' -sw $$ALL_CLOJURE_FILES && \
329330
clojure-lsp --ns-exclude-regex ".*/src/status_im2/core\.cljs$$" clean-ns && \
330-
sh scripts/lint-trailing-newline.sh --fix && \
331+
sh scripts/lint/trailing-newline.sh --fix && \
331332
node_modules/.bin/prettier --write .
332333

333334
shadow-server: export TARGET := clojure
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
if rg --quiet --multiline '^\(ns.*\n^\s*\(:require\n(^\s*(;|#_).*\n)*(^\s*\[status-im2\.setup\.i18n-resources\W)' src/status_im2/core.cljs; then
4+
exit 0
5+
elif [ $? -eq 1 ]; then
6+
echo "status-im2.setup.i18n-resources must be loaded first (be the first one in ns :require form) in status-im2.core"
7+
echo "For more info, check the comment here https://github.com/status-im/status-mobile/pull/17618#discussion_r1361275489"
8+
else
9+
exit $?
10+
fi
File renamed without changes.
File renamed without changes.

src/status_im/ui/screens/browser/views.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@
225225
(.. ^js % -nativeEvent -data)])
226226
:on-load #(re-frame/dispatch [:browser/loading-started])
227227
:on-error #(re-frame/dispatch [:browser/error-occured])
228-
:injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))}])]
228+
:injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))
229+
;; https://github.com/status-im/status-mobile/issues/17854
230+
:allows-inline-media-playback true}])]
229231
[navigation
230232
{:url url-original
231233
:name name

src/status_im/utils/test.cljs

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@
1515

1616
(def test-dir (.mkdtempSync fs test-dir-prefix))
1717

18+
(def initialized? (atom false))
19+
1820
(defn signal-received-callback
1921
[a]
2022
(re-frame/dispatch [:signals/signal-received a]))
2123

2224
;; We poll for signals, could not get callback working
2325
(defn init!
2426
[]
25-
(.setSignalEventCallback native-status)
26-
(js/setInterval (fn []
27-
(.pollSignal native-status signal-received-callback)
28-
100)))
27+
(when-not @initialized?
28+
(.setSignalEventCallback native-status)
29+
(reset! initialized? true)
30+
(js/setInterval (fn []
31+
(.pollSignal native-status signal-received-callback)
32+
100))))
2933

3034
(def status
3135
(clj->js

src/status_im2/contexts/communities/overview/events.cljs

+37-24
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,31 @@
4242
community-id %])
4343
:on-error #(log/error "failed to request to join community" community-id %)}]})
4444

45+
(defn request-to-join
46+
[{:keys [db]} [{:keys [community-id password]}]]
47+
(let [pub-key (get-in db [:profile/profile :public-key])
48+
addresses-to-reveal []]
49+
{:fx [[:json-rpc/call
50+
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
51+
:params [pub-key community-id addresses-to-reveal]
52+
:on-success [:communities/sign-data community-id password]
53+
:on-error [:communities/requested-to-join-error community-id]}]]]}))
54+
4555
;; Event to be called to request to join a community.
4656
;; This event will generate the data to be signed and then call the sign-data event.
4757
;; This is the only event that should be called from the UI.
48-
(rf/reg-event-fx :communities/request-to-join
49-
(fn [{:keys [db]} [{:keys [community-id password]}]]
50-
(let [pub-key (get-in db [:profile/profile :public-key])
51-
addresses-to-reveal []]
52-
{:fx [[:json-rpc/call
53-
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
54-
:params [pub-key community-id addresses-to-reveal]
55-
:on-success [:communities/sign-data community-id password]
56-
:on-error [:communities/requested-to-join-error community-id]}]]]})))
58+
(rf/reg-event-fx :communities/request-to-join request-to-join)
5759

58-
(rf/reg-event-fx :communities/sign-data
59-
(fn [_ [community-id password sign-params]]
60-
{:fx [[:json-rpc/call
61-
[{:method "wakuext_signData"
62-
:params [(map #(assoc % :password password) sign-params)]
63-
:on-success [:communities/request-to-join-with-signatures community-id]
64-
:on-error [:communities/requested-to-join-error community-id]}]]]}))
60+
(defn sign-data
61+
[_ [community-id password sign-params]]
62+
(let [addresses-to-reveal (map :account sign-params)]
63+
{:fx [[:json-rpc/call
64+
[{:method "wakuext_signData"
65+
:params [(map #(assoc % :password password) sign-params)]
66+
:on-success [:communities/request-to-join-with-signatures community-id addresses-to-reveal]
67+
:on-error [:communities/requested-to-join-error community-id]}]]]}))
68+
69+
(rf/reg-event-fx :communities/sign-data sign-data)
6570

6671
(rf/reg-event-fx :communities/requested-to-join-error
6772
(fn [{:keys [db]} [community-id error]]
@@ -71,11 +76,19 @@
7176
:event :communities/requested-to-join-error})
7277
{:db (assoc-in db [:password-authentication :error] error)}))
7378

74-
(rf/reg-event-fx :communities/request-to-join-with-signatures
75-
(fn [_ [community-id signatures]]
76-
{:fx [[:json-rpc/call
77-
[{:method "wakuext_requestToJoinCommunity"
78-
:params [{:communityId community-id :signatures signatures}]
79-
:js-response true
80-
:on-success [:communities/requested-to-join]
81-
:on-error [:communities/requested-to-join-error community-id]}]]]}))
79+
(defn request-to-join-with-signatures
80+
[_ [community-id addresses-to-reveal signatures]]
81+
{:fx [[:json-rpc/call
82+
[{:method "wakuext_requestToJoinCommunity"
83+
:params [{:communityId community-id
84+
:signatures signatures
85+
:addressesToReveal addresses-to-reveal
86+
;; NOTE: At least one airdrop address is required.
87+
;; This is a temporary solution while the address
88+
;; selection feature is not implemented in mobile.
89+
:airdropAddress (first addresses-to-reveal)}]
90+
:js-response true
91+
:on-success [:communities/requested-to-join]
92+
:on-error [:communities/requested-to-join-error community-id]}]]]})
93+
94+
(rf/reg-event-fx :communities/request-to-join-with-signatures request-to-join-with-signatures)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
(ns status-im2.contexts.communities.overview.events-test
2+
(:require [cljs.test :refer [deftest is]]
3+
[native-module.core :as native-module]
4+
[status-im2.contexts.communities.overview.events :as sut]))
5+
6+
(def password (native-module/sha3 "password123"))
7+
(def community-id "0x99")
8+
(def account-pub-key "0x1")
9+
10+
(deftest request-to-join-test
11+
(let [cofx {:db {:profile/profile {:public-key account-pub-key}}}
12+
expected {:fx [[:json-rpc/call
13+
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
14+
:params [account-pub-key community-id []]
15+
:on-success [:communities/sign-data community-id password]
16+
:on-error [:communities/requested-to-join-error community-id]}]]]}]
17+
(is (= expected
18+
(sut/request-to-join cofx
19+
[{:community-id community-id
20+
:password password}])))))
21+
22+
(deftest sign-data-test
23+
(let [cofx {:db {}}
24+
sign-params [{:data "123" :account account-pub-key}
25+
{:data "456" :account "0x2"}]
26+
addresses-to-reveal [account-pub-key "0x2"]
27+
expected {:fx
28+
[[:json-rpc/call
29+
[{:method "wakuext_signData"
30+
:params [[{:data "123" :account account-pub-key :password password}
31+
{:data "456" :account "0x2" :password password}]]
32+
:on-success [:communities/request-to-join-with-signatures
33+
community-id addresses-to-reveal]
34+
:on-error [:communities/requested-to-join-error community-id]}]]]}]
35+
(is (= expected
36+
(sut/sign-data cofx [community-id password sign-params])))))
37+
38+
(deftest request-to-join-with-signatures-test
39+
(let [cofx {:db {}}
40+
addresses-to-reveal [account-pub-key "0x2"]
41+
signatures ["11111" "222222"]
42+
expected {:fx [[:json-rpc/call
43+
[{:method "wakuext_requestToJoinCommunity"
44+
:params [{:communityId community-id
45+
:signatures signatures
46+
:addressesToReveal addresses-to-reveal
47+
:airdropAddress "0x1"}]
48+
:js-response true
49+
:on-success [:communities/requested-to-join]
50+
:on-error [:communities/requested-to-join-error
51+
community-id]}]]]}]
52+
(is (= expected
53+
(sut/request-to-join-with-signatures cofx [community-id addresses-to-reveal signatures])))))

src/status_im2/contexts/communities/overview/view.cljs

+9-7
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
(defn community-content
256256
[community]
257257
(rf/dispatch [:communities/check-all-community-channels-permissions (:id community)])
258-
(fn [{:keys [name description joined images tags color id] :as community}
258+
(fn [{:keys [name description joined images tags color id token-permissions] :as community}
259259
pending?
260260
{:keys [on-category-layout
261261
collapsed?
@@ -273,12 +273,14 @@
273273
:last-item-style style/last-community-tag
274274
:container-style style/community-tag-container}])
275275
[join-community community pending?]]
276-
[channel-list-component
277-
{:on-category-layout on-category-layout
278-
:community-id id
279-
:community-color color
280-
:on-first-channel-height-changed on-first-channel-height-changed}
281-
(add-handlers-to-categorized-chats id chats-by-category joined)]])))
276+
(when (or (and (seq token-permissions) joined)
277+
(empty? token-permissions))
278+
[channel-list-component
279+
{:on-category-layout on-category-layout
280+
:community-id id
281+
:community-color color
282+
:on-first-channel-height-changed on-first-channel-height-changed}
283+
(add-handlers-to-categorized-chats id chats-by-category joined)])])))
282284

283285
(defn sticky-category-header
284286
[_]

src/status_im2/integration_test/chat.cljs src/status_im2/integration_test/chat_test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns status-im2.integration-test.chat
1+
(ns status-im2.integration-test.chat-test
22
(:require
33
[cljs.test :refer [deftest is]]
44
[day8.re-frame.test :as rf-test]
@@ -16,7 +16,7 @@
1616
"0x0402905bed83f0bbf993cee8239012ccb1a8bc86907ead834c1e38476a0eda71414eed0e25f525f270592a2eebb01c9119a4ed6429ba114e51f5cb0a28dae1adfd")
1717

1818
(deftest one-to-one-chat-test
19-
(h/log-headline one-to-one-chat-test)
19+
(h/log-headline :one-to-one-chat-test)
2020
(rf-test/run-test-async
2121
(h/with-app-initialized
2222
(h/with-account

src/status_im2/integration_test/community.cljs src/status_im2/integration_test/community_test.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns status-im2.integration-test.community
1+
(ns status-im2.integration-test.community-test
22
(:require [cljs.test :refer [deftest]]
33
[day8.re-frame.test :as rf-test]
44
[re-frame.core :as rf]

src/status_im2/integration_test/core.cljs src/status_im2/integration_test/core_test.cljs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns status-im2.integration-test.core
1+
(ns status-im2.integration-test.core-test
22
(:require
33
[cljs.test :refer [deftest]]
44
[day8.re-frame.test :as rf-test]
@@ -8,17 +8,14 @@
88
status-im.subs.root
99
[status-im.utils.test :as utils.test]
1010
status-im2.events
11-
status-im2.integration-test.chat
12-
status-im2.integration-test.wallet
1311
status-im2.navigation.core
1412
status-im2.subs.root
1513
[test-helpers.integration :as h]))
1614

17-
(utils.test/init!)
18-
1915
(deftest initialize-app-test
2016
(h/log-headline :initialize-app-test)
2117
(rf-test/run-test-async
18+
(utils.test/init!)
2219
(rf/dispatch [:app-started])
2320
(rf-test/wait-for
2421
;; use initialize-view because it has the longest avg. time and

src/status_im2/integration_test/wallet.cljs src/status_im2/integration_test/wallet_test.cljs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
(ns status-im2.integration-test.wallet
1+
(ns status-im2.integration-test.wallet-test
22
(:require
3-
[cljs.test :refer [deftest is]]
3+
[cljs.test :refer [is]]
44
[clojure.string :as string]
55
[day8.re-frame.test :as rf-test]
66
[re-frame.core :as rf]
@@ -12,7 +12,9 @@
1212
status-im2.subs.root
1313
[test-helpers.integration :as h]))
1414

15-
(deftest create-wallet-account-test
15+
;; Workaround to skip test. Switch to `deftest` when test is fixed.
16+
(defn create-wallet-account-test
17+
[]
1618
(h/log-headline :create-wallet-account-test)
1719
(rf-test/run-test-async
1820
(h/with-app-initialized
@@ -24,7 +26,9 @@
2426
(h/logout)
2527
(rf-test/wait-for [::logout/logout-method]))))))
2628

27-
(deftest back-up-seed-phrase-test
29+
;; Workaround to skip test. Switch to `deftest` when test is fixed.
30+
(defn back-up-seed-phrase-test
31+
[]
2832
(h/log-headline :back-up-seed-phrase-test)
2933
(rf-test/run-test-async
3034
(h/with-app-initialized

src/test_helpers/integration.clj

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
(defmacro with-app-initialized
66
[& body]
7-
`(if (app-initialized)
8-
(do ~@body)
9-
(do
10-
(rf/dispatch [:app-started])
11-
(rf-test/wait-for
12-
[:profile/get-profiles-overview-success]
13-
~@body))))
7+
`(do
8+
(status-im.utils.test/init!)
9+
(if (test-helpers.integration/app-initialized)
10+
(do ~@body)
11+
(do
12+
(rf/dispatch [:app-started])
13+
(rf-test/wait-for [:profile/get-profiles-overview-success]
14+
~@body)))))
1415

1516
(defmacro with-account
1617
[& body]
17-
`(if (messenger-started)
18+
`(if (test-helpers.integration/messenger-started)
1819
(do ~@body)
1920
(do
20-
(create-multiaccount!)
21-
(rf-test/wait-for
22-
[:status-im.transport.core/messenger-started]
23-
(assert-messenger-started)
21+
(test-helpers.integration/create-multiaccount!)
22+
(rf-test/wait-for [:status-im.transport.core/messenger-started]
23+
(test-helpers.integration/assert-messenger-started)
2424
~@body))))

src/test_helpers/integration.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(ns test-helpers.integration
2+
(:require-macros [test-helpers.integration])
23
(:require
34
[cljs.test :refer [is]]
45
[native-module.core :as native-module]

0 commit comments

Comments
 (0)