Use new keycard flow with animation
Remove screens that are not needed for new flow Replace keycard flows with new interaction If card connected start processing on sheet open Remove outdated pin screens Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com> Do not hide sheet when tag was lost during generating keys Change cancel action for no-key on card recovery Change pin screen when loading keys to an initialised card Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
cc520a1f27
commit
826b7df982
|
@ -7,6 +7,7 @@
|
|||
|
||||
(defonce keycard (.-default js-dependencies/status-keycard))
|
||||
(defonce event-emitter (.-DeviceEventEmitter js-dependencies/react-native))
|
||||
(defonce active-listeners (atom []))
|
||||
|
||||
(defn- error-object->map [object]
|
||||
{:code (.-code object)
|
||||
|
@ -37,6 +38,9 @@
|
|||
(doseq [event ["keyCardOnConnected" "keyCardOnDisconnected"]]
|
||||
(.removeAllListeners event-emitter event)))
|
||||
|
||||
(defn remove-event-listener [event]
|
||||
(.remove event))
|
||||
|
||||
(defn on-card-connected [callback]
|
||||
(when (and config/hardwallet-enabled?
|
||||
platform/android?)
|
||||
|
@ -48,9 +52,11 @@
|
|||
(.addListener event-emitter "keyCardOnDisconnected" callback)))
|
||||
|
||||
(defn register-card-events []
|
||||
(remove-event-listeners)
|
||||
(on-card-connected #(re-frame/dispatch [:hardwallet.callback/on-card-connected %]))
|
||||
(on-card-disconnected #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected %])))
|
||||
(doseq [listener @active-listeners]
|
||||
(remove-event-listener listener))
|
||||
(reset! active-listeners
|
||||
[(on-card-connected #(re-frame/dispatch [:hardwallet.callback/on-card-connected]))
|
||||
(on-card-disconnected #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected]))]))
|
||||
|
||||
(defn get-application-info [{:keys [pairing on-success]}]
|
||||
(log/debug "[keycard] get-application-info")
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.hardwallet.onboarding :as onboarding]
|
||||
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
@ -33,6 +32,16 @@
|
|||
(assoc-in [:hardwallet :pin :status] nil))}
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil)))
|
||||
|
||||
(fx/defn discard-pin-change
|
||||
{:events [::on-cancel]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
(common/clear-pin)
|
||||
(common/hide-pair-sheet)
|
||||
(if (get-in db [:hardwallet :pin :puk-restore?])
|
||||
(navigation/navigate-to-cofx :multiaccounts nil)
|
||||
(navigation/navigate-to-cofx :keycard-settings nil))))
|
||||
|
||||
(fx/defn change-pin
|
||||
{:events [:hardwallet/change-pin]}
|
||||
[{:keys [db] :as cofx}]
|
||||
|
@ -51,12 +60,13 @@
|
|||
:pairing pairing}})
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/change-pin)
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil))))))
|
||||
(common/show-pair-sheet {:on-cancel [::on-cancel]}))))))
|
||||
|
||||
(fx/defn on-change-pin-success
|
||||
{:events [:hardwallet.callback/on-change-pin-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (get-in db [:hardwallet :pin :original])]
|
||||
(let [pin (get-in db [:hardwallet :pin :original])
|
||||
puk-restore? (get-in db [:hardwallet :pin :puk-restore?])]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:status nil
|
||||
:login pin
|
||||
|
@ -64,27 +74,24 @@
|
|||
:error-label nil})
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pin-changed)}}
|
||||
(common/clear-on-card-connected)
|
||||
(common/hide-pair-sheet)
|
||||
(if puk-restore?
|
||||
(navigation/navigate-to-cofx :multiaccounts nil)
|
||||
(navigation/navigate-to-cofx :keycard-settings nil))
|
||||
(when (:multiaccounts/login db)
|
||||
(navigation/navigate-to-cofx :keycard-login-pin nil))
|
||||
(when (:multiaccounts/login db)
|
||||
(common/get-keys-from-keycard))
|
||||
(when (:multiaccount/multiaccount db)
|
||||
(multiaccounts.logout/logout)))))
|
||||
(common/get-keys-from-keycard)))))
|
||||
|
||||
(fx/defn on-change-pin-error
|
||||
{:events [:hardwallet.callback/on-change-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] change pin error" error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))]
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))
|
||||
pairing (common/get-pairing db)]
|
||||
(fx/merge cofx
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)
|
||||
:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/cannot-read-card)}}
|
||||
(common/set-on-card-connected :hardwallet/change-pin)
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil))
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(common/set-on-card-connected :hardwallet/change-pin))
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
|
@ -96,5 +103,5 @@
|
|||
:sign []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil)
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
(common/get-application-info pairing nil))
|
||||
(common/show-wrong-keycard-alert true))))))
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
(zero? free-pairing-slots))
|
||||
:no-pairing-slots))
|
||||
|
||||
(defn- tag-lost? [error]
|
||||
(defn tag-lost? [error]
|
||||
(= error "Tag was lost."))
|
||||
|
||||
(defn find-multiaccount-by-keycard-instance-uid
|
||||
|
@ -158,24 +158,27 @@
|
|||
(assoc-in [:hardwallet :on-card-read] nil)
|
||||
(assoc-in [:hardwallet :last-on-card-read] nil))})
|
||||
|
||||
(defn keycard-sheet-content [on-cancel]
|
||||
(defn keycard-sheet-content [on-cancel connected?]
|
||||
(fn []
|
||||
(keycard-sheet/connect-keycard
|
||||
{:on-cancel #(re-frame/dispatch on-cancel)
|
||||
:on-connect :hardwallet.callback/on-card-connected
|
||||
:on-disconnect :hardwallet.callback/on-card-disconnected})))
|
||||
:connected? connected?
|
||||
:on-connect ::on-card-connected
|
||||
:on-disconnect ::on-card-disconnected})))
|
||||
|
||||
(fx/defn show-pair-sheet
|
||||
[cofx {:keys [on-cancel]
|
||||
:or {on-cancel [::cancel-sheet-confirm]}}]
|
||||
(log/debug "[hardwallet] show-pair-sheet")
|
||||
(let [connected? (get-in cofx [:db :hardwallet :card-connected?])]
|
||||
(fx/merge cofx
|
||||
{:dismiss-keyboard true}
|
||||
(bottom-sheet/show-bottom-sheet
|
||||
{:view {:show-handle? false
|
||||
:backdrop-dismiss? false
|
||||
:disable-drag? true
|
||||
:content (keycard-sheet-content on-cancel)}})))
|
||||
:content (keycard-sheet-content on-cancel
|
||||
connected?)}}))))
|
||||
|
||||
(fx/defn hide-pair-sheet
|
||||
[{:keys [db] :as cofx}]
|
||||
|
@ -237,7 +240,7 @@
|
|||
:content (i18n/label :t/wrong-card-text)}}))
|
||||
|
||||
(fx/defn unauthorized-operation
|
||||
[{:keys [db] :as cofx}]
|
||||
[cofx]
|
||||
(fx/merge cofx
|
||||
{:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/keycard-unauthorized-operation)}}
|
||||
|
@ -250,6 +253,12 @@
|
|||
(let [key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
multiaccount-key-uid (get-in db [:multiaccount :key-uid])
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing]))]
|
||||
;; TODO(Ferossgp): If last oeperation was with wrong card,
|
||||
;; it does not mean that current operation will be with the same card.
|
||||
;; Because key-uid is stored from latest application-info read user can't
|
||||
;; start the new operation cause account key-uid is not equal to the one from old read
|
||||
;; Ideally application info should not be stored in db and only checked when need
|
||||
;; thus we can ensure that we have always the right card info and not outdated one.
|
||||
(if (or (nil? keycard-multiaccount?)
|
||||
(and key-uid
|
||||
(= key-uid multiaccount-key-uid)))
|
||||
|
@ -281,15 +290,15 @@
|
|||
(fx/defn on-get-keys-success
|
||||
{:events [:hardwallet.callback/on-get-keys-success]}
|
||||
[{:keys [db] :as cofx} data]
|
||||
(let [{:keys [key-uid encryption-public-key whisper-private-key] :as account-data} (js->clj data :keywordize-keys true)
|
||||
(let [{:keys [key-uid encryption-public-key whisper-private-key]
|
||||
:as account-data} (js->clj data :keywordize-keys true)
|
||||
{:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts key-uid])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
multiaccount-data (types/clj->json {:name name
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path})
|
||||
save-keys? (get-in db [:multiaccounts/login :save-password?])]
|
||||
(fx/merge
|
||||
cofx
|
||||
(fx/merge cofx
|
||||
{:db
|
||||
(-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
|
@ -310,19 +319,18 @@
|
|||
(when save-keys?
|
||||
(keychain/save-hardwallet-keys key-uid encryption-public-key whisper-private-key))
|
||||
(clear-on-card-connected)
|
||||
(clear-on-card-read))))
|
||||
(clear-on-card-read)
|
||||
(hide-pair-sheet))))
|
||||
|
||||
(fx/defn on-get-keys-error
|
||||
{:events [:hardwallet.callback/on-get-keys-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] get keys error: " error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))
|
||||
(let [tag-was-lost? (tag-lost? (:error error))
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost nil))
|
||||
(if (re-matches pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:hardwallet/get-application-info {:pairing (get-pairing db key-uid)}
|
||||
|
@ -330,9 +338,9 @@
|
|||
:login []
|
||||
:import-multiaccount []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pin nil)
|
||||
(navigation/navigate-to-cofx :keycard-login-pin nil)))
|
||||
(hide-pair-sheet)
|
||||
(when (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pin nil)))
|
||||
(show-wrong-keycard-alert true)))))
|
||||
|
||||
;; Get application info
|
||||
|
@ -341,9 +349,7 @@
|
|||
{:events [:hardwallet/get-application-info]}
|
||||
[{:keys [db]} pairing on-card-read]
|
||||
(let [key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
pairing' (or pairing
|
||||
(when key-uid
|
||||
(get-pairing db key-uid)))]
|
||||
pairing' (or pairing (some->> key-uid (get-pairing db)))]
|
||||
{:hardwallet/get-application-info {:pairing pairing'
|
||||
:on-success on-card-read}}))
|
||||
|
||||
|
@ -355,16 +361,13 @@
|
|||
(update :key-uid ethereum/normalized-hex))
|
||||
{:keys [pin-retry-counter puk-retry-counter]} info'
|
||||
view-id (:view-id db)
|
||||
connect-screen? (contains? #{:hardwallet-connect
|
||||
:hardwallet-connect-sign
|
||||
:hardwallet-connect-settings} view-id)
|
||||
|
||||
{:keys [on-card-read]} (:hardwallet db)
|
||||
on-success' (or on-success on-card-read)
|
||||
enter-step (if (zero? pin-retry-counter)
|
||||
:puk
|
||||
(get-in db [:hardwallet :pin :enter-step]))]
|
||||
(log/debug "[hardwallet] on-get-application-info-success"
|
||||
"connect-screen?" connect-screen?
|
||||
"on-success" on-success')
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
|
@ -387,32 +390,29 @@
|
|||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] application info error " error)
|
||||
(let [on-card-read (get-in db [:hardwallet :on-card-read])
|
||||
on-card-connected (get-in db [:hardwallet :on-card-connected])
|
||||
connect-screen? (= (:view-id db) :hardwallet-connect)
|
||||
on-card-connected (get-in db [:hardwallet :on-card-conncted])
|
||||
login? (= on-card-read :hardwallet/login-with-keycard)
|
||||
tag-was-lost? (= "Tag was lost." (:error error))]
|
||||
(if tag-was-lost?
|
||||
(navigation/navigate-to-cofx cofx :keycard-connection-lost nil)
|
||||
tag-was-lost? (tag-lost? (:error error))]
|
||||
(when-not tag-was-lost?
|
||||
(if login?
|
||||
(fx/merge cofx
|
||||
(clear-on-card-read)
|
||||
(navigation/navigate-to-cofx :not-keycard nil))
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :application-info-error] error)}
|
||||
|
||||
(when (= on-card-connected :hardwallet/prepare-to-sign)
|
||||
(show-wrong-keycard-alert true))
|
||||
(when-not connect-screen?
|
||||
(clear-on-card-read))
|
||||
|
||||
(when on-card-read
|
||||
(dispatch-event on-card-read)))))))
|
||||
|
||||
(fx/defn on-card-connected
|
||||
{:events [:hardwallet.callback/on-card-connected]}
|
||||
{:events [::on-card-connected]}
|
||||
[{:keys [db] :as cofx} _]
|
||||
(log/debug "[hardwallet] card connected")
|
||||
(let [instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
accounts-screen? (= :multiaccounts (:view-id db))
|
||||
should-read-instance-uid? (nil? instance-uid)
|
||||
on-card-connected (get-in db [:hardwallet :on-card-connected])
|
||||
on-card-read (cond
|
||||
|
@ -424,7 +424,6 @@
|
|||
"on-card-read" on-card-read)
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-connected?] true)
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] (boolean on-card-read)))}
|
||||
(when on-card-connected
|
||||
(dispatch-event on-card-connected))
|
||||
|
@ -434,17 +433,12 @@
|
|||
(get-application-info pairing on-card-read)))))
|
||||
|
||||
(fx/defn on-card-disconnected
|
||||
{:events [:hardwallet.callback/on-card-disconnected]}
|
||||
{:events [::on-card-disconnected]}
|
||||
[{:keys [db] :as cofx} _]
|
||||
(log/debug "[hardwallet] card disconnected ")
|
||||
(let [setup-running? (get-in db [:hardwallet :setup-step])
|
||||
on-card-connected (get-in db [:hardwallet :on-card-connected])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-connected?] false)
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] false))}
|
||||
(restore-on-card-connected)
|
||||
(restore-on-card-read)
|
||||
(when (and setup-running?
|
||||
on-card-connected)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
||||
(restore-on-card-read)))
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
(ns status-im.hardwallet.core
|
||||
(:require [status-im.i18n :as i18n]
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.utils.datetime :as utils.datetime]
|
||||
[status-im.utils.fx :as fx]
|
||||
|
@ -19,23 +21,6 @@
|
|||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.multiaccounts.recover.core :as multiaccounts.recover]))
|
||||
|
||||
(fx/defn enter-pin-navigate-back-button-clicked
|
||||
{:events [:hardwallet.ui/enter-pin-navigate-back-button-clicked]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [screen-before (set (take 4 (:navigation-stack db)))
|
||||
navigate-to-browser? (contains? screen-before :browser-stack)]
|
||||
(if navigate-to-browser?
|
||||
(fx/merge cofx
|
||||
(common/clear-on-card-connected)
|
||||
;;TODO use new signing flow
|
||||
;;(wallet/discard-transaction)
|
||||
(navigation/navigate-to-cofx :browser nil))
|
||||
(if (= :enter-pin-login (:view-id db))
|
||||
(navigation/navigate-to-cofx cofx :multiaccounts nil)
|
||||
(fx/merge cofx
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-back))))))
|
||||
|
||||
(fx/defn show-keycard-has-multiaccount-alert
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
|
@ -63,7 +48,7 @@
|
|||
:import-multiaccount []
|
||||
:current []}))}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pin nil)))
|
||||
(navigation/navigate-replace-cofx :keycard-recovery-pin nil)))
|
||||
|
||||
(fx/defn proceed-setup-with-initialized-card
|
||||
[{:keys [db] :as cofx} flow instance-uid]
|
||||
|
@ -106,10 +91,6 @@
|
|||
(assoc-in [:hardwallet :setup-step] nil))}
|
||||
(common/clear-on-card-connected)))
|
||||
|
||||
(defn hardwallet-connect-screen-did-load
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :card-read-in-progress?] false)})
|
||||
|
||||
(defn reset-card-screen-did-load
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :reset-card :disabled?] false)})
|
||||
|
@ -134,6 +115,7 @@
|
|||
[_ supported?]
|
||||
{:hardwallet/set-nfc-supported supported?})
|
||||
|
||||
;; TODO: Should be listener and replace the view in bottom sheet to avoid this
|
||||
(fx/defn on-check-nfc-enabled-success
|
||||
{:events [:hardwallet.callback/check-nfc-enabled-success]}
|
||||
[{:keys [db]} nfc-enabled?]
|
||||
|
@ -161,19 +143,25 @@
|
|||
:current [0 0 0 0 0 0]
|
||||
:confirmation []
|
||||
:puk []
|
||||
:puk-restore? true
|
||||
:error-label nil}))}
|
||||
(common/hide-pair-sheet)
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil))))
|
||||
|
||||
(fx/defn on-unblock-pin-error
|
||||
{:events [:hardwallet.callback/on-unblock-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(let [pairing (common/get-pairing db)]
|
||||
(let [pairing (common/get-pairing db)
|
||||
tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(log/debug "[hardwallet] unblock pin error" error)
|
||||
(when-not tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:hardwallet/get-application-info {:pairing pairing}
|
||||
:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
:error-label :t/puk-mismatch
|
||||
:enter-step :puk
|
||||
:puk []})}))
|
||||
:puk []})}
|
||||
(common/hide-pair-sheet)))))
|
||||
|
||||
(fx/defn dispatch-on-verified-event
|
||||
[{:keys [db]} event]
|
||||
|
@ -185,10 +173,16 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(let [on-verified (get-in db [:hardwallet :pin :on-verified])
|
||||
pairing (common/get-pairing db)]
|
||||
(log/debug "[hardwaller] success pin verification. on-verified" on-verified)
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status nil
|
||||
:error-label nil})}
|
||||
(common/clear-on-card-connected)
|
||||
;; TODO(Ferossgp): Each pin input should handle this event on it's own,
|
||||
;; now for simplicity do not hide bottom sheet when generating key
|
||||
;; but should be refactored.
|
||||
(when-not (= on-verified :hardwallet/generate-and-load-key)
|
||||
(common/hide-pair-sheet))
|
||||
(when-not (contains? #{:hardwallet/unpair
|
||||
:hardwallet/generate-and-load-key
|
||||
:hardwallet/remove-key-with-unpair
|
||||
|
@ -200,20 +194,12 @@
|
|||
(fx/defn on-verify-pin-error
|
||||
{:events [:hardwallet.callback/on-verify-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))
|
||||
setup? (boolean (get-in db [:hardwallet :setup-step]))
|
||||
exporting? (get-in db [:hardwallet :on-export-success])]
|
||||
(log/debug "[hardwallet] verify pin error" error)
|
||||
(cond tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)
|
||||
:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/cannot-read-card)}}
|
||||
(common/set-on-card-connected :hardwallet/verify-pin)
|
||||
(navigation/navigate-to-cofx (if setup?
|
||||
:keycard-connection-lost-setup
|
||||
:keycard-connection-lost) nil))
|
||||
(re-matches common/pin-mismatch-error (:error error))
|
||||
(when-not tag-was-lost?
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
:enter-step :current
|
||||
|
@ -223,20 +209,23 @@
|
|||
:confirmation []
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(common/hide-pair-sheet)
|
||||
(when-not setup?
|
||||
(if exporting?
|
||||
(navigation/navigate-back)
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil)))
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
:else (common/show-wrong-keycard-alert true))))
|
||||
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(common/show-wrong-keycard-alert true))))))
|
||||
|
||||
(fx/defn verify-pin
|
||||
{:events [:hardwallet/verify-pin]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
||||
pairing (common/get-pairing db)
|
||||
card-connected? (get-in db [:hardwallet :card-connected?])
|
||||
setup? (boolean (get-in db [:hardwallet :setup-step]))]
|
||||
card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(if card-connected?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
|
@ -244,9 +233,7 @@
|
|||
:pairing pairing}})
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/verify-pin)
|
||||
(navigation/navigate-to-cofx (if setup?
|
||||
:keycard-connection-lost-setup
|
||||
:keycard-processing) nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(fx/defn unblock-pin
|
||||
{:events [:hardwallet/unblock-pin]}
|
||||
|
@ -262,7 +249,7 @@
|
|||
:pairing pairing}}
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/unblock-pin)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(def pin-code-length 6)
|
||||
(def puk-code-length 12)
|
||||
|
@ -367,13 +354,14 @@
|
|||
[{:keys [db]} pairings]
|
||||
{:db (assoc-in db [:hardwallet :pairings] pairings)})
|
||||
|
||||
;; When pairing to device has completed, we need to persist pairing data to
|
||||
;; local storage. That's needed to ensure that during keycard setup
|
||||
;; keycard won't run out of pairings slots, ie. we don't pair the same
|
||||
;; card to the same device more than one time. Also, this allows the user to proceed
|
||||
;; with setup and skip the pairing step if the pairing was already done during a previous
|
||||
;; unfinished setup.
|
||||
|
||||
(fx/defn on-pair-success
|
||||
"When pairing to device has completed, we need to persist pairing data to
|
||||
local storage. That's needed to ensure that during keycard setup
|
||||
keycard won't run out of pairings slots, ie. we don't pair the same
|
||||
card to the same device more than one time. Also, this allows the user to proceed
|
||||
with setup and skip the pairing step if the pairing was already done during a previous
|
||||
unfinished setup."
|
||||
{:events [:hardwallet.callback/on-pair-success]}
|
||||
[{:keys [db] :as cofx} pairing]
|
||||
(let [setup-step (get-in db [:hardwallet :setup-step])
|
||||
|
@ -394,7 +382,7 @@
|
|||
(assoc-in [:hardwallet :setup-step] next-step)
|
||||
(assoc-in [:hardwallet :secrets :pairing] pairing)
|
||||
(assoc-in [:hardwallet :secrets :paired-on] paired-on))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/hide-pair-sheet)
|
||||
(when multiaccount
|
||||
(set-multiaccount-pairing multiaccount pairing paired-on))
|
||||
(when (= flow :login)
|
||||
|
@ -413,17 +401,20 @@
|
|||
[{:keys [db] :as cofx} {:keys [error code]}]
|
||||
(log/debug "[hardwallet] pair error: " error)
|
||||
(let [setup-step (get-in db [:hardwallet :setup-step])
|
||||
tag-was-lost? (common/tag-lost? error)
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
(log/debug "[hardwallet] on-pair-error")
|
||||
(log/debug "[hardwallet] on-pair-error" setup-step "flow:" flow)
|
||||
(when-not tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))}
|
||||
(common/set-on-card-connected (if (= setup-step :pairing)
|
||||
:hardwallet/load-pairing-screen
|
||||
:hardwallet/pair))
|
||||
(common/hide-pair-sheet)
|
||||
(when (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pair nil))
|
||||
(when (not= setup-step :enter-pair-code)
|
||||
(common/process-error code error)))))
|
||||
(common/process-error code error))))))
|
||||
|
||||
(fx/defn set-setup-step
|
||||
[{:keys [db]} card-state]
|
||||
|
@ -458,9 +449,12 @@
|
|||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :card-state] card-state)}
|
||||
(set-setup-step card-state)
|
||||
(common/hide-pair-sheet)
|
||||
|
||||
(when (and flow
|
||||
(= card-state :init))
|
||||
(proceed-setup-with-initialized-card flow instance-uid))
|
||||
|
||||
(when (= card-state :pre-init)
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-no-key nil)
|
||||
|
@ -469,6 +463,7 @@
|
|||
cofx
|
||||
(common/clear-on-card-read)
|
||||
(load-pin-screen)))))
|
||||
|
||||
(when (and (= card-state :multiaccount)
|
||||
(= flow :import))
|
||||
(if (common/find-multiaccount-by-key-uid db key-uid)
|
||||
|
@ -476,17 +471,30 @@
|
|||
(if pairing
|
||||
(load-recovery-pin-screen)
|
||||
(recovery/load-pair-screen))))
|
||||
|
||||
(when (= card-state :blank)
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-no-key nil)
|
||||
(show-no-keycard-applet-alert)))
|
||||
|
||||
(when (and (= card-state :multiaccount)
|
||||
(#{:create :recovery} flow))
|
||||
(show-keycard-has-multiaccount-alert)))))
|
||||
|
||||
(fx/defn hardwallet-connect-navigate-back-button-clicked
|
||||
{:events [:hardwallet.ui/hardwallet-connect-navigate-back-button-clicked]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-back)))
|
||||
(fx/defn on-card-connected
|
||||
{:events [:hardwallet.callback/on-card-connected]}
|
||||
[{:keys [db]} _]
|
||||
(log/debug "[hardwallet] card globally connected")
|
||||
{:db (assoc-in db [:hardwallet :card-connected?] true)})
|
||||
|
||||
(fx/defn on-card-disconnected
|
||||
{:events [:hardwallet.callback/on-card-disconnected]}
|
||||
[{:keys [db]} _]
|
||||
(log/debug "[hardwallet] card disconnected ")
|
||||
{:db (assoc-in db [:hardwallet :card-connected?] false)})
|
||||
|
||||
(fx/defn on-register-card-events
|
||||
{:events [:hardwallet.callback/on-register-card-events]}
|
||||
[{:keys [db]} listeners]
|
||||
{:db (update-in db [:hardwallet :listeners] merge listeners)})
|
||||
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
(ns status-im.hardwallet.export-key
|
||||
(:require [status-im.utils.fx :as fx]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
||||
(fx/defn on-export-key-error
|
||||
{:events [:hardwallet.callback/on-export-key-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] export key error" error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))]
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(cond tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)
|
||||
:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/cannot-read-card)}}
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost nil))
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
|
||||
|
||||
(re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
|
@ -27,19 +22,22 @@
|
|||
:original []
|
||||
:confirmation []
|
||||
:sign []
|
||||
:export-key []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(navigation/navigate-back)
|
||||
(common/hide-pair-sheet)
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
:else (common/show-wrong-keycard-alert cofx true))))
|
||||
|
||||
:else
|
||||
(fx/merge cofx
|
||||
(common/show-wrong-keycard-alert true)
|
||||
(common/clear-pin)
|
||||
(common/hide-pair-sheet)))))
|
||||
|
||||
(fx/defn on-export-key-success
|
||||
{:events [:hardwallet.callback/on-export-key-success]}
|
||||
[{:keys [db] :as cofx} pubkey]
|
||||
(let [multiaccount-address (get-in db [:multiaccount :address])
|
||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
callback-fn (get-in db [:hardwallet :on-export-success])
|
||||
pairings (get-in db [:hardwallet :pairings])
|
||||
event-to-dispatch (callback-fn pubkey)]
|
||||
(re-frame/dispatch event-to-dispatch)
|
||||
(let [callback-fn (get-in db [:hardwallet :on-export-success])]
|
||||
(fx/merge cofx
|
||||
(common/clear-on-card-connected))))
|
||||
{:dispatch (callback-fn pubkey)}
|
||||
(common/clear-pin)
|
||||
(common/hide-pair-sheet))))
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]))
|
||||
|
||||
(fx/defn login-got-it-pressed
|
||||
{:events [:keycard.login.ui/got-it-pressed
|
||||
:keycard.login.ui/dismiss-pressed
|
||||
{:events [:keycard.login.pin.ui/got-it-pressed
|
||||
:keycard.login.pin.ui/cancel-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
|
@ -62,31 +61,37 @@
|
|||
pairing (:keycard-pairing multiaccount)]
|
||||
(cond
|
||||
(empty? application-info)
|
||||
(navigation/navigate-to-cofx cofx :not-keycard nil)
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(navigation/navigate-to-cofx :not-keycard nil))
|
||||
|
||||
(empty? key-uid)
|
||||
(navigation/navigate-to-cofx cofx :keycard-blank nil)
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(navigation/navigate-to-cofx :keycard-blank nil))
|
||||
|
||||
multiaccount-mismatch?
|
||||
(navigation/navigate-to-cofx cofx :keycard-wrong nil)
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(navigation/navigate-to-cofx :keycard-wrong nil))
|
||||
|
||||
(empty? pairing)
|
||||
(navigation/navigate-to-cofx cofx :keycard-unpaired nil)
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(navigation/navigate-to-cofx :keycard-unpaired nil))
|
||||
|
||||
:else
|
||||
(common/get-keys-from-keycard cofx))))
|
||||
|
||||
(fx/defn proceed-to-login
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [card-connected? nfc-enabled?]} (:hardwallet db)]
|
||||
(if nfc-enabled?
|
||||
(let [{:keys [card-connected?]} (:hardwallet db)]
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/get-application-info)
|
||||
(common/set-on-card-read :hardwallet/login-with-keycard)
|
||||
(if card-connected?
|
||||
(login-with-keycard)
|
||||
(navigation/navigate-to-cofx :keycard-login-connect-card nil)))
|
||||
(navigation/navigate-to-cofx cofx :keycard-nfc-on nil))))
|
||||
(common/show-pair-sheet {:on-cancel [::common/cancel-sheet-confirm]})))))
|
||||
|
||||
(fx/defn on-hardwallet-keychain-keys
|
||||
{:events [:multiaccounts.login.callback/get-hardwallet-keys-success]}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(assoc-in [:hardwallet :setup-step] :recovery-phrase)
|
||||
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-recovery-phrase nil)))
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase nil)))
|
||||
|
||||
(fx/defn set-mnemonic
|
||||
{:events [:test-mnemonic]}
|
||||
|
@ -59,7 +59,7 @@
|
|||
(common/set-on-card-connected :hardwallet/load-generating-mnemonic-screen)
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/generate-mnemonic)
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(fx/defn on-generate-mnemonic-error
|
||||
{:events [:hardwallet.callback/on-generate-mnemonic-error]}
|
||||
|
@ -87,4 +87,4 @@
|
|||
(common/set-on-card-connected :hardwallet/load-loading-keys-screen)
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/generate-and-load-key)
|
||||
(navigation/navigate-to-cofx :hardwallet-connect nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
(assoc-in [:hardwallet :pin :confirmation] []))})
|
||||
|
||||
(fx/defn start-installation
|
||||
{:events [:hardwallet/start-installation]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [card-state (get-in db [:hardwallet :card-state])
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :original]))]
|
||||
(log/debug "start-installation: card-state" card-state)
|
||||
(case card-state
|
||||
|
||||
:pre-init
|
||||
|
@ -43,11 +43,9 @@
|
|||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :preparing)}
|
||||
(common/set-on-card-connected :hardwallet/load-preparing-screen)
|
||||
(when card-connected?
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-preparing nil))
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/start-installation)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
||||
(start-installation)
|
||||
(common/show-pair-sheet {:on-cancel [::cancel-pressed]})))))
|
||||
|
||||
(fx/defn load-pairing-screen
|
||||
{:events [:hardwallet/load-pairing-screen
|
||||
|
@ -57,11 +55,9 @@
|
|||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :pairing)}
|
||||
(common/set-on-card-connected :hardwallet/load-pairing-screen)
|
||||
(when card-connected?
|
||||
(navigation/navigate-to-cofx :keycard-pairing nil))
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/pair)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
||||
(common/show-pair-sheet {:on-cancel [::cancel-pressed]})))))
|
||||
|
||||
(fx/defn puk-code-next-pressed
|
||||
{:events [:keycard.onboarding.puk-code.ui/next-pressed]}
|
||||
|
@ -81,11 +77,9 @@
|
|||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :loading-keys)}
|
||||
(common/set-on-card-connected :hardwallet/load-finishing-screen)
|
||||
(when card-connected?
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-finishing nil))
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/generate-and-load-key)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
||||
(common/show-pair-sheet {:on-cancel [::cancel-pressed]})))))
|
||||
|
||||
(fx/defn recovery-phrase-learn-more-pressed
|
||||
{:events [:keycard.onboarding.recovery-phrase.ui/learn-more-pressed]}
|
||||
|
@ -147,9 +141,11 @@
|
|||
(common/vector->string (get-in db [:hardwallet :pin :current])))]
|
||||
(if (empty? pin)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:enter-step :current
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin] {:enter-step :current
|
||||
:on-verified :hardwallet/generate-and-load-key
|
||||
:current []})}
|
||||
:current []})
|
||||
(assoc-in [:hardwallet :setup-step] :loading-keys))}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-pin nil))
|
||||
(load-finishing-screen cofx))))
|
||||
|
||||
|
@ -164,7 +160,7 @@
|
|||
(if (= (:view-id db) :keycard-onboarding-recovery-phrase-confirm-word1)
|
||||
(fx/merge cofx
|
||||
(recovery-phrase-next-word)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-recovery-phrase-confirm-word2 nil))
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-recovery-phrase-confirm-word2 nil))
|
||||
(proceed-with-generating-key cofx))
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
|
||||
|
@ -258,9 +254,9 @@
|
|||
(assoc-in [:hardwallet :card-state] :init)
|
||||
(assoc-in [:hardwallet :setup-step] :secret-keys)
|
||||
(update-in [:hardwallet :secrets] merge secrets'))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/hide-pair-sheet)
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-puk-code nil))))
|
||||
(navigation/navigate-replace-cofx :keycard-onboarding-puk-code nil))))
|
||||
|
||||
(fx/defn on-install-applet-and-init-card-error
|
||||
{:events [:hardwallet.callback/on-install-applet-and-init-card-error
|
||||
|
@ -287,14 +283,11 @@
|
|||
(fx/merge cofx
|
||||
{:hardwallet/generate-and-load-key {:mnemonic mnemonic'
|
||||
:pairing pairing
|
||||
:pin pin'}}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-finishing nil))))
|
||||
:pin pin'}})))
|
||||
|
||||
(fx/defn begin-setup-pressed
|
||||
{:events [:keycard.onboarding.intro.ui/begin-setup-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [nfc-enabled? (get-in db [:hardwallet :nfc-enabled?])
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :hardwallet
|
||||
|
@ -305,31 +298,21 @@
|
|||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||
(common/set-on-card-connected :hardwallet/get-application-info)
|
||||
(common/set-on-card-read :hardwallet/check-card-state)
|
||||
(if nfc-enabled?
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-start nil)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
|
||||
(navigation/navigate-to-cofx :keycard-nfc-on nil)))))
|
||||
(common/show-pair-sheet {})))
|
||||
|
||||
(fx/defn cancel-setup-pressed
|
||||
{:events [:keycard.onboarding.ui/cancel-pressed
|
||||
:hardwallet/back-button-pressed
|
||||
:keycard.onboarding.recovery-phrase.ui/cancel-pressed
|
||||
:keycard.onboarding.connection-lost-setup.ui/cancel-setup-pressed]}
|
||||
(fx/defn cancel-confirm
|
||||
{:events [::cancel-confirm]}
|
||||
[cofx]
|
||||
(fx/merge cofx
|
||||
(navigation/navigate-back)
|
||||
(common/cancel-sheet-confirm)))
|
||||
|
||||
(fx/defn cancel-pressed
|
||||
{:events [::cancel-pressed]}
|
||||
[_]
|
||||
{:ui/show-confirmation {:title (i18n/label :t/keycard-cancel-setup-title)
|
||||
:content (i18n/label :t/keycard-cancel-setup-text)
|
||||
:confirm-button-text (i18n/label :t/yes)
|
||||
:cancel-button-text (i18n/label :t/no)
|
||||
:on-accept #(re-frame/dispatch [:keycard.onboarding.ui/cancel-confirm-pressed])
|
||||
:on-accept #(re-frame/dispatch [::cancel-confirm])
|
||||
:on-cancel #()}})
|
||||
|
||||
(fx/defn cancel-setup-confirm-pressed
|
||||
{:events [:keycard.onboarding.ui/cancel-confirm-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
(common/remove-listener-to-hardware-back-button)
|
||||
(navigation/navigate-reset {:index 0
|
||||
:actions [{:routeName (if (seq (:multiaccounts/multiaccounts db))
|
||||
:multiaccounts
|
||||
:intro)}]})))
|
||||
|
|
|
@ -23,11 +23,9 @@
|
|||
card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/pair)
|
||||
(when card-connected?
|
||||
(pair* password))
|
||||
(if card-connected?
|
||||
(navigation/navigate-to-cofx :keycard-pairing nil)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
||||
(pair* password)
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(fx/defn pair-code-next-button-pressed
|
||||
{:events [:keycard.onboarding.pair.ui/input-submitted
|
||||
|
@ -82,11 +80,26 @@
|
|||
:hardwallet/check-nfc-enabled nil}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
|
||||
|
||||
(fx/defn cancel-confirm
|
||||
{:events [::cancel-confirm]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
(common/cancel-sheet-confirm)
|
||||
(navigation/navigate-back)))
|
||||
|
||||
(fx/defn cancel-pressed
|
||||
{:events [::cancel-pressed]}
|
||||
[_]
|
||||
{:ui/show-confirmation {:title (i18n/label :t/keycard-cancel-setup-title)
|
||||
:content (i18n/label :t/keycard-cancel-setup-text)
|
||||
:confirm-button-text (i18n/label :t/yes)
|
||||
:cancel-button-text (i18n/label :t/no)
|
||||
:on-accept #(re-frame/dispatch [::cancel-confirm])
|
||||
:on-cancel #()}})
|
||||
|
||||
(fx/defn begin-setup-pressed
|
||||
{:events [:keycard.recovery.intro.ui/begin-recovery-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [nfc-enabled? (get-in db [:hardwallet :nfc-enabled?])
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :hardwallet
|
||||
|
@ -97,11 +110,7 @@
|
|||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||
(common/set-on-card-connected :hardwallet/get-application-info)
|
||||
(common/set-on-card-read :hardwallet/check-card-state)
|
||||
(if nfc-enabled?
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-start nil)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
|
||||
(navigation/navigate-to-cofx :keycard-nfc-on nil)))))
|
||||
(common/show-pair-sheet {:on-cancel [::cancel-pressed]})))
|
||||
|
||||
(fx/defn recovery-success-finish-pressed
|
||||
{:events [:keycard.recovery.success/finish-pressed]}
|
||||
|
@ -205,18 +214,19 @@
|
|||
(update-in [:hardwallet :secrets] dissoc :pin :puk :password)
|
||||
(assoc :multiaccounts/new-installation-id (random-guid-generator))
|
||||
(update-in [:hardwallet :secrets] dissoc :mnemonic))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/remove-listener-to-hardware-back-button)
|
||||
(common/hide-pair-sheet)
|
||||
(create-keycard-multiaccount))))
|
||||
|
||||
(fx/defn on-generate-and-load-key-error
|
||||
{:events [:hardwallet.callback/on-generate-and-load-key-error]}
|
||||
[{:keys [db] :as cofx} {:keys [error code]}]
|
||||
(log/debug "[hardwallet] generate and load key error: " error)
|
||||
(when-not (common/tag-lost? error)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
||||
(common/set-on-card-connected :hardwallet/load-loading-keys-screen)
|
||||
(common/process-error code error)))
|
||||
(common/process-error code error))))
|
||||
|
||||
(fx/defn import-multiaccount
|
||||
{:events [:hardwallet/import-multiaccount]}
|
||||
|
@ -238,13 +248,12 @@
|
|||
(fx/defn load-recovering-key-screen
|
||||
{:events [:hardwallet/load-recovering-key-screen]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin] {:enter-step :import-multiaccount
|
||||
:import-multiaccount []
|
||||
:current []}))}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pin nil)))
|
||||
(common/set-on-card-connected :hardwallet/load-recovering-key-screen)
|
||||
(if card-connected?
|
||||
(common/dispatch-event :hardwallet/import-multiaccount)
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(fx/defn on-name-and-photo-generated
|
||||
{:events [::on-name-and-photo-generated]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.i18n :as i18n]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
||||
|
@ -37,13 +36,13 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(let [card-connected? (get-in db [:hardwallet :card-connected?])
|
||||
pairing (common/get-pairing db)]
|
||||
(fx/merge cofx
|
||||
(if card-connected?
|
||||
(common/get-application-info pairing :hardwallet/sign)
|
||||
(fn [cofx]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
||||
(common/get-application-info pairing :hardwallet/sign))
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:signing/sign :keycard-step] :connect)}
|
||||
(common/set-on-card-connected :hardwallet/prepare-to-sign)))))
|
||||
(common/set-on-card-connected :hardwallet/prepare-to-sign)
|
||||
(common/show-pair-sheet {})))))))
|
||||
|
||||
(fx/defn sign-message-completed
|
||||
[_ signature]
|
||||
|
@ -74,6 +73,7 @@
|
|||
(assoc-in [:hardwallet :transaction] nil))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/get-application-info (common/get-pairing db) nil)
|
||||
(common/hide-pair-sheet)
|
||||
(if transaction
|
||||
(send-transaction-with-signature {:transaction (types/clj->json transaction)
|
||||
:signature signature
|
||||
|
@ -84,24 +84,17 @@
|
|||
{:events [:hardwallet.callback/on-sign-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] sign error: " error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))]
|
||||
(fx/merge cofx
|
||||
(when tag-was-lost?
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(assoc-in [:signing/sign :keycard-step] :connect))
|
||||
:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/cannot-read-card)}}
|
||||
(common/set-on-card-connected :hardwallet/prepare-to-sign))))
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(when-not tag-was-lost?
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update-in [:hardwallet :pin] merge {:status :error
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})
|
||||
(assoc-in [:signing/sign :keycard-step] :pin))}
|
||||
(common/get-application-info (common/get-pairing db) nil)))
|
||||
(common/show-wrong-keycard-alert true)))))
|
||||
(common/hide-pair-sheet)
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
(fx/merge cofx
|
||||
(common/hide-pair-sheet)
|
||||
(common/show-wrong-keycard-alert true))))))
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
:pairing pairing}}
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/remove-key-with-unpair)
|
||||
(navigation/navigate-to-cofx :keycard-connection-lost nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
||||
(fx/defn on-remove-key-success
|
||||
{:events [:hardwallet.callback/on-remove-key-success]}
|
||||
|
@ -133,7 +133,7 @@
|
|||
{:events [:hardwallet.callback/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))]
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(fx/merge cofx
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.eip55 :as eip55]))
|
||||
|
||||
|
@ -24,8 +23,7 @@
|
|||
:public-key (str "0x" %)
|
||||
:path path}))
|
||||
:hardwallet/export-key {:pin pin :pairing pairing :path path}}
|
||||
(navigation/navigate-to-cofx :keycard-processing nil)
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account)
|
||||
(navigation/navigate-to-cofx :keycard-processing nil)))))
|
||||
(common/show-pair-sheet {})))))
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
[status-im.i18n :as i18n]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.common :as hardwallet.common]
|
||||
[status-im.utils.hex :as utils.hex]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.utils.security :as security]
|
||||
|
@ -283,7 +284,7 @@
|
|||
(fx/merge cofx
|
||||
{:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)}
|
||||
(check-queue)
|
||||
#(if on-result
|
||||
#(when on-result
|
||||
{:dispatch (conj on-result result)})))))
|
||||
|
||||
(fx/defn transaction-completed
|
||||
|
@ -304,8 +305,12 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [on-error]} (get-in db [:signing/tx])]
|
||||
(fx/merge cofx
|
||||
{:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)}
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(dissoc :signing/tx :signing/in-progress? :signing/sign))}
|
||||
(check-queue)
|
||||
(hardwallet.common/hide-pair-sheet)
|
||||
(hardwallet.common/clear-pin)
|
||||
#(when on-error
|
||||
{:dispatch (conj on-error "transaction was cancelled by user")}))))
|
||||
|
||||
|
|
|
@ -136,9 +136,7 @@
|
|||
(minimize-bar new-view-id))))
|
||||
:reagent-render
|
||||
(fn [keyboard-shown? view-id tab]
|
||||
(when-not (contains? #{:enter-pin-login
|
||||
:enter-pin-sign
|
||||
:enter-pin-settings} view-id)
|
||||
(when-not (contains? #{:enter-pin-settings} view-id)
|
||||
(case platform/os
|
||||
"ios" [tabs-animation-wrapper-ios
|
||||
[react/animated-view
|
||||
|
|
|
@ -205,16 +205,9 @@
|
|||
:home (chat.loading/offload-all-messages cofx)
|
||||
:keycard-settings (hardwallet/settings-screen-did-load %)
|
||||
:reset-card (hardwallet/reset-card-screen-did-load %)
|
||||
:enter-pin-login (hardwallet/enter-pin-screen-did-load %)
|
||||
:enter-pin-sign (hardwallet/enter-pin-screen-did-load %)
|
||||
:enter-pin-settings (hardwallet/enter-pin-screen-did-load %)
|
||||
:enter-pin-modal (hardwallet/enter-pin-screen-did-load %)
|
||||
:keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:add-new-account-pin (hardwallet/enter-pin-screen-did-load %)
|
||||
:hardwallet-connect (hardwallet/hardwallet-connect-screen-did-load %)
|
||||
:hardwallet-connect-sign (hardwallet/hardwallet-connect-screen-did-load %)
|
||||
:hardwallet-connect-settings (hardwallet/hardwallet-connect-screen-did-load %)
|
||||
:hardwallet-connect-modal (hardwallet/hardwallet-connect-screen-did-load %)
|
||||
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
||||
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
||||
nil))))
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
(ns status-im.ui.screens.hardwallet.connect.styles
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def container
|
||||
{:flex 1
|
||||
:background-color colors/white})
|
||||
|
||||
(def hardwallet-connect
|
||||
{:flex-direction :column
|
||||
:flex 1
|
||||
:align-items :center
|
||||
:justify-content :space-between})
|
||||
|
||||
(def hardwallet-card-image
|
||||
{:width 255
|
||||
:height 160})
|
||||
|
||||
(def turn-nfc-text-container
|
||||
{:margin-top 55})
|
||||
|
||||
(def status-hardwallet-text
|
||||
{:typography :header
|
||||
:text-align :center})
|
||||
|
||||
(defn bottom-action-container [nfc-enabled?]
|
||||
{:background-color (if nfc-enabled?
|
||||
colors/blue-light
|
||||
colors/gray-lighter)
|
||||
:width 369
|
||||
:height 80
|
||||
:border-radius 10
|
||||
:margin-bottom 20})
|
||||
|
||||
(def phone-nfc-on-image
|
||||
{:width 401
|
||||
:height 250})
|
||||
|
||||
(def phone-nfc-off-image
|
||||
{:width 301
|
||||
:height 180})
|
||||
|
||||
(def nfc-enabled-container
|
||||
{:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center
|
||||
:margin-top 50})
|
||||
|
||||
(def nfc-disabled-container
|
||||
{:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center
|
||||
:margin-top 120})
|
||||
|
||||
(def nfc-icon
|
||||
{:margin-left 52
|
||||
:margin-top 22})
|
||||
|
||||
(def go-to-settings-text
|
||||
{:text-align :center
|
||||
:padding-top 9
|
||||
:color colors/gray})
|
||||
|
||||
(def bottom-container
|
||||
{:height 52
|
||||
:justify-content :center
|
||||
:border-top-width 1
|
||||
:border-color colors/black-transparent})
|
||||
|
||||
(def product-info-container
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def product-info-text
|
||||
{:text-align :center
|
||||
:color colors/blue})
|
||||
|
||||
(def external-link-icon
|
||||
{:margin-left 5})
|
|
@ -1,64 +0,0 @@
|
|||
(ns status-im.ui.screens.hardwallet.connect.views
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.screens.hardwallet.connect.styles :as styles]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.toolbar.actions :as toolbar.actions]
|
||||
[status-im.ui.components.topbar :as topbar]))
|
||||
|
||||
(defview nfc-enabled []
|
||||
(letsubs [card-read-in-progress? [:hardwallet/card-read-in-progress?]]
|
||||
[react/view styles/nfc-enabled-container
|
||||
[react/view
|
||||
[react/image {:source (resources/get-image :hold-card-animation)
|
||||
:style styles/phone-nfc-on-image}]]
|
||||
[react/view styles/turn-nfc-text-container
|
||||
[react/text {:style styles/status-hardwallet-text
|
||||
:number-of-lines 2}
|
||||
(i18n/label :t/hold-card)]]
|
||||
(when card-read-in-progress?
|
||||
[react/view {:margin-top 35}
|
||||
[react/activity-indicator {:animating true
|
||||
:size :large}]])]))
|
||||
|
||||
(defn nfc-disabled []
|
||||
[react/view styles/nfc-disabled-container
|
||||
[react/view
|
||||
[react/image {:source (resources/get-image :phone-nfc-off)
|
||||
:style styles/phone-nfc-off-image}]]
|
||||
[react/view styles/turn-nfc-text-container
|
||||
[react/text {:style styles/status-hardwallet-text
|
||||
:on-press #(re-frame/dispatch [:hardwallet.ui/go-to-settings-button-pressed])}
|
||||
(i18n/label :t/turn-nfc-on)]
|
||||
[react/text {:style styles/go-to-settings-text
|
||||
:on-press #(re-frame/dispatch [:hardwallet.ui/go-to-settings-button-pressed])}
|
||||
(i18n/label :t/go-to-settings)]]])
|
||||
|
||||
(defview hardwallet-connect []
|
||||
(letsubs [nfc-enabled? [:hardwallet/nfc-enabled?]
|
||||
setup-step [:hardwallet-setup-step]]
|
||||
[react/view styles/container
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between}
|
||||
[topbar/topbar
|
||||
{:navigation
|
||||
{:icon :main-icons/back
|
||||
:accessibility-label :back-button
|
||||
:handler #(re-frame/dispatch [:hardwallet.ui/hardwallet-connect-navigate-back-button-clicked])}}]
|
||||
[react/view styles/hardwallet-connect
|
||||
(if nfc-enabled?
|
||||
[nfc-enabled]
|
||||
[nfc-disabled])]
|
||||
(if (= setup-step :begin)
|
||||
[react/view styles/bottom-container
|
||||
[react/touchable-highlight {:on-press #(.openURL react/linking "https://hardwallet.status.im")}
|
||||
[react/view styles/product-info-container
|
||||
[react/text {:style styles/product-info-text}
|
||||
(i18n/label :t/product-information)]
|
||||
[vector-icons/icon :main-icons/link {:color colors/blue
|
||||
:container-style styles/external-link-icon}]]]])]]))
|
|
@ -144,11 +144,7 @@
|
|||
error-label [:hardwallet/pin-error-label]]
|
||||
[react/view {:flex 1
|
||||
:background-color colors/white}
|
||||
[topbar/topbar
|
||||
{:navigation
|
||||
{:icon :main-icons/back
|
||||
:accessibility-label :back-button
|
||||
:handler #(re-frame/dispatch [:hardwallet.ui/enter-pin-navigate-back-button-clicked])}}]
|
||||
[topbar/topbar {}]
|
||||
(if (zero? pin-retry-counter)
|
||||
[pin-view {:pin pin
|
||||
:retry-counter (when (< puk-retry-counter puk-retries) puk-retry-counter)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns status-im.ui.screens.hardwallet.settings.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.utils.datetime :as utils.datetime]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
@ -9,11 +8,6 @@
|
|||
(some-> (get-in db [:multiaccount :keycard-paired-on])
|
||||
(utils.datetime/timestamp->year-month-day-date))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-pairing
|
||||
(fn [db]
|
||||
(common/get-pairing db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-multiaccount-pairing
|
||||
(fn [db]
|
||||
|
|
|
@ -265,7 +265,7 @@
|
|||
2000)
|
||||
(animation/start connect-animation)))
|
||||
|
||||
(defn animated-circles [{:keys [state on-card-connected on-card-disconnected]}]
|
||||
(defn animated-circles [{:keys [state connected? on-card-connected on-card-disconnected]}]
|
||||
(let [animation-small (animation/create-value 0)
|
||||
animation-medium (animation/create-value 0)
|
||||
animation-big (animation/create-value 0)
|
||||
|
@ -300,17 +300,25 @@
|
|||
(on-card-disconnected)
|
||||
(on-error
|
||||
{:state state
|
||||
:restart on-start-animation}))]
|
||||
:restart on-start-animation}))
|
||||
listeners (atom [])]
|
||||
(reagent/create-class
|
||||
{:component-did-mount
|
||||
(fn []
|
||||
(keycard-nfc/remove-event-listeners)
|
||||
(keycard-nfc/on-card-connected on-card-connected)
|
||||
(keycard-nfc/on-card-disconnected on-error)
|
||||
(on-start-animation))
|
||||
(doseq [listener @listeners]
|
||||
(keycard-nfc/remove-event-listener listener))
|
||||
|
||||
(reset! listeners [(keycard-nfc/on-card-connected on-card-connected)
|
||||
(keycard-nfc/on-card-disconnected on-error)])
|
||||
|
||||
(on-start-animation)
|
||||
|
||||
(when connected?
|
||||
(on-card-connected)))
|
||||
:component-will-unmount
|
||||
(fn []
|
||||
(keycard-nfc/remove-event-listeners))
|
||||
(doseq [listener @listeners]
|
||||
(keycard-nfc/remove-event-listener listener)))
|
||||
:render
|
||||
(fn []
|
||||
[react/view {:style {:position :absolute
|
||||
|
|
|
@ -26,12 +26,13 @@
|
|||
|
||||
(defn card-sync-flow []
|
||||
(let [state (reagent/atom nil)]
|
||||
(fn [{:keys [on-card-connected on-card-disconnected]}]
|
||||
(fn [{:keys [on-card-connected connected? on-card-disconnected]}]
|
||||
(let [translation (get state->translations @state)]
|
||||
[react/view {:style styles/container-style}
|
||||
[react/view {:height 200
|
||||
:margin-bottom 20}
|
||||
[animated-circles {:state state
|
||||
:connected? connected?
|
||||
:on-card-disconnected on-card-disconnected
|
||||
:on-card-connected on-card-connected}]]
|
||||
(when translation
|
||||
|
@ -39,8 +40,7 @@
|
|||
{:title (i18n/label (:title translation))
|
||||
:description (i18n/label (:description translation))}])]))))
|
||||
|
||||
(defn connect-keycard [{:keys [on-connect on-cancel on-disconnect]}]
|
||||
(fn []
|
||||
(defn connect-keycard [{:keys [on-connect on-cancel connected? on-disconnect]}]
|
||||
[react/view {:style {:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center}}
|
||||
|
@ -56,8 +56,9 @@
|
|||
:text-align :center}}
|
||||
(i18n/label :t/cancel)]])
|
||||
(if @(re-frame/subscribe [:hardwallet/nfc-enabled?])
|
||||
[card-sync-flow {:on-card-disconnected
|
||||
[card-sync-flow {:connected? connected?
|
||||
:on-card-disconnected
|
||||
#(re-frame/dispatch [on-disconnect])
|
||||
:on-card-connected
|
||||
#(re-frame/dispatch [on-connect])}]
|
||||
[turn-nfc/turn-nfc-on])]))
|
||||
[turn-nfc/turn-nfc-on])])
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[status-im.ui.screens.keycard.views :as views]
|
||||
[status-im.hardwallet.onboarding :as hardwallet.onboarding]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
|
@ -98,35 +99,6 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/begin-set-up)]]]]]]))
|
||||
|
||||
(defn start []
|
||||
[react/view styles/container
|
||||
[topbar/topbar]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:flex-direction :column
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:typography :header
|
||||
:text-align :center}}
|
||||
(i18n/label :t/keycard-onboarding-start-header)]]
|
||||
[react/view {:margin-top 16
|
||||
:width 311}
|
||||
[react/text {:style {:color colors/gray
|
||||
:text-align :center}}
|
||||
(i18n/label :t/keycard-onboarding-start-text)]]]
|
||||
[react/view {:align-items :center
|
||||
:flex 1
|
||||
:justify-content :center}
|
||||
[react/image {:source (resources/get-image :keycard-phone)
|
||||
:resize-mode :center
|
||||
:style {:width 160
|
||||
:height 170}}]
|
||||
[react/text {:style {:color colors/gray
|
||||
:text-align :center}}
|
||||
(i18n/label :t/hold-card)]]]])
|
||||
|
||||
(defview puk-code []
|
||||
(letsubs [secrets [:hardwallet-secrets]
|
||||
steps [:hardwallet-flow-steps]
|
||||
|
@ -135,7 +107,7 @@
|
|||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}}
|
||||
|
@ -219,29 +191,25 @@
|
|||
{:on-press #(re-frame/dispatch [:keycard.onboarding.puk-code.ui/next-pressed])
|
||||
:forward? true}]]]]]]))
|
||||
|
||||
(defn preparing []
|
||||
(views/loading :t/keycard-onboarding-preparing-header))
|
||||
|
||||
(defn finishing []
|
||||
(views/loading :t/keycard-onboarding-finishing-header))
|
||||
|
||||
(defview pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
enter-step [:hardwallet/pin-enter-step]
|
||||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
steps [:hardwallet-flow-steps]
|
||||
small-screen? [:dimensions/small-screen?]]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
setup-step [:hardwallet-setup-step]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
(when-not (= setup-step :loading-keys)
|
||||
[react/text {:style {:color colors/gray}}
|
||||
(i18n/label :t/step-i-of-n {:number steps
|
||||
:step 1})]]
|
||||
:step 1})])]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
|
@ -265,6 +233,7 @@
|
|||
:small-screen? small-screen?
|
||||
:error-label error-label
|
||||
:step enter-step}]
|
||||
(when-not (= setup-step :loading-keys)
|
||||
[react/view {:align-items :center
|
||||
:flex-direction :column
|
||||
:justify-content :center
|
||||
|
@ -272,7 +241,7 @@
|
|||
[react/text {:style {:color colors/gray
|
||||
:padding-horizontal 40
|
||||
:text-align :center}}
|
||||
(i18n/label :t/you-will-need-this-code)]]]]))
|
||||
(i18n/label :t/you-will-need-this-code)]])]]))
|
||||
|
||||
(defview recovery-phrase []
|
||||
(letsubs [mnemonic [:hardwallet-mnemonic]]
|
||||
|
@ -280,7 +249,7 @@
|
|||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}}
|
||||
|
@ -350,7 +319,7 @@
|
|||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [status-im.multiaccounts.recover.core :as multiaccounts.recover]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.hardwallet.recovery :as hardwallet.recovery]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[status-im.ui.screens.keycard.views :as views]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
|
@ -69,39 +70,6 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/keycard-recovery-intro-button-text)]]]]]])
|
||||
|
||||
(defn start []
|
||||
[react/view styles/container
|
||||
[topbar/topbar]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:flex-direction :column
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:typography :header
|
||||
:text-align :center}}
|
||||
(i18n/label :t/keycard-onboarding-start-header)]]
|
||||
[react/view {:margin-top 16
|
||||
:width 311}
|
||||
[react/text {:style {:font-size 15
|
||||
:line-height 22
|
||||
:color colors/gray
|
||||
:text-align :center}}
|
||||
(i18n/label :t/keycard-onboarding-start-text)]]]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
[react/view
|
||||
[react/image {:source (resources/get-image :keycard-phone)
|
||||
:resize-mode :center
|
||||
:style {:width 160
|
||||
:height 170}}]]]]])
|
||||
|
||||
(defn pairing []
|
||||
(views/loading :t/keycard-onboarding-pairing-header))
|
||||
|
||||
(defview pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
status [:hardwallet/pin-status]
|
||||
|
@ -112,7 +80,7 @@
|
|||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::hardwallet.recovery/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}}
|
||||
|
@ -139,16 +107,11 @@
|
|||
(defview pair []
|
||||
(letsubs [pair-code [:hardwallet-pair-code]
|
||||
error [:hardwallet-setup-error]
|
||||
{:keys [free-pairing-slots]} [:hardwallet-application-info]
|
||||
width [:dimensions/window-width]
|
||||
ref (atom nil)]
|
||||
{:keys [free-pairing-slots]} [:hardwallet-application-info]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
toolbar/default-nav-back
|
||||
[react/text {:style {:color colors/gray}}
|
||||
(i18n/label :t/step-i-of-n {:number 2
|
||||
:step 1})]]
|
||||
|
@ -200,9 +163,6 @@
|
|||
:disabled? (empty? pair-code)
|
||||
:forward? true}]]]]]))
|
||||
|
||||
(defn recovering []
|
||||
(views/loading :t/recovering-key))
|
||||
|
||||
(defview success []
|
||||
(letsubs [address [:hardwallet-multiaccount-wallet-address]
|
||||
whisper-public-key [:hardwallet-multiaccount-whisper-public-key]]
|
||||
|
@ -307,7 +267,7 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/generate-new-key)]]]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])}
|
||||
{:on-press #(re-frame/dispatch [:navigate-back])}
|
||||
[react/text {:style {:text-align :center
|
||||
:padding-top 27
|
||||
:color colors/blue}}
|
||||
|
|
|
@ -15,146 +15,6 @@
|
|||
[status-im.ui.screens.chat.photos :as photos]
|
||||
[status-im.ui.components.topbar :as topbar]))
|
||||
|
||||
(defview connection-lost []
|
||||
(letsubs [{:keys [card-connected?]} [:keycard]]
|
||||
[react/view {:flex 1
|
||||
:justify-content :center
|
||||
:align-items :center
|
||||
:background-color colors/gray-transparent-40}
|
||||
[react/view {:background-color colors/white
|
||||
:height 478
|
||||
:width "85%"
|
||||
:border-radius 16
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 32}
|
||||
[react/text {:style {:typography :title-bold
|
||||
:text-align :center}}
|
||||
(i18n/label :t/connection-with-the-card-lost)]
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:color colors/gray
|
||||
:padding-horizontal 50
|
||||
:text-align :center}}
|
||||
(i18n/label :t/connection-with-the-card-lost-text)]]]
|
||||
[react/view {:margin-top 16}
|
||||
(if card-connected?
|
||||
[react/activity-indicator {:size :large
|
||||
:animating true}]
|
||||
[react/image {:source (resources/get-image :keycard-connection)
|
||||
:resize-mode :center
|
||||
:style {:width 200
|
||||
:height 200}}])]
|
||||
[react/view {:margin-bottom 43}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.connection-lost.ui/cancel-pressed])}
|
||||
[react/text {:style {:color colors/red
|
||||
:text-align :center}}
|
||||
(i18n/label :t/cancel)]]]]]))
|
||||
|
||||
(defn connection-lost-setup []
|
||||
[react/view {:flex 1
|
||||
:justify-content :center
|
||||
:align-items :center
|
||||
:background-color colors/gray-transparent-40}
|
||||
[react/view {:background-color colors/white
|
||||
:height 478
|
||||
:width "85%"
|
||||
:border-radius 16
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 32}
|
||||
[react/text {:style {:typography :title-bold
|
||||
:text-align :center}}
|
||||
(i18n/label :t/connection-with-the-card-lost)]
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:color colors/gray
|
||||
:text-align :center}}
|
||||
(i18n/label :t/connection-with-the-card-lost-setup-text)]]]
|
||||
[react/view {:margin-top 16}
|
||||
[react/image {:source (resources/get-image :keycard-connection)
|
||||
:resize-mode :center
|
||||
:style {:width 200
|
||||
:height 200}}]]
|
||||
[react/view {:margin-bottom 43}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.onboarding.connection-lost-setup.ui/cancel-setup-pressed])}
|
||||
[react/text {:style {:color colors/red
|
||||
:text-align :center}}
|
||||
(i18n/label :t/cancel-keycard-setup)]]]]])
|
||||
|
||||
(defn nfc-on []
|
||||
[react/view styles/container
|
||||
[topbar/topbar]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:flex-direction :column
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:typography :header}}
|
||||
(i18n/label :t/turn-nfc-on)]]]
|
||||
[react/view
|
||||
[react/view {:align-items :center
|
||||
:justify-content :center}
|
||||
[react/image {:source (resources/get-image :keycard-nfc-on)
|
||||
:style {:width 170
|
||||
:height 170}}]]]
|
||||
[react/view
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.onboarding.nfc-on/open-nfc-settings-pressed])}
|
||||
[react/text {:style {:font-size 15
|
||||
:line-height 22
|
||||
:color colors/blue
|
||||
:text-align :center
|
||||
:margin-bottom 30}}
|
||||
(i18n/label :t/open-nfc-settings)]]]]])
|
||||
|
||||
(defn loading [title-label]
|
||||
[react/view styles/container
|
||||
[topbar/topbar {:navigation :none}]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center}
|
||||
[react/view {:flex-direction :column
|
||||
:align-items :center}
|
||||
[react/view {:margin-top 16}
|
||||
[react/activity-indicator {:animating true
|
||||
:size :large}]]
|
||||
[react/view {:margin-top 16}
|
||||
[react/text {:style {:typography :header
|
||||
:text-align :center}}
|
||||
(i18n/label title-label)]]
|
||||
[react/view {:margin-top 16
|
||||
:width 311}
|
||||
[react/text {:style {:font-size 15
|
||||
:line-height 22
|
||||
:color colors/gray
|
||||
:text-align :center}}
|
||||
(i18n/label :t/this-will-take-few-seconds)]]]
|
||||
[react/view {:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
[react/image {:source (resources/get-image :keycard-phone)
|
||||
:resize-mode :center
|
||||
:style {:width 160
|
||||
:height 170}}]
|
||||
[react/view {:margin-top 10}
|
||||
[react/text {:style {:text-align :center
|
||||
:color colors/gray
|
||||
:font-size 15
|
||||
:line-height 22}}
|
||||
(i18n/label :t/hold-card)]]]]])
|
||||
|
||||
(defn pairing []
|
||||
(loading :t/keycard-onboarding-pairing-header))
|
||||
|
||||
(defn processing []
|
||||
(loading :t/processing))
|
||||
|
||||
(defn welcome []
|
||||
[react/view {:flex 1
|
||||
:justify-content :space-between
|
||||
|
@ -179,6 +39,7 @@
|
|||
[react/activity-indicator {:size :large
|
||||
:animating true}]]])
|
||||
|
||||
;; NOTE(Ferossgp): Seems like it should be in popover
|
||||
(defn blank []
|
||||
[react/view {:flex 1
|
||||
:justify-content :center
|
||||
|
@ -208,7 +69,7 @@
|
|||
:height 114}}]]
|
||||
[react/view {:margin-bottom 32}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.login.ui/got-it-pressed])}
|
||||
{:on-press #(re-frame/dispatch [:navigate-back])}
|
||||
[react/view {:background-color colors/blue-light
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
|
@ -219,6 +80,7 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/ok-got-it)]]]]]])
|
||||
|
||||
;; NOTE(Ferossgp): Seems like it should be in popover
|
||||
(defn wrong []
|
||||
[react/view {:flex 1
|
||||
:justify-content :center
|
||||
|
@ -247,7 +109,7 @@
|
|||
:height 124}}]]
|
||||
[react/view {:margin-bottom 32}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.login.ui/got-it-pressed])}
|
||||
{:on-press #(re-frame/dispatch [:navigate-back])}
|
||||
[react/view {:background-color colors/blue-light
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
|
@ -304,6 +166,7 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/dismiss)]]]]]])
|
||||
|
||||
;; NOTE(Ferossgp): Seems like it should be in popover
|
||||
(defn not-keycard []
|
||||
[react/view {:flex 1
|
||||
:justify-content :center
|
||||
|
@ -343,7 +206,7 @@
|
|||
:container-style {:margin-left 5}}]]]]]
|
||||
[react/view {:margin-bottom 32}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.login.ui/got-it-pressed])}
|
||||
{:on-press #(re-frame/dispatch [:navigate-back])}
|
||||
[react/view {:background-color colors/blue-light
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
|
@ -365,13 +228,12 @@
|
|||
retry-counter [:hardwallet/retry-counter]]
|
||||
[react/view styles/container
|
||||
[topbar/topbar
|
||||
(cond-> {:accessories [{:icon :main-icons/more
|
||||
:handler #(re-frame/dispatch [:keycard.login.pin.ui/more-icon-pressed])}]}
|
||||
multiple-multiaccounts?
|
||||
(assoc :navigation
|
||||
{:accessories [{:icon :main-icons/more
|
||||
:handler #(re-frame/dispatch [:keycard.login.pin.ui/more-icon-pressed])}]
|
||||
:navigation
|
||||
{:icon :main-icons/back
|
||||
:accessibility-label :back-button
|
||||
:handler #(re-frame/dispatch [:keycard.login.pin.ui/cancel-pressed])}))]
|
||||
:handler #(re-frame/dispatch [:keycard.login.pin.ui/cancel-pressed])}}]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
|
@ -433,89 +295,6 @@
|
|||
[react/text {:style {:color colors/blue}}
|
||||
(i18n/label :t/recover-key)]]]]]))
|
||||
|
||||
(defview login-connect-card []
|
||||
(letsubs [status [:hardwallet/pin-status]
|
||||
{:keys [key-uid name] :as account} [:multiaccounts/login]]
|
||||
(let [in-progress? (= status :verifying)]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
nil
|
||||
[react/text {:style {:color colors/gray}}
|
||||
(i18n/label :t/step-i-of-n {:number 2
|
||||
:step 2})]
|
||||
[react/view {:margin-right 20}
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:keycard.login.pin.ui/more-icon-pressed])}
|
||||
[vector-icons/icon :main-icons/more {:color colors/black
|
||||
:container-style {:margin-left 5}}]]]]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
:justify-content :space-between
|
||||
:align-items :center
|
||||
:margin-top 15}
|
||||
[react/view {:flex-direction :column
|
||||
:justify-content :center
|
||||
:align-items :center}
|
||||
[react/view {:margin-horizontal 16
|
||||
:flex-direction :column}
|
||||
[react/view {:justify-content :center
|
||||
:align-items :center
|
||||
:flex-direction :row}
|
||||
[react/view {:width 69
|
||||
:height 69
|
||||
:justify-content :center
|
||||
:align-items :center}
|
||||
;;TODO this should be done in a subscription
|
||||
[photos/photo (multiaccounts/displayed-photo account) {:size 61}]
|
||||
[react/view {:justify-content :center
|
||||
:align-items :center
|
||||
:width 24
|
||||
:height 24
|
||||
:border-radius 24
|
||||
:position :absolute
|
||||
:right 0
|
||||
:bottom 0
|
||||
:background-color :white
|
||||
:border-width 1
|
||||
:border-color colors/black-transparent}
|
||||
[react/image {:source (resources/get-image :keycard-key)
|
||||
:style {:width 8
|
||||
:height 14}}]]]]
|
||||
[react/text {:style {:text-align :center
|
||||
:margin-top 12
|
||||
:color colors/black
|
||||
:font-weight "500"}
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :middle}
|
||||
name]
|
||||
[react/text {:style {:text-align :center
|
||||
:margin-top 4
|
||||
:color colors/gray
|
||||
:font-family "monospace"}
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :middle}
|
||||
(utils.core/truncate-str key-uid 14 true)]]]
|
||||
[react/view {:margin-bottom 12
|
||||
:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
[react/image {:source (resources/get-image :keycard-phone)
|
||||
:resize-mode :center
|
||||
:style {:width 200
|
||||
:height 211}}]
|
||||
[react/view {:margin-top 10}
|
||||
[react/text {:style {:text-align :center
|
||||
:color colors/gray
|
||||
:font-size 15
|
||||
:line-height 22}}
|
||||
(i18n/label :t/hold-card)]]]
|
||||
[react/view {:margin-bottom 50
|
||||
:height 30}
|
||||
(when in-progress?
|
||||
[react/activity-indicator {:size :large
|
||||
:animating true}])]]])))
|
||||
|
||||
(defn- more-sheet-content []
|
||||
[react/view {:flex 1}
|
||||
[list-item/list-item
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[react/view
|
||||
[list-item/list-item {:theme :action
|
||||
:on-press #(do (re-frame/dispatch [:bottom-sheet/hide])
|
||||
(re-frame/dispatch [:multiaccounts.create.ui/intro-wizard false]))
|
||||
(re-frame/dispatch [:multiaccounts.create.ui/intro-wizard]))
|
||||
:icon :main-icons/add
|
||||
:accessibility-label :generate-a-new-key
|
||||
:title :t/generate-a-new-key}]])
|
||||
|
|
|
@ -34,6 +34,20 @@
|
|||
(assoc :view-id go-to-view-id)))
|
||||
::navigate-to [go-to-view-id screen-params]}))
|
||||
|
||||
(fx/defn navigate-replace-cofx
|
||||
[{:keys [db]} go-to-view-id screen-params]
|
||||
(let [view-id (:view-id db)
|
||||
db (cond-> (assoc db :view-id go-to-view-id)
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params go-to-view-id]
|
||||
screen-params))]
|
||||
{:db (if (= view-id go-to-view-id)
|
||||
db
|
||||
(-> db
|
||||
(update :navigation-stack conj go-to-view-id)
|
||||
(assoc :view-id go-to-view-id)))
|
||||
::navigate-replace [go-to-view-id screen-params]}))
|
||||
|
||||
(fx/defn navigate-reset
|
||||
[{:keys [db]} {:keys [index actions] :as config}]
|
||||
(let [stack (into '() (map :routeName actions))
|
||||
|
@ -74,12 +88,24 @@
|
|||
(log/debug :navigate-reset config)
|
||||
(navigation/navigate-reset config)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::navigate-replace
|
||||
(fn [[view-id params]]
|
||||
(log/debug :navigate-replace view-id params)
|
||||
(navigation/navigate-replace (name view-id) params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to
|
||||
navigation-interceptors
|
||||
(fn [cofx [_ & [go-to-view-id screen-params]]]
|
||||
(navigate-to-cofx cofx go-to-view-id screen-params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-replace
|
||||
navigation-interceptors
|
||||
(fn [cofx [_ & [go-to-view-id screen-params]]]
|
||||
(navigate-replace-cofx cofx go-to-view-id screen-params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-modal
|
||||
navigation-interceptors
|
||||
|
|
|
@ -19,30 +19,20 @@
|
|||
:intro
|
||||
:intro-wizard
|
||||
:hardwallet-authentication-method
|
||||
:hardwallet-connect
|
||||
:keycard-connection-lost
|
||||
:keycard-connection-lost-setup
|
||||
:keycard-nfc-on
|
||||
:keycard-pairing
|
||||
:keycard-blank
|
||||
:keycard-wrong
|
||||
:keycard-unpaired
|
||||
:keycard-login-pin
|
||||
:keycard-login-connect-card
|
||||
:not-keycard
|
||||
:keycard-onboarding-intro
|
||||
:keycard-onboarding-start
|
||||
:keycard-onboarding-puk-code
|
||||
:keycard-onboarding-preparing
|
||||
:keycard-onboarding-finishing
|
||||
:keycard-onboarding-pin
|
||||
:keycard-onboarding-recovery-phrase
|
||||
:keycard-onboarding-recovery-phrase-confirm-word1
|
||||
:keycard-onboarding-recovery-phrase-confirm-word2
|
||||
:keycard-recovery-intro
|
||||
:keycard-recovery-start
|
||||
:keycard-recovery-pair
|
||||
:keycard-recovery-recovering
|
||||
:keycard-recovery-success
|
||||
:keycard-recovery-no-key
|
||||
:keycard-recovery-pin})
|
||||
|
@ -68,10 +58,7 @@
|
|||
|
||||
config/hardwallet-enabled?
|
||||
(concat [:hardwallet-authentication-method
|
||||
:hardwallet-connect
|
||||
:keycard-login-pin
|
||||
:keycard-login-connect-card
|
||||
:keycard-nfc-on
|
||||
:keycard-blank
|
||||
:keycard-wrong
|
||||
:keycard-unpaired
|
||||
|
@ -79,7 +66,7 @@
|
|||
:config (if
|
||||
;; add view-id here if you'd like that view to be
|
||||
;; first view when app is started
|
||||
(#{:login :progress :multiaccounts :enter-pin-login :keycard-login-pin} view-id)
|
||||
(#{:login :progress :multiaccounts :keycard-login-pin} view-id)
|
||||
{:initialRouteName view-id}
|
||||
{:initialRouteName :login})})
|
||||
|
||||
|
@ -88,23 +75,15 @@
|
|||
(update :screens conj
|
||||
:intro
|
||||
:intro-wizard
|
||||
:keycard-connection-lost
|
||||
:keycard-connection-lost-setup
|
||||
:keycard-nfc-on
|
||||
:keycard-pairing
|
||||
:keycard-onboarding-intro
|
||||
:keycard-onboarding-start
|
||||
:keycard-onboarding-puk-code
|
||||
:keycard-onboarding-preparing
|
||||
:keycard-onboarding-finishing
|
||||
:keycard-onboarding-pin
|
||||
:keycard-onboarding-recovery-phrase
|
||||
:keycard-onboarding-recovery-phrase-confirm-word1
|
||||
:keycard-onboarding-recovery-phrase-confirm-word2
|
||||
:keycard-recovery-intro
|
||||
:keycard-recovery-start
|
||||
:keycard-recovery-pair
|
||||
:keycard-recovery-recovering
|
||||
:keycard-recovery-success
|
||||
:keycard-recovery-no-key
|
||||
:keycard-recovery-pin)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[:chat-modal
|
||||
:stickers-pack-modal
|
||||
:tribute-learn-more
|
||||
:enter-pin-modal
|
||||
:hardwallet-connect-modal
|
||||
:selection-modal-screen
|
||||
:wallet-transactions-filter
|
||||
:welcome
|
||||
|
|
|
@ -42,7 +42,5 @@
|
|||
config/hardwallet-enabled?
|
||||
(concat [:keycard-settings
|
||||
:reset-card
|
||||
:keycard-connection-lost
|
||||
:keycard-processing
|
||||
:enter-pin-settings]))
|
||||
:config {:initialRouteName :my-profile}})
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
[status-im.ui.screens.hardwallet.authentication-method.views
|
||||
:as
|
||||
hardwallet.authentication]
|
||||
[status-im.ui.screens.hardwallet.connect.views :as hardwallet.connect]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as hardwallet.pin]
|
||||
[status-im.ui.screens.hardwallet.settings.views :as hardwallet.settings]
|
||||
[status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding]
|
||||
|
@ -83,31 +82,15 @@
|
|||
:multiaccounts multiaccounts/multiaccounts
|
||||
:intro intro/intro
|
||||
:hardwallet-authentication-method hardwallet.authentication/hardwallet-authentication-method
|
||||
:hardwallet-connect hardwallet.connect/hardwallet-connect
|
||||
:hardwallet-connect-settings hardwallet.connect/hardwallet-connect
|
||||
:hardwallet-connect-sign hardwallet.connect/hardwallet-connect
|
||||
:hardwallet-connect-modal [:modal hardwallet.connect/hardwallet-connect]
|
||||
:enter-pin-settings hardwallet.pin/enter-pin
|
||||
:enter-pin-sign hardwallet.pin/enter-pin
|
||||
:enter-pin-modal [:modal hardwallet.pin/enter-pin]
|
||||
:keycard-onboarding-intro keycard.onboarding/intro
|
||||
:keycard-onboarding-start keycard.onboarding/start
|
||||
:keycard-onboarding-puk-code keycard.onboarding/puk-code
|
||||
:keycard-onboarding-preparing keycard.onboarding/preparing
|
||||
:keycard-onboarding-finishing keycard.onboarding/finishing
|
||||
:keycard-onboarding-pin keycard.onboarding/pin
|
||||
:keycard-onboarding-recovery-phrase keycard.onboarding/recovery-phrase
|
||||
:keycard-onboarding-recovery-phrase-confirm-word1 keycard.onboarding/recovery-phrase-confirm-word
|
||||
:keycard-onboarding-recovery-phrase-confirm-word2 keycard.onboarding/recovery-phrase-confirm-word
|
||||
:keycard-pairing keycard/pairing
|
||||
:keycard-nfc-on keycard/nfc-on
|
||||
:keycard-connection-lost keycard/connection-lost
|
||||
:keycard-connection-lost-setup keycard/connection-lost-setup
|
||||
:keycard-processing keycard/processing
|
||||
:keycard-recovery-intro keycard.recovery/intro
|
||||
:keycard-recovery-start keycard.recovery/start
|
||||
:keycard-recovery-pair keycard.recovery/pair
|
||||
:keycard-recovery-recovering keycard.recovery/recovering
|
||||
:keycard-recovery-success keycard.recovery/success
|
||||
:keycard-recovery-no-key keycard.recovery/no-key
|
||||
:keycard-recovery-pin keycard.recovery/pin
|
||||
|
@ -115,7 +98,6 @@
|
|||
:keycard-wrong keycard/wrong
|
||||
:keycard-unpaired keycard/unpaired
|
||||
:keycard-login-pin keycard/login-pin
|
||||
:keycard-login-connect-card keycard/login-connect-card
|
||||
:not-keycard keycard/not-keycard
|
||||
:home home/home-wrapper
|
||||
:chat chat/chat
|
||||
|
@ -189,3 +171,4 @@
|
|||
|
||||
(defn get-screen [screen]
|
||||
(get all-screens screen #(throw (str "Screen " screen " is not defined."))))
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
(ns status-im.ui.screens.routing.wallet-stack
|
||||
(:require [status-im.utils.config :as config]))
|
||||
(ns status-im.ui.screens.routing.wallet-stack)
|
||||
|
||||
(def wallet-stack
|
||||
{:name :wallet-stack
|
||||
|
@ -15,8 +14,5 @@
|
|||
:wallet-settings-assets
|
||||
:wallet-add-custom-token
|
||||
:wallet-custom-token-details
|
||||
:currency-settings]
|
||||
config/hardwallet-enabled?
|
||||
(concat [:keycard-connection-lost
|
||||
:keycard-processing]))
|
||||
:currency-settings])
|
||||
:config {:initialRouteName :wallet}})
|
||||
|
|
|
@ -105,31 +105,6 @@
|
|||
:status status
|
||||
:error-label error-label}]]))
|
||||
|
||||
(defn- keycard-connect-view []
|
||||
[react/view {:padding-vertical 20
|
||||
:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
[react/image {:source (resources/get-image :keycard-phone)
|
||||
:resize-mode :center
|
||||
:style {:width 160
|
||||
:height 170}}]
|
||||
[react/view {:margin-top 10}
|
||||
[react/text {:style {:text-align :center
|
||||
:color colors/gray}}
|
||||
(i18n/label :t/hold-card)]]])
|
||||
|
||||
(defn- keycard-processing-view []
|
||||
[react/view {:flex-direction :column
|
||||
:flex 1
|
||||
:justify-content :center
|
||||
:align-items :center}
|
||||
[react/activity-indicator {:size :large
|
||||
:animating true}]
|
||||
[react/text {:style {:margin-top 16
|
||||
:color colors/gray}}
|
||||
(i18n/label :t/processing)]])
|
||||
|
||||
(defn sign-with-keycard-button
|
||||
[amount-error gas-error]
|
||||
(let [disabled? (or amount-error gas-error)]
|
||||
|
@ -155,8 +130,6 @@
|
|||
[signing-phrase-view phrase]
|
||||
(case keycard-step
|
||||
:pin [keycard-pin-view]
|
||||
:connect [keycard-connect-view]
|
||||
:signing [keycard-processing-view]
|
||||
[react/view {:align-items :center :margin-top 16 :margin-bottom 40}
|
||||
[sign-with-keycard-button nil nil]])])
|
||||
|
||||
|
|
|
@ -29,6 +29,15 @@
|
|||
#js {:routeName (name route)
|
||||
:params (clj->js params)}))))
|
||||
|
||||
(defn navigate-replace [route params]
|
||||
(when (can-be-called?)
|
||||
(.dispatch
|
||||
@navigator-ref
|
||||
(.replace
|
||||
stack-actions
|
||||
#js {:routeName (name route)
|
||||
:params (clj->js params)}))))
|
||||
|
||||
(defn- navigate [params]
|
||||
(when (can-be-called?)
|
||||
(.navigate navigation-actions (clj->js params))))
|
||||
|
|
Loading…
Reference in New Issue