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:
Gheorghe Pinzaru 2020-02-25 12:54:11 +03:00
parent cc520a1f27
commit 826b7df982
No known key found for this signature in database
GPG Key ID: C9A094959935A952
33 changed files with 543 additions and 1020 deletions

View File

@ -7,6 +7,7 @@
(defonce keycard (.-default js-dependencies/status-keycard)) (defonce keycard (.-default js-dependencies/status-keycard))
(defonce event-emitter (.-DeviceEventEmitter js-dependencies/react-native)) (defonce event-emitter (.-DeviceEventEmitter js-dependencies/react-native))
(defonce active-listeners (atom []))
(defn- error-object->map [object] (defn- error-object->map [object]
{:code (.-code object) {:code (.-code object)
@ -37,6 +38,9 @@
(doseq [event ["keyCardOnConnected" "keyCardOnDisconnected"]] (doseq [event ["keyCardOnConnected" "keyCardOnDisconnected"]]
(.removeAllListeners event-emitter event))) (.removeAllListeners event-emitter event)))
(defn remove-event-listener [event]
(.remove event))
(defn on-card-connected [callback] (defn on-card-connected [callback]
(when (and config/hardwallet-enabled? (when (and config/hardwallet-enabled?
platform/android?) platform/android?)
@ -48,9 +52,11 @@
(.addListener event-emitter "keyCardOnDisconnected" callback))) (.addListener event-emitter "keyCardOnDisconnected" callback)))
(defn register-card-events [] (defn register-card-events []
(remove-event-listeners) (doseq [listener @active-listeners]
(on-card-connected #(re-frame/dispatch [:hardwallet.callback/on-card-connected %])) (remove-event-listener listener))
(on-card-disconnected #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected %]))) (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]}] (defn get-application-info [{:keys [pairing on-success]}]
(log/debug "[keycard] get-application-info") (log/debug "[keycard] get-application-info")

View File

@ -2,7 +2,6 @@
(:require [status-im.i18n :as i18n] (:require [status-im.i18n :as i18n]
[status-im.ui.screens.navigation :as navigation] [status-im.ui.screens.navigation :as navigation]
[status-im.hardwallet.onboarding :as onboarding] [status-im.hardwallet.onboarding :as onboarding]
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.hardwallet.common :as common])) [status-im.hardwallet.common :as common]))
@ -33,6 +32,16 @@
(assoc-in [:hardwallet :pin :status] nil))} (assoc-in [:hardwallet :pin :status] nil))}
(navigation/navigate-to-cofx :enter-pin-settings 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 (fx/defn change-pin
{:events [:hardwallet/change-pin]} {:events [:hardwallet/change-pin]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -51,12 +60,13 @@
:pairing pairing}}) :pairing pairing}})
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/change-pin) (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 (fx/defn on-change-pin-success
{:events [:hardwallet.callback/on-change-pin-success]} {:events [:hardwallet.callback/on-change-pin-success]}
[{:keys [db] :as cofx}] [{: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 (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin] {:status nil {:db (assoc-in db [:hardwallet :pin] {:status nil
:login pin :login pin
@ -64,27 +74,24 @@
:error-label nil}) :error-label nil})
:utils/show-popup {:title "" :utils/show-popup {:title ""
:content (i18n/label :t/pin-changed)}} :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) (when (:multiaccounts/login db)
(navigation/navigate-to-cofx :keycard-login-pin nil)) (common/get-keys-from-keycard)))))
(when (:multiaccounts/login db)
(common/get-keys-from-keycard))
(when (:multiaccount/multiaccount db)
(multiaccounts.logout/logout)))))
(fx/defn on-change-pin-error (fx/defn on-change-pin-error
{:events [:hardwallet.callback/on-change-pin-error]} {:events [:hardwallet.callback/on-change-pin-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] change pin error" 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 (fx/merge cofx
(if tag-was-lost? (if tag-was-lost?
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :status] nil) {:db (assoc-in db [:hardwallet :pin :status] nil)}
:utils/show-popup {:title (i18n/label :t/error) (common/set-on-card-connected :hardwallet/change-pin))
:content (i18n/label :t/cannot-read-card)}}
(common/set-on-card-connected :hardwallet/change-pin)
(navigation/navigate-to-cofx :hardwallet-connect nil))
(if (re-matches common/pin-mismatch-error (:error error)) (if (re-matches common/pin-mismatch-error (:error error))
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:hardwallet :pin] merge {:status :error {:db (update-in db [:hardwallet :pin] merge {:status :error
@ -96,5 +103,5 @@
:sign [] :sign []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(navigation/navigate-to-cofx :enter-pin-settings nil) (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)))))) (common/show-wrong-keycard-alert true))))))

View File

