mirror of
https://github.com/status-im/status-react.git
synced 2025-02-22 15:48:50 +00:00
Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
parent
5926c2bb55
commit
99e00898f9
@ -54,7 +54,7 @@
|
||||
"react-native-safe-area-view": "0.9.0",
|
||||
"react-native-securerandom": "git+https://github.com/status-im/react-native-securerandom.git#0.1.1-2",
|
||||
"react-native-splash-screen": "3.1.1",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.0",
|
||||
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.3",
|
||||
"react-native-svg": "^9.2.4",
|
||||
"react-native-svg-transformer": "^0.12.1",
|
||||
"react-native-tcp": "git+https://github.com/status-im/react-native-tcp.git#v3.3.0-1-status",
|
||||
|
@ -5582,9 +5582,9 @@ react-native-splash-screen@3.1.1:
|
||||
resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.1.1.tgz#1a4e46c9fdce53ff52af2a2cb4181788c4e30b30"
|
||||
integrity sha512-PU2YocOSGbLjL9Vgcq/cwMNuHHKNjjuPpa1IPMuWo+6EB/fSZ5VOmxSa7+eucQe3631s3NhGuk3eHKahU03a4Q==
|
||||
|
||||
"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.0":
|
||||
version "2.5.0"
|
||||
resolved "git+https://github.com/status-im/react-native-status-keycard.git#d9ccdd6a7db0ae6c3d52b8c998529ac5a21ca029"
|
||||
"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.3":
|
||||
version "2.5.3"
|
||||
resolved "git+https://github.com/status-im/react-native-status-keycard.git#4ba5e8a771e764c449c19180e5eaa8553c789b8d"
|
||||
|
||||
react-native-svg-transformer@^0.12.1:
|
||||
version "0.12.1"
|
||||
|
@ -263,12 +263,9 @@
|
||||
|
||||
(fx/defn open-keycard-login
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [navigation-stack (:navigation-stack db)]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :enter-step] :login)}
|
||||
(if (empty? navigation-stack)
|
||||
(navigation/navigate-to-cofx :accounts nil)
|
||||
(navigation/navigate-to-cofx :enter-pin nil)))))
|
||||
(navigation/navigate-to-cofx :enter-pin nil)))
|
||||
|
||||
(fx/defn get-user-password
|
||||
[_ address]
|
||||
|
@ -66,6 +66,14 @@
|
||||
(fn [realm]
|
||||
(core/create realm :account (serialize-account account) true)))
|
||||
|
||||
(defn delete-account-tx
|
||||
"Returns tx function for deleting account"
|
||||
[address]
|
||||
(fn [realm]
|
||||
(let [account (core/single (core/get-by-field realm :account :address address))]
|
||||
(when account
|
||||
(core/delete realm account)))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:data-store/get-all-accounts
|
||||
(fn [coeffects _]
|
||||
|
@ -1146,6 +1146,16 @@
|
||||
(fn [cofx [_ error]]
|
||||
(hardwallet/on-delete-error cofx error)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.callback/on-remove-key-success
|
||||
(fn [cofx _]
|
||||
(hardwallet/on-remove-key-success cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.callback/on-remove-key-error
|
||||
(fn [cofx [_ error]]
|
||||
(hardwallet/on-remove-key-error cofx error)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.callback/on-get-keys-success
|
||||
(fn [cofx [_ data]]
|
||||
@ -1336,6 +1346,11 @@
|
||||
(fn [cofx _]
|
||||
(hardwallet/card-ready-next-button-pressed cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet/proceed-to-generate-mnemonic
|
||||
(fn [cofx _]
|
||||
(hardwallet/proceed-to-generate-mnemonic cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet/generate-mnemonic
|
||||
(fn [cofx _]
|
||||
@ -1383,6 +1398,11 @@
|
||||
(fn [cofx _]
|
||||
(hardwallet/unpair cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet/verify-pin
|
||||
(fn [cofx _]
|
||||
(hardwallet/verify-pin cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:keycard-settings.ui/reset-card-pressed
|
||||
(fn [cofx _]
|
||||
@ -1403,6 +1423,11 @@
|
||||
(fn [cofx _]
|
||||
(hardwallet/unpair-and-delete cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet/remove-key-with-unpair
|
||||
(fn [cofx _]
|
||||
(hardwallet/remove-key-with-unpair cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet/navigate-to-enter-pin-screen
|
||||
(fn [cofx _]
|
||||
|
@ -140,6 +140,20 @@
|
||||
(then #(re-frame/dispatch [:hardwallet.callback/on-delete-success %]))
|
||||
(catch #(re-frame/dispatch [:hardwallet.callback/on-delete-error (error-object->map %)]))))
|
||||
|
||||
(defn remove-key
|
||||
[{:keys [pin pairing]}]
|
||||
(.. keycard
|
||||
(removeKey pairing pin)
|
||||
(then #(re-frame/dispatch [:hardwallet.callback/on-remove-key-success %]))
|
||||
(catch #(re-frame/dispatch [:hardwallet.callback/on-remove-key-error (error-object->map %)]))))
|
||||
|
||||
(defn remove-key-with-unpair
|
||||
[{:keys [pin pairing]}]
|
||||
(.. keycard
|
||||
(removeKeyWithUnpair pairing pin)
|
||||
(then #(re-frame/dispatch [:hardwallet.callback/on-remove-key-success %]))
|
||||
(catch #(re-frame/dispatch [:hardwallet.callback/on-remove-key-error (error-object->map %)]))))
|
||||
|
||||
(defn unpair-and-delete
|
||||
[{:keys [pin pairing]}]
|
||||
(when (and pairing pin)
|
||||
|
@ -47,6 +47,8 @@
|
||||
navigate-to-browser? (contains? #{:wallet-sign-message-modal
|
||||
:wallet-send-transaction-modal
|
||||
:wallet-send-modal-stack} screen-before)]
|
||||
(if (nil? screen-before)
|
||||
(navigation/navigate-to-cofx cofx :accounts nil)
|
||||
(if navigate-to-browser?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :on-card-connected] nil)}
|
||||
@ -54,7 +56,7 @@
|
||||
(navigation/navigate-to-cofx :browser nil))
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :on-card-connected] nil)}
|
||||
(navigation/navigate-back)))))
|
||||
(navigation/navigate-back))))))
|
||||
|
||||
(fx/defn remove-pairing-from-account
|
||||
[{:keys [db]} {:keys [remove-instance-uid?]}]
|
||||
@ -99,6 +101,7 @@
|
||||
(case state
|
||||
:not-paired :pair
|
||||
:no-pairing-slots :no-slots
|
||||
:init :card-ready
|
||||
:begin))
|
||||
|
||||
(defn- get-card-state
|
||||
@ -114,7 +117,6 @@
|
||||
:no-pairing-slots
|
||||
|
||||
(and (not paired?)
|
||||
has-master-key?
|
||||
(pos? free-pairing-slots))
|
||||
:not-paired
|
||||
|
||||
@ -144,7 +146,7 @@
|
||||
(fx/merge cofx
|
||||
{:db db'}
|
||||
(set-setup-step card-state)
|
||||
(if (= :pre-init card-state)
|
||||
(if (contains? #{:init :pre-init} card-state)
|
||||
(navigation/navigate-to-cofx :hardwallet-setup nil)
|
||||
(when-not (= :not-paired card-state)
|
||||
(navigation/navigate-to-cofx :hardwallet-authentication-method nil)))
|
||||
@ -447,20 +449,70 @@
|
||||
{:hardwallet/unpair-and-delete {:pin pin
|
||||
:pairing pairing}}))
|
||||
|
||||
(fx/defn on-delete-success
|
||||
(fx/defn remove-key-with-unpair
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (vector->string (get-in db [:hardwallet :pin :current]))
|
||||
pairing (get-pairing db)
|
||||
card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(if card-connected?
|
||||
{:hardwallet/remove-key-with-unpair {:pin pin
|
||||
:pairing pairing}}
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/remove-key-with-unpair)}
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
|
||||
|
||||
(fx/defn on-remove-key-success
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [account-address (get-in db [:account/account :address])
|
||||
pairing (get-in db [:account/account :keycard-pairing])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :accounts/accounts dissoc account-address)
|
||||
(assoc-in [:hardwallet :whisper-public-key] nil)
|
||||
(assoc-in [:hardwallet :wallet-address] nil)
|
||||
(assoc-in [:hardwallet :secrets] {:pairing pairing})
|
||||
(assoc-in [:hardwallet :application-info] nil)
|
||||
(assoc-in [:hardwallet :on-card-connected] nil)
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:data-store/base-tx [(accounts-store/delete-account-tx account-address)]
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-reseted)}}
|
||||
(accounts.logout/logout))))
|
||||
|
||||
(fx/defn on-remove-key-error
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] remove key error" error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))]
|
||||
(fx/merge cofx
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-connected] :hardwallet/remove-key-with-unpair)
|
||||
(assoc-in [:hardwallet :pin :status] nil))
|
||||
:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/cannot-read-card)}}
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil))
|
||||
(show-wrong-keycard-alert cofx true)))))
|
||||
|
||||
(fx/defn on-delete-success
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [account-address (get-in db [:account/account :address])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :accounts/accounts dissoc account-address)
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(assoc-in [:hardwallet :application-info] nil)
|
||||
(assoc-in [:hardwallet :on-card-connected] nil)
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:data-store/base-tx [(accounts-store/delete-account-tx account-address)]
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-reseted)}}
|
||||
(remove-pairing-from-account {:remove-instance-uid? true})
|
||||
(navigation/navigate-to-cofx :keycard-settings nil)))
|
||||
|
||||
(accounts.logout/logout))))
|
||||
|
||||
(fx/defn on-delete-error
|
||||
[{:keys [db] :as cofx} error]
|
||||
@ -517,7 +569,7 @@
|
||||
:puk []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :hardwallet/unpair-and-delete}))}
|
||||
:on-verified :hardwallet/remove-key-with-unpair}))}
|
||||
(if card-connected?
|
||||
(navigate-to-enter-pin-screen)
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
|
||||
@ -627,7 +679,9 @@
|
||||
{:db (-> db
|
||||
(update-in [:hardwallet :pin] merge {:status nil
|
||||
:error-label nil}))}
|
||||
(when-not (contains? #{:hardwallet/unpair :hardwallet/unpair-and-delete} on-verified)
|
||||
(when-not (contains? #{:hardwallet/unpair
|
||||
:hardwallet/remove-key-with-unpair
|
||||
:hardwallet/unpair-and-delete} on-verified)
|
||||
(get-application-info pairing nil))
|
||||
(when on-verified
|
||||
(dispatch-on-verified-event on-verified)))))
|
||||
@ -696,12 +750,17 @@
|
||||
(navigation/navigate-to-cofx :keycard-settings nil)))
|
||||
|
||||
(defn- verify-pin
|
||||
[{:keys [db] :as fx}]
|
||||
(let [pin (vector->string (get-in fx [:db :hardwallet :pin :current]))
|
||||
pairing (get-pairing db)]
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (vector->string (get-in cofx [:db :hardwallet :pin :current]))
|
||||
pairing (get-pairing db)
|
||||
card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(if card-connected?
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
:hardwallet/verify-pin {:pin pin
|
||||
:pairing pairing}}))
|
||||
:pairing pairing}}
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :on-card-connected] :hardwallet/verify-pin)}
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
|
||||
|
||||
(defn- unblock-pin
|
||||
[{:keys [db] :as cofx}]
|
||||
@ -1055,6 +1114,22 @@
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
|
||||
(fx/defn card-ready-next-button-pressed
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (get-in db [:hardwallet :secrets :pin])
|
||||
pin-already-set? (boolean pin)]
|
||||
(if pin-already-set?
|
||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
||||
(load-generating-mnemonic-screen cofx)
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)})
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :pin)
|
||||
(assoc-in [:hardwallet :pin :enter-step] :current)
|
||||
(assoc-in [:hardwallet :pin :on-verified] :hardwallet/proceed-to-generate-mnemonic)
|
||||
(assoc-in [:hardwallet :pin :current] [])
|
||||
(assoc-in [:hardwallet :pin :original] nil))}))))
|
||||
|
||||
(fx/defn proceed-to-generate-mnemonic
|
||||
[{:keys [db] :as cofx}]
|
||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
||||
(load-generating-mnemonic-screen cofx)
|
||||
@ -1071,12 +1146,12 @@
|
||||
|
||||
(fx/defn generate-and-load-key
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [mnemonic pairing]} (get-in db [:hardwallet :secrets])
|
||||
pin (vector->string (get-in db [:hardwallet :pin :original]))]
|
||||
(let [{:keys [mnemonic pairing pin]} (get-in db [:hardwallet :secrets])
|
||||
pin' (or pin (vector->string (get-in db [:hardwallet :pin :current])))]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/generate-and-load-key {:mnemonic mnemonic
|
||||
:pairing pairing
|
||||
:pin pin}})))
|
||||
:pin pin'}})))
|
||||
|
||||
(fx/defn create-keycard-account
|
||||
[{:keys [db] :as cofx}]
|
||||
|
@ -69,6 +69,14 @@
|
||||
:hardwallet/delete
|
||||
card/delete)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-key
|
||||
card/remove-key)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-key-with-unpair
|
||||
card/remove-key-with-unpair)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/unpair-and-delete
|
||||
card/unpair-and-delete)
|
||||
|
@ -140,7 +140,7 @@
|
||||
[cofx]
|
||||
(let [{{:accounts/keys [accounts] :as db} :db} cofx]
|
||||
(if (empty? accounts)
|
||||
(navigation/navigate-to-clean cofx :intro nil)
|
||||
(navigation/navigate-to-cofx cofx :intro nil)
|
||||
(let [account-with-notification
|
||||
(when-not platform/desktop?
|
||||
(notifications/lookup-contact-pubkey-from-hash
|
||||
|
@ -130,6 +130,7 @@
|
||||
(minimize-bar new-view-id))))
|
||||
:reagent-render
|
||||
(fn [keyboard-shown? view-id tab]
|
||||
(when (not= view-id :enter-pin)
|
||||
(if platform/ios?
|
||||
[tabs-animation-wrapper-ios
|
||||
[react/animated-view
|
||||
@ -140,7 +141,7 @@
|
||||
view-id
|
||||
[react/animated-view
|
||||
{:style (tabs.styles/animated-container visible? keyboard-shown?)}
|
||||
[tabs tab]]]))}))
|
||||
[tabs tab]]])))}))
|
||||
|
||||
(def disappearance-duration 150)
|
||||
(def appearance-duration 100)
|
||||
|
@ -109,8 +109,11 @@
|
||||
[pin-view {:pin pin
|
||||
:title-label (case step
|
||||
:confirmation :t/repeat-pin
|
||||
:current :t/current-pin
|
||||
:t/create-a-pin)
|
||||
:description-label :t/create-pin-description
|
||||
:description-label (case step
|
||||
:current :t/current-pin-description
|
||||
:t/create-pin-description)
|
||||
:step step
|
||||
:status status
|
||||
:error-label error-label}]))
|
||||
|
@ -45,7 +45,7 @@
|
||||
{:text-align :center
|
||||
:color colors/gray
|
||||
:margin-bottom 21
|
||||
:padding-horizontal 80
|
||||
:padding-horizontal 70
|
||||
:padding-top 20})
|
||||
|
||||
(def bottom-action-container
|
||||
|
@ -187,7 +187,8 @@
|
||||
(log/debug :component view-id)
|
||||
(switch-navigator
|
||||
(into {}
|
||||
[(build-screen (intro-login-stack/intro-login-stack view-id))
|
||||
[(build-screen (intro-login-stack/login-stack view-id))
|
||||
(build-screen (intro-login-stack/intro-stack))
|
||||
[:tabs-and-modals
|
||||
{:screen
|
||||
(stack-navigator
|
||||
@ -206,4 +207,6 @@
|
||||
{:mode :modal
|
||||
:initialRouteName :tabs
|
||||
:onTransitionStart (fn [])})}]])
|
||||
{:initialRouteName :intro-login-stack}))
|
||||
{:initialRouteName (if (= view-id :intro)
|
||||
:intro-stack
|
||||
:login-stack)}))
|
||||
|
@ -14,15 +14,13 @@
|
||||
:hardwallet-setup
|
||||
:hardwallet-success})
|
||||
|
||||
(defn intro-login-stack [view-id]
|
||||
{:name :intro-login-stack
|
||||
(defn login-stack [view-id]
|
||||
{:name :login-stack
|
||||
:screens (cond-> [:login
|
||||
:progress
|
||||
:create-account
|
||||
:recover
|
||||
:accounts]
|
||||
(= :intro view-id)
|
||||
(conj :intro)
|
||||
|
||||
config/hardwallet-enabled?
|
||||
(concat [:hardwallet-authentication-method
|
||||
@ -33,6 +31,12 @@
|
||||
:config (if
|
||||
;; add view-id here if you'd like that view to be
|
||||
;; first view when app is started
|
||||
(#{:intro :login :progress :accounts} view-id)
|
||||
(#{:login :progress :accounts :enter-pin} view-id)
|
||||
{:initialRouteName view-id}
|
||||
{:initialRouteName :login})})
|
||||
|
||||
(defn intro-stack []
|
||||
(-> (login-stack :intro)
|
||||
(update :screens conj :intro)
|
||||
(assoc :name :intro-stack)
|
||||
(assoc :config {:initialRouteName :intro})))
|
||||
|
Loading…
x
Reference in New Issue
Block a user