Show mainnet warning

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Dmitry Novotochinov 2018-06-20 18:00:36 +03:00 committed by Igor Mandrigin
parent 63da0ffb50
commit 08932c4e2b
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
12 changed files with 85 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -19,3 +19,4 @@ INSTABUG_SURVEYS=1
GROUP_CHATS_ENABLED=0
FORCE_SENT_RECEIVED_TRACKING=0
USE_SYM_KEY=0
MAINNET_WARNING_ENABLED=1

View File

@ -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}])

View File

@ -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}}})

View File

@ -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))

View File

@ -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"

View File

@ -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)))

View File

@ -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} _]

View File

@ -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

View File

@ -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)))

View File

@ -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 []