@ -57,7 +57,7 @@
(zero? free-pairing-slots)) (zero? free-pairing-slots))
:no-pairing-slots)) :no-pairing-slots))
(defn- tag-lost? [error] (defn tag-lost? [error]
(= error "Tag was lost.")) (= error "Tag was lost."))
(defn find-multiaccount-by-keycard-instance-uid (defn find-multiaccount-by-keycard-instance-uid
@ -158,24 +158,27 @@
(assoc-in [:hardwallet :on-card-read] nil) (assoc-in [:hardwallet :on-card-read] nil)
(assoc-in [:hardwallet :last-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 [] (fn []
(keycard-sheet/connect-keycard (keycard-sheet/connect-keycard
{:on-cancel #(re-frame/dispatch on-cancel) {:on-cancel #(re-frame/dispatch on-cancel)
:on-connect :hardwallet.callback/on-card-connected :connected? connected?
:on-disconnect :hardwallet.callback/on-card-disconnected}))) :on-connect ::on-card-connected
:on-disconnect ::on-card-disconnected})))
(fx/defn show-pair-sheet (fx/defn show-pair-sheet
[cofx {:keys [on-cancel] [cofx {:keys [on-cancel]
:or {on-cancel [::cancel-sheet-confirm]}}] :or {on-cancel [::cancel-sheet-confirm]}}]
(log/debug "[hardwallet] show-pair-sheet") (log/debug "[hardwallet] show-pair-sheet")
(let [connected? (get-in cofx [:db :hardwallet :card-connected?])]
(fx/merge cofx (fx/merge cofx
{:dismiss-keyboard true} {:dismiss-keyboard true}
(bottom-sheet/show-bottom-sheet (bottom-sheet/show-bottom-sheet
{:view {:show-handle? false {:view {:show-handle? false
:backdrop-dismiss? false :backdrop-dismiss? false
:disable-drag? true :disable-drag? true
:content (keycard-sheet-content on-cancel)}}))) :content (keycard-sheet-content on-cancel
connected?)}}))))
(fx/defn hide-pair-sheet (fx/defn hide-pair-sheet
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -237,7 +240,7 @@
:content (i18n/label :t/wrong-card-text)}})) :content (i18n/label :t/wrong-card-text)}}))
(fx/defn unauthorized-operation (fx/defn unauthorized-operation
[{:keys [db] :as cofx}] [cofx]
(fx/merge cofx (fx/merge cofx
{:utils/show-popup {:title "" {:utils/show-popup {:title ""
:content (i18n/label :t/keycard-unauthorized-operation)}} :content (i18n/label :t/keycard-unauthorized-operation)}}
@ -250,6 +253,12 @@
(let [key-uid (get-in db [:hardwallet :application-info :key-uid]) (let [key-uid (get-in db [:hardwallet :application-info :key-uid])
multiaccount-key-uid (get-in db [:multiaccount :key-uid]) multiaccount-key-uid (get-in db [:multiaccount :key-uid])
keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing]))] 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?) (if (or (nil? keycard-multiaccount?)
(and key-uid (and key-uid
(= key-uid multiaccount-key-uid))) (= key-uid multiaccount-key-uid)))
@ -281,15 +290,15 @@
(fx/defn on-get-keys-success (fx/defn on-get-keys-success
{:events [:hardwallet.callback/on-get-keys-success]} {:events [:hardwallet.callback/on-get-keys-success]}
[{:keys [db] :as cofx} data] [{: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]) {:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts key-uid])
key-uid (get-in db [:hardwallet :application-info :key-uid]) key-uid (get-in db [:hardwallet :application-info :key-uid])
multiaccount-data (types/clj->json {:name name multiaccount-data (types/clj->json {:name name
:key-uid key-uid :key-uid key-uid
:photo-path photo-path}) :photo-path photo-path})
save-keys? (get-in db [:multiaccounts/login :save-password?])] save-keys? (get-in db [:multiaccounts/login :save-password?])]
(fx/merge (fx/merge cofx
cofx
{:db {:db
(-> db (-> db
(assoc-in [:hardwallet :pin :status] nil) (assoc-in [:hardwallet :pin :status] nil)
@ -310,19 +319,18 @@
(when save-keys? (when save-keys?
(keychain/save-hardwallet-keys key-uid encryption-public-key whisper-private-key)) (keychain/save-hardwallet-keys key-uid encryption-public-key whisper-private-key))
(clear-on-card-connected) (clear-on-card-connected)
(clear-on-card-read)))) (clear-on-card-read)
(hide-pair-sheet))))
(fx/defn on-get-keys-error (fx/defn on-get-keys-error
{:events [:hardwallet.callback/on-get-keys-error]} {:events [:hardwallet.callback/on-get-keys-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] get keys error: " 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]) key-uid (get-in db [:hardwallet :application-info :key-uid])
flow (get-in db [:hardwallet :flow])] flow (get-in db [:hardwallet :flow])]
(if tag-was-lost? (if tag-was-lost?
(fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :status] nil)} {:db (assoc-in db [:hardwallet :pin :status] nil)}
(navigation/navigate-to-cofx :keycard-connection-lost nil))
(if (re-matches pin-mismatch-error (:error error)) (if (re-matches pin-mismatch-error (:error error))
(fx/merge cofx (fx/merge cofx
{:hardwallet/get-application-info {:pairing (get-pairing db key-uid)} {:hardwallet/get-application-info {:pairing (get-pairing db key-uid)}
@ -330,9 +338,9 @@
:login [] :login []
:import-multiaccount [] :import-multiaccount []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(if (= flow :import) (hide-pair-sheet)
(navigation/navigate-to-cofx :keycard-recovery-pin nil) (when (= flow :import)
(navigation/navigate-to-cofx :keycard-login-pin nil))) (navigation/navigate-to-cofx :keycard-recovery-pin nil)))
(show-wrong-keycard-alert true))))) (show-wrong-keycard-alert true)))))
;; Get application info ;; Get application info
@ -341,9 +349,7 @@
{:events [:hardwallet/get-application-info]} {:events [:hardwallet/get-application-info]}
[{:keys [db]} pairing on-card-read] [{:keys [db]} pairing on-card-read]
(let [key-uid (get-in db [:hardwallet :application-info :key-uid]) (let [key-uid (get-in db [:hardwallet :application-info :key-uid])
pairing' (or pairing pairing' (or pairing (some->> key-uid (get-pairing db)))]
(when key-uid
(get-pairing db key-uid)))]
{:hardwallet/get-application-info {:pairing pairing' {:hardwallet/get-application-info {:pairing pairing'
:on-success on-card-read}})) :on-success on-card-read}}))
@ -355,16 +361,13 @@
(update :key-uid ethereum/normalized-hex)) (update :key-uid ethereum/normalized-hex))
{:keys [pin-retry-counter puk-retry-counter]} info' {:keys [pin-retry-counter puk-retry-counter]} info'
view-id (:view-id db) view-id (:view-id db)
connect-screen? (contains? #{:hardwallet-connect
:hardwallet-connect-sign
:hardwallet-connect-settings} view-id)
{:keys [on-card-read]} (:hardwallet db) {:keys [on-card-read]} (:hardwallet db)
on-success' (or on-success on-card-read) on-success' (or on-success on-card-read)
enter-step (if (zero? pin-retry-counter) enter-step (if (zero? pin-retry-counter)
:puk :puk
(get-in db [:hardwallet :pin :enter-step]))] (get-in db [:hardwallet :pin :enter-step]))]
(log/debug "[hardwallet] on-get-application-info-success" (log/debug "[hardwallet] on-get-application-info-success"
"connect-screen?" connect-screen?
"on-success" on-success') "on-success" on-success')
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
@ -387,32 +390,29 @@
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] application info error " error) (log/debug "[hardwallet] application info error " error)
(let [on-card-read (get-in db [:hardwallet :on-card-read]) (let [on-card-read (get-in db [:hardwallet :on-card-read])
on-card-connected (get-in db [:hardwallet :on-card-connected]) on-card-connected (get-in db [:hardwallet :on-card-conncted])
connect-screen? (= (:view-id db) :hardwallet-connect)
login? (= on-card-read :hardwallet/login-with-keycard) login? (= on-card-read :hardwallet/login-with-keycard)
tag-was-lost? (= "Tag was lost." (:error error))] tag-was-lost? (tag-lost? (:error error))]
(if tag-was-lost? (when-not tag-was-lost?
(navigation/navigate-to-cofx cofx :keycard-connection-lost nil)
(if login? (if login?
(fx/merge cofx (fx/merge cofx
(clear-on-card-read) (clear-on-card-read)
(navigation/navigate-to-cofx :not-keycard nil)) (navigation/navigate-to-cofx :not-keycard nil))
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :application-info-error] error)} {:db (assoc-in db [:hardwallet :application-info-error] error)}
(when (= on-card-connected :hardwallet/prepare-to-sign) (when (= on-card-connected :hardwallet/prepare-to-sign)
(show-wrong-keycard-alert true)) (show-wrong-keycard-alert true))
(when-not connect-screen?
(clear-on-card-read))
(when on-card-read (when on-card-read
(dispatch-event on-card-read))))))) (dispatch-event on-card-read)))))))
(fx/defn on-card-connected (fx/defn on-card-connected
{:events [:hardwallet.callback/on-card-connected]} {:events [::on-card-connected]}
[{:keys [db] :as cofx} _] [{:keys [db] :as cofx} _]
(log/debug "[hardwallet] card connected") (log/debug "[hardwallet] card connected")
(let [instance-uid (get-in db [:hardwallet :application-info :instance-uid]) (let [instance-uid (get-in db [:hardwallet :application-info :instance-uid])
key-uid (get-in db [:hardwallet :application-info :key-uid]) key-uid (get-in db [:hardwallet :application-info :key-uid])
accounts-screen? (= :multiaccounts (:view-id db))
should-read-instance-uid? (nil? instance-uid) should-read-instance-uid? (nil? instance-uid)
on-card-connected (get-in db [:hardwallet :on-card-connected]) on-card-connected (get-in db [:hardwallet :on-card-connected])
on-card-read (cond on-card-read (cond
@ -424,7 +424,6 @@
"on-card-read" on-card-read) "on-card-read" on-card-read)
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:hardwallet :card-connected?] true)
(assoc-in [:hardwallet :card-read-in-progress?] (boolean on-card-read)))} (assoc-in [:hardwallet :card-read-in-progress?] (boolean on-card-read)))}
(when on-card-connected (when on-card-connected
(dispatch-event on-card-connected)) (dispatch-event on-card-connected))
@ -434,17 +433,12 @@
(get-application-info pairing on-card-read))))) (get-application-info pairing on-card-read)))))
(fx/defn on-card-disconnected (fx/defn on-card-disconnected
{:events [:hardwallet.callback/on-card-disconnected]} {:events [::on-card-disconnected]}
[{:keys [db] :as cofx} _] [{:keys [db] :as cofx} _]
(log/debug "[hardwallet] card disconnected ") (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 (fx/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:hardwallet :card-connected?] false)
(assoc-in [:hardwallet :card-read-in-progress?] false))} (assoc-in [:hardwallet :card-read-in-progress?] false))}
(restore-on-card-connected) (restore-on-card-connected)
(restore-on-card-read) (restore-on-card-read)))
(when (and setup-running?
on-card-connected)
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))

View File

