From 7b425c1a5301996afa28a079c159c80f952e05c3 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 3 Aug 2023 08:59:28 +0800 Subject: [PATCH] Add method for fast creation of communities (#16806) * fast create community to test * fix: in PR builds only token gated community is available * update status-go-version.json --- .env.e2e | 1 + .env.jenkins | 1 + .env.nightly | 1 + src/status_im/communities/core.cljs | 30 +++++++++++++++++ src/status_im2/config.cljs | 3 ++ .../communities/actions/home_plus/view.cljs | 33 ++++++++++++++----- status-go-version.json | 6 ++-- 7 files changed, 63 insertions(+), 12 deletions(-) diff --git a/.env.e2e b/.env.e2e index fb3b958e39..4a14f20199 100644 --- a/.env.e2e +++ b/.env.e2e @@ -32,3 +32,4 @@ DELETE_MESSAGE_ENABLED=1 TWO_MINUTES_SYNCING=1 STICKERS_TEST_ENABLED=1 LOCAL_PAIRING_ENABLED=1 +FAST_CREATE_COMMUNITY_ENABLED=1 diff --git a/.env.jenkins b/.env.jenkins index 37663ce1e8..68791e1faf 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -34,3 +34,4 @@ TWO_MINUTES_SYNCING=1 ENABLE_QUO_PREVIEW=1 STICKERS_TEST_ENABLED=1 LOCAL_PAIRING_ENABLED=1 +FAST_CREATE_COMMUNITY_ENABLED=1 diff --git a/.env.nightly b/.env.nightly index 15e3adcb35..99ab68cd3c 100644 --- a/.env.nightly +++ b/.env.nightly @@ -21,3 +21,4 @@ BLANK_PREVIEW=0 COMMUNITIES_ENABLED=1 DATABASE_MANAGEMENT_ENABLED=1 DELETE_MESSAGE_ENABLED=1 +FAST_CREATE_COMMUNITY_ENABLED=0 diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index 3513089bf4..7a7f1ae3fb 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -532,6 +532,36 @@ {:db (assoc db :communities/create {:membership constants/community-no-membership-access})} (navigation/navigate-to :community-create nil))) +(rf/defn create-closed-community + {:events [:fast-create-community/create-closed-community]} + [_] + {:json-rpc/call [{:method "wakuext_createClosedCommunity" + :params [] + :js-response true + :on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) + :on-error #(log/error "failed to create closed community." {:error %})}] + :dispatch [:hide-bottom-sheet]}) + +(rf/defn create-open-community + {:events [:fast-create-community/create-open-community]} + [_] + {:json-rpc/call [{:method "wakuext_createOpenCommunity" + :params [] + :js-response true + :on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) + :on-error #(log/error "failed to create open community." {:error %})}] + :dispatch [:hide-bottom-sheet]}) + +(rf/defn create-token-gated-community + {:events [:fast-create-community/create-token-gated-community]} + [_] + {:json-rpc/call [{:method "wakuext_createTokenGatedCommunity" + :params [] + :js-response true + :on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) + :on-error #(log/error "failed to create token gated community." {:error %})}] + :dispatch [:hide-bottom-sheet]}) + (rf/defn open-edit-community {:events [::open-edit-community :communities/open-edit-community]} [{:keys [db] :as cofx} id] diff --git a/src/status_im2/config.cljs b/src/status_im2/config.cljs index e54787279e..46970abc41 100644 --- a/src/status_im2/config.cljs +++ b/src/status_im2/config.cljs @@ -68,6 +68,9 @@ (get-config :VERIFY_ENS_CONTRACT_ADDRESS ((ethereum/chain-id->chain-keyword verify-ens-chain-id) ens/ens-registries))) +(def fast-create-community-enabled? + (enabled? (get-config :FAST_CREATE_COMMUNITY_ENABLED "0"))) + (def default-multiaccount {:preview-privacy? blank-preview? :wallet/visible-tokens {:mainnet #{:SNT}} diff --git a/src/status_im2/contexts/communities/actions/home_plus/view.cljs b/src/status_im2/contexts/communities/actions/home_plus/view.cljs index d1cdb18bb1..772cebab42 100644 --- a/src/status_im2/contexts/communities/actions/home_plus/view.cljs +++ b/src/status_im2/contexts/communities/actions/home_plus/view.cljs @@ -1,15 +1,30 @@ (ns status-im2.contexts.communities.actions.home-plus.view (:require [quo2.core :as quo] - [utils.re-frame :as rf])) + [utils.re-frame :as rf] + [status-im2.config :as config])) (defn view [] [quo/action-drawer - [[{:icon :i/download - :accessibility-label :import-community - :label "Import community" - :on-press #(rf/dispatch [:navigate-to :community-import])} - {:icon :i/communities - :accessibility-label :create-community - :label "Create community (only for e2e)" - :on-press #(rf/dispatch [:legacy-only-for-e2e/open-create-community])}]]]) + [(concat [{:icon :i/download + :accessibility-label :import-community + :label "Import community" + :on-press #(rf/dispatch [:navigate-to :community-import])} + {:icon :i/communities + :accessibility-label :create-community + :label "Create community (only for e2e)" + :on-press #(rf/dispatch [:legacy-only-for-e2e/open-create-community])}] + (when config/fast-create-community-enabled? + [{:icon :i/communities + :accessibility-label :create-closed-community + :label "Create closed community" + :on-press #(rf/dispatch [:fast-create-community/create-closed-community])} + {:icon :i/communities + :accessibility-label :create-open-community + :label "Create open community" + :on-press #(rf/dispatch [:fast-create-community/create-open-community])} + {:icon :i/communities + :accessibility-label :create-token-gated-community + :label "Create token-gated community" + :on-press #(rf/dispatch + [:fast-create-community/create-token-gated-community])}]))]]) diff --git a/status-go-version.json b/status-go-version.json index 7bc6140ee3..36599d269f 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.162.13", - "commit-sha1": "b81ad3fcac4c8c5c24964fb9f62dedc020ec3eb5", - "src-sha256": "0w69rdpaqm88wa9yxkdg46iw7cvd8aln1c3znzph2wf0803ab1qm" + "version": "v0.162.14", + "commit-sha1": "60143556ff942e24f4641dc741049e8ad4fef619", + "src-sha256": "0b8rk8v9fmsf36611c3frzdgq6y09pzy83h4zbz50fccphzrcxcf" }