From 27b77a6dc9f2fd9388c4529905dbd747592e0faa Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 26 Jul 2019 10:12:10 +0200 Subject: [PATCH] Add datasync,v1messages & disable discovery topic In preparation for v1 this commits adds a few options so we can get start debugging the protocol for v1. This options are: 1) Datasync: If enabled it will send datasync messages 2) V1Messages: If enabled it will send v1 messages (just adding a signature to the message) 3) Disable discovery topic: If enabled it will stop listening/publishing on the discovery topic. You will be able to receive messages only from clients who have this enabled as well. If any of this option is on, it will only be compatitle with builds >= this one. A logout is required for any change to take effect. All this options will be removed before v1, they are there just to make it easier for us to test and find potential issues. Signed-off-by: Andrea Maria Piana --- src/status_im/events.cljs | 15 +++++++++ src/status_im/multiaccounts/core.cljs | 33 +++++++++++++++++++ src/status_im/node/core.cljs | 8 ++++- .../desktop/main/tabs/profile/views.cljs | 29 +++++++++++++++- .../ui/screens/profile/user/views.cljs | 21 ++++++++++++ status-go-version.json | 6 ++-- translations/en.json | 10 ++++++ 7 files changed, 117 insertions(+), 5 deletions(-) diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 24eeea4cb8..667087ea61 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -232,6 +232,21 @@ (fn [cofx [_ enabled?]] (multiaccounts/toggle-device-to-device cofx enabled?))) +(handlers/register-handler-fx + :multiaccounts.ui/toggle-datasync + (fn [cofx [_ enabled?]] + (multiaccounts/toggle-datasync cofx enabled?))) + +(handlers/register-handler-fx + :multiaccounts.ui/toggle-v1-messages + (fn [cofx [_ enabled?]] + (multiaccounts/toggle-v1-messages cofx enabled?))) + +(handlers/register-handler-fx + :multiaccounts.ui/toggle-disable-discovery-topic + (fn [cofx [_ enabled?]] + (multiaccounts/toggle-disable-discovery-topic cofx enabled?))) + (handlers/register-handler-fx :multiaccounts.ui/web3-opt-in-mode-switched (fn [cofx [_ opt-in]] diff --git a/src/status_im/multiaccounts/core.cljs b/src/status_im/multiaccounts/core.cljs index 66d16ff296..8df8909fae 100644 --- a/src/status_im/multiaccounts/core.cljs +++ b/src/status_im/multiaccounts/core.cljs @@ -108,6 +108,39 @@ (multiaccounts.update/update-settings (assoc settings :pfs? enabled?) {})))) +(fx/defn toggle-datasync + [{:keys [db] :as cofx} enabled?] + (let [settings (get-in db [:multiaccount :settings]) + warning {:utils/show-popup {:title (i18n/label :t/datasync-warning-title) + :content (i18n/label :t/datasync-warning-content)}}] + + (fx/merge cofx + (when enabled? warning) + (multiaccounts.update/update-settings (assoc settings :datasync? enabled?) + {})))) + +(fx/defn toggle-v1-messages + [{:keys [db] :as cofx} enabled?] + (let [settings (get-in db [:multiaccount :settings]) + warning {:utils/show-popup {:title (i18n/label :t/v1-messages-warning-title) + :content (i18n/label :t/v1-messages-warning-content)}}] + + (fx/merge cofx + (when enabled? warning) + (multiaccounts.update/update-settings (assoc settings :v1-messages? enabled?) + {})))) + +(fx/defn toggle-disable-discovery-topic + [{:keys [db] :as cofx} enabled?] + (let [settings (get-in db [:multiaccount :settings]) + warning {:utils/show-popup {:title (i18n/label :t/disable-discovery-topic-warning-title) + :content (i18n/label :t/disable-discovery-topic-warning-content)}}] + + (fx/merge cofx + (when enabled? warning) + (multiaccounts.update/update-settings (assoc settings :disable-discovery-topic? enabled?) + {})))) + (fx/defn switch-web3-opt-in-mode [{:keys [db] :as cofx} opt-in] (let [settings (get-in db [:multiaccount :settings])] diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index 340f732214..37871f1383 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -100,7 +100,10 @@ :installation-id (get db :multiaccounts/new-installation-id)} (get multiaccounts address)) use-custom-bootnodes (get-in settings [:bootnodes network]) - log-level (get-log-level settings)] + log-level (get-log-level settings) + datasync? (:datasync? settings) + disable-discovery-topic? (:disable-discovery-topic? settings) + v1-messages? (:v1-messages? settings)] (cond-> (get-in networks [network :config]) :always (get-base-node-config) @@ -127,6 +130,9 @@ :InstallationID installation-id :MaxMessageDeliveryAttempts config/max-message-delivery-attempts :MailServerConfirmations config/mailserver-confirmations-enabled? + :DataSyncEnabled (boolean datasync?) + :DisableGenericDiscoveryTopic (boolean disable-discovery-topic?) + :SendV1Messages (boolean v1-messages?) :PFSEnabled true} :RequireTopics (get-topics network)) diff --git a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs index 82e8aa3b66..2936108bdc 100644 --- a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs +++ b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs @@ -165,6 +165,9 @@ current-mailserver-id preferred-mailserver-id) pfs? (:pfs? settings) + datasync? (:datasync? settings) + v1-messages? (:datasync? settings) + disable-discovery-topic? (:disable-discovery-topic? settings) connection-message (connection-status peers-count node-status mailserver-state disconnected)] [react/scroll-view [react/text {:style styles/advanced-settings-title} @@ -217,7 +220,31 @@ [react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/device-to-device)] [react/switch {:track-color #js {:true colors/blue :false nil} :value pfs? - :on-value-change #(re-frame/dispatch [:multiaccounts.ui/toggle-device-to-device (not pfs?)])}]]]))) + :on-value-change #(re-frame/dispatch [:multiaccounts.ui/toggle-device-to-device (not pfs?)])}]] + + [react/view {:style styles/title-separator}] + [react/text {:style styles/adv-settings-subtitle} (i18n/label :t/v1-messages)] + [react/view {:style (styles/profile-row false)} + [react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/v1-messages)] + [react/switch {:track-color #js {:true colors/blue :false nil} + :value pfs? + :on-value-change #(re-frame/dispatch [:multiaccounts.ui/toggle-v1-messages (not v1-messages?)])}]] + + [react/view {:style styles/title-separator}] + [react/text {:style styles/adv-settings-subtitle} (i18n/label :t/datasync)] + [react/view {:style (styles/profile-row false)} + [react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/datasync)] + [react/switch {:track-color #js {:true colors/blue :false nil} + :value pfs? + :on-value-change #(re-frame/dispatch [:multiaccounts.ui/toggle-datasync (not datasync?)])}]] + + [react/view {:style styles/title-separator}] + [react/text {:style styles/adv-settings-subtitle} (i18n/label :t/disable-discovery-topic)] + [react/view {:style (styles/profile-row false)} + [react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/disable-discovery-topic)] + [react/switch {:track-color #js {:true colors/blue :false nil} + :value pfs? + :on-value-change #(re-frame/dispatch [:multiaccounts.ui/toggle-disable-discovery-topic (not disable-discovery-topic?)])}]]]))) (views/defview installations [] (views/letsubs [installations [:pairing/installations]] diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 701e8096a5..2e1ebf5c83 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -224,6 +224,27 @@ {:label-kw :t/device-to-device :value (:pfs? settings) :action-fn #(re-frame/dispatch [:multiaccounts.ui/toggle-device-to-device %])}]) + (when dev-mode? + [profile.components/settings-item-separator]) + (when dev-mode? + [profile.components/settings-switch-item + {:label-kw :t/datasync + :value (:datasync? settings) + :action-fn #(re-frame/dispatch [:multiaccounts.ui/toggle-datasync %])}]) + (when dev-mode? + [profile.components/settings-item-separator]) + (when dev-mode? + [profile.components/settings-switch-item + {:label-kw :t/v1-messages + :value (:v1-messages? settings) + :action-fn #(re-frame/dispatch [:multiaccounts.ui/toggle-v1-messages %])}]) + (when dev-mode? + [profile.components/settings-item-separator]) + (when dev-mode? + [profile.components/settings-switch-item + {:label-kw :t/disable-discovery-topic + :value (:disable-discovery-topic? settings) + :action-fn #(re-frame/dispatch [:multiaccounts.ui/toggle-disable-discovery-topic %])}]) [profile.components/settings-item-separator] [profile.components/settings-switch-item {:label-kw :t/dev-mode diff --git a/status-go-version.json b/status-go-version.json index cbd75da6b6..8b63e7be48 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.30.1-beta.0", - "commit-sha1": "e93d994460fdbb8c10cb2f417eabe72559a2c517", - "src-sha256": "13y3rwjpqw2mmwc9ngjc2wawnl2myyf3wxm5vk49dgvh14dv6y61" + "version": "release-0.30.1-beta.2", + "commit-sha1": "960b4763a6ef861173f603c858bfa4dc8e2a37ee", + "src-sha256": "1d00gk04l360jr7fi4i161vv6zsj4waxbazrn64k71r32685ig1q" } diff --git a/translations/en.json b/translations/en.json index 525ee25b2a..3cf9a05f51 100644 --- a/translations/en.json +++ b/translations/en.json @@ -254,6 +254,16 @@ "device-to-device": "Device-to-device Enabled", "device-to-device-warning-title": "Warning, experimental feature", "device-to-device-warning-content": "If enabled, only users who are running 0.9.32 and higher will be able to read your direct and public messages.", + "datasync": "DataSync Enabled", + "datasync-warning-title": "Warning, experimental feature", + "datasync-warning-content": "If enabled, only users who are running builds with datasync will be able to read your direct messages. Please logout/login for the changes to take effect", + "v1-messages": "V1 Messages Enabled", + "v1-messages-warning-title": "Warning, experimental feature", + "v1-messages-warning-content": "If enabled, only users who are running builds with v1-messages will be able to read your messages. Please logout/login for the changes to take effect", + + "disable-discovery-topic": "Discovery topic Disabled", + "disable-discovery-topic-warning-title": "Warning, experimental feature", + "disable-discovery-topic-warning-content": "If enabled, only users who have this on will be able to read your messages and send you messages. Please logout/login for the changes to take effect", "open-dapp": "Open ÐApp", "new-transaction": "New Transaction", "currency-display-name-bbd": "Barbados Dollar",