@ -1,5 +1,7 @@
(ns status-im.hardwallet.core (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.ui.screens.navigation :as navigation]
[status-im.utils.datetime :as utils.datetime] [status-im.utils.datetime :as utils.datetime]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
@ -19,23 +21,6 @@
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.multiaccounts.recover.core :as multiaccounts.recover])) [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 (fx/defn show-keycard-has-multiaccount-alert
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(fx/merge cofx (fx/merge cofx
@ -63,7 +48,7 @@
:import-multiaccount [] :import-multiaccount []
:current []}))} :current []}))}
(common/listen-to-hardware-back-button) (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 (fx/defn proceed-setup-with-initialized-card
[{:keys [db] :as cofx} flow instance-uid] [{:keys [db] :as cofx} flow instance-uid]
@ -106,10 +91,6 @@
(assoc-in [:hardwallet :setup-step] nil))} (assoc-in [:hardwallet :setup-step] nil))}
(common/clear-on-card-connected))) (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 (defn reset-card-screen-did-load
[{:keys [db]}] [{:keys [db]}]
{:db (assoc-in db [:hardwallet :reset-card :disabled?] false)}) {:db (assoc-in db [:hardwallet :reset-card :disabled?] false)})
@ -134,6 +115,7 @@
[_ supported?] [_ supported?]
{:hardwallet/set-nfc-supported 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 (fx/defn on-check-nfc-enabled-success
{:events [:hardwallet.callback/check-nfc-enabled-success]} {:events [:hardwallet.callback/check-nfc-enabled-success]}
[{:keys [db]} nfc-enabled?] [{:keys [db]} nfc-enabled?]
@ -161,19 +143,25 @@
:current [0 0 0 0 0 0] :current [0 0 0 0 0 0]
:confirmation [] :confirmation []
:puk [] :puk []
:puk-restore? true
:error-label nil}))} :error-label nil}))}
(common/hide-pair-sheet)
(navigation/navigate-to-cofx :enter-pin-settings nil)))) (navigation/navigate-to-cofx :enter-pin-settings nil))))
(fx/defn on-unblock-pin-error (fx/defn on-unblock-pin-error
{:events [:hardwallet.callback/on-unblock-pin-error]} {:events [:hardwallet.callback/on-unblock-pin-error]}
[{:keys [db] :as cofx} 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) (log/debug "[hardwallet] unblock pin error" error)
(when-not tag-was-lost?
(fx/merge cofx
{:hardwallet/get-application-info {:pairing pairing} {:hardwallet/get-application-info {:pairing pairing}
:db (update-in db [:hardwallet :pin] merge {:status :error :db (update-in db [:hardwallet :pin] merge {:status :error
:error-label :t/puk-mismatch :error-label :t/puk-mismatch
:enter-step :puk :enter-step :puk
:puk []})})) :puk []})}
(common/hide-pair-sheet)))))
(fx/defn dispatch-on-verified-event (fx/defn dispatch-on-verified-event
[{:keys [db]} event] [{:keys [db]} event]
@ -185,10 +173,16 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [on-verified (get-in db [:hardwallet :pin :on-verified]) (let [on-verified (get-in db [:hardwallet :pin :on-verified])
pairing (common/get-pairing db)] pairing (common/get-pairing db)]
(log/debug "[hardwaller] success pin verification. on-verified" on-verified)
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:hardwallet :pin] merge {:status nil {:db (update-in db [:hardwallet :pin] merge {:status nil
:error-label nil})} :error-label nil})}
(common/clear-on-card-connected) (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 (when-not (contains? #{:hardwallet/unpair
:hardwallet/generate-and-load-key :hardwallet/generate-and-load-key
:hardwallet/remove-key-with-unpair :hardwallet/remove-key-with-unpair
@ -200,20 +194,12 @@
(fx/defn on-verify-pin-error (fx/defn on-verify-pin-error
{:events [:hardwallet.callback/on-verify-pin-error]} {:events [:hardwallet.callback/on-verify-pin-error]}
[{:keys [db] :as cofx} 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])) setup? (boolean (get-in db [:hardwallet :setup-step]))
exporting? (get-in db [:hardwallet :on-export-success])] exporting? (get-in db [:hardwallet :on-export-success])]
(log/debug "[hardwallet] verify pin error" error) (log/debug "[hardwallet] verify pin error" error)
(cond tag-was-lost? (when-not tag-was-lost?
(fx/merge cofx (if (re-matches common/pin-mismatch-error (:error error))
{: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))
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:hardwallet :pin] merge {:status :error {:db (update-in db [:hardwallet :pin] merge {:status :error
:enter-step :current :enter-step :current
@ -223,20 +209,23 @@
:confirmation [] :confirmation []
:sign [] :sign []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(common/hide-pair-sheet)
(when-not setup? (when-not setup?
(if exporting? (if exporting?
(navigation/navigate-back) (navigation/navigate-back)
(navigation/navigate-to-cofx :enter-pin-settings nil))) (navigation/navigate-to-cofx :enter-pin-settings nil)))
(common/get-application-info (common/get-pairing db) 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 (fx/defn verify-pin
{:events [:hardwallet/verify-pin]} {:events [:hardwallet/verify-pin]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [pin (common/vector->string (get-in db [:hardwallet :pin :current])) (let [pin (common/vector->string (get-in db [:hardwallet :pin :current]))
pairing (common/get-pairing db) pairing (common/get-pairing db)
card-connected? (get-in db [:hardwallet :card-connected?]) card-connected? (get-in db [:hardwallet :card-connected?])]
setup? (boolean (get-in db [:hardwallet :setup-step]))]
(if card-connected? (if card-connected?
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :status] :verifying) {:db (assoc-in db [:hardwallet :pin :status] :verifying)
@ -244,9 +233,7 @@
:pairing pairing}}) :pairing pairing}})
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/verify-pin) (common/set-on-card-connected :hardwallet/verify-pin)
(navigation/navigate-to-cofx (if setup? (common/show-pair-sheet {})))))
:keycard-connection-lost-setup
:keycard-processing) nil)))))
(fx/defn unblock-pin (fx/defn unblock-pin
{:events [:hardwallet/unblock-pin]} {:events [:hardwallet/unblock-pin]}
@ -262,7 +249,7 @@
:pairing pairing}} :pairing pairing}}
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/unblock-pin) (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 pin-code-length 6)
(def puk-code-length 12) (def puk-code-length 12)
@ -367,13 +354,14 @@
[{:keys [db]} pairings] [{:keys [db]} pairings]
{:db (assoc-in db [:hardwallet :pairings] 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 (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]} {:events [:hardwallet.callback/on-pair-success]}
[{:keys [db] :as cofx} pairing] [{:keys [db] :as cofx} pairing]
(let [setup-step (get-in db [:hardwallet :setup-step]) (let [setup-step (get-in db [:hardwallet :setup-step])
@ -394,7 +382,7 @@
(assoc-in [:hardwallet :setup-step] next-step) (assoc-in [:hardwallet :setup-step] next-step)
(assoc-in [:hardwallet :secrets :pairing] pairing) (assoc-in [:hardwallet :secrets :pairing] pairing)
(assoc-in [:hardwallet :secrets :paired-on] paired-on))} (assoc-in [:hardwallet :secrets :paired-on] paired-on))}
(common/clear-on-card-connected) (common/hide-pair-sheet)
(when multiaccount (when multiaccount
(set-multiaccount-pairing multiaccount pairing paired-on)) (set-multiaccount-pairing multiaccount pairing paired-on))
(when (= flow :login) (when (= flow :login)
@ -413,17 +401,20 @@
[{:keys [db] :as cofx} {:keys [error code]}] [{:keys [db] :as cofx} {:keys [error code]}]
(log/debug "[hardwallet] pair error: " error) (log/debug "[hardwallet] pair error: " error)
(let [setup-step (get-in db [:hardwallet :setup-step]) (let [setup-step (get-in db [:hardwallet :setup-step])
tag-was-lost? (common/tag-lost? error)
flow (get-in db [:hardwallet :flow])] 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 (fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))} {:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))}
(common/set-on-card-connected (if (= setup-step :pairing) (common/set-on-card-connected (if (= setup-step :pairing)
:hardwallet/load-pairing-screen :hardwallet/load-pairing-screen
:hardwallet/pair)) :hardwallet/pair))
(common/hide-pair-sheet)
(when (= flow :import) (when (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-pair nil)) (navigation/navigate-to-cofx :keycard-recovery-pair nil))
(when (not= setup-step :enter-pair-code) (when (not= setup-step :enter-pair-code)
(common/process-error code error))))) (common/process-error code error))))))
(fx/defn set-setup-step (fx/defn set-setup-step
[{:keys [db]} card-state] [{:keys [db]} card-state]
@ -458,9 +449,12 @@
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :card-state] card-state)} {:db (assoc-in db [:hardwallet :card-state] card-state)}
(set-setup-step card-state) (set-setup-step card-state)
(common/hide-pair-sheet)
(when (and flow (when (and flow
(= card-state :init)) (= card-state :init))
(proceed-setup-with-initialized-card flow instance-uid)) (proceed-setup-with-initialized-card flow instance-uid))
(when (= card-state :pre-init) (when (= card-state :pre-init)
(if (= flow :import) (if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-no-key nil) (navigation/navigate-to-cofx :keycard-recovery-no-key nil)
@ -469,6 +463,7 @@
cofx cofx
(common/clear-on-card-read) (common/clear-on-card-read)
(load-pin-screen))))) (load-pin-screen)))))
(when (and (= card-state :multiaccount) (when (and (= card-state :multiaccount)
(= flow :import)) (= flow :import))
(if (common/find-multiaccount-by-key-uid db key-uid) (if (common/find-multiaccount-by-key-uid db key-uid)
@ -476,17 +471,30 @@
(if pairing (if pairing
(load-recovery-pin-screen) (load-recovery-pin-screen)
(recovery/load-pair-screen)))) (recovery/load-pair-screen))))
(when (= card-state :blank) (when (= card-state :blank)
(if (= flow :import) (if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-no-key nil) (navigation/navigate-to-cofx :keycard-recovery-no-key nil)
(show-no-keycard-applet-alert))) (show-no-keycard-applet-alert)))
(when (and (= card-state :multiaccount) (when (and (= card-state :multiaccount)
(#{:create :recovery} flow)) (#{:create :recovery} flow))
(show-keycard-has-multiaccount-alert))))) (show-keycard-has-multiaccount-alert)))))
(fx/defn hardwallet-connect-navigate-back-button-clicked (fx/defn on-card-connected
{:events [:hardwallet.ui/hardwallet-connect-navigate-back-button-clicked]} {:events [:hardwallet.callback/on-card-connected]}
[{:keys [db] :as cofx}] [{:keys [db]} _]
(fx/merge cofx (log/debug "[hardwallet] card globally connected")
(common/clear-on-card-connected) {:db (assoc-in db [:hardwallet :card-connected?] true)})
(navigation/navigate-back)))
(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)})

View File

