Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7a0540794 | ||
|
|
56f7206da7 | ||
|
|
eb5de3506a | ||
|
|
22005f916e | ||
|
|
ff50aacb3a | ||
|
|
91300b9ff8 | ||
|
|
d93b20242a | ||
|
|
0a43e5c97a |
@@ -225,7 +225,9 @@
|
|||||||
(.. ^js % -nativeEvent -data)])
|
(.. ^js % -nativeEvent -data)])
|
||||||
:on-load #(re-frame/dispatch [:browser/loading-started])
|
:on-load #(re-frame/dispatch [:browser/loading-started])
|
||||||
:on-error #(re-frame/dispatch [:browser/error-occured])
|
:on-error #(re-frame/dispatch [:browser/error-occured])
|
||||||
:injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))}])]
|
:injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))
|
||||||
|
;; https://github.com/status-im/status-mobile/issues/17854
|
||||||
|
:allows-inline-media-playback true}])]
|
||||||
[navigation
|
[navigation
|
||||||
{:url url-original
|
{:url url-original
|
||||||
:name name
|
:name name
|
||||||
|
|||||||
@@ -42,26 +42,31 @@
|
|||||||
community-id %])
|
community-id %])
|
||||||
:on-error #(log/error "failed to request to join community" community-id %)}]})
|
:on-error #(log/error "failed to request to join community" community-id %)}]})
|
||||||
|
|
||||||
|
(defn request-to-join
|
||||||
|
[{:keys [db]} [{:keys [community-id password]}]]
|
||||||
|
(let [pub-key (get-in db [:profile/profile :public-key])
|
||||||
|
addresses-to-reveal []]
|
||||||
|
{:fx [[:json-rpc/call
|
||||||
|
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
|
||||||
|
:params [pub-key community-id addresses-to-reveal]
|
||||||
|
:on-success [:communities/sign-data community-id password]
|
||||||
|
:on-error [:communities/requested-to-join-error community-id]}]]]}))
|
||||||
|
|
||||||
;; Event to be called to request to join a community.
|
;; Event to be called to request to join a community.
|
||||||
;; This event will generate the data to be signed and then call the sign-data event.
|
;; This event will generate the data to be signed and then call the sign-data event.
|
||||||
;; This is the only event that should be called from the UI.
|
;; This is the only event that should be called from the UI.
|
||||||
(rf/reg-event-fx :communities/request-to-join
|
(rf/reg-event-fx :communities/request-to-join request-to-join)
|
||||||
(fn [{:keys [db]} [{:keys [community-id password]}]]
|
|
||||||
(let [pub-key (get-in db [:profile/profile :public-key])
|
|
||||||
addresses-to-reveal []]
|
|
||||||
{:fx [[:json-rpc/call
|
|
||||||
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
|
|
||||||
:params [pub-key community-id addresses-to-reveal]
|
|
||||||
:on-success [:communities/sign-data community-id password]
|
|
||||||
:on-error [:communities/requested-to-join-error community-id]}]]]})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/sign-data
|
(defn sign-data
|
||||||
(fn [_ [community-id password sign-params]]
|
[_ [community-id password sign-params]]
|
||||||
{:fx [[:json-rpc/call
|
(let [addresses-to-reveal (map :account sign-params)]
|
||||||
[{:method "wakuext_signData"
|
{:fx [[:json-rpc/call
|
||||||
:params [(map #(assoc % :password password) sign-params)]
|
[{:method "wakuext_signData"
|
||||||
:on-success [:communities/request-to-join-with-signatures community-id]
|
:params [(map #(assoc % :password password) sign-params)]
|
||||||
:on-error [:communities/requested-to-join-error community-id]}]]]}))
|
:on-success [:communities/request-to-join-with-signatures community-id addresses-to-reveal]
|
||||||
|
:on-error [:communities/requested-to-join-error community-id]}]]]}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :communities/sign-data sign-data)
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/requested-to-join-error
|
(rf/reg-event-fx :communities/requested-to-join-error
|
||||||
(fn [{:keys [db]} [community-id error]]
|
(fn [{:keys [db]} [community-id error]]
|
||||||
@@ -71,11 +76,19 @@
|
|||||||
:event :communities/requested-to-join-error})
|
:event :communities/requested-to-join-error})
|
||||||
{:db (assoc-in db [:password-authentication :error] error)}))
|
{:db (assoc-in db [:password-authentication :error] error)}))
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/request-to-join-with-signatures
|
(defn request-to-join-with-signatures
|
||||||
(fn [_ [community-id signatures]]
|
[_ [community-id addresses-to-reveal signatures]]
|
||||||
{:fx [[:json-rpc/call
|
{:fx [[:json-rpc/call
|
||||||
[{:method "wakuext_requestToJoinCommunity"
|
[{:method "wakuext_requestToJoinCommunity"
|
||||||
:params [{:communityId community-id :signatures signatures}]
|
:params [{:communityId community-id
|
||||||
:js-response true
|
:signatures signatures
|
||||||
:on-success [:communities/requested-to-join]
|
:addressesToReveal addresses-to-reveal
|
||||||
:on-error [:communities/requested-to-join-error community-id]}]]]}))
|
;; NOTE: At least one airdrop address is required.
|
||||||
|
;; This is a temporary solution while the address
|
||||||
|
;; selection feature is not implemented in mobile.
|
||||||
|
:airdropAddress (first addresses-to-reveal)}]
|
||||||
|
:js-response true
|
||||||
|
:on-success [:communities/requested-to-join]
|
||||||
|
:on-error [:communities/requested-to-join-error community-id]}]]]})
|
||||||
|
|
||||||
|
(rf/reg-event-fx :communities/request-to-join-with-signatures request-to-join-with-signatures)
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
(ns status-im2.contexts.communities.overview.events-test
|
||||||
|
(:require [cljs.test :refer [deftest is]]
|
||||||
|
[native-module.core :as native-module]
|
||||||
|
[status-im2.contexts.communities.overview.events :as sut]))
|
||||||
|
|
||||||
|
(def password (native-module/sha3 "password123"))
|
||||||
|
(def community-id "0x99")
|
||||||
|
(def account-pub-key "0x1")
|
||||||
|
|
||||||
|
(deftest request-to-join-test
|
||||||
|
(let [cofx {:db {:profile/profile {:public-key account-pub-key}}}
|
||||||
|
expected {:fx [[:json-rpc/call
|
||||||
|
[{:method "wakuext_generateJoiningCommunityRequestsForSigning"
|
||||||
|
:params [account-pub-key community-id []]
|
||||||
|
:on-success [:communities/sign-data community-id password]
|
||||||
|
:on-error [:communities/requested-to-join-error community-id]}]]]}]
|
||||||
|
(is (= expected
|
||||||
|
(sut/request-to-join cofx
|
||||||
|
[{:community-id community-id
|
||||||
|
:password password}])))))
|
||||||
|
|
||||||
|
(deftest sign-data-test
|
||||||
|
(let [cofx {:db {}}
|
||||||
|
sign-params [{:data "123" :account account-pub-key}
|
||||||
|
{:data "456" :account "0x2"}]
|
||||||
|
addresses-to-reveal [account-pub-key "0x2"]
|
||||||
|
expected {:fx
|
||||||
|
[[:json-rpc/call
|
||||||
|
[{:method "wakuext_signData"
|
||||||
|
:params [[{:data "123" :account account-pub-key :password password}
|
||||||
|
{:data "456" :account "0x2" :password password}]]
|
||||||
|
:on-success [:communities/request-to-join-with-signatures
|
||||||
|
community-id addresses-to-reveal]
|
||||||
|
:on-error [:communities/requested-to-join-error community-id]}]]]}]
|
||||||
|
(is (= expected
|
||||||
|
(sut/sign-data cofx [community-id password sign-params])))))
|
||||||
|
|
||||||
|
(deftest request-to-join-with-signatures-test
|
||||||
|
(let [cofx {:db {}}
|
||||||
|
addresses-to-reveal [account-pub-key "0x2"]
|
||||||
|
signatures ["11111" "222222"]
|
||||||
|
expected {:fx [[:json-rpc/call
|
||||||
|
[{:method "wakuext_requestToJoinCommunity"
|
||||||
|
:params [{:communityId community-id
|
||||||
|
:signatures signatures
|
||||||
|
:addressesToReveal addresses-to-reveal
|
||||||
|
:airdropAddress "0x1"}]
|
||||||
|
:js-response true
|
||||||
|
:on-success [:communities/requested-to-join]
|
||||||
|
:on-error [:communities/requested-to-join-error
|
||||||
|
community-id]}]]]}]
|
||||||
|
(is (= expected
|
||||||
|
(sut/request-to-join-with-signatures cofx [community-id addresses-to-reveal signatures])))))
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
(defn community-content
|
(defn community-content
|
||||||
[community]
|
[community]
|
||||||
(rf/dispatch [:communities/check-all-community-channels-permissions (:id community)])
|
(rf/dispatch [:communities/check-all-community-channels-permissions (:id community)])
|
||||||
(fn [{:keys [name description joined images tags color id] :as community}
|
(fn [{:keys [name description joined images tags color id token-permissions] :as community}
|
||||||
pending?
|
pending?
|
||||||
{:keys [on-category-layout
|
{:keys [on-category-layout
|
||||||
collapsed?
|
collapsed?
|
||||||
@@ -273,12 +273,14 @@
|
|||||||
:last-item-style style/last-community-tag
|
:last-item-style style/last-community-tag
|
||||||
:container-style style/community-tag-container}])
|
:container-style style/community-tag-container}])
|
||||||
[join-community community pending?]]
|
[join-community community pending?]]
|
||||||
[channel-list-component
|
(when (or (and (seq token-permissions) joined)
|
||||||
{:on-category-layout on-category-layout
|
(empty? token-permissions))
|
||||||
:community-id id
|
[channel-list-component
|
||||||
:community-color color
|
{:on-category-layout on-category-layout
|
||||||
:on-first-channel-height-changed on-first-channel-height-changed}
|
:community-id id
|
||||||
(add-handlers-to-categorized-chats id chats-by-category joined)]])))
|
:community-color color
|
||||||
|
:on-first-channel-height-changed on-first-channel-height-changed}
|
||||||
|
(add-handlers-to-categorized-chats id chats-by-category joined)])])))
|
||||||
|
|
||||||
(defn sticky-category-header
|
(defn sticky-category-header
|
||||||
[_]
|
[_]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.171.11",
|
"version": "release/0.171.x",
|
||||||
"commit-sha1": "8a4c2d8d2f17117aa0a00338e83b0f753ebf1328",
|
"commit-sha1": "d700763232415c2d0f57e8c525c813523e3e0c66",
|
||||||
"src-sha256": "160qnl9dsl1ypvqg9w6z8wps4fvgq3qxi16piymhrlzgssdwkz8h"
|
"src-sha256": "1agvd4iklw1kgsd80vlkp4bg9inm6x3xjsj9j0czm2whyh2zvhg3"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user