From 08932c4e2bec34afc45bbebc958a8e8a2a6ee11a Mon Sep 17 00:00:00 2001 From: Dmitry Novotochinov Date: Wed, 20 Jun 2018 18:00:36 +0300 Subject: [PATCH] Show mainnet warning Signed-off-by: Igor Mandrigin --- .env.jenkins | 1 + .env.nightly | 1 + .env.prod | 1 + .../data_store/realm/schemas/base/core.cljs | 8 +++-- .../realm/schemas/base/v6/account.cljs | 31 +++++++++++++++++++ .../realm/schemas/base/v6/core.cljs | 12 +++++++ src/status_im/translations/en.cljs | 3 ++ src/status_im/ui/screens/accounts/db.cljs | 3 +- src/status_im/ui/screens/accounts/events.cljs | 21 +++++++++++++ src/status_im/ui/screens/events.cljs | 3 +- src/status_im/utils/config.cljs | 1 + src/status_im/utils/notifications.cljs | 6 ++-- 12 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 src/status_im/data_store/realm/schemas/base/v6/account.cljs create mode 100644 src/status_im/data_store/realm/schemas/base/v6/core.cljs diff --git a/.env.jenkins b/.env.jenkins index 850f5e212d..b06a2f7305 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -19,3 +19,4 @@ GROUP_CHATS_ENABLED=0 FORCE_SENT_RECEIVED_TRACKING=1 USE_SYM_KEY=0 SPAM_BUTTON_DETECTION_ENABLED=1 +MAINNET_WARNING_ENABLED=1 diff --git a/.env.nightly b/.env.nightly index f520cf5fd4..4a7fd8b7ba 100644 --- a/.env.nightly +++ b/.env.nightly @@ -18,3 +18,4 @@ INSTABUG_SURVEYS=1 GROUP_CHATS_ENABLED=0 FORCE_SENT_RECEIVED_TRACKING=1 SPAM_BUTTON_DETECTION_ENABLED=1 +MAINNET_WARNING_ENABLED=1 diff --git a/.env.prod b/.env.prod index c9f3b81c54..88c8323df6 100644 --- a/.env.prod +++ b/.env.prod @@ -19,3 +19,4 @@ INSTABUG_SURVEYS=1 GROUP_CHATS_ENABLED=0 FORCE_SENT_RECEIVED_TRACKING=0 USE_SYM_KEY=0 +MAINNET_WARNING_ENABLED=1 diff --git a/src/status_im/data_store/realm/schemas/base/core.cljs b/src/status_im/data_store/realm/schemas/base/core.cljs index 956a3c4a9f..3070c9550b 100644 --- a/src/status_im/data_store/realm/schemas/base/core.cljs +++ b/src/status_im/data_store/realm/schemas/base/core.cljs @@ -3,7 +3,8 @@ [status-im.data-store.realm.schemas.base.v2.core :as v2] [status-im.data-store.realm.schemas.base.v3.core :as v3] [status-im.data-store.realm.schemas.base.v4.core :as v4] - [status-im.data-store.realm.schemas.base.v5.core :as v5])) + [status-im.data-store.realm.schemas.base.v5.core :as v5] + [status-im.data-store.realm.schemas.base.v6.core :as v6])) ;; put schemas ordered by version (def schemas [{:schema v1/schema @@ -20,4 +21,7 @@ :migration v4/migration} {:schema v5/schema :schemaVersion 5 - :migration v5/migration}]) + :migration v5/migration} + {:schema v6/schema + :schemaVersion 6 + :migration v6/migration}]) diff --git a/src/status_im/data_store/realm/schemas/base/v6/account.cljs b/src/status_im/data_store/realm/schemas/base/v6/account.cljs new file mode 100644 index 0000000000..4d942c7552 --- /dev/null +++ b/src/status_im/data_store/realm/schemas/base/v6/account.cljs @@ -0,0 +1,31 @@ +(ns status-im.data-store.realm.schemas.base.v6.account) + +(def schema {:name :account + :primaryKey :address + :properties {:address :string + :public-key :string + :name {:type :string :optional true} + :email {:type :string :optional true} + :status {:type :string :optional true} + :debug? {:type :bool :default false} + :photo-path :string + :signing-phrase {:type :string} + :mnemonic {:type :string :optional true} + :last-updated {:type :int :default 0} + :last-sign-in {:type :int :default 0} + :signed-up? {:type :bool + :default false} + :network :string + :networks {:type :list + :objectType :network} + :bootnodes {:type :list + :objectType :bootnode} + :last-request {:type :int :optional true} + :settings {:type :string} + :sharing-usage-data? {:type :bool :default false} + :dev-mode? {:type :bool :default false} + :seed-backed-up? {:type :bool :default false} + :wallet-set-up-passed? {:type :bool + :default false} + :mainnet-warning-shown? {:type :bool + :default false}}}) diff --git a/src/status_im/data_store/realm/schemas/base/v6/core.cljs b/src/status_im/data_store/realm/schemas/base/v6/core.cljs new file mode 100644 index 0000000000..4beb126af8 --- /dev/null +++ b/src/status_im/data_store/realm/schemas/base/v6/core.cljs @@ -0,0 +1,12 @@ +(ns status-im.data-store.realm.schemas.base.v6.core + (:require [status-im.data-store.realm.schemas.base.v1.network :as network] + [status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode] + [status-im.data-store.realm.schemas.base.v6.account :as account] + [taoensso.timbre :as log])) + +(def schema [network/schema + bootnode/schema + account/schema]) + +(defn migration [old-realm new-realm] + (log/debug "migrating base database v6: " old-realm new-realm)) diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 7d5110f687..6665dcadf5 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -669,6 +669,9 @@ :delete-bootnode-are-you-sure "Are you sure you want to delete this bootnode?" :delete-bootnode "Delete bootnode" + :mainnet-is-default-alert-title "Hello" + :mainnet-is-default-alert-text "Thanks for choosing Status! We are now in Beta, which means new installs are automatically connected to the Mainnet. If you upgraded, you may still need to switch networks, which you can do easily by navigating to your Profile -> Advanced Mode -> Switch Developer Mode on -> Choose your network. Now just have fun! Browse DApps, exchange assets, start your own #chats, and message your friends, all from the world's first decentralised, mobile client for Ethereum.\n\nPlease note that this is a beta release and we advise you that using this app should be done for testing purposes only and you assume the full responsibility for all risks concerning your data and funds." + :main-networks "Main networks" :test-networks "Test networks" :custom-networks "Custom networks" diff --git a/src/status_im/ui/screens/accounts/db.cljs b/src/status_im/ui/screens/accounts/db.cljs index 68581841ff..9cfea15453 100644 --- a/src/status_im/ui/screens/accounts/db.cljs +++ b/src/status_im/ui/screens/accounts/db.cljs @@ -34,6 +34,7 @@ (spec/def :account/dev-mode? (spec/nilable boolean?)) (spec/def :account/seed-backed-up? (spec/nilable boolean?)) (spec/def :account/wallet-set-up-passed? (spec/nilable boolean?)) +(spec/def :account/mainnet-warning-shown? (spec/nilable boolean?)) (spec/def :accounts/account (allowed-keys :req-un [:account/name :account/address :account/public-key @@ -44,7 +45,7 @@ :account/last-sign-in :account/sharing-usage-data? :account/dev-mode? :account/seed-backed-up? :account/mnemonic :account/wallet-set-up-passed? :account/last-request - :account/bootnodes])) + :account/bootnodes :account/mainnet-warning-shown?])) (spec/def :accounts/accounts (spec/nilable (spec/map-of :account/address :accounts/account))) diff --git a/src/status_im/ui/screens/accounts/events.cljs b/src/status_im/ui/screens/accounts/events.cljs index af1d63811e..df4a2431bd 100644 --- a/src/status_im/ui/screens/accounts/events.cljs +++ b/src/status_im/ui/screens/accounts/events.cljs @@ -6,6 +6,9 @@ [status-im.utils.identicon :refer [identicon]] [status-im.utils.random :as random] [clojure.string :as str] + [status-im.i18n :as i18n] + [status-im.utils.config :as config] + [status-im.utils.utils :as utils] [status-im.utils.datetime :as time] [status-im.utils.handlers :as handlers] [status-im.utils.handlers-macro :as handlers-macro] @@ -152,6 +155,24 @@ (fn [{db :db now :now :as cofx} _] (accounts.utils/account-update {:last-sign-in now} cofx))) +(handlers/register-handler-fx + :update-mainnet-warning-shown + (fn [cofx _] + (accounts.utils/account-update {:mainnet-warning-shown? true} cofx))) + +(handlers/register-handler-fx + :show-mainnet-is-default-alert + (fn [{:keys [db]}] + (let [enter-name-screen? (= :enter-name (get-in db [:accounts/create :step])) + shown? (get-in db [:account/account :mainnet-warning-shown?])] + (when (and config/mainnet-warning-enabled? + (not shown?) + (not enter-name-screen?)) + (utils/show-popup + (i18n/label :mainnet-is-default-alert-title) + (i18n/label :mainnet-is-default-alert-text) + #(re-frame/dispatch [:update-mainnet-warning-shown])))))) + (handlers/register-handler-fx :reset-account-creation (fn [{db :db} _] diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index 3a6337b23f..84ed7a093f 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -320,7 +320,8 @@ [:update-wallet] [:update-transactions] [:get-fcm-token] - [:update-sign-in-time]] + [:update-sign-in-time] + [:show-mainnet-is-default-alert]] (seq events-after) (into events-after))})) (handlers/register-handler-fx diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index e032363b0b..ecd07307b3 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -44,3 +44,4 @@ (def group-chats-enabled? (enabled? (get-config :GROUP_CHATS_ENABLED))) (def spam-button-detection-enabled? (enabled? (get-config :SPAM_BUTTON_DETECTION_ENABLED "0"))) +(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0))) diff --git a/src/status_im/utils/notifications.cljs b/src/status_im/utils/notifications.cljs index 6a7c438ae4..974854d48c 100644 --- a/src/status_im/utils/notifications.cljs +++ b/src/status_im/utils/notifications.cljs @@ -18,11 +18,13 @@ (handlers/register-handler-fx :request-notifications-granted - (fn [_ _])) + (fn [_ _] + (re-frame.core/dispatch [:show-mainnet-is-default-alert]))) (handlers/register-handler-fx :request-notifications-denied - (fn [_ _])) + (fn [_ _] + (re-frame.core/dispatch [:show-mainnet-is-default-alert]))) ;; NOTE: Only need to explicitly request permissions on iOS. (defn request-permissions []