@ -1,23 +1,18 @@
(ns status-im.hardwallet.export-key (ns status-im.hardwallet.export-key
(:require [status-im.utils.fx :as fx] (:require [status-im.utils.fx :as fx]
[re-frame.core :as re-frame]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.i18n :as i18n]
[status-im.ui.screens.navigation :as navigation]
[status-im.hardwallet.common :as common])) [status-im.hardwallet.common :as common]))
(fx/defn on-export-key-error (fx/defn on-export-key-error
{:events [:hardwallet.callback/on-export-key-error]} {:events [:hardwallet.callback/on-export-key-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] export key error" 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? (cond tag-was-lost?
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :pin :status] nil) {:db (assoc-in db [:hardwallet :pin :status] nil)}
:utils/show-popup {:title (i18n/label :t/error) (common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
: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))
(re-matches common/pin-mismatch-error (:error error)) (re-matches common/pin-mismatch-error (:error error))
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:hardwallet :pin] merge {:status :error {:db (update-in db [:hardwallet :pin] merge {:status :error
@ -27,19 +22,22 @@
:original [] :original []
:confirmation [] :confirmation []
:sign [] :sign []
:export-key []
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(navigation/navigate-back) (common/hide-pair-sheet)
(common/get-application-info (common/get-pairing db) nil)) (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 (fx/defn on-export-key-success
{:events [:hardwallet.callback/on-export-key-success]} {:events [:hardwallet.callback/on-export-key-success]}
[{:keys [db] :as cofx} pubkey] [{:keys [db] :as cofx} pubkey]
(let [multiaccount-address (get-in db [:multiaccount :address]) (let [callback-fn (get-in db [:hardwallet :on-export-success])]
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)
(fx/merge cofx (fx/merge cofx
(common/clear-on-card-connected)))) {:dispatch (callback-fn pubkey)}
(common/clear-pin)
(common/hide-pair-sheet))))

View File

@ -11,8 +11,7 @@
[status-im.ui.components.bottom-sheet.core :as bottom-sheet])) [status-im.ui.components.bottom-sheet.core :as bottom-sheet]))
(fx/defn login-got-it-pressed (fx/defn login-got-it-pressed
{:events [:keycard.login.ui/got-it-pressed {:events [:keycard.login.pin.ui/got-it-pressed
:keycard.login.ui/dismiss-pressed
:keycard.login.pin.ui/cancel-pressed]} :keycard.login.pin.ui/cancel-pressed]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(fx/merge cofx (fx/merge cofx
@ -62,31 +61,37 @@
pairing (:keycard-pairing multiaccount)] pairing (:keycard-pairing multiaccount)]
(cond (cond
(empty? application-info) (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) (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? 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) (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 :else
(common/get-keys-from-keycard cofx)))) (common/get-keys-from-keycard cofx))))
(fx/defn proceed-to-login (fx/defn proceed-to-login
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{:keys [card-connected? nfc-enabled?]} (:hardwallet db)] (let [{:keys [card-connected?]} (:hardwallet db)]
(if nfc-enabled?
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/get-application-info) (common/set-on-card-connected :hardwallet/get-application-info)
(common/set-on-card-read :hardwallet/login-with-keycard) (common/set-on-card-read :hardwallet/login-with-keycard)
(if card-connected? (if card-connected?
(login-with-keycard) (login-with-keycard)
(navigation/navigate-to-cofx :keycard-login-connect-card nil))) (common/show-pair-sheet {:on-cancel [::common/cancel-sheet-confirm]})))))
(navigation/navigate-to-cofx cofx :keycard-nfc-on nil))))
(fx/defn on-hardwallet-keychain-keys (fx/defn on-hardwallet-keychain-keys
{:events [:multiaccounts.login.callback/get-hardwallet-keys-success]} {:events [:multiaccounts.login.callback/get-hardwallet-keys-success]}

View File

@ -15,7 +15,7 @@
(assoc-in [:hardwallet :setup-step] :recovery-phrase) (assoc-in [:hardwallet :setup-step] :recovery-phrase)
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))} (assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
(common/clear-on-card-connected) (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 (fx/defn set-mnemonic
{:events [:test-mnemonic]} {:events [:test-mnemonic]}
@ -59,7 +59,7 @@
(common/set-on-card-connected :hardwallet/load-generating-mnemonic-screen) (common/set-on-card-connected :hardwallet/load-generating-mnemonic-screen)
(if card-connected? (if card-connected?
(common/dispatch-event :hardwallet/generate-mnemonic) (common/dispatch-event :hardwallet/generate-mnemonic)
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (common/show-pair-sheet {})))))
(fx/defn on-generate-mnemonic-error (fx/defn on-generate-mnemonic-error
{:events [:hardwallet.callback/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) (common/set-on-card-connected :hardwallet/load-loading-keys-screen)
(if card-connected? (if card-connected?
(common/dispatch-event :hardwallet/generate-and-load-key) (common/dispatch-event :hardwallet/generate-and-load-key)
(navigation/navigate-to-cofx :hardwallet-connect nil))))) (common/show-pair-sheet {})))))

View File

