mirror of
https://github.com/status-im/status-react.git
synced 2025-01-10 19:16:59 +00:00
[#3939]: Introducing wallet / welcome screen;
[#3940]: Introducing wallet / signing phrase; open-migrated-realm has been removed;
This commit is contained in:
parent
62a9f26e30
commit
01a4869397
BIN
resources/images/ui/wallet-setup.png
Normal file
BIN
resources/images/ui/wallet-setup.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
resources/images/ui/wallet-welcome.png
Normal file
BIN
resources/images/ui/wallet-welcome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
@ -57,17 +57,6 @@
|
||||
(delete-realm file-name)
|
||||
(open-realm (last schemas) file-name encryption-key))
|
||||
|
||||
(defn open-migrated-realm
|
||||
[file-name schemas encryption-key]
|
||||
;; TODO: remove for release 0.9.18
|
||||
;; delete the realm file if its schema version is higher
|
||||
;; than existing schema version (this means the previous
|
||||
;; install has incompatible database schemas)
|
||||
(if (> (realm-version file-name encryption-key)
|
||||
(apply max (map :schemaVersion base/schemas)))
|
||||
(reset-realm file-name schemas encryption-key)
|
||||
(migrate-realm file-name schemas encryption-key)))
|
||||
|
||||
(defn- index-entity-schemas [all-schemas]
|
||||
(into {} (map (juxt :name identity)) (-> all-schemas last :schema)))
|
||||
|
||||
@ -89,14 +78,14 @@
|
||||
(log/debug "Opening base realm... (first run)")
|
||||
(when @base-realm
|
||||
(close @base-realm))
|
||||
(reset! base-realm (open-migrated-realm (.-defaultPath rn-dependencies/realm) base/schemas encryption-key))
|
||||
(reset! base-realm (migrate-realm (.-defaultPath rn-dependencies/realm) base/schemas encryption-key))
|
||||
(log/debug "Created @base-realm"))
|
||||
|
||||
(defn reset-account-realm [encryption-key]
|
||||
(log/debug "Resetting account realm...")
|
||||
(when @account-realm
|
||||
(close @account-realm))
|
||||
(reset! account-realm (open-migrated-realm new-account-filename account/schemas encryption-key))
|
||||
(reset! account-realm (migrate-realm new-account-filename account/schemas encryption-key))
|
||||
(.write @account-realm #(.deleteAll @account-realm))
|
||||
(log/debug "Created @account-realm"))
|
||||
|
||||
@ -104,7 +93,7 @@
|
||||
(log/debug "Moved file with error: " err address)
|
||||
(if err
|
||||
(log/error "Error moving account realm: " (.-message err))
|
||||
(reset! account-realm (open-migrated-realm address account/schemas encryption-key)))
|
||||
(reset! account-realm (migrate-realm address account/schemas encryption-key)))
|
||||
(handler err))
|
||||
|
||||
(defn change-account [address new-account? encryption-key handler]
|
||||
@ -117,7 +106,7 @@
|
||||
(log/debug "Moving file " path " to " new-path)
|
||||
(fs/move-file path new-path #(move-file-handler address encryption-key % handler)))
|
||||
(do
|
||||
(reset! account-realm (open-migrated-realm address account/schemas encryption-key))
|
||||
(reset! account-realm (migrate-realm address account/schemas encryption-key))
|
||||
(handler nil)))))
|
||||
|
||||
(declare realm-obj->clj)
|
||||
|
@ -1,7 +1,11 @@
|
||||
(ns status-im.data-store.realm.schemas.base.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.core :as v1]))
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.core :as v1]
|
||||
[status-im.data-store.realm.schemas.base.v2.core :as v2]))
|
||||
|
||||
;; put schemas ordered by version
|
||||
(def schemas [{:schema v1/schema
|
||||
:schemaVersion 1
|
||||
:migration v1/migration}])
|
||||
:migration v1/migration}
|
||||
{:schema v2/schema
|
||||
:schemaVersion 2
|
||||
:migration v2/migration}])
|
||||
|
26
src/status_im/data_store/realm/schemas/base/v2/account.cljs
Normal file
26
src/status_im/data_store/realm/schemas/base/v2/account.cljs
Normal file
@ -0,0 +1,26 @@
|
||||
(ns status-im.data-store.realm.schemas.base.v2.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}
|
||||
: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}
|
||||
: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}}})
|
10
src/status_im/data_store/realm/schemas/base/v2/core.cljs
Normal file
10
src/status_im/data_store/realm/schemas/base/v2/core.cljs
Normal file
@ -0,0 +1,10 @@
|
||||
(ns status-im.data-store.realm.schemas.base.v2.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v2.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v2: " old-realm new-realm))
|
@ -45,4 +45,6 @@
|
||||
:welcome-image (js/require "./resources/images/ui/welcome-image.png")
|
||||
:lock {:image (js/require "./resources/images/ui/lock.png")
|
||||
:width 993
|
||||
:height 933}})
|
||||
:height 933}
|
||||
:wallet-welcome (js/require "./resources/images/ui/wallet-welcome.png")
|
||||
:wallet-setup (js/require "./resources/images/ui/wallet-setup.png")})
|
||||
|
@ -162,6 +162,14 @@
|
||||
:word-n-description "In order to check if you have backed up your seed phrase correctly, enter the word #{{number}} above."
|
||||
:word-n "Word #{{number}}"
|
||||
|
||||
:wallet-onboarding-title "Simple and secure cryptocurrency wallet"
|
||||
:wallet-onboarding-description "Send, receive, and store your cryptocurrency with the Status Wallet"
|
||||
:wallet-onboarding-set-up "Let’s get set up"
|
||||
:wallet-set-up-title "Set up your wallet"
|
||||
:wallet-set-up-signing-phrase "This is your personal transaction phrase that you’ll use everytime you make a transaction. Make sure to write it down on a piece of paper, store it somewhere, and only confirm transactions when you see these three words."
|
||||
:wallet-set-up-confirm-title "Wrote it down?"
|
||||
:wallet-set-up-confirm-description "You won’t be able to see your 3-word transaction phrase again after this."
|
||||
|
||||
;;make_photo
|
||||
:image-source-title "Edit picture"
|
||||
:image-source-make-photo "Capture"
|
||||
|
@ -72,11 +72,11 @@
|
||||
(when forward?
|
||||
[icons/icon :icons/forward {:color colors/blue}])]])
|
||||
|
||||
(defn button [{:keys [on-press label background? style] :or {background? true}}]
|
||||
(defn button [{:keys [on-press label background? button-style label-style] :or {background? true}}]
|
||||
[react/touchable-highlight {:on-press on-press}
|
||||
[react/view {:style (styles/button style background?)}
|
||||
[react/view {:style (styles/button button-style background?)}
|
||||
[react/text {:uppercase? true
|
||||
:style styles/button-label}
|
||||
:style (merge styles/button-label label-style)}
|
||||
label]]])
|
||||
|
||||
(defn counter
|
||||
|
@ -138,10 +138,10 @@
|
||||
(merge
|
||||
{:padding-vertical 12
|
||||
:padding-horizontal 42
|
||||
:border-radius 8}
|
||||
style
|
||||
(when background?
|
||||
{:background-color (colors/alpha colors/blue 0.1)})))
|
||||
:border-radius 8
|
||||
:background-color (when background?
|
||||
(colors/alpha colors/blue 0.1))}
|
||||
style))
|
||||
|
||||
(def button-label
|
||||
{:font-size 15
|
||||
|
@ -30,6 +30,7 @@
|
||||
(spec/def :account/sharing-usage-data? (spec/nilable boolean?))
|
||||
(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 :accounts/account (allowed-keys
|
||||
:req-un [:account/name :account/address :account/public-key
|
||||
@ -38,7 +39,8 @@
|
||||
:account/email :account/signed-up? :account/network
|
||||
:account/networks :account/settings :account/wnode
|
||||
:account/last-sign-in :account/sharing-usage-data? :account/dev-mode?
|
||||
:account/seed-backed-up? :account/mnemonic]))
|
||||
:account/seed-backed-up? :account/mnemonic
|
||||
:account/wallet-set-up-passed?]))
|
||||
|
||||
(spec/def :accounts/accounts (spec/nilable (spec/map-of :account/address :accounts/account)))
|
||||
|
||||
|
@ -156,3 +156,8 @@
|
||||
:switch-dev-mode
|
||||
(fn [cofx [_ dev-mode]]
|
||||
(accounts.utils/account-update {:dev-mode? dev-mode} cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet-set-up-passed
|
||||
(fn [cofx]
|
||||
(accounts.utils/account-update {:wallet-set-up-passed? true} cofx)))
|
@ -39,7 +39,8 @@
|
||||
:mnemonic ""
|
||||
:signed-up? true
|
||||
:signing-phrase phrase
|
||||
:settings constants/default-account-settings}]
|
||||
:settings constants/default-account-settings
|
||||
:wallet-set-up-passed? true}]
|
||||
(when-not (string/blank? public-key)
|
||||
(-> db
|
||||
(accounts-events/add-account account)
|
||||
|
@ -18,7 +18,7 @@
|
||||
[react/text {:style styles/intro-text-description}
|
||||
(i18n/label :t/intro-text-description)]]
|
||||
[react/view styles/buttons-container
|
||||
[components.common/button {:style {:flex-direction :row}
|
||||
[components.common/button {:button-style {:flex-direction :row}
|
||||
:on-press #(re-frame/dispatch [:navigate-to :create-account])
|
||||
:label (i18n/label :t/create-account)}]
|
||||
[react/view styles/bottom-button-container
|
||||
|
@ -42,7 +42,7 @@
|
||||
(i18n/label :t/your-data-belongs-to-you)]
|
||||
[react/text {:style styles/intro-description}
|
||||
(i18n/label :t/your-data-belongs-to-you-description)]
|
||||
[components.common/button {:style styles/intro-button
|
||||
[components.common/button {:button-style styles/intro-button
|
||||
:on-press #(re-frame/dispatch [:set-in [:my-profile/seed :step] :12-words])
|
||||
:label (i18n/label :t/ok-continue)}]])
|
||||
|
||||
@ -130,7 +130,7 @@
|
||||
(i18n/label :t/you-are-all-set)]
|
||||
[react/text {:style styles/finish-description}
|
||||
(i18n/label :t/you-are-all-set-description)]
|
||||
[components.common/button {:style styles/finish-button
|
||||
[components.common/button {:button-style styles/finish-button
|
||||
:on-press #(re-frame/dispatch [:navigate-back])
|
||||
:label (i18n/label :t/ok-got-it)}]])
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
[react/text {:style styles/help-improve-text-description}
|
||||
(i18n/label :t/help-improve-description)]]
|
||||
[react/view styles/buttons-container
|
||||
[components.common/button {:style {:flex-direction :row}
|
||||
[components.common/button {:button-style {:flex-direction :row}
|
||||
:on-press #(re-frame/dispatch [:help-improve-handler true next])
|
||||
:label (i18n/label :t/share-usage-data)}]
|
||||
[react/view styles/bottom-button-container
|
||||
|
@ -33,6 +33,7 @@
|
||||
[status-im.ui.screens.wallet.choose-recipient.views :refer [choose-recipient]]
|
||||
[status-im.ui.screens.wallet.request.views :refer [request-transaction send-transaction-request]]
|
||||
[status-im.ui.screens.wallet.components.views :as wallet.components]
|
||||
[status-im.ui.screens.wallet.onboarding.setup.views :as wallet.onboarding.setup]
|
||||
[status-im.ui.screens.wallet.send.views :as wallet.send]
|
||||
[status-im.ui.screens.wallet.settings.views :as wallet-settings]
|
||||
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
|
||||
@ -123,6 +124,7 @@
|
||||
:browser browser
|
||||
:open-dapp open-dapp
|
||||
:dapp-description dapp-description
|
||||
:wallet-onboarding-setup wallet.onboarding.setup/screen
|
||||
:wallet-send-transaction send-transaction
|
||||
:wallet-transaction-sent transaction-sent
|
||||
:wallet-request-transaction request-transaction
|
||||
|
43
src/status_im/ui/screens/wallet/onboarding/setup/styles.cljs
Normal file
43
src/status_im/ui/screens/wallet/onboarding/setup/styles.cljs
Normal file
@ -0,0 +1,43 @@
|
||||
(ns status-im.ui.screens.wallet.onboarding.setup.styles
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def setup-image-container
|
||||
{:align-items :center
|
||||
:margin 41})
|
||||
|
||||
(def setup-image
|
||||
{:width 151
|
||||
:height 77})
|
||||
|
||||
(def signing-phrase
|
||||
{:background-color colors/white
|
||||
:border-radius 8
|
||||
:margin-left 16
|
||||
:margin-right 16
|
||||
:flex-direction :row})
|
||||
|
||||
(def signing-word
|
||||
{:flex 1
|
||||
:height 52
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def signing-word-text
|
||||
{:font-size 15
|
||||
:letter-spacing -0.2})
|
||||
|
||||
(def description
|
||||
{:font-size 14
|
||||
:letter-spacing -0.2
|
||||
:color colors/white
|
||||
:margin-left 24
|
||||
:margin-right 24
|
||||
:margin-top 16
|
||||
:text-align :center})
|
||||
|
||||
(def bottom-buttons
|
||||
{:background-color colors/blue
|
||||
:padding-vertical 8})
|
||||
|
||||
(def got-it-button-text
|
||||
{:padding-horizontal 0})
|
50
src/status_im/ui/screens/wallet/onboarding/setup/views.cljs
Normal file
50
src/status_im/ui/screens/wallet/onboarding/setup/views.cljs
Normal file
@ -0,0 +1,50 @@
|
||||
(ns status-im.ui.screens.wallet.onboarding.setup.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.styles :as components.styles]
|
||||
[status-im.ui.screens.wallet.components :as comp]
|
||||
[status-im.ui.screens.wallet.onboarding.setup.styles :as styles]
|
||||
[status-im.ui.components.bottom-buttons.view :as bottom-buttons]
|
||||
[status-im.ui.components.button.view :as button]
|
||||
[status-im.utils.utils :as utils]))
|
||||
|
||||
(defn signing-word [word]
|
||||
[react/view styles/signing-word
|
||||
[react/text {:style styles/signing-word-text
|
||||
:font :roboto-mono
|
||||
:number-of-lines 1}
|
||||
word]])
|
||||
|
||||
(defn display-confirmation []
|
||||
(utils/show-question
|
||||
(i18n/label :t/wallet-set-up-confirm-title)
|
||||
(i18n/label :t/wallet-set-up-confirm-description)
|
||||
#(do (re-frame/dispatch [:wallet-set-up-passed])
|
||||
(re-frame/dispatch [:navigate-back]))))
|
||||
|
||||
(views/defview screen []
|
||||
(views/letsubs [{:keys [signing-phrase]} [:get-current-account]]
|
||||
(let [signing-words (string/split signing-phrase #" ")]
|
||||
[comp/simple-screen {:avoid-keyboard? true}
|
||||
[comp/toolbar (i18n/label :t/wallet-set-up-title)]
|
||||
[react/view components.styles/flex
|
||||
[react/view {:style styles/setup-image-container}
|
||||
[react/image {:source (:wallet-setup resources/ui)
|
||||
:style styles/setup-image}]]
|
||||
[react/view {:style styles/signing-phrase}
|
||||
(for [word signing-words]
|
||||
^{:key (str "signing-word-" word)}
|
||||
[signing-word word])]
|
||||
[react/text {:style styles/description}
|
||||
(i18n/label :t/wallet-set-up-signing-phrase)]
|
||||
[bottom-buttons/bottom-buttons styles/bottom-buttons
|
||||
nil
|
||||
[button/button {:on-press display-confirmation
|
||||
:text-style styles/got-it-button-text
|
||||
:accessibility-label :done-button}
|
||||
(i18n/label :t/got-it)
|
||||
nil]]]])))
|
43
src/status_im/ui/screens/wallet/onboarding/styles.cljs
Normal file
43
src/status_im/ui/screens/wallet/onboarding/styles.cljs
Normal file
@ -0,0 +1,43 @@
|
||||
(ns status-im.ui.screens.wallet.onboarding.styles
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def root
|
||||
{:flex 1
|
||||
:background-color colors/blue
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
:padding-horizontal 30})
|
||||
|
||||
(def onboarding-image-container
|
||||
{:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def onboarding-image
|
||||
{:width 285
|
||||
:height 312})
|
||||
|
||||
(def onboarding-title
|
||||
{:line-height 28
|
||||
:font-size 22
|
||||
:font-weight :bold
|
||||
:letter-spacing -0.3
|
||||
:text-align :center
|
||||
:color colors/white})
|
||||
|
||||
(def onboarding-text
|
||||
{:line-height 21
|
||||
:margin-top 8
|
||||
:margin-bottom 32
|
||||
:font-size 14
|
||||
:letter-spacing -0.2
|
||||
:text-align :center
|
||||
:color colors/white-lighter-transparent})
|
||||
|
||||
(def set-up-button
|
||||
{:flex-direction :row
|
||||
:background-color (colors/alpha colors/black 0.1)
|
||||
:margin-bottom 32})
|
||||
|
||||
(def set-up-button-label
|
||||
{:color "white"})
|
24
src/status_im/ui/screens/wallet/onboarding/views.cljs
Normal file
24
src/status_im/ui/screens/wallet/onboarding/views.cljs
Normal file
@ -0,0 +1,24 @@
|
||||
(ns status-im.ui.screens.wallet.onboarding.views
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.common.common :as components.common]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.wallet.onboarding.styles :as styles]
|
||||
[status-im.react-native.resources :as resources]))
|
||||
|
||||
(defn onboarding []
|
||||
[react/view styles/root
|
||||
[react/view {:style styles/onboarding-image-container}
|
||||
[react/image {:source (:wallet-welcome resources/ui)
|
||||
:style styles/onboarding-image}]]
|
||||
[react/text {:style styles/onboarding-title}
|
||||
(i18n/label :t/wallet-onboarding-title)]
|
||||
[react/text {:style styles/onboarding-text}
|
||||
(i18n/label :t/wallet-onboarding-description)]
|
||||
|
||||
[components.common/button
|
||||
{:button-style styles/set-up-button
|
||||
:label-style styles/set-up-button-label
|
||||
:on-press #(re-frame/dispatch [:navigate-to :wallet-onboarding-setup])
|
||||
:label (i18n/label :t/wallet-onboarding-set-up)}]])
|
@ -6,6 +6,7 @@
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.screens.wallet.onboarding.views :as onboarding.views]
|
||||
[status-im.ui.screens.wallet.styles :as styles]
|
||||
[status-im.ui.screens.wallet.utils :as wallet.utils]
|
||||
[status-im.utils.ethereum.core :as ethereum]
|
||||
@ -79,7 +80,7 @@
|
||||
:data assets
|
||||
:render-fn (render-asset currency)}]])
|
||||
|
||||
(views/defview wallet []
|
||||
(views/defview wallet-root []
|
||||
(views/letsubs [assets [:wallet/visible-assets-with-amount]
|
||||
currency [:wallet/currency]
|
||||
portfolio-value [:portfolio-value]]
|
||||
@ -95,3 +96,9 @@
|
||||
[list/action-list actions
|
||||
{:container-style styles/action-section}]
|
||||
[asset-section assets currency]]]))
|
||||
|
||||
(views/defview wallet []
|
||||
(views/letsubs [{:keys [wallet-set-up-passed?]} [:get-current-account]]
|
||||
(if wallet-set-up-passed?
|
||||
[wallet-root]
|
||||
[onboarding.views/onboarding])))
|
Loading…
x
Reference in New Issue
Block a user