Use new keycard flow with animation
Remove screens that are not needed for new flow Replace keycard flows with new interaction If card connected start processing on sheet open Remove outdated pin screens Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com> Do not hide sheet when tag was lost during generating keys Change cancel action for no-key on card recovery Change pin screen when loading keys to an initialised card Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
cc520a1f27
commit
826b7df982
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
(defonce keycard (.-default js-dependencies/status-keycard))
|
(defonce 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")
|
||||||
|
|
|
@ -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,13 +32,23 @@
|
||||||
(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}]
|
||||||
(let [pairing (common/get-pairing db)
|
(let [pairing (common/get-pairing db)
|
||||||
new-pin (common/vector->string (get-in db [:hardwallet :pin :original]))
|
new-pin (common/vector->string (get-in db [:hardwallet :pin :original]))
|
||||||
current-pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
current-pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
||||||
setup-step (get-in db [:hardwallet :setup-step])
|
setup-step (get-in db [:hardwallet :setup-step])
|
||||||
card-connected? (get-in db [:hardwallet :card-connected?])]
|
card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||||
(if (= setup-step :pin)
|
(if (= setup-step :pin)
|
||||||
(onboarding/load-preparing-screen cofx)
|
(onboarding/load-preparing-screen 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))))))
|
||||||
|
|
|
@ -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")
|
||||||
(fx/merge cofx
|
(let [connected? (get-in cofx [:db :hardwallet :card-connected?])]
|
||||||
{:dismiss-keyboard true}
|
(fx/merge cofx
|
||||||
(bottom-sheet/show-bottom-sheet
|
{:dismiss-keyboard true}
|
||||||
{:view {:show-handle? false
|
(bottom-sheet/show-bottom-sheet
|
||||||
:backdrop-dismiss? false
|
{:view {:show-handle? false
|
||||||
:disable-drag? true
|
:backdrop-dismiss? false
|
||||||
:content (keycard-sheet-content on-cancel)}})))
|
:disable-drag? true
|
||||||
|
: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)}}
|
||||||
|
@ -247,9 +250,15 @@
|
||||||
(fx/defn navigate-to-enter-pin-screen
|
(fx/defn navigate-to-enter-pin-screen
|
||||||
{:events [:hardwallet/navigate-to-enter-pin-screen]}
|
{:events [:hardwallet/navigate-to-enter-pin-screen]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(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)))
|
||||||
|
@ -271,7 +280,7 @@
|
||||||
[{:keys [db]}]
|
[{:keys [db]}]
|
||||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||||
pairing (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing])
|
pairing (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing])
|
||||||
pin (string/join (get-in db [:hardwallet :pin :login]))]
|
pin (string/join (get-in db [:hardwallet :pin :login]))]
|
||||||
(when (and pairing
|
(when (and pairing
|
||||||
(seq pin))
|
(seq pin))
|
||||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||||
|
@ -281,48 +290,47 @@
|
||||||
(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)
|
(assoc-in [:hardwallet :pin :login] [])
|
||||||
(assoc-in [:hardwallet :pin :login] [])
|
(assoc-in [:hardwallet :multiaccount]
|
||||||
(assoc-in [:hardwallet :multiaccount]
|
(update account-data :whisper-public-key ethereum/normalized-hex))
|
||||||
(update account-data :whisper-public-key ethereum/normalized-hex))
|
(assoc-in [:hardwallet :flow] nil)
|
||||||
(assoc-in [:hardwallet :flow] nil)
|
(update :multiaccounts/login assoc
|
||||||
(update :multiaccounts/login assoc
|
:password encryption-public-key
|
||||||
:password encryption-public-key
|
:key-uid key-uid
|
||||||
:key-uid key-uid
|
:photo-path photo-path
|
||||||
:photo-path photo-path
|
:name name))
|
||||||
:name name))
|
|
||||||
|
|
||||||
:hardwallet/get-application-info {:pairing (get-pairing db key-uid)}
|
:hardwallet/get-application-info {:pairing (get-pairing db key-uid)}
|
||||||
:hardwallet/login-with-keycard {:multiaccount-data multiaccount-data
|
:hardwallet/login-with-keycard {:multiaccount-data multiaccount-data
|
||||||
:password encryption-public-key
|
:password encryption-public-key
|
||||||
:chat-key whisper-private-key}}
|
:chat-key whisper-private-key}}
|
||||||
(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
|
||||||
|
@ -340,10 +348,8 @@
|
||||||
(fx/defn get-application-info
|
(fx/defn get-application-info
|
||||||
{: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
|
||||||
|
@ -386,45 +389,41 @@
|
||||||
{:events [:hardwallet.callback/on-get-application-info-error]}
|
{:events [:hardwallet.callback/on-get-application-info-error]}
|
||||||
[{: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-lost? (:error error))]
|
||||||
tag-was-lost? (= "Tag was lost." (:error error))]
|
(when-not tag-was-lost?
|
||||||
(if 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
|
||||||
should-read-instance-uid? :hardwallet/get-application-info
|
should-read-instance-uid? :hardwallet/get-application-info
|
||||||
:else (get-in db [:hardwallet :on-card-read]))
|
:else (get-in db [:hardwallet :on-card-read]))
|
||||||
pairing (get-pairing db key-uid)]
|
pairing (get-pairing db key-uid)]
|
||||||
(log/debug "[hardwallet] on-card-connected"
|
(log/debug "[hardwallet] on-card-connected"
|
||||||
"on-card-connected" on-card-connected
|
"on-card-connected" on-card-connected
|
||||||
"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])
|
(fx/merge cofx
|
||||||
on-card-connected (get-in db [:hardwallet :on-card-connected])]
|
{:db (-> db
|
||||||
(fx/merge cofx
|
(assoc-in [:hardwallet :card-read-in-progress?] false))}
|
||||||
{:db (-> db
|
(restore-on-card-connected)
|
||||||
(assoc-in [:hardwallet :card-connected?] false)
|
(restore-on-card-read)))
|
||||||
(assoc-in [:hardwallet :card-read-in-progress?] false))}
|
|
||||||
(restore-on-card-connected)
|
|
||||||
(restore-on-card-read)
|
|
||||||
(when (and setup-running?
|
|
||||||
on-card-connected)
|
|
||||||
(navigation/navigate-to-cofx :keycard-connection-lost-setup nil)))))
|
|
||||||
|
|
|
@ -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?]
|
||||||
|
@ -155,25 +137,31 @@
|
||||||
(let [pairing (common/get-pairing db)]
|
(let [pairing (common/get-pairing db)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:hardwallet/get-application-info {:pairing pairing}
|
{:hardwallet/get-application-info {:pairing pairing}
|
||||||
:db (-> db
|
:db (-> db
|
||||||
(update-in [:hardwallet :pin] merge {:status nil
|
(update-in [:hardwallet :pin] merge {:status nil
|
||||||
:enter-step :original
|
:enter-step :original
|
||||||
:current [0 0 0 0 0 0]
|
:current [0 0 0 0 0 0]
|
||||||
:confirmation []
|
:confirmation []
|
||||||
:puk []
|
:puk []
|
||||||
:error-label nil}))}
|
:puk-restore? true
|
||||||
|
: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)
|
||||||
{:hardwallet/get-application-info {:pairing pairing}
|
(when-not tag-was-lost?
|
||||||
:db (update-in db [:hardwallet :pin] merge {:status :error
|
(fx/merge cofx
|
||||||
:error-label :t/puk-mismatch
|
{:hardwallet/get-application-info {:pairing pairing}
|
||||||
:enter-step :puk
|
:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||||
:puk []})}))
|
:error-label :t/puk-mismatch
|
||||||
|
:enter-step :puk
|
||||||
|
:puk []})}
|
||||||
|
(common/hide-pair-sheet)))))
|
||||||
|
|
||||||
(fx/defn dispatch-on-verified-event
|
(fx/defn dispatch-on-verified-event
|
||||||
[{:keys [db]} event]
|
[{:keys [db]} event]
|
||||||
|
@ -184,11 +172,17 @@
|
||||||
{:events [:hardwallet.callback/on-verify-pin-success]}
|
{:events [:hardwallet.callback/on-verify-pin-success]}
|
||||||
[{: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,43 +194,38 @@
|
||||||
(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)
|
(fx/merge cofx
|
||||||
:utils/show-popup {:title (i18n/label :t/error)
|
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||||
:content (i18n/label :t/cannot-read-card)}}
|
:enter-step :current
|
||||||
(common/set-on-card-connected :hardwallet/verify-pin)
|
:puk []
|
||||||
(navigation/navigate-to-cofx (if setup?
|
:current []
|
||||||
:keycard-connection-lost-setup
|
:original []
|
||||||
:keycard-connection-lost) nil))
|
:confirmation []
|
||||||
(re-matches common/pin-mismatch-error (:error error))
|
:sign []
|
||||||
(fx/merge cofx
|
:error-label :t/pin-mismatch})}
|
||||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
(common/hide-pair-sheet)
|
||||||
:enter-step :current
|
(when-not setup?
|
||||||
:puk []
|
(if exporting?
|
||||||
:current []
|
(navigation/navigate-back)
|
||||||
:original []
|
(navigation/navigate-to-cofx :enter-pin-settings nil)))
|
||||||
:confirmation []
|
(common/get-application-info (common/get-pairing db) nil))
|
||||||
:sign []
|
|
||||||
:error-label :t/pin-mismatch})}
|
(fx/merge cofx
|
||||||
(when-not setup?
|
(common/hide-pair-sheet)
|
||||||
(if exporting?
|
(common/show-wrong-keycard-alert true))))))
|
||||||
(navigation/navigate-back)
|
|
||||||
(navigation/navigate-to-cofx :enter-pin-settings nil)))
|
|
||||||
(common/get-application-info (common/get-pairing db) nil))
|
|
||||||
:else (common/show-wrong-keycard-alert true))))
|
|
||||||
|
|
||||||
(fx/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,25 +354,26 @@
|
||||||
[{: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])
|
||||||
flow (get-in db [:hardwallet :flow])
|
flow (get-in db [:hardwallet :flow])
|
||||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||||
multiaccount (common/find-multiaccount-by-keycard-instance-uid db instance-uid)
|
multiaccount (common/find-multiaccount-by-keycard-instance-uid db instance-uid)
|
||||||
paired-on (utils.datetime/timestamp)
|
paired-on (utils.datetime/timestamp)
|
||||||
pairings (assoc (get-in db [:hardwallet :pairings]) instance-uid {:pairing pairing
|
pairings (assoc (get-in db [:hardwallet :pairings]) instance-uid {:pairing pairing
|
||||||
:paired-on paired-on})
|
:paired-on paired-on})
|
||||||
next-step (if (= setup-step :pair)
|
next-step (if (= setup-step :pair)
|
||||||
:begin
|
:begin
|
||||||
:card-ready)]
|
:card-ready)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:hardwallet/persist-pairings pairings
|
{:hardwallet/persist-pairings pairings
|
||||||
:db (-> db
|
:db (-> db
|
||||||
|
@ -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)
|
||||||
|
@ -412,18 +400,21 @@
|
||||||
{:events [:hardwallet.callback/on-pair-error]}
|
{:events [:hardwallet.callback/on-pair-error]}
|
||||||
[{: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])
|
||||||
flow (get-in db [:hardwallet :flow])]
|
tag-was-lost? (common/tag-lost? error)
|
||||||
(log/debug "[hardwallet] on-pair-error")
|
flow (get-in db [:hardwallet :flow])]
|
||||||
(fx/merge cofx
|
(log/debug "[hardwallet] on-pair-error" setup-step "flow:" flow)
|
||||||
{:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))}
|
(when-not tag-was-lost?
|
||||||
(common/set-on-card-connected (if (= setup-step :pairing)
|
(fx/merge cofx
|
||||||
:hardwallet/load-pairing-screen
|
{:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))}
|
||||||
:hardwallet/pair))
|
(common/set-on-card-connected (if (= setup-step :pairing)
|
||||||
(when (= flow :import)
|
:hardwallet/load-pairing-screen
|
||||||
(navigation/navigate-to-cofx :keycard-recovery-pair nil))
|
:hardwallet/pair))
|
||||||
(when (not= setup-step :enter-pair-code)
|
(common/hide-pair-sheet)
|
||||||
(common/process-error code error)))))
|
(when (= flow :import)
|
||||||
|
(navigation/navigate-to-cofx :keycard-recovery-pair nil))
|
||||||
|
(when (not= setup-step :enter-pair-code)
|
||||||
|
(common/process-error code error))))))
|
||||||
|
|
||||||
(fx/defn set-setup-step
|
(fx/defn set-setup-step
|
||||||
[{:keys [db]} card-state]
|
[{:keys [db]} card-state]
|
||||||
|
@ -446,21 +437,24 @@
|
||||||
(fx/defn check-card-state
|
(fx/defn check-card-state
|
||||||
{:events [:hardwallet/check-card-state]}
|
{:events [:hardwallet/check-card-state]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [app-info (get-in db [:hardwallet :application-info])
|
(let [app-info (get-in db [:hardwallet :application-info])
|
||||||
flow (get-in db [:hardwallet :flow])
|
flow (get-in db [:hardwallet :flow])
|
||||||
{:keys [instance-uid key-uid]} app-info
|
{:keys [instance-uid key-uid]} app-info
|
||||||
pairing (common/get-pairing db key-uid)
|
pairing (common/get-pairing db key-uid)
|
||||||
app-info' (if pairing (assoc app-info :paired? true) app-info)
|
app-info' (if pairing (assoc app-info :paired? true) app-info)
|
||||||
card-state (common/get-card-state app-info')]
|
card-state (common/get-card-state app-info')]
|
||||||
(log/debug "[hardwallet] check-card-state"
|
(log/debug "[hardwallet] check-card-state"
|
||||||
"card-state" card-state
|
"card-state" card-state
|
||||||
"flow" flow)
|
"flow" flow)
|
||||||
(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)})
|
||||||
|
|
||||||
|
|
|
@ -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))))
|
||||||
|
|
|
@ -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
|
||||||
|
@ -53,40 +52,46 @@
|
||||||
(fx/defn login-with-keycard
|
(fx/defn login-with-keycard
|
||||||
{:events [:hardwallet/login-with-keycard]}
|
{:events [:hardwallet/login-with-keycard]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [application-info (get-in db [:hardwallet :application-info])
|
(let [application-info (get-in db [:hardwallet :application-info])
|
||||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||||
multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :key-uid])])
|
multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :key-uid])])
|
||||||
multiaccount-key-uid (get multiaccount :key-uid)
|
multiaccount-key-uid (get multiaccount :key-uid)
|
||||||
multiaccount-mismatch? (or (nil? multiaccount)
|
multiaccount-mismatch? (or (nil? multiaccount)
|
||||||
(not= multiaccount-key-uid key-uid))
|
(not= multiaccount-key-uid key-uid))
|
||||||
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)
|
(common/show-pair-sheet {:on-cancel [::common/cancel-sheet-confirm]})))))
|
||||||
(navigation/navigate-to-cofx :keycard-login-connect-card nil)))
|
|
||||||
(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]}
|
||||||
|
|
|
@ -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 {})))))
|
||||||
|
|
|
@ -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
|
||||||
:on-verified :hardwallet/generate-and-load-key
|
(assoc-in [:hardwallet :pin] {:enter-step :current
|
||||||
:current []})}
|
:on-verified :hardwallet/generate-and-load-key
|
||||||
|
: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
|
||||||
|
@ -275,61 +271,48 @@
|
||||||
(fx/defn generate-and-load-key
|
(fx/defn generate-and-load-key
|
||||||
{:events [:hardwallet/generate-and-load-key]}
|
{:events [:hardwallet/generate-and-load-key]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [mnemonic pairing pin]} (get-in db [:hardwallet :secrets])
|
(let [{:keys [mnemonic pairing pin]} (get-in db [:hardwallet :secrets])
|
||||||
{:keys [selected-id multiaccounts]} (:intro-wizard db)
|
{:keys [selected-id multiaccounts]} (:intro-wizard db)
|
||||||
user-selected-mnemonic (->> multiaccounts
|
user-selected-mnemonic (->> multiaccounts
|
||||||
(filter #(= (:id %) selected-id))
|
(filter #(= (:id %) selected-id))
|
||||||
first
|
first
|
||||||
:mnemonic)
|
:mnemonic)
|
||||||
recovery-mnemonic (get-in db [:intro-wizard :passphrase])
|
recovery-mnemonic (get-in db [:intro-wizard :passphrase])
|
||||||
mnemonic' (or user-selected-mnemonic mnemonic recovery-mnemonic)
|
mnemonic' (or user-selected-mnemonic mnemonic recovery-mnemonic)
|
||||||
pin' (or pin (common/vector->string (get-in db [:hardwallet :pin :current])))]
|
pin' (or pin (common/vector->string (get-in db [:hardwallet :pin :current])))]
|
||||||
(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?])
|
(fx/merge cofx
|
||||||
flow (get-in db [:hardwallet :flow])]
|
{:db (-> db
|
||||||
(fx/merge cofx
|
(update :hardwallet
|
||||||
{:db (-> db
|
dissoc :secrets :card-state :multiaccount-wallet-address
|
||||||
(update :hardwallet
|
:multiaccount-whisper-public-key
|
||||||
dissoc :secrets :card-state :multiaccount-wallet-address
|
:application-info)
|
||||||
:multiaccount-whisper-public-key
|
(assoc-in [:hardwallet :setup-step] :begin)
|
||||||
:application-info)
|
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||||
(assoc-in [:hardwallet :setup-step] :begin)
|
(common/set-on-card-connected :hardwallet/get-application-info)
|
||||||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
(common/set-on-card-read :hardwallet/check-card-state)
|
||||||
(common/set-on-card-connected :hardwallet/get-application-info)
|
(common/show-pair-sheet {})))
|
||||||
(common/set-on-card-read :hardwallet/check-card-state)
|
|
||||||
(if nfc-enabled?
|
|
||||||
(if (= flow :import)
|
|
||||||
(navigation/navigate-to-cofx :keycard-recovery-start nil)
|
|
||||||
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
|
|
||||||
(navigation/navigate-to-cofx :keycard-nfc-on nil)))))
|
|
||||||
|
|
||||||
(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)}]})))
|
|
||||||
|
|
|
@ -20,14 +20,12 @@
|
||||||
{:events [:hardwallet/pair]}
|
{:events [:hardwallet/pair]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [password]} (get-in cofx [:db :hardwallet :secrets])
|
(let [{:keys [password]} (get-in cofx [:db :hardwallet :secrets])
|
||||||
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,26 +80,37 @@
|
||||||
: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?])
|
(fx/merge cofx
|
||||||
flow (get-in db [:hardwallet :flow])]
|
{:db (-> db
|
||||||
(fx/merge cofx
|
(update :hardwallet
|
||||||
{:db (-> db
|
dissoc :secrets :card-state :multiaccount-wallet-address
|
||||||
(update :hardwallet
|
:multiaccount-whisper-public-key
|
||||||
dissoc :secrets :card-state :multiaccount-wallet-address
|
:application-info)
|
||||||
:multiaccount-whisper-public-key
|
(assoc-in [:hardwallet :setup-step] :begin)
|
||||||
:application-info)
|
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||||
(assoc-in [:hardwallet :setup-step] :begin)
|
(common/set-on-card-connected :hardwallet/get-application-info)
|
||||||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
(common/set-on-card-read :hardwallet/check-card-state)
|
||||||
(common/set-on-card-connected :hardwallet/get-application-info)
|
(common/show-pair-sheet {:on-cancel [::cancel-pressed]})))
|
||||||
(common/set-on-card-read :hardwallet/check-card-state)
|
|
||||||
(if nfc-enabled?
|
|
||||||
(if (= flow :import)
|
|
||||||
(navigation/navigate-to-cofx :keycard-recovery-start nil)
|
|
||||||
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
|
|
||||||
(navigation/navigate-to-cofx :keycard-nfc-on nil)))))
|
|
||||||
|
|
||||||
(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)
|
||||||
(fx/merge cofx
|
(when-not (common/tag-lost? error)
|
||||||
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
(fx/merge cofx
|
||||||
(common/set-on-card-connected :hardwallet/load-loading-keys-screen)
|
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
||||||
(common/process-error code error)))
|
(common/set-on-card-connected :hardwallet/load-loading-keys-screen)
|
||||||
|
(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}]
|
||||||
(fx/merge cofx
|
(let [card-connected? (get-in db [:hardwallet :card-connected?])]
|
||||||
{:db (-> db
|
(fx/merge cofx
|
||||||
(assoc-in [:hardwallet :pin] {:enter-step :import-multiaccount
|
(common/set-on-card-connected :hardwallet/load-recovering-key-screen)
|
||||||
:import-multiaccount []
|
(if card-connected?
|
||||||
:current []}))}
|
(common/dispatch-event :hardwallet/import-multiaccount)
|
||||||
(common/listen-to-hardware-back-button)
|
(common/show-pair-sheet {})))))
|
||||||
(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]
|
||||||
|
|
|
@ -4,20 +4,19 @@
|
||||||
[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]))
|
||||||
|
|
||||||
(fx/defn sign
|
(fx/defn sign
|
||||||
{:events [:hardwallet/sign]}
|
{:events [:hardwallet/sign]}
|
||||||
[{: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)
|
||||||
multiaccount-keycard-instance-uid (get-in db [:multiaccount :keycard-instance-uid])
|
multiaccount-keycard-instance-uid (get-in db [:multiaccount :keycard-instance-uid])
|
||||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||||
keycard-match? (= multiaccount-keycard-instance-uid instance-uid)
|
keycard-match? (= multiaccount-keycard-instance-uid instance-uid)
|
||||||
hash (get-in db [:hardwallet :hash])
|
hash (get-in db [:hardwallet :hash])
|
||||||
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))]
|
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))]
|
||||||
(if (and card-connected?
|
(if (and card-connected?
|
||||||
keycard-match?)
|
keycard-match?)
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
|
@ -36,14 +35,14 @@
|
||||||
{:events [:hardwallet/prepare-to-sign]}
|
{:events [:hardwallet/prepare-to-sign]}
|
||||||
[{: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)]
|
||||||
(if card-connected?
|
(fx/merge cofx
|
||||||
(fx/merge cofx
|
(if card-connected?
|
||||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
(common/get-application-info pairing :hardwallet/sign)
|
||||||
(common/get-application-info pairing :hardwallet/sign))
|
(fn [cofx]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:signing/sign :keycard-step] :connect)}
|
(common/set-on-card-connected :hardwallet/prepare-to-sign)
|
||||||
(common/set-on-card-connected :hardwallet/prepare-to-sign)))))
|
(common/show-pair-sheet {})))))))
|
||||||
|
|
||||||
(fx/defn sign-message-completed
|
(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?
|
(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
|
||||||
(assoc-in [:hardwallet :pin :status] nil)
|
:sign []
|
||||||
(assoc-in [:signing/sign :keycard-step] :connect))
|
:error-label :t/pin-mismatch})
|
||||||
:utils/show-popup {:title (i18n/label :t/error)
|
(assoc-in [:signing/sign :keycard-step] :pin))}
|
||||||
:content (i18n/label :t/cannot-read-card)}}
|
(common/hide-pair-sheet)
|
||||||
(common/set-on-card-connected :hardwallet/prepare-to-sign))))
|
(common/get-application-info (common/get-pairing db) nil))
|
||||||
(if (re-matches common/pin-mismatch-error (:error error))
|
(fx/merge cofx
|
||||||
(fn [{:keys [db] :as cofx}]
|
(common/hide-pair-sheet)
|
||||||
(fx/merge cofx
|
(common/show-wrong-keycard-alert true))))))
|
||||||
{:db (-> db
|
|
||||||
(update-in [:hardwallet :pin] merge {:status :error
|
|
||||||
:sign []
|
|
||||||
:error-label :t/pin-mismatch})
|
|
||||||
(assoc-in [:signing/sign :keycard-step] :pin))}
|
|
||||||
(common/get-application-info (common/get-pairing db) nil)))
|
|
||||||
(common/show-wrong-keycard-alert true)))))
|
|
||||||
|
|
|
@ -95,15 +95,15 @@
|
||||||
(fx/defn remove-key-with-unpair
|
(fx/defn remove-key-with-unpair
|
||||||
{:events [:hardwallet/remove-key-with-unpair]}
|
{:events [:hardwallet/remove-key-with-unpair]}
|
||||||
[{: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?])]
|
||||||
(if card-connected?
|
(if card-connected?
|
||||||
{:hardwallet/remove-key-with-unpair {:pin pin
|
{:hardwallet/remove-key-with-unpair {:pin pin
|
||||||
: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
|
||||||
|
|
|
@ -3,18 +3,17 @@
|
||||||
[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]))
|
||||||
|
|
||||||
(fx/defn generate-new-keycard-account
|
(fx/defn generate-new-keycard-account
|
||||||
{:events [:wallet.accounts/generate-new-keycard-account]}
|
{:events [:wallet.accounts/generate-new-keycard-account]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [path-num (inc (get-in db [:multiaccount :latest-derived-path]))
|
(let [path-num (inc (get-in db [:multiaccount :latest-derived-path]))
|
||||||
path (str constants/path-wallet-root "/" path-num)
|
path (str constants/path-wallet-root "/" path-num)
|
||||||
card-connected? (get-in db [:hardwallet :card-connected?])
|
card-connected? (get-in db [:hardwallet :card-connected?])
|
||||||
pin (common/vector->string (get-in db [:hardwallet :pin :export-key]))
|
pin (common/vector->string (get-in db [:hardwallet :pin :export-key]))
|
||||||
pairing (common/get-pairing db)]
|
pairing (common/get-pairing db)]
|
||||||
(if card-connected?
|
(if card-connected?
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:hardwallet :on-export-success]
|
{:db (assoc-in db [:hardwallet :on-export-success]
|
||||||
|
@ -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 {})))))
|
||||||
|
|
|
@ -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")}))))
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -201,20 +201,13 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc db :view-id view-id)}
|
{:db (assoc db :view-id view-id)}
|
||||||
#(case view-id
|
#(case view-id
|
||||||
:chat (chat.loading/load-messages cofx)
|
:chat (chat.loading/load-messages cofx)
|
||||||
: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-settings (hardwallet/enter-pin-screen-did-load %)
|
||||||
:enter-pin-sign (hardwallet/enter-pin-screen-did-load %)
|
:keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
|
||||||
:enter-pin-settings (hardwallet/enter-pin-screen-did-load %)
|
:add-new-account-pin (hardwallet/enter-pin-screen-did-load %)
|
||||||
:enter-pin-modal (hardwallet/enter-pin-screen-did-load %)
|
|
||||||
:keycard-login-pin (hardwallet/enter-pin-screen-did-load %)
|
|
||||||
:add-new-account-pin (hardwallet/enter-pin-screen-did-load %)
|
|
||||||
:hardwallet-connect (hardwallet/hardwallet-connect-screen-did-load %)
|
|
||||||
:hardwallet-connect-sign (hardwallet/hardwallet-connect-screen-did-load %)
|
|
||||||
:hardwallet-connect-settings (hardwallet/hardwallet-connect-screen-did-load %)
|
|
||||||
:hardwallet-connect-modal (hardwallet/hardwallet-connect-screen-did-load %)
|
|
||||||
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
:hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
||||||
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
||||||
nil))))
|
nil))))
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
(ns status-im.ui.screens.hardwallet.connect.styles
|
|
||||||
(:require [status-im.ui.components.colors :as colors]))
|
|
||||||
|
|
||||||
(def container
|
|
||||||
{:flex 1
|
|
||||||
:background-color colors/white})
|
|
||||||
|
|
||||||
(def hardwallet-connect
|
|
||||||
{:flex-direction :column
|
|
||||||
:flex 1
|
|
||||||
:align-items :center
|
|
||||||
:justify-content :space-between})
|
|
||||||
|
|
||||||
(def hardwallet-card-image
|
|
||||||
{:width 255
|
|
||||||
:height 160})
|
|
||||||
|
|
||||||
(def turn-nfc-text-container
|
|
||||||
{:margin-top 55})
|
|
||||||
|
|
||||||
(def status-hardwallet-text
|
|
||||||
{:typography :header
|
|
||||||
:text-align :center})
|
|
||||||
|
|
||||||
(defn bottom-action-container [nfc-enabled?]
|
|
||||||
{:background-color (if nfc-enabled?
|
|
||||||
colors/blue-light
|
|
||||||
colors/gray-lighter)
|
|
||||||
:width 369
|
|
||||||
:height 80
|
|
||||||
:border-radius 10
|
|
||||||
:margin-bottom 20})
|
|
||||||
|
|
||||||
(def phone-nfc-on-image
|
|
||||||
{:width 401
|
|
||||||
:height 250})
|
|
||||||
|
|
||||||
(def phone-nfc-off-image
|
|
||||||
{:width 301
|
|
||||||
:height 180})
|
|
||||||
|
|
||||||
(def nfc-enabled-container
|
|
||||||
{:flex-direction :column
|
|
||||||
:justify-content :space-between
|
|
||||||
:align-items :center
|
|
||||||
:margin-top 50})
|
|
||||||
|
|
||||||
(def nfc-disabled-container
|
|
||||||
{:flex-direction :column
|
|
||||||
:justify-content :space-between
|
|
||||||
:align-items :center
|
|
||||||
:margin-top 120})
|
|
||||||
|
|
||||||
(def nfc-icon
|
|
||||||
{:margin-left 52
|
|
||||||
:margin-top 22})
|
|
||||||
|
|
||||||
(def go-to-settings-text
|
|
||||||
{:text-align :center
|
|
||||||
:padding-top 9
|
|
||||||
:color colors/gray})
|
|
||||||
|
|
||||||
(def bottom-container
|
|
||||||
{:height 52
|
|
||||||
:justify-content :center
|
|
||||||
:border-top-width 1
|
|
||||||
:border-color colors/black-transparent})
|
|
||||||
|
|
||||||
(def product-info-container
|
|
||||||
{:flex-direction :row
|
|
||||||
:align-items :center
|
|
||||||
:justify-content :center})
|
|
||||||
|
|
||||||
(def product-info-text
|
|
||||||
{:text-align :center
|
|
||||||
:color colors/blue})
|
|
||||||
|
|
||||||
(def external-link-icon
|
|
||||||
{:margin-left 5})
|
|
|
@ -1,64 +0,0 @@
|
||||||
(ns status-im.ui.screens.hardwallet.connect.views
|
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[status-im.react-native.resources :as resources]
|
|
||||||
[status-im.ui.screens.hardwallet.connect.styles :as styles]
|
|
||||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
|
||||||
[status-im.ui.components.react :as react]
|
|
||||||
[status-im.i18n :as i18n]
|
|
||||||
[status-im.ui.components.colors :as colors]
|
|
||||||
[status-im.ui.components.toolbar.actions :as toolbar.actions]
|
|
||||||
[status-im.ui.components.topbar :as topbar]))
|
|
||||||
|
|
||||||
(defview nfc-enabled []
|
|
||||||
(letsubs [card-read-in-progress? [:hardwallet/card-read-in-progress?]]
|
|
||||||
[react/view styles/nfc-enabled-container
|
|
||||||
[react/view
|
|
||||||
[react/image {:source (resources/get-image :hold-card-animation)
|
|
||||||
:style styles/phone-nfc-on-image}]]
|
|
||||||
[react/view styles/turn-nfc-text-container
|
|
||||||
[react/text {:style styles/status-hardwallet-text
|
|
||||||
:number-of-lines 2}
|
|
||||||
(i18n/label :t/hold-card)]]
|
|
||||||
(when card-read-in-progress?
|
|
||||||
[react/view {:margin-top 35}
|
|
||||||
[react/activity-indicator {:animating true
|
|
||||||
:size :large}]])]))
|
|
||||||
|
|
||||||
(defn nfc-disabled []
|
|
||||||
[react/view styles/nfc-disabled-container
|
|
||||||
[react/view
|
|
||||||
[react/image {:source (resources/get-image :phone-nfc-off)
|
|
||||||
:style styles/phone-nfc-off-image}]]
|
|
||||||
[react/view styles/turn-nfc-text-container
|
|
||||||
[react/text {:style styles/status-hardwallet-text
|
|
||||||
:on-press #(re-frame/dispatch [:hardwallet.ui/go-to-settings-button-pressed])}
|
|
||||||
(i18n/label :t/turn-nfc-on)]
|
|
||||||
[react/text {:style styles/go-to-settings-text
|
|
||||||
:on-press #(re-frame/dispatch [:hardwallet.ui/go-to-settings-button-pressed])}
|
|
||||||
(i18n/label :t/go-to-settings)]]])
|
|
||||||
|
|
||||||
(defview hardwallet-connect []
|
|
||||||
(letsubs [nfc-enabled? [:hardwallet/nfc-enabled?]
|
|
||||||
setup-step [:hardwallet-setup-step]]
|
|
||||||
[react/view styles/container
|
|
||||||
[react/view {:flex 1
|
|
||||||
:flex-direction :column
|
|
||||||
:justify-content :space-between}
|
|
||||||
[topbar/topbar
|
|
||||||
{:navigation
|
|
||||||
{:icon :main-icons/back
|
|
||||||
:accessibility-label :back-button
|
|
||||||
:handler #(re-frame/dispatch [:hardwallet.ui/hardwallet-connect-navigate-back-button-clicked])}}]
|
|
||||||
[react/view styles/hardwallet-connect
|
|
||||||
(if nfc-enabled?
|
|
||||||
[nfc-enabled]
|
|
||||||
[nfc-disabled])]
|
|
||||||
(if (= setup-step :begin)
|
|
||||||
[react/view styles/bottom-container
|
|
||||||
[react/touchable-highlight {:on-press #(.openURL react/linking "https://hardwallet.status.im")}
|
|
||||||
[react/view styles/product-info-container
|
|
||||||
[react/text {:style styles/product-info-text}
|
|
||||||
(i18n/label :t/product-information)]
|
|
||||||
[vector-icons/icon :main-icons/link {:color colors/blue
|
|
||||||
:container-style styles/external-link-icon}]]]])]]))
|
|
|
@ -144,11 +144,7 @@
|
||||||
error-label [:hardwallet/pin-error-label]]
|
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)
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,25 +40,25 @@
|
||||||
{: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}}
|
(when on-cancel
|
||||||
(when on-cancel
|
[react/touchable-highlight
|
||||||
[react/touchable-highlight
|
{:on-press on-cancel
|
||||||
{:on-press on-cancel
|
:style {:position :absolute
|
||||||
:style {:position :absolute
|
:top 0
|
||||||
:top 0
|
:right 0}}
|
||||||
:right 0}}
|
[react/text {:style {:line-height 22
|
||||||
[react/text {:style {:line-height 22
|
:padding-horizontal 16
|
||||||
:padding-horizontal 16
|
:color colors/blue
|
||||||
:color colors/blue
|
: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 {:connected? connected?
|
||||||
[card-sync-flow {:on-card-disconnected
|
: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])])
|
||||||
|
|
|
@ -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)]
|
||||||
[react/text {:style {:color colors/gray}}
|
(when-not (= setup-step :loading-keys)
|
||||||
(i18n/label :t/step-i-of-n {:number steps
|
[react/text {:style {:color colors/gray}}
|
||||||
:step 1})]]
|
(i18n/label :t/step-i-of-n {:number steps
|
||||||
|
: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,14 +233,15 @@
|
||||||
:small-screen? small-screen?
|
:small-screen? small-screen?
|
||||||
:error-label error-label
|
:error-label error-label
|
||||||
:step enter-step}]
|
:step enter-step}]
|
||||||
[react/view {:align-items :center
|
(when-not (= setup-step :loading-keys)
|
||||||
:flex-direction :column
|
[react/view {:align-items :center
|
||||||
:justify-content :center
|
:flex-direction :column
|
||||||
:margin-bottom 15}
|
:justify-content :center
|
||||||
[react/text {:style {:color colors/gray
|
:margin-bottom 15}
|
||||||
:padding-horizontal 40
|
[react/text {:style {:color colors/gray
|
||||||
:text-align :center}}
|
:padding-horizontal 40
|
||||||
(i18n/label :t/you-will-need-this-code)]]]]))
|
:text-align :center}}
|
||||||
|
(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}}
|
||||||
|
|
|
@ -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}}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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}]])
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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}})
|
||||||
|
|
|
@ -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."))))
|
||||||
|
|
||||||
|
|
|
@ -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}})
|
||||||
|
|
|
@ -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)]
|
||||||
|
@ -154,9 +129,7 @@
|
||||||
[react/view {:height 520}
|
[react/view {:height 520}
|
||||||
[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]])])
|
||||||
|
|
||||||
|
|
|
@ -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))))
|
||||||
|
|
Loading…
Reference in New Issue