@ -20,10 +20,10 @@
(assoc-in [:hardwallet :pin :confirmation] []))}) (assoc-in [:hardwallet :pin :confirmation] []))})
(fx/defn start-installation (fx/defn start-installation
{:events [:hardwallet/start-installation]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [card-state (get-in db [:hardwallet :card-state]) (let [card-state (get-in db [:hardwallet :card-state])
pin (common/vector->string (get-in db [:hardwallet :pin :original]))] pin (common/vector->string (get-in db [:hardwallet :pin :original]))]
(log/debug "start-installation: card-state" card-state)
(case card-state (case card-state
:pre-init :pre-init
@ -43,11 +43,9 @@
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-step] :preparing)} {:db (assoc-in db [:hardwallet :setup-step] :preparing)}
(common/set-on-card-connected :hardwallet/load-preparing-screen) (common/set-on-card-connected :hardwallet/load-preparing-screen)
(when card-connected?
(navigation/navigate-to-cofx :keycard-onboarding-preparing nil))
(if card-connected? (if card-connected?
(common/dispatch-event :hardwallet/start-installation) (start-installation)
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil))))) (common/show-pair-sheet {:on-cancel [::cancel-pressed]})))))
(fx/defn load-pairing-screen (fx/defn load-pairing-screen
{:events [:hardwallet/load-pairing-screen {:events [:hardwallet/load-pairing-screen
@ -57,11 +55,9 @@
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-step] :pairing)} {:db (assoc-in db [:hardwallet :setup-step] :pairing)}
(common/set-on-card-connected :hardwallet/load-pairing-screen) (common/set-on-card-connected :hardwallet/load-pairing-screen)
(when card-connected?
(navigation/navigate-to-cofx :keycard-pairing nil))
(if card-connected? (if card-connected?
(common/dispatch-event :hardwallet/pair) (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 (fx/defn puk-code-next-pressed
{:events [:keycard.onboarding.puk-code.ui/next-pressed]} {:events [:keycard.onboarding.puk-code.ui/next-pressed]}
@ -81,11 +77,9 @@
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-step] :loading-keys)} {:db (assoc-in db [:hardwallet :setup-step] :loading-keys)}
(common/set-on-card-connected :hardwallet/load-finishing-screen) (common/set-on-card-connected :hardwallet/load-finishing-screen)
(when card-connected?
(navigation/navigate-to-cofx :keycard-onboarding-finishing nil))
(if card-connected? (if card-connected?
(common/dispatch-event :hardwallet/generate-and-load-key) (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 (fx/defn recovery-phrase-learn-more-pressed
{:events [:keycard.onboarding.recovery-phrase.ui/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])))] (common/vector->string (get-in db [:hardwallet :pin :current])))]
(if (empty? pin) (if (empty? pin)
(fx/merge cofx (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 :on-verified :hardwallet/generate-and-load-key
:current []})} :current []})
(assoc-in [:hardwallet :setup-step] :loading-keys))}
(navigation/navigate-to-cofx :keycard-onboarding-pin nil)) (navigation/navigate-to-cofx :keycard-onboarding-pin nil))
(load-finishing-screen cofx)))) (load-finishing-screen cofx))))
@ -164,7 +160,7 @@
(if (= (:view-id db) :keycard-onboarding-recovery-phrase-confirm-word1) (if (= (:view-id db) :keycard-onboarding-recovery-phrase-confirm-word1)
(fx/merge cofx (fx/merge cofx
(recovery-phrase-next-word) (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)) (proceed-with-generating-key cofx))
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))}))) {: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 :card-state] :init)
(assoc-in [:hardwallet :setup-step] :secret-keys) (assoc-in [:hardwallet :setup-step] :secret-keys)
(update-in [:hardwallet :secrets] merge secrets'))} (update-in [:hardwallet :secrets] merge secrets'))}
(common/clear-on-card-connected) (common/hide-pair-sheet)
(common/listen-to-hardware-back-button) (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 (fx/defn on-install-applet-and-init-card-error
{:events [:hardwallet.callback/on-install-applet-and-init-card-error {:events [:hardwallet.callback/on-install-applet-and-init-card-error
@ -287,14 +283,11 @@
(fx/merge cofx (fx/merge cofx
{:hardwallet/generate-and-load-key {:mnemonic mnemonic' {:hardwallet/generate-and-load-key {:mnemonic mnemonic'
:pairing pairing :pairing pairing
:pin pin'}} :pin pin'}})))
(navigation/navigate-to-cofx :keycard-onboarding-finishing nil))))
(fx/defn begin-setup-pressed (fx/defn begin-setup-pressed
{:events [:keycard.onboarding.intro.ui/begin-setup-pressed]} {:events [:keycard.onboarding.intro.ui/begin-setup-pressed]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [nfc-enabled? (get-in db [:hardwallet :nfc-enabled?])
flow (get-in db [:hardwallet :flow])]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(update :hardwallet (update :hardwallet
@ -305,31 +298,21 @@
(assoc-in [:hardwallet :pin :on-verified] nil))} (assoc-in [:hardwallet :pin :on-verified] nil))}
(common/set-on-card-connected :hardwallet/get-application-info) (common/set-on-card-connected :hardwallet/get-application-info)
(common/set-on-card-read :hardwallet/check-card-state) (common/set-on-card-read :hardwallet/check-card-state)
(if nfc-enabled? (common/show-pair-sheet {})))
(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)))))
(fx/defn cancel-setup-pressed (fx/defn cancel-confirm
{:events [:keycard.onboarding.ui/cancel-pressed {:events [::cancel-confirm]}
:hardwallet/back-button-pressed [cofx]
:keycard.onboarding.recovery-phrase.ui/cancel-pressed (fx/merge cofx
:keycard.onboarding.connection-lost-setup.ui/cancel-setup-pressed]} (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) {:ui/show-confirmation {:title (i18n/label :t/keycard-cancel-setup-title)
:content (i18n/label :t/keycard-cancel-setup-text) :content (i18n/label :t/keycard-cancel-setup-text)
:confirm-button-text (i18n/label :t/yes) :confirm-button-text (i18n/label :t/yes)
:cancel-button-text (i18n/label :t/no) :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 #()}}) :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)}]})))

View File

@ -23,11 +23,9 @@
card-connected? (get-in db [:hardwallet :card-connected?])] card-connected? (get-in db [:hardwallet :card-connected?])]
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/pair) (common/set-on-card-connected :hardwallet/pair)
(when card-connected?
(pair* password))
(if card-connected? (if card-connected?
(navigation/navigate-to-cofx :keycard-pairing nil) (pair* password)
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil))))) (common/show-pair-sheet {})))))
(fx/defn pair-code-next-button-pressed (fx/defn pair-code-next-button-pressed
{:events [:keycard.onboarding.pair.ui/input-submitted {:events [:keycard.onboarding.pair.ui/input-submitted
@ -82,11 +80,26 @@
:hardwallet/check-nfc-enabled nil} :hardwallet/check-nfc-enabled nil}
(navigation/navigate-to-cofx :keycard-onboarding-intro 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 (fx/defn begin-setup-pressed
{:events [:keycard.recovery.intro.ui/begin-recovery-pressed]} {:events [:keycard.recovery.intro.ui/begin-recovery-pressed]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [nfc-enabled? (get-in db [:hardwallet :nfc-enabled?])
flow (get-in db [:hardwallet :flow])]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(update :hardwallet (update :hardwallet
@ -97,11 +110,7 @@
(assoc-in [:hardwallet :pin :on-verified] nil))} (assoc-in [:hardwallet :pin :on-verified] nil))}
(common/set-on-card-connected :hardwallet/get-application-info) (common/set-on-card-connected :hardwallet/get-application-info)
(common/set-on-card-read :hardwallet/check-card-state) (common/set-on-card-read :hardwallet/check-card-state)
(if nfc-enabled? (common/show-pair-sheet {:on-cancel [::cancel-pressed]})))
(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)))))
(fx/defn recovery-success-finish-pressed (fx/defn recovery-success-finish-pressed
{:events [:keycard.recovery.success/finish-pressed]} {:events [:keycard.recovery.success/finish-pressed]}
@ -205,18 +214,19 @@
(update-in [:hardwallet :secrets] dissoc :pin :puk :password) (update-in [:hardwallet :secrets] dissoc :pin :puk :password)
(assoc :multiaccounts/new-installation-id (random-guid-generator)) (assoc :multiaccounts/new-installation-id (random-guid-generator))
(update-in [:hardwallet :secrets] dissoc :mnemonic))} (update-in [:hardwallet :secrets] dissoc :mnemonic))}
(common/clear-on-card-connected)
(common/remove-listener-to-hardware-back-button) (common/remove-listener-to-hardware-back-button)
(common/hide-pair-sheet)
(create-keycard-multiaccount)))) (create-keycard-multiaccount))))
(fx/defn on-generate-and-load-key-error (fx/defn on-generate-and-load-key-error
{:events [:hardwallet.callback/on-generate-and-load-key-error]} {:events [:hardwallet.callback/on-generate-and-load-key-error]}
[{:keys [db] :as cofx} {:keys [error code]}] [{:keys [db] :as cofx} {:keys [error code]}]
(log/debug "[hardwallet] generate and load key error: " error) (log/debug "[hardwallet] generate and load key error: " error)
(when-not (common/tag-lost? error)
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:hardwallet :setup-error] error)} {:db (assoc-in db [:hardwallet :setup-error] error)}
(common/set-on-card-connected :hardwallet/load-loading-keys-screen) (common/set-on-card-connected :hardwallet/load-loading-keys-screen)
(common/process-error code error))) (common/process-error code error))))
(fx/defn import-multiaccount (fx/defn import-multiaccount
{:events [:hardwallet/import-multiaccount]} {:events [:hardwallet/import-multiaccount]}
@ -238,13 +248,12 @@
(fx/defn load-recovering-key-screen (fx/defn load-recovering-key-screen
{:events [:hardwallet/load-recovering-key-screen]} {:events [:hardwallet/load-recovering-key-screen]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [card-connected? (get-in db [:hardwallet :card-connected?])]
(fx/merge cofx (fx/merge cofx
{:db (-> db (common/set-on-card-connected :hardwallet/load-recovering-key-screen)
(assoc-in [:hardwallet :pin] {:enter-step :import-multiaccount (if card-connected?
:import-multiaccount [] (common/dispatch-event :hardwallet/import-multiaccount)
:current []}))} (common/show-pair-sheet {})))))
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-recovery-pin nil)))
(fx/defn on-name-and-photo-generated (fx/defn on-name-and-photo-generated
{:events [::on-name-and-photo-generated] {:events [::on-name-and-photo-generated]

View File

@ -4,7 +4,6 @@
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.i18n :as i18n]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.hardwallet.common :as common])) [status-im.hardwallet.common :as common]))
@ -37,13 +36,13 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [card-connected? (get-in db [:hardwallet :card-connected?]) (let [card-connected? (get-in db [:hardwallet :card-connected?])
pairing (common/get-pairing db)] pairing (common/get-pairing db)]
(fx/merge cofx
(if card-connected? (if card-connected?
(common/get-application-info pairing :hardwallet/sign)
(fn [cofx]
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:signing/sign :keycard-step] :signing)} (common/set-on-card-connected :hardwallet/prepare-to-sign)
(common/get-application-info pairing :hardwallet/sign)) (common/show-pair-sheet {})))))))
(fx/merge cofx
{:db (assoc-in db [:signing/sign :keycard-step] :connect)}
(common/set-on-card-connected :hardwallet/prepare-to-sign)))))
(fx/defn sign-message-completed (fx/defn sign-message-completed
[_ signature] [_ signature]
@ -74,6 +73,7 @@
(assoc-in [:hardwallet :transaction] nil))} (assoc-in [:hardwallet :transaction] nil))}
(common/clear-on-card-connected) (common/clear-on-card-connected)
(common/get-application-info (common/get-pairing db) nil) (common/get-application-info (common/get-pairing db) nil)
(common/hide-pair-sheet)
(if transaction (if transaction
(send-transaction-with-signature {:transaction (types/clj->json transaction) (send-transaction-with-signature {:transaction (types/clj->json transaction)
:signature signature :signature signature
@ -84,24 +84,17 @@
{:events [:hardwallet.callback/on-sign-error]} {:events [:hardwallet.callback/on-sign-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] sign error: " error) (log/debug "[hardwallet] sign error: " error)
(let [tag-was-lost? (= "Tag was lost." (:error error))] (let [tag-was-lost? (common/tag-lost? (:error error))]
(fx/merge cofx (when-not tag-was-lost?
(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))))
(if (re-matches common/pin-mismatch-error (:error error)) (if (re-matches common/pin-mismatch-error (:error error))
(fn [{:keys [db] :as cofx}]
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(update-in [:hardwallet :pin] merge {:status :error (update-in [:hardwallet :pin] merge {:status :error
:sign [] :sign []
:error-label :t/pin-mismatch}) :error-label :t/pin-mismatch})
(assoc-in [:signing/sign :keycard-step] :pin))} (assoc-in [:signing/sign :keycard-step] :pin))}
(common/get-application-info (common/get-pairing db) nil))) (common/hide-pair-sheet)
(common/show-wrong-keycard-alert true))))) (common/get-application-info (common/get-pairing db) nil))
(fx/merge cofx
(common/hide-pair-sheet)
(common/show-wrong-keycard-alert true))))))

View File

@ -103,7 +103,7 @@
:pairing pairing}} :pairing pairing}}
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :hardwallet/remove-key-with-unpair) (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 (fx/defn on-remove-key-success
{:events [:hardwallet.callback/on-remove-key-success]} {:events [:hardwallet.callback/on-remove-key-success]}
@ -133,7 +133,7 @@
{:events [:hardwallet.callback/on-remove-key-error]} {:events [:hardwallet.callback/on-remove-key-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]
(log/debug "[hardwallet] remove key error" 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 (fx/merge cofx
(if tag-was-lost? (if tag-was-lost?
(fx/merge cofx (fx/merge cofx

View File

@ -3,7 +3,6 @@
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.hardwallet.common :as common] [status-im.hardwallet.common :as common]
[status-im.ui.screens.navigation :as navigation]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.ethereum.eip55 :as eip55])) [status-im.ethereum.eip55 :as eip55]))
@ -24,8 +23,7 @@
:public-key (str "0x" %) :public-key (str "0x" %)
:path path})) :path path}))
:hardwallet/export-key {:pin pin :pairing pairing :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)) (common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
(fx/merge cofx (fx/merge cofx
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account) (common/set-on-card-connected :wallet.accounts/generate-new-keycard-account)
(navigation/navigate-to-cofx :keycard-processing nil))))) (common/show-pair-sheet {})))))

View File

@ -11,6 +11,7 @@
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.hardwallet.common :as hardwallet.common]
[status-im.utils.hex :as utils.hex] [status-im.utils.hex :as utils.hex]
[status-im.utils.money :as money] [status-im.utils.money :as money]
[status-im.utils.security :as security] [status-im.utils.security :as security]
@ -283,7 +284,7 @@
(fx/merge cofx (fx/merge cofx
{:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)} {:db (dissoc db :signing/tx :signing/in-progress? :signing/sign)}
(check-queue) (check-queue)
#(if on-result #(when on-result
{:dispatch (conj on-result result)}))))) {:dispatch (conj on-result result)})))))
(fx/defn transaction-completed (fx/defn transaction-completed
@ -304,8 +305,12 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{:keys [on-error]} (get-in db [:signing/tx])] (let [{:keys [on-error]} (get-in db [:signing/tx])]
(fx/merge cofx (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) (check-queue)
(hardwallet.common/hide-pair-sheet)
(hardwallet.common/clear-pin)
#(when on-error #(when on-error
{:dispatch (conj on-error "transaction was cancelled by user")})))) {:dispatch (conj on-error "transaction was cancelled by user")}))))

View File

@ -136,9 +136,7 @@
(minimize-bar new-view-id)))) (minimize-bar new-view-id))))
:reagent-render :reagent-render
(fn [keyboard-shown? view-id tab] (fn [keyboard-shown? view-id tab]
(when-not (contains? #{:enter-pin-login (when-not (contains? #{:enter-pin-settings} view-id)
:enter-pin-sign
:enter-pin-settings} view-id)
(case platform/os (case platform/os
"ios" [tabs-animation-wrapper-ios "ios" [tabs-animation-wrapper-ios
[react/animated-view [react/animated-view

View File

@ -205,16 +205,9 @@
:home (chat.loading/offload-all-messages cofx) :home (chat.loading/offload-all-messages cofx)
:keycard-settings (hardwallet/settings-screen-did-load %) :keycard-settings (hardwallet/settings-screen-did-load %)
:reset-card (hardwallet/reset-card-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-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 %) :keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
:add-new-account-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 %) :hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
:multiaccounts (hardwallet/multiaccounts-screen-did-load %) :multiaccounts (hardwallet/multiaccounts-screen-did-load %)
nil)))) nil))))

View File

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

View File

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

View File

@ -144,11 +144,7 @@
error-label [:hardwallet/pin-error-label]] error-label [:hardwallet/pin-error-label]]
[react/view {:flex 1 [react/view {:flex 1
:background-color colors/white} :background-color colors/white}
[topbar/topbar [topbar/topbar {}]
{:navigation
{:icon :main-icons/back
:accessibility-label :back-button
:handler #(re-frame/dispatch [:hardwallet.ui/enter-pin-navigate-back-button-clicked])}}]
(if (zero? pin-retry-counter) (if (zero? pin-retry-counter)
[pin-view {:pin pin [pin-view {:pin pin
:retry-counter (when (< puk-retry-counter puk-retries) puk-retry-counter) :retry-counter (when (< puk-retry-counter puk-retries) puk-retry-counter)

View File

@ -1,6 +1,5 @@
(ns status-im.ui.screens.hardwallet.settings.subs (ns status-im.ui.screens.hardwallet.settings.subs
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.hardwallet.common :as common]
[status-im.utils.datetime :as utils.datetime])) [status-im.utils.datetime :as utils.datetime]))
(re-frame/reg-sub (re-frame/reg-sub
@ -9,11 +8,6 @@
(some-> (get-in db [:multiaccount :keycard-paired-on]) (some-> (get-in db [:multiaccount :keycard-paired-on])
(utils.datetime/timestamp->year-month-day-date)))) (utils.datetime/timestamp->year-month-day-date))))
(re-frame/reg-sub
:keycard-pairing
(fn [db]
(common/get-pairing db)))
(re-frame/reg-sub (re-frame/reg-sub
:keycard-multiaccount-pairing :keycard-multiaccount-pairing
(fn [db] (fn [db]

View File

@ -265,7 +265,7 @@
2000) 2000)
(animation/start connect-animation))) (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) (let [animation-small (animation/create-value 0)
animation-medium (animation/create-value 0) animation-medium (animation/create-value 0)
animation-big (animation/create-value 0) animation-big (animation/create-value 0)
@ -300,17 +300,25 @@
(on-card-disconnected) (on-card-disconnected)
(on-error (on-error
{:state state {:state state
:restart on-start-animation}))] :restart on-start-animation}))
listeners (atom [])]
(reagent/create-class (reagent/create-class
{:component-did-mount {:component-did-mount
(fn [] (fn []
(keycard-nfc/remove-event-listeners) (doseq [listener @listeners]
(keycard-nfc/on-card-connected on-card-connected) (keycard-nfc/remove-event-listener listener))
(keycard-nfc/on-card-disconnected on-error)
(on-start-animation)) (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 :component-will-unmount
(fn [] (fn []
(keycard-nfc/remove-event-listeners)) (doseq [listener @listeners]
(keycard-nfc/remove-event-listener listener)))
:render :render
(fn [] (fn []
[react/view {:style {:position :absolute [react/view {:style {:position :absolute

View File

@ -26,12 +26,13 @@
(defn card-sync-flow [] (defn card-sync-flow []
(let [state (reagent/atom nil)] (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)] (let [translation (get state->translations @state)]
[react/view {:style styles/container-style} [react/view {:style styles/container-style}
[react/view {:height 200 [react/view {:height 200
:margin-bottom 20} :margin-bottom 20}
[animated-circles {:state state [animated-circles {:state state
:connected? connected?
:on-card-disconnected on-card-disconnected :on-card-disconnected on-card-disconnected
:on-card-connected on-card-connected}]] :on-card-connected on-card-connected}]]
(when translation (when translation
@ -39,8 +40,7 @@
{:title (i18n/label (:title translation)) {:title (i18n/label (:title translation))
:description (i18n/label (:description translation))}])])))) :description (i18n/label (:description translation))}])]))))
(defn connect-keycard [{:keys [on-connect on-cancel on-disconnect]}] (defn connect-keycard [{:keys [on-connect on-cancel connected? on-disconnect]}]
(fn []
[react/view {:style {:flex 1 [react/view {:style {:flex 1
:align-items :center :align-items :center
:justify-content :center}} :justify-content :center}}
@ -56,8 +56,9 @@
:text-align :center}} :text-align :center}}
(i18n/label :t/cancel)]]) (i18n/label :t/cancel)]])
(if @(re-frame/subscribe [:hardwallet/nfc-enabled?]) (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]) #(re-frame/dispatch [on-disconnect])
:on-card-connected :on-card-connected
#(re-frame/dispatch [on-connect])}] #(re-frame/dispatch [on-connect])}]
[turn-nfc/turn-nfc-on])])) [turn-nfc/turn-nfc-on])])

View File

@ -3,6 +3,7 @@
(:require [status-im.ui.components.react :as react] (:require [status-im.ui.components.react :as react]
[status-im.ui.screens.keycard.styles :as styles] [status-im.ui.screens.keycard.styles :as styles]
[status-im.ui.screens.keycard.views :as views] [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.toolbar.view :as toolbar]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.icons.vector-icons :as vector-icons]
@ -98,35 +99,6 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/begin-set-up)]]]]]])) (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 [] (defview puk-code []
(letsubs [secrets [:hardwallet-secrets] (letsubs [secrets [:hardwallet-secrets]
steps [:hardwallet-flow-steps] steps [:hardwallet-flow-steps]
@ -135,7 +107,7 @@
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text [toolbar/nav-text
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed]) {:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
:style {:padding-left 21}} :style {:padding-left 21}}
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}
@ -219,29 +191,25 @@
{:on-press #(re-frame/dispatch [:keycard.onboarding.puk-code.ui/next-pressed]) {:on-press #(re-frame/dispatch [:keycard.onboarding.puk-code.ui/next-pressed])
:forward? true}]]]]]])) :forward? true}]]]]]]))
(defn preparing []
(views/loading :t/keycard-onboarding-preparing-header))
(defn finishing []
(views/loading :t/keycard-onboarding-finishing-header))
(defview pin [] (defview pin []
(letsubs [pin [:hardwallet/pin] (letsubs [pin [:hardwallet/pin]
enter-step [:hardwallet/pin-enter-step] enter-step [:hardwallet/pin-enter-step]
status [:hardwallet/pin-status] status [:hardwallet/pin-status]
error-label [:hardwallet/pin-error-label] error-label [:hardwallet/pin-error-label]
steps [:hardwallet-flow-steps] steps [:hardwallet-flow-steps]
small-screen? [:dimensions/small-screen?]] small-screen? [:dimensions/small-screen?]
setup-step [:hardwallet-setup-step]]
[react/view styles/container [react/view styles/container
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text [toolbar/nav-text
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed]) {:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
:style {:padding-left 21}} :style {:padding-left 21}}
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
(when-not (= setup-step :loading-keys)
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}
(i18n/label :t/step-i-of-n {:number steps (i18n/label :t/step-i-of-n {:number steps
:step 1})]] :step 1})])]
[react/view {:flex 1 [react/view {:flex 1
:flex-direction :column :flex-direction :column
:justify-content :space-between :justify-content :space-between
@ -265,6 +233,7 @@
:small-screen? small-screen? :small-screen? small-screen?
:error-label error-label :error-label error-label
:step enter-step}] :step enter-step}]
(when-not (= setup-step :loading-keys)
[react/view {:align-items :center [react/view {:align-items :center
:flex-direction :column :flex-direction :column
:justify-content :center :justify-content :center
@ -272,7 +241,7 @@
[react/text {:style {:color colors/gray [react/text {:style {:color colors/gray
:padding-horizontal 40 :padding-horizontal 40
:text-align :center}} :text-align :center}}
(i18n/label :t/you-will-need-this-code)]]]])) (i18n/label :t/you-will-need-this-code)]])]]))
(defview recovery-phrase [] (defview recovery-phrase []
(letsubs [mnemonic [:hardwallet-mnemonic]] (letsubs [mnemonic [:hardwallet-mnemonic]]
@ -280,7 +249,7 @@
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text [toolbar/nav-text
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed]) {:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
:style {:padding-left 21}} :style {:padding-left 21}}
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}
@ -350,7 +319,7 @@
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text [toolbar/nav-text
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed]) {:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
:style {:padding-left 21}} :style {:padding-left 21}}
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}

View File

@ -2,6 +2,7 @@
(:require-macros [status-im.utils.views :refer [defview letsubs]]) (:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [status-im.multiaccounts.recover.core :as multiaccounts.recover] (:require [status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.ui.components.react :as react] [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.styles :as styles]
[status-im.ui.screens.keycard.views :as views] [status-im.ui.screens.keycard.views :as views]
[status-im.ui.components.toolbar.view :as toolbar] [status-im.ui.components.toolbar.view :as toolbar]
@ -69,39 +70,6 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/keycard-recovery-intro-button-text)]]]]]]) (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 [] (defview pin []
(letsubs [pin [:hardwallet/pin] (letsubs [pin [:hardwallet/pin]
status [:hardwallet/pin-status] status [:hardwallet/pin-status]
@ -112,7 +80,7 @@
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text [toolbar/nav-text
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed]) {:handler #(re-frame/dispatch [::hardwallet.recovery/cancel-pressed])
:style {:padding-left 21}} :style {:padding-left 21}}
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}
@ -139,16 +107,11 @@
(defview pair [] (defview pair []
(letsubs [pair-code [:hardwallet-pair-code] (letsubs [pair-code [:hardwallet-pair-code]
error [:hardwallet-setup-error] error [:hardwallet-setup-error]
{:keys [free-pairing-slots]} [:hardwallet-application-info] {:keys [free-pairing-slots]} [:hardwallet-application-info]]
width [:dimensions/window-width]
ref (atom nil)]
[react/view styles/container [react/view styles/container
[toolbar/toolbar [toolbar/toolbar
{:transparent? true} {:transparent? true}
[toolbar/nav-text toolbar/default-nav-back
{:handler #(re-frame/dispatch [:keycard.onboarding.ui/cancel-pressed])
:style {:padding-left 21}}
(i18n/label :t/cancel)]
[react/text {:style {:color colors/gray}} [react/text {:style {:color colors/gray}}
(i18n/label :t/step-i-of-n {:number 2 (i18n/label :t/step-i-of-n {:number 2
:step 1})]] :step 1})]]
@ -200,9 +163,6 @@
:disabled? (empty? pair-code) :disabled? (empty? pair-code)
:forward? true}]]]]])) :forward? true}]]]]]))
(defn recovering []
(views/loading :t/recovering-key))
(defview success [] (defview success []
(letsubs [address [:hardwallet-multiaccount-wallet-address] (letsubs [address [:hardwallet-multiaccount-wallet-address]
whisper-public-key [:hardwallet-multiaccount-whisper-public-key]] whisper-public-key [:hardwallet-multiaccount-whisper-public-key]]
@ -307,7 +267,7 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/generate-new-key)]]] (i18n/label :t/generate-new-key)]]]
[react/touchable-highlight [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 [react/text {:style {:text-align :center
:padding-top 27 :padding-top 27
:color colors/blue}} :color colors/blue}}

View File

@ -15,146 +15,6 @@
[status-im.ui.screens.chat.photos :as photos] [status-im.ui.screens.chat.photos :as photos]
[status-im.ui.components.topbar :as topbar])) [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 [] (defn welcome []
[react/view {:flex 1 [react/view {:flex 1
:justify-content :space-between :justify-content :space-between
@ -179,6 +39,7 @@
[react/activity-indicator {:size :large [react/activity-indicator {:size :large
:animating true}]]]) :animating true}]]])
;; NOTE(Ferossgp): Seems like it should be in popover
(defn blank [] (defn blank []
[react/view {:flex 1 [react/view {:flex 1
:justify-content :center :justify-content :center
@ -208,7 +69,7 @@
:height 114}}]] :height 114}}]]
[react/view {:margin-bottom 32} [react/view {:margin-bottom 32}
[react/touchable-highlight [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 [react/view {:background-color colors/blue-light
:align-items :center :align-items :center
:justify-content :center :justify-content :center
@ -219,6 +80,7 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/ok-got-it)]]]]]]) (i18n/label :t/ok-got-it)]]]]]])
;; NOTE(Ferossgp): Seems like it should be in popover
(defn wrong [] (defn wrong []
[react/view {:flex 1 [react/view {:flex 1
:justify-content :center :justify-content :center
@ -247,7 +109,7 @@
:height 124}}]] :height 124}}]]
[react/view {:margin-bottom 32} [react/view {:margin-bottom 32}
[react/touchable-highlight [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 [react/view {:background-color colors/blue-light
:align-items :center :align-items :center
:justify-content :center :justify-content :center
@ -304,6 +166,7 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/dismiss)]]]]]]) (i18n/label :t/dismiss)]]]]]])
;; NOTE(Ferossgp): Seems like it should be in popover
(defn not-keycard [] (defn not-keycard []
[react/view {:flex 1 [react/view {:flex 1
:justify-content :center :justify-content :center
@ -343,7 +206,7 @@
:container-style {:margin-left 5}}]]]]] :container-style {:margin-left 5}}]]]]]
[react/view {:margin-bottom 32} [react/view {:margin-bottom 32}
[react/touchable-highlight [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 [react/view {:background-color colors/blue-light
:align-items :center :align-items :center
:justify-content :center :justify-content :center
@ -365,13 +228,12 @@
retry-counter [:hardwallet/retry-counter]] retry-counter [:hardwallet/retry-counter]]
[react/view styles/container [react/view styles/container
[topbar/topbar [topbar/topbar
(cond-> {:accessories [{:icon :main-icons/more {:accessories [{:icon :main-icons/more
:handler #(re-frame/dispatch [:keycard.login.pin.ui/more-icon-pressed])}]} :handler #(re-frame/dispatch [:keycard.login.pin.ui/more-icon-pressed])}]
multiple-multiaccounts? :navigation
(assoc :navigation
{:icon :main-icons/back {:icon :main-icons/back
:accessibility-label :back-button :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 [react/view {:flex 1
:flex-direction :column :flex-direction :column
:justify-content :space-between :justify-content :space-between
@ -433,89 +295,6 @@
[react/text {:style {:color colors/blue}} [react/text {:style {:color colors/blue}}
(i18n/label :t/recover-key)]]]]])) (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 [] (defn- more-sheet-content []
[react/view {:flex 1} [react/view {:flex 1}
[list-item/list-item [list-item/list-item

View File

@ -7,7 +7,7 @@
[react/view [react/view
[list-item/list-item {:theme :action [list-item/list-item {:theme :action
:on-press #(do (re-frame/dispatch [:bottom-sheet/hide]) :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 :icon :main-icons/add
:accessibility-label :generate-a-new-key :accessibility-label :generate-a-new-key
:title :t/generate-a-new-key}]]) :title :t/generate-a-new-key}]])

View File

@ -34,6 +34,20 @@
(assoc :view-id go-to-view-id))) (assoc :view-id go-to-view-id)))
::navigate-to [go-to-view-id screen-params]})) ::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 (fx/defn navigate-reset
[{:keys [db]} {:keys [index actions] :as config}] [{:keys [db]} {:keys [index actions] :as config}]
(let [stack (into '() (map :routeName actions)) (let [stack (into '() (map :routeName actions))
@ -74,12 +88,24 @@
(log/debug :navigate-reset config) (log/debug :navigate-reset config)
(navigation/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 (handlers/register-handler-fx
:navigate-to :navigate-to
navigation-interceptors navigation-interceptors
(fn [cofx [_ & [go-to-view-id screen-params]]] (fn [cofx [_ & [go-to-view-id screen-params]]]
(navigate-to-cofx 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 (handlers/register-handler-fx
:navigate-to-modal :navigate-to-modal
navigation-interceptors navigation-interceptors

View File

@ -19,30 +19,20 @@
:intro :intro
:intro-wizard :intro-wizard
:hardwallet-authentication-method :hardwallet-authentication-method
:hardwallet-connect
:keycard-connection-lost
:keycard-connection-lost-setup
:keycard-nfc-on
:keycard-pairing :keycard-pairing
:keycard-blank :keycard-blank
:keycard-wrong :keycard-wrong
:keycard-unpaired :keycard-unpaired
:keycard-login-pin :keycard-login-pin
:keycard-login-connect-card
:not-keycard :not-keycard
:keycard-onboarding-intro :keycard-onboarding-intro
:keycard-onboarding-start
:keycard-onboarding-puk-code :keycard-onboarding-puk-code
:keycard-onboarding-preparing
: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-word1
:keycard-onboarding-recovery-phrase-confirm-word2 :keycard-onboarding-recovery-phrase-confirm-word2
:keycard-recovery-intro :keycard-recovery-intro
:keycard-recovery-start
:keycard-recovery-pair :keycard-recovery-pair
:keycard-recovery-recovering
:keycard-recovery-success :keycard-recovery-success
:keycard-recovery-no-key :keycard-recovery-no-key
:keycard-recovery-pin}) :keycard-recovery-pin})
@ -68,10 +58,7 @@
config/hardwallet-enabled? config/hardwallet-enabled?
(concat [:hardwallet-authentication-method (concat [:hardwallet-authentication-method
:hardwallet-connect
:keycard-login-pin :keycard-login-pin
:keycard-login-connect-card
:keycard-nfc-on
:keycard-blank :keycard-blank
:keycard-wrong :keycard-wrong
:keycard-unpaired :keycard-unpaired
@ -79,7 +66,7 @@
:config (if :config (if
;; add view-id here if you'd like that view to be ;; add view-id here if you'd like that view to be
;; first view when app is started ;; 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 view-id}
{:initialRouteName :login})}) {:initialRouteName :login})})
@ -88,23 +75,15 @@
(update :screens conj (update :screens conj
:intro :intro
:intro-wizard :intro-wizard
:keycard-connection-lost
:keycard-connection-lost-setup
:keycard-nfc-on
:keycard-pairing :keycard-pairing
:keycard-onboarding-intro :keycard-onboarding-intro
:keycard-onboarding-start
:keycard-onboarding-puk-code :keycard-onboarding-puk-code
:keycard-onboarding-preparing
: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-word1
:keycard-onboarding-recovery-phrase-confirm-word2 :keycard-onboarding-recovery-phrase-confirm-word2
:keycard-recovery-intro :keycard-recovery-intro
:keycard-recovery-start
:keycard-recovery-pair :keycard-recovery-pair
:keycard-recovery-recovering
:keycard-recovery-success :keycard-recovery-success
:keycard-recovery-no-key :keycard-recovery-no-key
:keycard-recovery-pin) :keycard-recovery-pin)

View File

@ -4,8 +4,6 @@
[:chat-modal [:chat-modal
:stickers-pack-modal :stickers-pack-modal
:tribute-learn-more :tribute-learn-more
:enter-pin-modal
:hardwallet-connect-modal
:selection-modal-screen :selection-modal-screen
:wallet-transactions-filter :wallet-transactions-filter
:welcome :welcome

View File

@ -42,7 +42,5 @@
config/hardwallet-enabled? config/hardwallet-enabled?
(concat [:keycard-settings (concat [:keycard-settings
:reset-card :reset-card
:keycard-connection-lost
:keycard-processing
:enter-pin-settings])) :enter-pin-settings]))
:config {:initialRouteName :my-profile}}) :config {:initialRouteName :my-profile}})

View File

@ -25,7 +25,6 @@
[status-im.ui.screens.hardwallet.authentication-method.views [status-im.ui.screens.hardwallet.authentication-method.views
:as :as
hardwallet.authentication] 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.pin.views :as hardwallet.pin]
[status-im.ui.screens.hardwallet.settings.views :as hardwallet.settings] [status-im.ui.screens.hardwallet.settings.views :as hardwallet.settings]
[status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding] [status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding]
@ -83,31 +82,15 @@
:multiaccounts multiaccounts/multiaccounts :multiaccounts multiaccounts/multiaccounts
:intro intro/intro :intro intro/intro
:hardwallet-authentication-method hardwallet.authentication/hardwallet-authentication-method :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-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-intro keycard.onboarding/intro
:keycard-onboarding-start keycard.onboarding/start
:keycard-onboarding-puk-code keycard.onboarding/puk-code :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-pin keycard.onboarding/pin
:keycard-onboarding-recovery-phrase keycard.onboarding/recovery-phrase :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-word1 keycard.onboarding/recovery-phrase-confirm-word
:keycard-onboarding-recovery-phrase-confirm-word2 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-intro keycard.recovery/intro
:keycard-recovery-start keycard.recovery/start
:keycard-recovery-pair keycard.recovery/pair :keycard-recovery-pair keycard.recovery/pair
:keycard-recovery-recovering keycard.recovery/recovering
:keycard-recovery-success keycard.recovery/success :keycard-recovery-success keycard.recovery/success
:keycard-recovery-no-key keycard.recovery/no-key :keycard-recovery-no-key keycard.recovery/no-key
:keycard-recovery-pin keycard.recovery/pin :keycard-recovery-pin keycard.recovery/pin
@ -115,7 +98,6 @@
:keycard-wrong keycard/wrong :keycard-wrong keycard/wrong
:keycard-unpaired keycard/unpaired :keycard-unpaired keycard/unpaired
:keycard-login-pin keycard/login-pin :keycard-login-pin keycard/login-pin
:keycard-login-connect-card keycard/login-connect-card
:not-keycard keycard/not-keycard :not-keycard keycard/not-keycard
:home home/home-wrapper :home home/home-wrapper
:chat chat/chat :chat chat/chat
@ -189,3 +171,4 @@
(defn get-screen [screen] (defn get-screen [screen]
(get all-screens screen #(throw (str "Screen " screen " is not defined.")))) (get all-screens screen #(throw (str "Screen " screen " is not defined."))))

View File

@ -1,5 +1,4 @@
(ns status-im.ui.screens.routing.wallet-stack (ns status-im.ui.screens.routing.wallet-stack)
(:require [status-im.utils.config :as config]))
(def wallet-stack (def wallet-stack
{:name :wallet-stack {:name :wallet-stack
@ -15,8 +14,5 @@
:wallet-settings-assets :wallet-settings-assets
:wallet-add-custom-token :wallet-add-custom-token
:wallet-custom-token-details :wallet-custom-token-details
:currency-settings] :currency-settings])
config/hardwallet-enabled?
(concat [:keycard-connection-lost
:keycard-processing]))
:config {:initialRouteName :wallet}}) :config {:initialRouteName :wallet}})

View File

@ -105,31 +105,6 @@
:status status :status status
:error-label error-label}]])) :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 (defn sign-with-keycard-button
[amount-error gas-error] [amount-error gas-error]
(let [disabled? (or amount-error gas-error)] (let [disabled? (or amount-error gas-error)]
@ -155,8 +130,6 @@
[signing-phrase-view phrase] [signing-phrase-view phrase]
(case keycard-step (case keycard-step
:pin [keycard-pin-view] :pin [keycard-pin-view]
:connect [keycard-connect-view]
:signing [keycard-processing-view]
[react/view {:align-items :center :margin-top 16 :margin-bottom 40} [react/view {:align-items :center :margin-top 16 :margin-bottom 40}
[sign-with-keycard-button nil nil]])]) [sign-with-keycard-button nil nil]])])

View File

@ -29,6 +29,15 @@
#js {:routeName (name route) #js {:routeName (name route)
:params (clj->js params)})))) :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] (defn- navigate [params]
(when (can-be-called?) (when (can-be-called?)
(.navigate navigation-actions (clj->js params)))) (.navigate navigation-actions (clj->js params))))