[keycard] Rename all "hardwallet" occurencies to "keycard"
Previously we used both "keycard" and "hardwallet" names for stuff related to keycard. It can be confusing as "hardwallet" might be used for other hardwallets in future.
This commit is contained in:
parent
67ce4b03aa
commit
15cbec07e9
1
.env
1
.env
|
@ -7,7 +7,6 @@ ETHEREUM_DEV_CLUSTER=1
|
|||
EXTENSIONS=0
|
||||
FLEET=eth.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
HARDWALLET_ENABLED=1
|
||||
LOG_LEVEL=info
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
PFS_ENCRYPTION_ENABLED=1
|
||||
|
|
1
.env.e2e
1
.env.e2e
|
@ -5,7 +5,6 @@ ETHEREUM_DEV_CLUSTER=1
|
|||
EXTENSIONS=0
|
||||
FLEET=eth.staging
|
||||
GROUP_CHATS_ENABLED=1
|
||||
HARDWALLET_ENABLED=1
|
||||
LOG_LEVEL=info
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||
PAIRING_POPUP_DISABLED=1
|
||||
|
|
|
@ -6,7 +6,6 @@ ETHEREUM_DEV_CLUSTER=1
|
|||
EXTENSIONS=0
|
||||
FLEET=eth.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
HARDWALLET_ENABLED=1
|
||||
LOG_LEVEL=info
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
MAINNET_WARNING_ENABLED=1
|
||||
|
|
|
@ -16,5 +16,4 @@ SNOOPY=0
|
|||
RPC_NETWORKS_ONLY=0
|
||||
PARTITIONED_TOPIC=0
|
||||
CONTRACT_NODES=1
|
||||
HARDWALLET_ENABLED=1
|
||||
ENABLE_ROOT_ALERT=1
|
|
@ -15,5 +15,4 @@ POW_TIME=1
|
|||
SNOOPY=0
|
||||
RPC_NETWORKS_ONLY=1
|
||||
PARTITIONED_TOPIC=0
|
||||
HARDWALLET_ENABLED=1
|
||||
ENABLE_ROOT_ALERT=1
|
|
@ -37,7 +37,7 @@
|
|||
:registry {}
|
||||
:stickers/packs-owned #{}
|
||||
:stickers/packs-pending #{}
|
||||
:hardwallet {:nfc-enabled? false
|
||||
:keycard {:nfc-enabled? false
|
||||
:pin {:original []
|
||||
:confirmation []
|
||||
:current []
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
status-im.wallet.collectibles.core
|
||||
status-im.wallet.accounts.core
|
||||
status-im.popover.core
|
||||
[status-im.hardwallet.core :as hardwallet]
|
||||
[status-im.keycard.core :as keycard]
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
[status-im.constants :as constants]
|
||||
|
@ -136,7 +136,7 @@
|
|||
cofx
|
||||
{:db (-> db
|
||||
(dissoc :intro-wizard)
|
||||
(update :hardwallet dissoc :application-info))}
|
||||
(update :keycard dissoc :application-info))}
|
||||
(multiaccounts.login/open-login key-uid photo-path name public-key)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -577,50 +577,50 @@
|
|||
(log/debug :event-str event-str)
|
||||
(signals/process cofx event-str)))
|
||||
|
||||
;; hardwallet module
|
||||
;; keycard module
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/go-to-settings-button-pressed
|
||||
:keycard.ui/go-to-settings-button-pressed
|
||||
(fn [_ _]
|
||||
{:hardwallet/open-nfc-settings nil}))
|
||||
{:keycard/open-nfc-settings nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/pair-card-button-pressed
|
||||
:keycard.ui/pair-card-button-pressed
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :enter-pair-code)}))
|
||||
{:db (assoc-in db [:keycard :setup-step] :enter-pair-code)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/pair-code-input-changed
|
||||
:keycard.ui/pair-code-input-changed
|
||||
(fn [{:keys [db]} [_ pair-code]]
|
||||
{:db (assoc-in db [:hardwallet :secrets :password] pair-code)}))
|
||||
{:db (assoc-in db [:keycard :secrets :password] pair-code)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/recovery-phrase-confirm-word-back-button-pressed
|
||||
:keycard.ui/recovery-phrase-confirm-word-back-button-pressed
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)}))
|
||||
{:db (assoc-in db [:keycard :setup-step] :recovery-phrase)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/recovery-phrase-confirm-word-input-changed
|
||||
:keycard.ui/recovery-phrase-confirm-word-input-changed
|
||||
(fn [{:keys [db]} [_ input]]
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :input-word] input)}))
|
||||
{:db (assoc-in db [:keycard :recovery-phrase :input-word] input)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/recovery-phrase-cancel-pressed
|
||||
:keycard.ui/recovery-phrase-cancel-pressed
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)}))
|
||||
{:db (assoc-in db [:keycard :setup-step] :recovery-phrase)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/pin-numpad-delete-button-pressed
|
||||
:keycard.ui/pin-numpad-delete-button-pressed
|
||||
(fn [{:keys [db]} [_ step]]
|
||||
(when-not (empty? (get-in db [:hardwallet :pin step]))
|
||||
{:db (update-in db [:hardwallet :pin step] pop)})))
|
||||
(when-not (empty? (get-in db [:keycard :pin step]))
|
||||
{:db (update-in db [:keycard :pin step] pop)})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hardwallet.ui/create-pin-button-pressed
|
||||
:keycard.ui/create-pin-button-pressed
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :pin)
|
||||
(assoc-in [:hardwallet :pin :enter-step] :original))}))
|
||||
(assoc-in [:keycard :setup-step] :pin)
|
||||
(assoc-in [:keycard :pin :enter-step] :original))}))
|
||||
|
||||
;; browser module
|
||||
|
||||
|
@ -1276,15 +1276,15 @@
|
|||
(fn [cofx [_ view-id]]
|
||||
(fx/merge cofx
|
||||
#(case view-id
|
||||
:keycard-settings (hardwallet/settings-screen-did-load %)
|
||||
:reset-card (hardwallet/reset-card-screen-did-load %)
|
||||
:enter-pin-settings (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-authentication-method (hardwallet/authentication-method-screen-did-load %)
|
||||
:keycard-settings (keycard/settings-screen-did-load %)
|
||||
:reset-card (keycard/reset-card-screen-did-load %)
|
||||
:enter-pin-settings (keycard/enter-pin-screen-did-load %)
|
||||
:keycard-login-pin (keycard/enter-pin-screen-did-load %)
|
||||
:add-new-account-pin (keycard/enter-pin-screen-did-load %)
|
||||
:keycard-authentication-method (keycard/authentication-method-screen-did-load %)
|
||||
;; We need this as if you click on universal-links you transition
|
||||
;; from chat to chat, and therefore we won't be loading new
|
||||
;; messages
|
||||
:chat (chat.loading/load-messages %)
|
||||
:multiaccounts (hardwallet/multiaccounts-screen-did-load %)
|
||||
:multiaccounts (keycard/multiaccounts-screen-did-load %)
|
||||
nil))))
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
(ns status-im.hardwallet.core-test)
|
||||
|
||||
;;TODO re-enable after fixing hardwallet flow
|
||||
#_(deftest process-pin-input
|
||||
(testing "start entering PIN"
|
||||
(is (= {:db {:hardwallet {:pin {:original [1]
|
||||
:confirmation []
|
||||
:status nil
|
||||
:enter-step :original}}}}
|
||||
(hardwallet/process-pin-input {:db {:hardwallet {:pin {:original [1]
|
||||
:confirmation []
|
||||
:enter-step :original}}}}))))
|
||||
(testing "first 6 numbers entered"
|
||||
(is (= {:db {:hardwallet {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation []
|
||||
:status nil
|
||||
:enter-step :confirmation}}}}
|
||||
(hardwallet/process-pin-input {:db {:hardwallet {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation []
|
||||
:enter-step :original}}}}))))
|
||||
(testing "confirmation entered"
|
||||
(is (= {:db {:hardwallet {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 6]
|
||||
:current [1 1 1 1 1 1]
|
||||
:enter-step :confirmation
|
||||
:status :verifying}
|
||||
:card-connected? true}}
|
||||
:hardwallet/change-pin {:new-pin "123456"
|
||||
:current-pin "111111"
|
||||
:pairing nil}}
|
||||
(hardwallet/process-pin-input {:db {:hardwallet {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 6]
|
||||
:current [1 1 1 1 1 1]
|
||||
:enter-step :confirmation}
|
||||
:card-connected? true}}}))))
|
||||
|
||||
(testing "confirmation doesn't match"
|
||||
(is (= {:db {:hardwallet {:pin {:original []
|
||||
:confirmation []
|
||||
:enter-step :original
|
||||
:error-label :t/pin-mismatch
|
||||
:status :error}}}}
|
||||
(hardwallet/process-pin-input {:db {:hardwallet {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 7]
|
||||
:enter-step :confirmation}}}})))))
|
||||
|
||||
#_(deftest on-generate-and-load-key-success
|
||||
(is (= (select-keys
|
||||
(get-in
|
||||
(hardwallet/on-generate-and-load-key-success
|
||||
{:random-guid-generator (constantly "")
|
||||
:signing-phrase ""
|
||||
:status ""
|
||||
:db {}}
|
||||
#js {"whisper-private-key" "f342f3ef17ce86abfa92b912b3a108a4546cfc687fd8e0f02fedf87a60ee4c0f"
|
||||
"whisper-public-key" "04de2e21f1642ebee03b9aa4bf1936066124cc89967eaf269544c9b90c539fd5c980166a897d06dd4d3732b38116239f63c89395a8d73eac72881fab802010cb56"
|
||||
"encryption-public-key" "04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8"
|
||||
"whisper-address" "87df2285f90b71221fab6267b7cb37532fedbb1f"
|
||||
"wallet-address" "7e92236392a850980d00d0cd2a4b92886bd7fe7b"})
|
||||
[:db :hardwallet :multiaccount])
|
||||
[:whisper-private-key
|
||||
:whisper-public-key
|
||||
:encryption-public-key
|
||||
:wallet-address
|
||||
:whisper-address]))
|
||||
{:whisper-private-key "f342f3ef17ce86abfa92b912b3a108a4546cfc687fd8e0f02fedf87a60ee4c0f"
|
||||
:whisper-public-key "0x04de2e21f1642ebee03b9aa4bf1936066124cc89967eaf269544c9b90c539fd5c980166a897d06dd4d3732b38116239f63c89395a8d73eac72881fab802010cb56"
|
||||
:encryption-public-key "04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8"
|
||||
:whisper-address "87df2285f90b71221fab6267b7cb37532fedbb1f"
|
||||
:wallet-address "7e92236392a850980d00d0cd2a4b92886bd7fe7b"}))
|
|
@ -1,45 +0,0 @@
|
|||
(ns status-im.hardwallet.export-key
|
||||
(:require [status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.wallet :as wallet]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
|
||||
(fx/defn on-export-key-error
|
||||
{:events [:hardwallet.callback/on-export-key-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] export key error" error)
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(cond tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
|
||||
|
||||
(re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
:enter-step :export-key
|
||||
:puk []
|
||||
:current []
|
||||
:original []
|
||||
:confirmation []
|
||||
:sign []
|
||||
:export-key []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(common/hide-connection-sheet)
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
|
||||
:else
|
||||
(fx/merge cofx
|
||||
(common/show-wrong-keycard-alert true)
|
||||
(common/clear-pin)
|
||||
(common/hide-connection-sheet)))))
|
||||
|
||||
(fx/defn on-export-key-success
|
||||
{:events [:hardwallet.callback/on-export-key-success]}
|
||||
[{:keys [db] :as cofx} pubkey]
|
||||
(let [callback-fn (get-in db [:hardwallet :on-export-success])]
|
||||
(fx/merge cofx
|
||||
{:dispatch (callback-fn pubkey)}
|
||||
(wallet/hide-pin-sheet)
|
||||
(common/clear-pin)
|
||||
(common/hide-connection-sheet))))
|
|
@ -837,8 +837,8 @@
|
|||
:start-new-chat
|
||||
:status
|
||||
:status-confirmed
|
||||
:status-hardwallet
|
||||
:status-keycard
|
||||
:status-hardwallet
|
||||
:status-not-sent-click
|
||||
:status-not-sent-tap
|
||||
:status-pending
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
(fx/defn initialize-app-db
|
||||
"Initialize db to initial state"
|
||||
[{{:keys [hardwallet initial-props supported-biometric-auth app-active-since]
|
||||
[{{:keys [keycard initial-props supported-biometric-auth app-active-since]
|
||||
:network/keys [type]} :db
|
||||
now :now}]
|
||||
{:db (assoc app-db
|
||||
:initial-props initial-props
|
||||
:network/type type
|
||||
:hardwallet (dissoc hardwallet :secrets)
|
||||
:keycard (dissoc keycard :secrets)
|
||||
:supported-biometric-auth supported-biometric-auth
|
||||
:app-active-since (or app-active-since now)
|
||||
:multiaccounts/loading true)})
|
||||
|
@ -58,10 +58,10 @@
|
|||
::open-multiaccounts #(re-frame/dispatch [::initialize-multiaccounts % {:logout? false}])
|
||||
:ui/listen-to-window-dimensions-change nil
|
||||
::network/listen-to-network-info nil
|
||||
:hardwallet/register-card-events nil
|
||||
:hardwallet/check-nfc-support nil
|
||||
:hardwallet/check-nfc-enabled nil
|
||||
:hardwallet/retrieve-pairings nil}
|
||||
:keycard/register-card-events nil
|
||||
:keycard/check-nfc-support nil
|
||||
:keycard/check-nfc-enabled nil
|
||||
:keycard/retrieve-pairings nil}
|
||||
(initialize-app-db)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
(ns status-im.hardwallet.card
|
||||
(ns status-im.keycard.card
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.hardwallet.ios-keycard :as ios-keycard]
|
||||
[status-im.hardwallet.keycard :as keycard]
|
||||
[status-im.hardwallet.real-keycard :as real-keycard]
|
||||
[status-im.hardwallet.simulated-keycard :as simulated-keycard]
|
||||
[status-im.keycard.ios-keycard :as ios-keycard]
|
||||
[status-im.keycard.keycard :as keycard]
|
||||
[status-im.keycard.real-keycard :as real-keycard]
|
||||
[status-im.keycard.simulated-keycard :as simulated-keycard]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.platform :as platform]
|
||||
[taoensso.timbre :as log]))
|
||||
|
@ -22,7 +22,7 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response] check-nfc-support")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/check-nfc-support-success response]))}))
|
||||
[:keycard.callback/check-nfc-support-success response]))}))
|
||||
|
||||
(defn check-nfc-enabled []
|
||||
(log/info "[keycard] check-nfc-enabled")
|
||||
|
@ -32,7 +32,7 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response] check-nfc-enabled")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/check-nfc-enabled-success response]))}))
|
||||
[:keycard.callback/check-nfc-enabled-success response]))}))
|
||||
|
||||
(defn open-nfc-settings []
|
||||
(log/info "[keycard] open-nfc-settings")
|
||||
|
@ -59,16 +59,16 @@
|
|||
(keycard/register-card-events
|
||||
card
|
||||
{:on-card-connected
|
||||
#(re-frame/dispatch [:hardwallet.callback/on-card-connected])
|
||||
#(re-frame/dispatch [:keycard.callback/on-card-connected])
|
||||
|
||||
:on-card-disconnected
|
||||
#(re-frame/dispatch [:hardwallet.callback/on-card-disconnected])
|
||||
#(re-frame/dispatch [:keycard.callback/on-card-disconnected])
|
||||
|
||||
:on-nfc-enabled
|
||||
#(re-frame/dispatch [:hardwallet.callback/check-nfc-enabled-success true])
|
||||
#(re-frame/dispatch [:keycard.callback/check-nfc-enabled-success true])
|
||||
|
||||
:on-nfc-disabled
|
||||
#(re-frame/dispatch [:hardwallet.callback/check-nfc-enabled-success false])}))
|
||||
#(re-frame/dispatch [:keycard.callback/check-nfc-enabled-success false])}))
|
||||
|
||||
(defn- error-object->map [^js object]
|
||||
{:code (.-code object)
|
||||
|
@ -84,13 +84,13 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] get-application-info")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-get-application-info-success
|
||||
[:keycard.callback/on-get-application-info-success
|
||||
response on-success]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] get-application-info")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-get-application-info-error
|
||||
[:keycard.callback/on-get-application-info-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn install-applet []
|
||||
|
@ -101,12 +101,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] install-applet")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-success response]))
|
||||
[:keycard.callback/on-install-applet-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] install-applet")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-error
|
||||
[:keycard.callback/on-install-applet-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn init-card [pin]
|
||||
|
@ -118,12 +118,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] init-card")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-init-card-success response]))
|
||||
[:keycard.callback/on-init-card-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] init-card")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-init-card-error
|
||||
[:keycard.callback/on-init-card-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn install-applet-and-init-card [pin]
|
||||
|
@ -135,13 +135,13 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] install-applet-and-init-card")
|
||||
#(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-and-init-card-success
|
||||
[:keycard.callback/on-install-applet-and-init-card-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] install-applet-and-init-card")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-and-init-card-error
|
||||
[:keycard.callback/on-install-applet-and-init-card-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn pair [args]
|
||||
|
@ -154,12 +154,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] pair")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-pair-success response]))
|
||||
[:keycard.callback/on-pair-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] pair")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-pair-error (error-object->map response)]))})))
|
||||
[:keycard.callback/on-pair-error (error-object->map response)]))})))
|
||||
|
||||
(defn generate-and-load-key [args]
|
||||
(log/info "[keycard] generate-and-load-key")
|
||||
|
@ -171,12 +171,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] generate-and-load-key")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-generate-and-load-key-success response]))
|
||||
[:keycard.callback/on-generate-and-load-key-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] generate-and-load-key")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-generate-and-load-key-error
|
||||
[:keycard.callback/on-generate-and-load-key-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn unblock-pin [args]
|
||||
|
@ -189,11 +189,11 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] unblock-pin")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-unblock-pin-success response]))
|
||||
[:keycard.callback/on-unblock-pin-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] unblock-pin")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-unblock-pin-error
|
||||
(re-frame/dispatch [:keycard.callback/on-unblock-pin-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn verify-pin [args]
|
||||
|
@ -205,13 +205,13 @@
|
|||
{:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] verify-pin")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-verify-pin-success
|
||||
(re-frame/dispatch [:keycard.callback/on-verify-pin-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] verify-pin")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-verify-pin-error
|
||||
[:keycard.callback/on-verify-pin-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn change-pin [args]
|
||||
|
@ -224,12 +224,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] change-pin")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-change-pin-success response]))
|
||||
[:keycard.callback/on-change-pin-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] change-pin")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-change-pin-error
|
||||
[:keycard.callback/on-change-pin-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn unpair [args]
|
||||
|
@ -242,12 +242,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] unpair")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-unpair-success response]))
|
||||
[:keycard.callback/on-unpair-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] unpair")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-unpair-error
|
||||
[:keycard.callback/on-unpair-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn delete []
|
||||
|
@ -258,12 +258,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] delete")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-delete-success response]))
|
||||
[:keycard.callback/on-delete-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/debug "[keycard response fail] delete")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-delete-error
|
||||
[:keycard.callback/on-delete-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn remove-key [args]
|
||||
|
@ -275,12 +275,12 @@
|
|||
{:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] remove-key")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-remove-key-success
|
||||
(re-frame/dispatch [:keycard.callback/on-remove-key-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] remove-key")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-remove-key-error
|
||||
(re-frame/dispatch [:keycard.callback/on-remove-key-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn remove-key-with-unpair [args]
|
||||
|
@ -292,12 +292,12 @@
|
|||
{:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] remove-key-with-unpair")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-remove-key-success
|
||||
(re-frame/dispatch [:keycard.callback/on-remove-key-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] remove-key-with-unpair")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-remove-key-error
|
||||
(re-frame/dispatch [:keycard.callback/on-remove-key-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn export-key [args]
|
||||
|
@ -309,12 +309,12 @@
|
|||
{:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] export-key")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-export-key-success
|
||||
(re-frame/dispatch [:keycard.callback/on-export-key-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] export-key")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-export-key-error
|
||||
(re-frame/dispatch [:keycard.callback/on-export-key-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn unpair-and-delete [args]
|
||||
|
@ -326,12 +326,12 @@
|
|||
{:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] unpair-and-delete")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-delete-success
|
||||
(re-frame/dispatch [:keycard.callback/on-delete-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] unpair-and-delete")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-delete-error
|
||||
(re-frame/dispatch [:keycard.callback/on-delete-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn get-keys [{:keys [on-success] :as args}]
|
||||
|
@ -344,13 +344,13 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] get-keys")
|
||||
(re-frame/dispatch
|
||||
[(or on-success :hardwallet.callback/on-get-keys-success)
|
||||
[(or on-success :keycard.callback/on-get-keys-success)
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] get-keys"
|
||||
(error-object->map response))
|
||||
(re-frame/dispatch [:hardwallet.callback/on-get-keys-error
|
||||
(re-frame/dispatch [:keycard.callback/on-get-keys-error
|
||||
(error-object->map response)]))})))
|
||||
|
||||
(defn sign [{:keys [on-success on-failure] :as args}]
|
||||
|
@ -364,14 +364,14 @@
|
|||
(log/info "[keycard response succ] sign")
|
||||
(if on-success
|
||||
(on-success response)
|
||||
(re-frame/dispatch [:hardwallet.callback/on-sign-success response])))
|
||||
(re-frame/dispatch [:keycard.callback/on-sign-success response])))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] sign")
|
||||
(if on-failure
|
||||
(on-failure response)
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-sign-error
|
||||
[:keycard.callback/on-sign-error
|
||||
(error-object->map response)])))})))
|
||||
|
||||
(defn install-cash-applet []
|
||||
|
@ -382,12 +382,12 @@
|
|||
(fn [response]
|
||||
(log/info "[keycard response succ] install-cash-applet")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-success response]))
|
||||
[:keycard.callback/on-install-applet-success response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] install-cash-applet")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-install-applet-error
|
||||
[:keycard.callback/on-install-applet-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn sign-typed-data
|
||||
|
@ -399,13 +399,13 @@
|
|||
:on-success
|
||||
(fn [response]
|
||||
(log/info "[keycard response succ] sign-typed-data")
|
||||
(re-frame/dispatch [:hardwallet.callback/on-sign-success
|
||||
(re-frame/dispatch [:keycard.callback/on-sign-success
|
||||
response]))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/info "[keycard response fail] sign-typed-data")
|
||||
(re-frame/dispatch
|
||||
[:hardwallet.callback/on-sign-error
|
||||
[:keycard.callback/on-sign-error
|
||||
(error-object->map response)]))}))
|
||||
|
||||
(defn save-multiaccount-and-login [args]
|
|
@ -1,38 +1,38 @@
|
|||
(ns status-im.hardwallet.change-pin
|
||||
(ns status-im.keycard.change-pin
|
||||
(:require [status-im.i18n :as i18n]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.hardwallet.onboarding :as onboarding]
|
||||
[status-im.keycard.onboarding :as onboarding]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.hardwallet.login :as hardwallet.login]))
|
||||
[status-im.keycard.common :as common]
|
||||
[status-im.keycard.login :as keycard.login]))
|
||||
|
||||
(fx/defn change-pin-pressed
|
||||
{:events [:keycard-settings.ui/change-pin-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin-retry-counter (get-in db [:hardwallet :application-info :pin-retry-counter])
|
||||
(let [pin-retry-counter (get-in db [:keycard :application-info :pin-retry-counter])
|
||||
enter-step (if (zero? pin-retry-counter) :puk :current)]
|
||||
(if (= enter-step :puk)
|
||||
(hardwallet.login/reset-pin cofx)
|
||||
(keycard.login/reset-pin cofx)
|
||||
(fx/merge cofx
|
||||
{:db
|
||||
(assoc-in db [:hardwallet :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:original []
|
||||
:confirmation []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :hardwallet/proceed-to-change-pin})}
|
||||
(assoc-in db [:keycard :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:original []
|
||||
:confirmation []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :keycard/proceed-to-change-pin})}
|
||||
(common/navigate-to-enter-pin-screen)))))
|
||||
|
||||
(fx/defn proceed-to-change-pin
|
||||
{:events [:hardwallet/proceed-to-change-pin]}
|
||||
{:events [:keycard/proceed-to-change-pin]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] :original)
|
||||
(assoc-in [:hardwallet :pin :status] nil))}
|
||||
(assoc-in [:keycard :pin :enter-step] :original)
|
||||
(assoc-in [:keycard :pin :status] nil))}
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil)))
|
||||
|
||||
(fx/defn discard-pin-change
|
||||
|
@ -41,48 +41,48 @@
|
|||
(fx/merge cofx
|
||||
(common/clear-pin)
|
||||
(common/hide-connection-sheet)
|
||||
(if (get-in db [:hardwallet :pin :puk-restore?])
|
||||
(if (get-in db [:keycard :pin :puk-restore?])
|
||||
(navigation/navigate-to-cofx :multiaccounts nil)
|
||||
(navigation/navigate-to-cofx :keycard-settings nil))))
|
||||
|
||||
(fx/defn change-pin
|
||||
{:events [:hardwallet/change-pin]}
|
||||
{:events [:keycard/change-pin]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [setup-step (get-in db [:hardwallet :setup-step])]
|
||||
(log/debug "[hardwallet] change-pin"
|
||||
(let [setup-step (get-in db [:keycard :setup-step])]
|
||||
(log/debug "[keycard] change-pin"
|
||||
"setup-step" setup-step)
|
||||
(if (= setup-step :pin)
|
||||
(onboarding/load-preparing-screen cofx)
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:sheet-options {:on-cancel [::on-cancel]}
|
||||
:on-card-connected :hardwallet/change-pin
|
||||
:on-card-connected :keycard/change-pin
|
||||
:handler
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(let [pairing (common/get-pairing db)
|
||||
new-pin (common/vector->string
|
||||
(get-in db [:hardwallet :pin :original]))
|
||||
(get-in db [:keycard :pin :original]))
|
||||
current-pin (common/vector->string
|
||||
(get-in db [:hardwallet :pin :current]))]
|
||||
(get-in db [:keycard :pin :current]))]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
{:db (assoc-in db [:keycard :pin :status] :verifying)
|
||||
|
||||
:hardwallet/change-pin
|
||||
:keycard/change-pin
|
||||
{:new-pin new-pin
|
||||
:current-pin current-pin
|
||||
:pairing pairing}})))}))))
|
||||
|
||||
(fx/defn on-change-pin-success
|
||||
{:events [:hardwallet.callback/on-change-pin-success]}
|
||||
{:events [:keycard.callback/on-change-pin-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (get-in db [:hardwallet :pin :original])
|
||||
puk-restore? (get-in db [:hardwallet :pin :puk-restore?])]
|
||||
(let [pin (get-in db [:keycard :pin :original])
|
||||
puk-restore? (get-in db [:keycard :pin :puk-restore?])]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:status nil
|
||||
:login pin
|
||||
:confirmation []
|
||||
:error-label nil})
|
||||
{:db (assoc-in db [:keycard :pin] {:status nil
|
||||
:login pin
|
||||
:confirmation []
|
||||
:error-label nil})
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pin-changed)}}
|
||||
(common/hide-connection-sheet)
|
||||
|
@ -93,26 +93,26 @@
|
|||
(common/get-keys-from-keycard)))))
|
||||
|
||||
(fx/defn on-change-pin-error
|
||||
{:events [:hardwallet.callback/on-change-pin-error]}
|
||||
{:events [:keycard.callback/on-change-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] change pin error" error)
|
||||
(log/debug "[keycard] change pin error" error)
|
||||
(let [tag-was-lost? (= "Tag was lost." (:error error))
|
||||
pairing (common/get-pairing db)]
|
||||
(fx/merge cofx
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(common/set-on-card-connected :hardwallet/change-pin))
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
(common/set-on-card-connected :keycard/change-pin))
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status :error
|
||||
:enter-step :current
|
||||
:puk []
|
||||
:current []
|
||||
:original []
|
||||
:confirmation []
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})}
|
||||
{:db (update-in db [:keycard :pin] merge {:status :error
|
||||
:enter-step :current
|
||||
:puk []
|
||||
:current []
|
||||
:original []
|
||||
:confirmation []
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil)
|
||||
(common/get-application-info pairing nil))
|
||||
(common/show-wrong-keycard-alert true))))))
|
|
@ -1,8 +1,8 @@
|
|||
(ns status-im.hardwallet.common
|
||||
(ns status-im.keycard.common
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.hardwallet.nfc :as nfc]
|
||||
[status-im.keycard.nfc :as nfc]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.ui.components.bottom-sheet.events :as bottom-sheet]
|
||||
|
@ -71,93 +71,93 @@
|
|||
|
||||
(defn get-pairing
|
||||
([db]
|
||||
(get-pairing db (get-in db [:hardwallet :application-info :key-uid])))
|
||||
(get-pairing db (get-in db [:keycard :application-info :key-uid])))
|
||||
([db key-uid]
|
||||
(or
|
||||
(get-in db [:multiaccount :keycard-pairing])
|
||||
(get-in db [:hardwallet :secrets :pairing])
|
||||
(get-in db [:keycard :secrets :pairing])
|
||||
(when key-uid
|
||||
(:keycard-pairing
|
||||
(find-multiaccount-by-key-uid db key-uid))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/set-nfc-supported
|
||||
:keycard/set-nfc-supported
|
||||
(fn [supported?]
|
||||
(nfc/set-nfc-supported? supported?)))
|
||||
|
||||
(fx/defn listen-to-hardware-back-button
|
||||
[{:keys [db]}]
|
||||
(when-not (get-in db [:hardwallet :back-button-listener])
|
||||
{:hardwallet/listen-to-hardware-back-button nil}))
|
||||
(when-not (get-in db [:keycard :back-button-listener])
|
||||
{:keycard/listen-to-hardware-back-button nil}))
|
||||
|
||||
(fx/defn remove-listener-to-hardware-back-button
|
||||
[{:keys [db]}]
|
||||
(when-let [listener (get-in db [:hardwallet :back-button-listener])]
|
||||
{:hardwallet/remove-listener-to-hardware-back-button listener}))
|
||||
(when-let [listener (get-in db [:keycard :back-button-listener])]
|
||||
{:keycard/remove-listener-to-hardware-back-button listener}))
|
||||
|
||||
(fx/defn set-on-card-connected
|
||||
[{:keys [db]} on-connect]
|
||||
(log/debug "[hardwallet] set-on-card-connected" on-connect)
|
||||
(log/debug "[keycard] set-on-card-connected" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-connected] on-connect)
|
||||
(assoc-in [:hardwallet :last-on-card-connected] nil))})
|
||||
(assoc-in [:keycard :on-card-connected] on-connect)
|
||||
(assoc-in [:keycard :last-on-card-connected] nil))})
|
||||
|
||||
(fx/defn stash-on-card-connected
|
||||
[{:keys [db]}]
|
||||
(let [on-connect (get-in db [:hardwallet :on-card-connected])]
|
||||
(log/debug "[hardwallet] stash-on-card-connected" on-connect)
|
||||
(let [on-connect (get-in db [:keycard :on-card-connected])]
|
||||
(log/debug "[keycard] stash-on-card-connected" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :last-on-card-connected] on-connect)
|
||||
(assoc-in [:hardwallet :on-card-connected] nil))}))
|
||||
(assoc-in [:keycard :last-on-card-connected] on-connect)
|
||||
(assoc-in [:keycard :on-card-connected] nil))}))
|
||||
|
||||
(fx/defn restore-on-card-connected
|
||||
[{:keys [db]}]
|
||||
(let [on-connect (or
|
||||
(get-in db [:hardwallet :on-card-connected])
|
||||
(get-in db [:hardwallet :last-on-card-connected]))]
|
||||
(log/debug "[hardwallet] restore-on-card-connected" on-connect)
|
||||
(get-in db [:keycard :on-card-connected])
|
||||
(get-in db [:keycard :last-on-card-connected]))]
|
||||
(log/debug "[keycard] restore-on-card-connected" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-connected] on-connect)
|
||||
(assoc-in [:hardwallet :last-on-card-connect] nil))}))
|
||||
(assoc-in [:keycard :on-card-connected] on-connect)
|
||||
(assoc-in [:keycard :last-on-card-connect] nil))}))
|
||||
|
||||
(fx/defn clear-on-card-connected
|
||||
[{:keys [db]}]
|
||||
(log/debug "[hardwallet] clear-on-card-connected")
|
||||
(log/debug "[keycard] clear-on-card-connected")
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-connected] nil)
|
||||
(assoc-in [:hardwallet :last-on-card-connected] nil))})
|
||||
(assoc-in [:keycard :on-card-connected] nil)
|
||||
(assoc-in [:keycard :last-on-card-connected] nil))})
|
||||
|
||||
(fx/defn set-on-card-read
|
||||
[{:keys [db]} on-connect]
|
||||
(log/debug "[hardwallet] set-on-card-read" on-connect)
|
||||
(log/debug "[keycard] set-on-card-read" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-read] on-connect)
|
||||
(assoc-in [:hardwallet :last-on-card-read] nil))})
|
||||
(assoc-in [:keycard :on-card-read] on-connect)
|
||||
(assoc-in [:keycard :last-on-card-read] nil))})
|
||||
|
||||
(fx/defn stash-on-card-read
|
||||
[{:keys [db]}]
|
||||
(let [on-connect (get-in db [:hardwallet :on-card-read])]
|
||||
(log/debug "[hardwallet] stash-on-card-read" on-connect)
|
||||
(let [on-connect (get-in db [:keycard :on-card-read])]
|
||||
(log/debug "[keycard] stash-on-card-read" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :last-on-card-read] on-connect)
|
||||
(assoc-in [:hardwallet :on-card-read] nil))}))
|
||||
(assoc-in [:keycard :last-on-card-read] on-connect)
|
||||
(assoc-in [:keycard :on-card-read] nil))}))
|
||||
|
||||
(fx/defn restore-on-card-read
|
||||
[{:keys [db]}]
|
||||
(let [on-connect (or
|
||||
(get-in db [:hardwallet :on-card-read])
|
||||
(get-in db [:hardwallet :last-on-card-read]))]
|
||||
(log/debug "[hardwallet] restore-on-card-read" on-connect)
|
||||
(get-in db [:keycard :on-card-read])
|
||||
(get-in db [:keycard :last-on-card-read]))]
|
||||
(log/debug "[keycard] restore-on-card-read" on-connect)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-read] on-connect)
|
||||
(assoc-in [:hardwallet :last-on-card-connect] nil))}))
|
||||
(assoc-in [:keycard :on-card-read] on-connect)
|
||||
(assoc-in [:keycard :last-on-card-connect] nil))}))
|
||||
|
||||
(fx/defn clear-on-card-read
|
||||
[{:keys [db]}]
|
||||
(log/debug "[hardwallet] clear-on-card-read")
|
||||
(log/debug "[keycard] clear-on-card-read")
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :on-card-read] nil)
|
||||
(assoc-in [:hardwallet :last-on-card-read] nil))})
|
||||
(assoc-in [:keycard :on-card-read] nil)
|
||||
(assoc-in [:keycard :last-on-card-read] nil))})
|
||||
|
||||
(defn keycard-sheet-content [on-cancel connected? params]
|
||||
(fn []
|
||||
|
@ -175,8 +175,8 @@
|
|||
:sheet-options}]
|
||||
(assert (keyword? on-card-connected))
|
||||
(assert (fn? handler))
|
||||
(let [connected? (get-in db [:hardwallet :card-connected?])]
|
||||
(log/debug "[hardwallet] show-sheet-with-connection-check"
|
||||
(let [connected? (get-in db [:keycard :card-connected?])]
|
||||
(log/debug "[keycard] show-sheet-with-connection-check"
|
||||
"card-connected?" connected?)
|
||||
(fx/merge
|
||||
cofx
|
||||
|
@ -198,7 +198,7 @@
|
|||
(fx/defn hide-connection-sheet
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :card-read-in-progress?] false)}
|
||||
{:db (assoc-in db [:keycard :card-read-in-progress?] false)}
|
||||
(restore-on-card-connected)
|
||||
(restore-on-card-read)
|
||||
(bottom-sheet/hide-bottom-sheet)))
|
||||
|
@ -208,9 +208,9 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db
|
||||
[:hardwallet :pin]
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:login (get-in db [:hardwallet :pin :original])
|
||||
:login (get-in db [:keycard :pin :original])
|
||||
:export-key []
|
||||
:sign []
|
||||
:puk []
|
||||
|
@ -218,14 +218,14 @@
|
|||
:original []
|
||||
:confirmation []
|
||||
:error-label nil
|
||||
:on-verified (get-in db [:hardwallet :pin :on-verified])
|
||||
:on-verified-failure (get-in db [:hardwallet :pin :on-verified])})}))
|
||||
:on-verified (get-in db [:keycard :pin :on-verified])
|
||||
:on-verified-failure (get-in db [:keycard :pin :on-verified])})}))
|
||||
|
||||
(fx/defn cancel-sheet-confirm
|
||||
{:events [::cancel-sheet-confirm
|
||||
:hardwallet/back-button-pressed]}
|
||||
:keycard/back-button-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(when-not (get-in db [:hardwallet :card-connected?])
|
||||
(when-not (get-in db [:keycard :card-connected?])
|
||||
(fx/merge cofx
|
||||
(hide-connection-sheet)
|
||||
(clear-pin))))
|
||||
|
@ -245,9 +245,9 @@
|
|||
During keycard setup we show user a warning that setup will be cancelled
|
||||
when back button pressed. This prevents user from going back during setup
|
||||
flow as some of the actions changing keycard step could not be repeated."
|
||||
{:events [:hardwallet/add-listener-to-hardware-back-button]}
|
||||
{:events [:keycard/add-listener-to-hardware-back-button]}
|
||||
[{:keys [db]} listener]
|
||||
{:db (assoc-in db [:hardwallet :back-button-listener] listener)})
|
||||
{:db (assoc-in db [:keycard :back-button-listener] listener)})
|
||||
|
||||
(fx/defn show-wrong-keycard-alert
|
||||
[_ card-connected?]
|
||||
|
@ -264,9 +264,9 @@
|
|||
(navigation/navigate-to-cofx :keycard-settings nil)))
|
||||
|
||||
(fx/defn navigate-to-enter-pin-screen
|
||||
{:events [:hardwallet/navigate-to-enter-pin-screen]}
|
||||
{:events [:keycard/navigate-to-enter-pin-screen]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
(let [key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
multiaccount-key-uid (get-in db [:multiaccount :key-uid])
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing]))]
|
||||
;; TODO(Ferossgp): If last oeperation was with wrong card,
|
||||
|
@ -279,7 +279,7 @@
|
|||
(and key-uid
|
||||
(= key-uid multiaccount-key-uid)))
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :current] [])}
|
||||
{:db (assoc-in db [:keycard :pin :current] [])}
|
||||
(navigation/navigate-to-cofx :enter-pin-settings nil))
|
||||
(unauthorized-operation cofx))))
|
||||
|
||||
|
@ -290,29 +290,29 @@
|
|||
|
||||
(fx/defn process-error [{:keys [db]} code error]
|
||||
(when-not (tag-lost-exception? code error)
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :error)}))
|
||||
{:db (assoc-in db [:keycard :setup-step] :error)}))
|
||||
|
||||
(fx/defn get-keys-from-keycard
|
||||
[{:keys [db]}]
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||
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 [:keycard :pin :login]))]
|
||||
(log/debug "[keycard] get-keys-from-keycard"
|
||||
"not nil pairing:" (boolean pairing)
|
||||
", not empty pin:" (boolean (seq pin)))
|
||||
(when (and pairing
|
||||
(seq pin))
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
:hardwallet/get-keys {:pairing pairing
|
||||
:pin pin}})))
|
||||
{:db (assoc-in db [:keycard :pin :status] :verifying)
|
||||
:keycard/get-keys {:pairing pairing
|
||||
:pin pin}})))
|
||||
|
||||
(fx/defn on-get-keys-success
|
||||
{:events [:hardwallet.callback/on-get-keys-success]}
|
||||
{:events [:keycard.callback/on-get-keys-success]}
|
||||
[{:keys [db] :as cofx} data]
|
||||
(let [{:keys [key-uid encryption-public-key whisper-private-key]
|
||||
:as account-data} (js->clj data :keywordize-keys true)
|
||||
{: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 [:keycard :application-info :key-uid])
|
||||
multiaccount-data (types/clj->json {:name name
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path})
|
||||
|
@ -320,45 +320,45 @@
|
|||
(fx/merge cofx
|
||||
{:db
|
||||
(-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(assoc-in [:hardwallet :pin :login] [])
|
||||
(assoc-in [:hardwallet :multiaccount]
|
||||
(assoc-in [:keycard :pin :status] nil)
|
||||
(assoc-in [:keycard :pin :login] [])
|
||||
(assoc-in [:keycard :multiaccount]
|
||||
(update account-data :whisper-public-key ethereum/normalized-hex))
|
||||
(assoc-in [:hardwallet :flow] nil)
|
||||
(assoc-in [:keycard :flow] nil)
|
||||
(update :multiaccounts/login assoc
|
||||
:password encryption-public-key
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path
|
||||
:name name))
|
||||
|
||||
:hardwallet/get-application-info {:pairing (get-pairing db key-uid)}
|
||||
:hardwallet/login-with-keycard {:multiaccount-data multiaccount-data
|
||||
:password encryption-public-key
|
||||
:chat-key whisper-private-key
|
||||
:key-uid key-uid}}
|
||||
:keycard/get-application-info {:pairing (get-pairing db key-uid)}
|
||||
:keycard/login-with-keycard {:multiaccount-data multiaccount-data
|
||||
:password encryption-public-key
|
||||
:chat-key whisper-private-key
|
||||
:key-uid key-uid}}
|
||||
(when save-keys?
|
||||
(keychain/save-hardwallet-keys key-uid encryption-public-key whisper-private-key))
|
||||
(keychain/save-keycard-keys key-uid encryption-public-key whisper-private-key))
|
||||
(clear-on-card-connected)
|
||||
(clear-on-card-read)
|
||||
(hide-connection-sheet))))
|
||||
|
||||
(fx/defn on-get-keys-error
|
||||
{:events [:hardwallet.callback/on-get-keys-error]}
|
||||
{:events [:keycard.callback/on-get-keys-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] get keys error: " error)
|
||||
(log/debug "[keycard] get keys error: " error)
|
||||
(let [tag-was-lost? (tag-lost? (:error error))
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
flow (get-in db [:keycard :flow])]
|
||||
(if tag-was-lost?
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
(if (re-matches pin-mismatch-error (:error error))
|
||||
(fx/merge
|
||||
cofx
|
||||
{:hardwallet/get-application-info
|
||||
{:keycard/get-application-info
|
||||
{:pairing (get-pairing db key-uid)}
|
||||
|
||||
:db
|
||||
(update-in db [:hardwallet :pin] merge
|
||||
(update-in db [:keycard :pin] merge
|
||||
{:status :error
|
||||
:login []
|
||||
:import-multiaccount []
|
||||
|
@ -371,48 +371,48 @@
|
|||
;; Get application info
|
||||
|
||||
(fx/defn get-application-info
|
||||
{:events [:hardwallet/get-application-info]}
|
||||
{:events [:keycard/get-application-info]}
|
||||
[{:keys [db]} pairing on-card-read]
|
||||
(let [key-uid
|
||||
(when-not (:intro-wizard db)
|
||||
(get-in
|
||||
db [:hardwallet :application-info :key-uid]
|
||||
db [:keycard :application-info :key-uid]
|
||||
(get-in db [:multiaccounts/login :key-uid])))
|
||||
pairing' (or pairing (some->> key-uid (get-pairing db)))]
|
||||
(log/debug "[hardwallet] get-application-info"
|
||||
(log/debug "[keycard] get-application-info"
|
||||
"pairing" pairing')
|
||||
{:hardwallet/get-application-info {:pairing pairing'
|
||||
:on-success on-card-read}}))
|
||||
{:keycard/get-application-info {:pairing pairing'
|
||||
:on-success on-card-read}}))
|
||||
|
||||
(fx/defn frozen-keycard-popup
|
||||
[{:keys [db] :as cofx}]
|
||||
(if (:multiaccounts/login db)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :frozen-card)}
|
||||
{:db (assoc-in db [:keycard :pin :status] :frozen-card)}
|
||||
hide-connection-sheet)
|
||||
{:db (assoc db :popover/popover {:view :frozen-card})}))
|
||||
|
||||
(fx/defn on-get-application-info-success
|
||||
{:events [:hardwallet.callback/on-get-application-info-success]}
|
||||
{:events [:keycard.callback/on-get-application-info-success]}
|
||||
[{:keys [db] :as cofx} info on-success]
|
||||
(let [{:keys [pin-retry-counter puk-retry-counter]} info
|
||||
view-id (:view-id db)
|
||||
|
||||
{:keys [on-card-read]} (:hardwallet db)
|
||||
{:keys [on-card-read]} (:keycard db)
|
||||
on-success' (or on-success on-card-read)
|
||||
enter-step (get-in db [:hardwallet :pin :enter-step])]
|
||||
(log/debug "[hardwallet] on-get-application-info-success"
|
||||
enter-step (get-in db [:keycard :pin :enter-step])]
|
||||
(log/debug "[keycard] on-get-application-info-success"
|
||||
"on-success" on-success'
|
||||
"pin-retry-counter" pin-retry-counter
|
||||
"puk-retry-counter" puk-retry-counter)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] enter-step)
|
||||
(assoc-in [:hardwallet :application-info] info)
|
||||
(assoc-in [:hardwallet :application-info :applet-installed?] true)
|
||||
(assoc-in [:hardwallet :application-info-error] nil))}
|
||||
(assoc-in [:keycard :pin :enter-step] enter-step)
|
||||
(assoc-in [:keycard :application-info] info)
|
||||
(assoc-in [:keycard :application-info :applet-installed?] true)
|
||||
(assoc-in [:keycard :application-info-error] nil))}
|
||||
(stash-on-card-read)
|
||||
(when (and (zero? pin-retry-counter)
|
||||
(pos? puk-retry-counter)
|
||||
|
@ -422,20 +422,20 @@
|
|||
(if (zero? puk-retry-counter)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :blocked-card)}
|
||||
{:db (assoc-in db [:keycard :pin :status] :blocked-card)}
|
||||
hide-connection-sheet)
|
||||
(when on-success'
|
||||
(dispatch-event cofx on-success')))))))
|
||||
|
||||
(fx/defn on-get-application-info-error
|
||||
{:events [:hardwallet.callback/on-get-application-info-error]}
|
||||
{:events [:keycard.callback/on-get-application-info-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(let [on-card-read (get-in db [:hardwallet :on-card-read])
|
||||
on-card-connected (get-in db [:hardwallet :on-card-connected])
|
||||
last-on-card-connected (get-in db [:hardwallet :last-on-card-connected])
|
||||
login? (= on-card-read :hardwallet/login-with-keycard)
|
||||
(let [on-card-read (get-in db [:keycard :on-card-read])
|
||||
on-card-connected (get-in db [:keycard :on-card-connected])
|
||||
last-on-card-connected (get-in db [:keycard :last-on-card-connected])
|
||||
login? (= on-card-read :keycard/login-with-keycard)
|
||||
tag-was-lost? (tag-lost? (:error error))]
|
||||
(log/debug "[hardwallet] application info error"
|
||||
(log/debug "[keycard] application info error"
|
||||
error
|
||||
on-card-connected
|
||||
last-on-card-connected)
|
||||
|
@ -445,11 +445,11 @@
|
|||
(clear-on-card-read)
|
||||
(navigation/navigate-to-cofx :not-keycard nil))
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :application-info-error] error)}
|
||||
{:db (assoc-in db [:keycard :application-info-error] error)}
|
||||
|
||||
(when (contains?
|
||||
#{last-on-card-connected on-card-connected}
|
||||
:hardwallet/prepare-to-sign)
|
||||
:keycard/prepare-to-sign)
|
||||
(show-wrong-keycard-alert true))
|
||||
|
||||
(when on-card-read
|
||||
|
@ -458,20 +458,20 @@
|
|||
(fx/defn on-card-connected
|
||||
{:events [::on-card-connected]}
|
||||
[{:keys [db] :as cofx} _]
|
||||
(let [instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
(let [instance-uid (get-in db [:keycard :application-info :instance-uid])
|
||||
key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
should-read-instance-uid? (nil? instance-uid)
|
||||
on-card-connected (get-in db [:hardwallet :on-card-connected])
|
||||
on-card-connected (get-in db [:keycard :on-card-connected])
|
||||
on-card-read (cond
|
||||
should-read-instance-uid? :hardwallet/get-application-info
|
||||
:else (get-in db [:hardwallet :on-card-read]))
|
||||
should-read-instance-uid? :keycard/get-application-info
|
||||
:else (get-in db [:keycard :on-card-read]))
|
||||
pairing (get-pairing db key-uid)]
|
||||
(log/debug "[hardwallet] on-card-connected" on-card-connected
|
||||
(log/debug "[keycard] on-card-connected" on-card-connected
|
||||
"on-card-read" on-card-read)
|
||||
(when on-card-connected
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] (boolean on-card-read)))}
|
||||
(assoc-in [:keycard :card-read-in-progress?] (boolean on-card-read)))}
|
||||
(when on-card-connected
|
||||
(dispatch-event on-card-connected))
|
||||
(stash-on-card-connected)
|
||||
|
@ -482,10 +482,10 @@
|
|||
(fx/defn on-card-disconnected
|
||||
{:events [::on-card-disconnected]}
|
||||
[{:keys [db] :as cofx} _]
|
||||
(log/debug "[hardwallet] card disconnected")
|
||||
(log/debug "[keycard] card disconnected")
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] false))}
|
||||
(assoc-in [:keycard :card-read-in-progress?] false))}
|
||||
(restore-on-card-connected)
|
||||
(restore-on-card-read)))
|
||||
|
||||
|
@ -493,31 +493,31 @@
|
|||
(boolean (get-in db [:multiaccount :keycard-pairing])))
|
||||
|
||||
(fx/defn verify-pin
|
||||
{:events [:hardwallet/verify-pin]}
|
||||
{:events [:keycard/verify-pin]}
|
||||
[{:keys [db] :as cofx} {:keys [pin-step on-card-connected on-failure on-success]}]
|
||||
(let [on-success (or on-success
|
||||
(get-in db [:hardwallet :pin :on-verified]))
|
||||
(get-in db [:keycard :pin :on-verified]))
|
||||
on-failure (or on-failure
|
||||
(get-in db [:hardwallet :pin :on-verified-failure]))
|
||||
(get-in db [:keycard :pin :on-verified-failure]))
|
||||
pin-step (or pin-step
|
||||
(get-in db [:hardwallet :pin :step]))]
|
||||
(get-in db [:keycard :pin :step]))]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (update-in db [:hardwallet :pin] assoc
|
||||
{:db (update-in db [:keycard :pin] assoc
|
||||
:step pin-step
|
||||
:on-verified on-success
|
||||
:on-verified-failure on-failure)}
|
||||
(show-connection-sheet
|
||||
{:on-card-connected (or on-card-connected :hardwallet/verify-pin)
|
||||
{:on-card-connected (or on-card-connected :keycard/verify-pin)
|
||||
:handler
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(let [pin (vector->string (get-in db [:hardwallet :pin pin-step]))
|
||||
(let [pin (vector->string (get-in db [:keycard :pin pin-step]))
|
||||
pairing (get-pairing db)]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
:hardwallet/verify-pin {:pin pin
|
||||
:pairing pairing}})))}))))
|
||||
{:db (assoc-in db [:keycard :pin :status] :verifying)
|
||||
:keycard/verify-pin {:pin pin
|
||||
:pairing pairing}})))}))))
|
||||
|
||||
(fx/defn navigete-to-keycard-settings
|
||||
{:events [::navigate-to-keycard-settings]}
|
|
@ -1,29 +1,29 @@
|
|||
(ns status-im.hardwallet.common-test
|
||||
(ns status-im.keycard.common-test
|
||||
(:require [cljs.test :refer-macros [deftest is testing]]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
[status-im.keycard.common :as common]))
|
||||
|
||||
(deftest test-show-connection-sheet
|
||||
(testing "the card is not connected yet"
|
||||
(let [db {:hardwallet {:card-connected? false}}
|
||||
(let [db {:keycard {:card-connected? false}}
|
||||
res (common/show-connection-sheet
|
||||
{:db db}
|
||||
{:on-card-connected :do-something
|
||||
:handler (fn [{:keys [db]}]
|
||||
{:db (assoc db :some-key :some-value)})})]
|
||||
(is (= :do-something
|
||||
(get-in res [:db :hardwallet :on-card-connected])))
|
||||
(get-in res [:db :keycard :on-card-connected])))
|
||||
(is (nil? (get-in res [:db :some-key])))
|
||||
(is (true? (get-in res [:db :bottom-sheet/show?])))))
|
||||
(testing "the card is connected before the interaction"
|
||||
(let [db {:hardwallet {:card-connected? true}}
|
||||
(let [db {:keycard {:card-connected? true}}
|
||||
res (common/show-connection-sheet
|
||||
{:db db}
|
||||
{:on-card-connected :do-something
|
||||
:handler (fn [{:keys [db]}]
|
||||
{:db (assoc db :some-key :some-value)})})]
|
||||
(is (nil? (get-in res [:db :hardwallet :on-card-connected])))
|
||||
(is (nil? (get-in res [:db :keycard :on-card-connected])))
|
||||
(is (= :do-something
|
||||
(get-in res [:db :hardwallet :last-on-card-connected])))
|
||||
(get-in res [:db :keycard :last-on-card-connected])))
|
||||
(is (= :some-value (get-in res [:db :some-key])))
|
||||
(is (true? (get-in res [:db :bottom-sheet/show?])))))
|
||||
(testing "on-card-connected is not specified"
|
|
@ -1,14 +1,14 @@
|
|||
(ns status-im.hardwallet.core
|
||||
(:require [status-im.hardwallet.change-pin :as change-pin]
|
||||
[status-im.hardwallet.common :as common]
|
||||
status-im.hardwallet.delete-key
|
||||
status-im.hardwallet.export-key
|
||||
[status-im.hardwallet.login :as login]
|
||||
[status-im.hardwallet.mnemonic :as mnemonic]
|
||||
[status-im.hardwallet.onboarding :as onboarding]
|
||||
[status-im.hardwallet.recovery :as recovery]
|
||||
[status-im.hardwallet.sign :as sign]
|
||||
[status-im.hardwallet.wallet :as wallet]
|
||||
(ns status-im.keycard.core
|
||||
(:require [status-im.keycard.change-pin :as change-pin]
|
||||
[status-im.keycard.common :as common]
|
||||
status-im.keycard.delete-key
|
||||
status-im.keycard.export-key
|
||||
[status-im.keycard.login :as login]
|
||||
[status-im.keycard.mnemonic :as mnemonic]
|
||||
[status-im.keycard.onboarding :as onboarding]
|
||||
[status-im.keycard.recovery :as recovery]
|
||||
[status-im.keycard.sign :as sign]
|
||||
[status-im.keycard.wallet :as wallet]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
|
@ -20,7 +20,7 @@
|
|||
(fx/defn show-keycard-has-multiaccount-alert
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] nil)
|
||||
{:db (assoc-in db [:keycard :setup-step] nil)
|
||||
:utils/show-confirmation {:title nil
|
||||
:content (i18n/label :t/keycard-has-multiaccount-on-it)
|
||||
:cancel-button-text ""
|
||||
|
@ -30,32 +30,32 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :pin)
|
||||
(assoc-in [:hardwallet :pin] {:enter-step :original
|
||||
:original []
|
||||
:confirmation []}))}
|
||||
(assoc-in [:keycard :setup-step] :pin)
|
||||
(assoc-in [:keycard :pin] {:enter-step :original
|
||||
:original []
|
||||
:confirmation []}))}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-pin nil)))
|
||||
|
||||
(fx/defn load-recovery-pin-screen
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin] {:enter-step :import-multiaccount
|
||||
:import-multiaccount []
|
||||
:current []}))}
|
||||
(assoc-in [:keycard :pin] {:enter-step :import-multiaccount
|
||||
:import-multiaccount []
|
||||
:current []}))}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-replace :keycard-recovery-pin nil)))
|
||||
|
||||
(fx/defn proceed-setup-with-initialized-card
|
||||
[{:keys [db] :as cofx} flow instance-uid]
|
||||
(log/debug "[hardwallet] proceed-setup-with-initialized-card"
|
||||
(log/debug "[keycard] proceed-setup-with-initialized-card"
|
||||
"instance-uid" instance-uid)
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx cofx :keycard-recovery-no-key nil)
|
||||
(let [pairing-data (get-in db [:hardwallet :pairings instance-uid])]
|
||||
(let [pairing-data (get-in db [:keycard :pairings instance-uid])]
|
||||
(if pairing-data
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :secrets] merge pairing-data)}
|
||||
{:db (update-in db [:keycard :secrets] merge pairing-data)}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(when (= flow :create)
|
||||
(mnemonic/set-mnemonic))
|
||||
|
@ -68,77 +68,77 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :on-verified] nil)
|
||||
(assoc-in [:hardwallet :setup-step] nil))}
|
||||
(assoc-in [:keycard :pin :on-verified] nil)
|
||||
(assoc-in [:keycard :setup-step] nil))}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-to-cofx :keycard-settings nil)))
|
||||
|
||||
(fx/defn password-option-pressed
|
||||
{:eevents [:hardwallet.ui/password-option-pressed]}
|
||||
{:eevents [:keycard.ui/password-option-pressed]}
|
||||
[{:keys [db]}]
|
||||
(when (= (get-in db [:hardwallet :flow]) :create)
|
||||
(when (= (get-in db [:keycard :flow]) :create)
|
||||
#())) ;;TODO with v1 flow
|
||||
|
||||
(fx/defn settings-screen-did-load
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :on-verified] nil)
|
||||
(assoc-in [:hardwallet :setup-step] nil))}
|
||||
(assoc-in [:keycard :pin :on-verified] nil)
|
||||
(assoc-in [:keycard :setup-step] nil))}
|
||||
(common/clear-on-card-connected)))
|
||||
|
||||
(defn reset-card-screen-did-load
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :reset-card :disabled?] false)})
|
||||
{:db (assoc-in db [:keycard :reset-card :disabled?] false)})
|
||||
|
||||
(defn enter-pin-screen-did-load
|
||||
[{:keys [db]}]
|
||||
(let [enter-step (get-in db [:hardwallet :pin :enter-step])]
|
||||
{:db (assoc-in db [:hardwallet :pin enter-step] [])}))
|
||||
(let [enter-step (get-in db [:keycard :pin :enter-step])]
|
||||
{:db (assoc-in db [:keycard :pin enter-step] [])}))
|
||||
|
||||
(defn multiaccounts-screen-did-load
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :setup-step] nil)})
|
||||
{:db (assoc-in db [:keycard :setup-step] nil)})
|
||||
|
||||
(defn authentication-method-screen-did-load
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :setup-step] nil)})
|
||||
{:db (assoc-in db [:keycard :setup-step] nil)})
|
||||
|
||||
(fx/defn set-nfc-supported
|
||||
{:events [:hardwallet.callback/check-nfc-support-success]}
|
||||
{:events [:keycard.callback/check-nfc-support-success]}
|
||||
[_ supported?]
|
||||
{:hardwallet/set-nfc-supported supported?})
|
||||
{:keycard/set-nfc-supported supported?})
|
||||
|
||||
;; TODO: Should be listener and replace the view in bottom sheet to avoid this
|
||||
(fx/defn on-check-nfc-enabled-success
|
||||
{:events [:hardwallet.callback/check-nfc-enabled-success]}
|
||||
{:events [:keycard.callback/check-nfc-enabled-success]}
|
||||
[{:keys [db]} nfc-enabled?]
|
||||
(log/debug "[hardwallet] check-nfc-enabled-success"
|
||||
(log/debug "[keycard] check-nfc-enabled-success"
|
||||
"nfc-enabled?" nfc-enabled?)
|
||||
{:db (assoc-in db [:hardwallet :nfc-enabled?] nfc-enabled?)})
|
||||
{:db (assoc-in db [:keycard :nfc-enabled?] nfc-enabled?)})
|
||||
|
||||
(defn- proceed-to-pin-confirmation [fx]
|
||||
(assoc-in fx [:db :hardwallet :pin :enter-step] :confirmation))
|
||||
(assoc-in fx [:db :keycard :pin :enter-step] :confirmation))
|
||||
|
||||
(defn- proceed-to-pin-reset-confirmation [fx]
|
||||
(-> fx
|
||||
(update-in [:db :hardwallet :pin] dissoc :reset-confirmation)
|
||||
(assoc-in [:db :hardwallet :pin :enter-step] :reset-confirmation)))
|
||||
(update-in [:db :keycard :pin] dissoc :reset-confirmation)
|
||||
(assoc-in [:db :keycard :pin :enter-step] :reset-confirmation)))
|
||||
|
||||
(defn- proceed-to-puk-confirmation [fx]
|
||||
(assoc-in fx [:db :hardwallet :pin :enter-step] :puk))
|
||||
(assoc-in fx [:db :keycard :pin :enter-step] :puk))
|
||||
|
||||
(fx/defn on-unblock-pin-success
|
||||
{:events [:hardwallet.callback/on-unblock-pin-success]}
|
||||
{:events [:keycard.callback/on-unblock-pin-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pairing (common/get-pairing db)
|
||||
reset-pin (get-in db [:hardwallet :pin :reset])]
|
||||
reset-pin (get-in db [:keycard :pin :reset])]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/get-application-info
|
||||
{:keycard/get-application-info
|
||||
{:pairing pairing}
|
||||
|
||||
:db
|
||||
(update-in db [:hardwallet :pin] merge
|
||||
(update-in db [:keycard :pin] merge
|
||||
{:status :after-unblocking
|
||||
:enter-step :login
|
||||
:login reset-pin
|
||||
|
@ -151,18 +151,18 @@
|
|||
(common/clear-on-card-read))))
|
||||
|
||||
(fx/defn on-unblock-pin-error
|
||||
{:events [:hardwallet.callback/on-unblock-pin-error]}
|
||||
{:events [:keycard.callback/on-unblock-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(let [pairing (common/get-pairing db)
|
||||
tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(log/debug "[hardwallet] unblock pin error" error)
|
||||
(log/debug "[keycard] unblock pin error" error)
|
||||
(when-not tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:hardwallet/get-application-info
|
||||
{:keycard/get-application-info
|
||||
{:pairing pairing}
|
||||
|
||||
:db
|
||||
(update-in db [:hardwallet :pin] merge
|
||||
(update-in db [:keycard :pin] merge
|
||||
{:status :error
|
||||
:error-label :t/puk-mismatch
|
||||
:enter-step :puk
|
||||
|
@ -171,29 +171,29 @@
|
|||
|
||||
(fx/defn clear-on-verify-handlers
|
||||
[{:keys [db]}]
|
||||
{:db (update-in db [:hardwallet :pin]
|
||||
{:db (update-in db [:keycard :pin]
|
||||
dissoc :on-verified-failure :on-verified)})
|
||||
|
||||
(fx/defn on-verify-pin-success
|
||||
{:events [:hardwallet.callback/on-verify-pin-success]}
|
||||
{:events [:keycard.callback/on-verify-pin-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [on-verified (get-in db [:hardwallet :pin :on-verified])
|
||||
(let [on-verified (get-in db [:keycard :pin :on-verified])
|
||||
pairing (common/get-pairing db)]
|
||||
(log/debug "[hardwaller] success pin verification. on-verified" on-verified)
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin] merge {:status nil
|
||||
:error-label nil})}
|
||||
{:db (update-in db [:keycard :pin] merge {:status nil
|
||||
:error-label nil})}
|
||||
(common/clear-on-card-connected)
|
||||
(common/clear-on-card-read)
|
||||
;; 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)
|
||||
(when-not (= on-verified :keycard/generate-and-load-key)
|
||||
(common/hide-connection-sheet))
|
||||
(when-not (contains? #{:hardwallet/unpair
|
||||
:hardwallet/generate-and-load-key
|
||||
:hardwallet/remove-key-with-unpair
|
||||
:hardwallet/unpair-and-delete
|
||||
(when-not (contains? #{:keycard/unpair
|
||||
:keycard/generate-and-load-key
|
||||
:keycard/remove-key-with-unpair
|
||||
:keycard/unpair-and-delete
|
||||
:wallet.accounts/generate-new-keycard-account} on-verified)
|
||||
(common/get-application-info pairing nil))
|
||||
(when on-verified
|
||||
|
@ -201,17 +201,17 @@
|
|||
(clear-on-verify-handlers))))
|
||||
|
||||
(fx/defn on-verify-pin-error
|
||||
{:events [:hardwallet.callback/on-verify-pin-error]}
|
||||
{:events [:keycard.callback/on-verify-pin-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))
|
||||
setup? (boolean (get-in db [:hardwallet :setup-step]))
|
||||
on-verified-failure (get-in db [:hardwallet :pin :on-verified-failure])
|
||||
exporting? (get-in db [:hardwallet :on-export-success])]
|
||||
(log/debug "[hardwallet] verify pin error" error)
|
||||
setup? (boolean (get-in db [:keycard :setup-step]))
|
||||
on-verified-failure (get-in db [:keycard :pin :on-verified-failure])
|
||||
exporting? (get-in db [:keycard :on-export-success])]
|
||||
(log/debug "[keycard] verify pin error" error)
|
||||
(when-not tag-was-lost?
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:hardwallet :pin]
|
||||
{:db (update-in db [:keycard :pin]
|
||||
merge
|
||||
{:status :error
|
||||
:enter-step :current
|
||||
|
@ -240,19 +240,19 @@
|
|||
(clear-on-verify-handlers))))))
|
||||
|
||||
(fx/defn unblock-pin
|
||||
{:events [:hardwallet/unblock-pin]}
|
||||
{:events [:keycard/unblock-pin]}
|
||||
[cofx]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:on-card-connected :hardwallet/unblock-pin
|
||||
{:on-card-connected :keycard/unblock-pin
|
||||
:handler
|
||||
(fn [{:keys [db]}]
|
||||
(let [puk (common/vector->string (get-in db [:hardwallet :pin :puk]))
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :reset]))
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
(let [puk (common/vector->string (get-in db [:keycard :pin :puk]))
|
||||
pin (common/vector->string (get-in db [:keycard :pin :reset]))
|
||||
key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
pairing (common/get-pairing db key-uid)]
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
:hardwallet/unblock-pin
|
||||
{:db (assoc-in db [:keycard :pin :status] :verifying)
|
||||
:keycard/unblock-pin
|
||||
{:puk puk
|
||||
:new-pin pin
|
||||
:pairing pairing}}))}))
|
||||
|
@ -262,40 +262,40 @@
|
|||
|
||||
(fx/defn handle-pin-input
|
||||
[{:keys [db]} enter-step]
|
||||
(let [numbers-entered (count (get-in db [:hardwallet :pin enter-step]))]
|
||||
(let [numbers-entered (count (get-in db [:keycard :pin enter-step]))]
|
||||
(when (or (= numbers-entered pin-code-length)
|
||||
(= numbers-entered puk-code-length))
|
||||
{:dispatch [:hardwallet/process-pin-input]})))
|
||||
{:dispatch [:keycard/process-pin-input]})))
|
||||
|
||||
(fx/defn update-pin
|
||||
{:events [:hardwallet.ui/pin-numpad-button-pressed]}
|
||||
{:events [:keycard.ui/pin-numpad-button-pressed]}
|
||||
[{:keys [db] :as cofx} number enter-step]
|
||||
(log/debug "update-pin" enter-step)
|
||||
(let [numbers-entered (count (get-in db [:hardwallet :pin enter-step]))
|
||||
(let [numbers-entered (count (get-in db [:keycard :pin enter-step]))
|
||||
need-update? (if (= enter-step :puk)
|
||||
(< numbers-entered puk-code-length)
|
||||
(< numbers-entered pin-code-length))]
|
||||
(fx/merge cofx
|
||||
{:db (cond-> (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] enter-step)
|
||||
(assoc-in [:hardwallet :pin :status] nil))
|
||||
need-update? (update-in [:hardwallet :pin enter-step] (fnil conj []) number))}
|
||||
(assoc-in [:keycard :pin :enter-step] enter-step)
|
||||
(assoc-in [:keycard :pin :status] nil))
|
||||
need-update? (update-in [:keycard :pin enter-step] (fnil conj []) number))}
|
||||
(when need-update?
|
||||
(handle-pin-input enter-step)))))
|
||||
|
||||
(defn- pin-enter-error [fx error-label]
|
||||
(update-in fx [:db :hardwallet :pin] merge {:status :error
|
||||
:error-label error-label
|
||||
:enter-step :original
|
||||
:original []
|
||||
:confirmation []}))
|
||||
(update-in fx [:db :keycard :pin] merge {:status :error
|
||||
:error-label error-label
|
||||
:enter-step :original
|
||||
:original []
|
||||
:confirmation []}))
|
||||
|
||||
(defn- pin-reset-error [fx error-label]
|
||||
(update-in fx [:db :hardwallet :pin] merge {:status :error
|
||||
:error-label error-label
|
||||
:enter-step :reset
|
||||
:reset []
|
||||
:reset-confirmation []}))
|
||||
(update-in fx [:db :keycard :pin] merge {:status :error
|
||||
:error-label error-label
|
||||
:enter-step :reset
|
||||
:reset []
|
||||
:reset-confirmation []}))
|
||||
|
||||
; PIN enter steps:
|
||||
; login - PIN is used to login
|
||||
|
@ -304,15 +304,15 @@
|
|||
; original - new PIN when user changes it or creates new one
|
||||
; confirmation - confirmation for new PIN
|
||||
(fx/defn process-pin-input
|
||||
{:events [:hardwallet/process-pin-input]}
|
||||
{:events [:keycard/process-pin-input]}
|
||||
[{:keys [db]}]
|
||||
(let [enter-step (get-in db [:hardwallet :pin :enter-step])
|
||||
pin (get-in db [:hardwallet :pin enter-step])
|
||||
(let [enter-step (get-in db [:keycard :pin :enter-step])
|
||||
pin (get-in db [:keycard :pin enter-step])
|
||||
numbers-entered (count pin)]
|
||||
(log/debug "[hardwallet] process-pin-input"
|
||||
(log/debug "[keycard] process-pin-input"
|
||||
"enter-step" enter-step
|
||||
"numbers-entered" numbers-entered)
|
||||
(cond-> {:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(cond-> {:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
|
||||
(and (= enter-step :login)
|
||||
(= 6 numbers-entered))
|
||||
|
@ -348,28 +348,28 @@
|
|||
(unblock-pin)
|
||||
|
||||
(and (= enter-step :confirmation)
|
||||
(= (get-in db [:hardwallet :pin :original])
|
||||
(get-in db [:hardwallet :pin :confirmation])))
|
||||
(= (get-in db [:keycard :pin :original])
|
||||
(get-in db [:keycard :pin :confirmation])))
|
||||
(change-pin/change-pin)
|
||||
|
||||
(and (= enter-step :confirmation)
|
||||
(= pin-code-length numbers-entered)
|
||||
(not= (get-in db [:hardwallet :pin :original])
|
||||
(get-in db [:hardwallet :pin :confirmation])))
|
||||
(not= (get-in db [:keycard :pin :original])
|
||||
(get-in db [:keycard :pin :confirmation])))
|
||||
(pin-enter-error :t/pin-mismatch)
|
||||
|
||||
(= enter-step :reset)
|
||||
(proceed-to-pin-reset-confirmation)
|
||||
|
||||
(and (= enter-step :reset-confirmation)
|
||||
(= (get-in db [:hardwallet :pin :reset])
|
||||
(get-in db [:hardwallet :pin :reset-confirmation])))
|
||||
(= (get-in db [:keycard :pin :reset])
|
||||
(get-in db [:keycard :pin :reset-confirmation])))
|
||||
(proceed-to-puk-confirmation)
|
||||
|
||||
(and (= enter-step :reset-confirmation)
|
||||
(= pin-code-length numbers-entered)
|
||||
(not= (get-in db [:hardwallet :pin :reset])
|
||||
(get-in db [:hardwallet :pin :reset-confirmation])))
|
||||
(not= (get-in db [:keycard :pin :reset])
|
||||
(get-in db [:keycard :pin :reset-confirmation])))
|
||||
(pin-reset-error :t/pin-mismatch))))
|
||||
|
||||
(fx/defn set-multiaccount-pairing
|
||||
|
@ -381,9 +381,9 @@
|
|||
:keycard-paired-on paired-on {})))
|
||||
|
||||
(fx/defn on-retrieve-pairings-success
|
||||
{:events [:hardwallet.callback/on-retrieve-pairings-success]}
|
||||
{:events [:keycard.callback/on-retrieve-pairings-success]}
|
||||
[{:keys [db]} pairings]
|
||||
{:db (assoc-in db [:hardwallet :pairings] pairings)})
|
||||
{:db (assoc-in db [:keycard :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
|
||||
|
@ -393,26 +393,26 @@
|
|||
;; unfinished setup.
|
||||
|
||||
(fx/defn on-pair-success
|
||||
{:events [:hardwallet.callback/on-pair-success]}
|
||||
{:events [:keycard.callback/on-pair-success]}
|
||||
[{:keys [db] :as cofx} pairing]
|
||||
(let [setup-step (get-in db [:hardwallet :setup-step])
|
||||
flow (get-in db [:hardwallet :flow])
|
||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
(let [setup-step (get-in db [:keycard :setup-step])
|
||||
flow (get-in db [:keycard :flow])
|
||||
instance-uid (get-in db [:keycard :application-info :instance-uid])
|
||||
multiaccount (common/find-multiaccount-by-keycard-instance-uid db instance-uid)
|
||||
paired-on (utils.datetime/timestamp)
|
||||
pairings (assoc (get-in db [:hardwallet :pairings]) instance-uid {:pairing pairing
|
||||
:paired-on paired-on})
|
||||
pairings (assoc (get-in db [:keycard :pairings]) instance-uid {:pairing pairing
|
||||
:paired-on paired-on})
|
||||
next-step (if (= setup-step :pair)
|
||||
:begin
|
||||
:card-ready)]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/persist-pairings pairings
|
||||
{:keycard/persist-pairings pairings
|
||||
:db (-> db
|
||||
(assoc-in [:hardwallet :pairings] pairings)
|
||||
(assoc-in [:hardwallet :application-info :paired?] true)
|
||||
(assoc-in [:hardwallet :setup-step] next-step)
|
||||
(assoc-in [:hardwallet :secrets :pairing] pairing)
|
||||
(assoc-in [:hardwallet :secrets :paired-on] paired-on))}
|
||||
(assoc-in [:keycard :pairings] pairings)
|
||||
(assoc-in [:keycard :application-info :paired?] true)
|
||||
(assoc-in [:keycard :setup-step] next-step)
|
||||
(assoc-in [:keycard :secrets :pairing] pairing)
|
||||
(assoc-in [:keycard :secrets :paired-on] paired-on))}
|
||||
(common/hide-connection-sheet)
|
||||
(when multiaccount
|
||||
(set-multiaccount-pairing multiaccount pairing paired-on))
|
||||
|
@ -428,19 +428,19 @@
|
|||
(mnemonic/set-mnemonic)))))
|
||||
|
||||
(fx/defn on-pair-error
|
||||
{:events [:hardwallet.callback/on-pair-error]}
|
||||
{:events [:keycard.callback/on-pair-error]}
|
||||
[{:keys [db] :as cofx} {:keys [error code]}]
|
||||
(log/debug "[hardwallet] pair error: " error)
|
||||
(let [setup-step (get-in db [:hardwallet :setup-step])
|
||||
(log/debug "[keycard] pair error: " error)
|
||||
(let [setup-step (get-in db [:keycard :setup-step])
|
||||
tag-was-lost? (common/tag-lost? error)
|
||||
flow (get-in db [:hardwallet :flow])]
|
||||
(log/debug "[hardwallet] on-pair-error" setup-step "flow:" flow)
|
||||
flow (get-in db [:keycard :flow])]
|
||||
(log/debug "[keycard] on-pair-error" setup-step "flow:" flow)
|
||||
(when-not tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-error] (i18n/label :t/invalid-pairing-password))}
|
||||
{:db (assoc-in db [:keycard :setup-error] (i18n/label :t/invalid-pairing-password))}
|
||||
(common/set-on-card-connected (if (= setup-step :pairing)
|
||||
:hardwallet/load-pairing-screen
|
||||
:hardwallet/pair))
|
||||
:keycard/load-pairing-screen
|
||||
:keycard/pair))
|
||||
(common/hide-connection-sheet)
|
||||
(when (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pair nil))
|
||||
|
@ -449,7 +449,7 @@
|
|||
|
||||
(fx/defn set-setup-step
|
||||
[{:keys [db]} card-state]
|
||||
{:db (assoc-in db [:hardwallet :setup-step]
|
||||
{:db (assoc-in db [:keycard :setup-step]
|
||||
(case card-state
|
||||
:not-paired :pair
|
||||
:no-pairing-slots :no-slots
|
||||
|
@ -466,19 +466,19 @@
|
|||
;; NOTE: Maybe replaced by multiple events based on on flow to make it easier to maintain.
|
||||
;; Because there are many execution paths it is harder to follow all possible states.
|
||||
(fx/defn check-card-state
|
||||
{:events [:hardwallet/check-card-state]}
|
||||
{:events [:keycard/check-card-state]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [app-info (get-in db [:hardwallet :application-info])
|
||||
flow (get-in db [:hardwallet :flow])
|
||||
(let [app-info (get-in db [:keycard :application-info])
|
||||
flow (get-in db [:keycard :flow])
|
||||
{:keys [instance-uid key-uid]} app-info
|
||||
pairing (common/get-pairing db key-uid)
|
||||
app-info' (if pairing (assoc app-info :paired? true) app-info)
|
||||
card-state (common/get-card-state app-info')]
|
||||
(log/debug "[hardwallet] check-card-state"
|
||||
(log/debug "[keycard] check-card-state"
|
||||
"card-state" card-state
|
||||
"flow" flow)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :card-state] card-state)}
|
||||
{:db (assoc-in db [:keycard :card-state] card-state)}
|
||||
(set-setup-step card-state)
|
||||
(common/hide-connection-sheet)
|
||||
|
||||
|
@ -513,18 +513,18 @@
|
|||
(show-keycard-has-multiaccount-alert)))))
|
||||
|
||||
(fx/defn on-card-connected
|
||||
{:events [:hardwallet.callback/on-card-connected]}
|
||||
{:events [:keycard.callback/on-card-connected]}
|
||||
[{:keys [db]} _]
|
||||
(log/debug "[hardwallet] card globally connected")
|
||||
{:db (assoc-in db [:hardwallet :card-connected?] true)})
|
||||
(log/debug "[keycard] card globally connected")
|
||||
{:db (assoc-in db [:keycard :card-connected?] true)})
|
||||
|
||||
(fx/defn on-card-disconnected
|
||||
{:events [:hardwallet.callback/on-card-disconnected]}
|
||||
{:events [:keycard.callback/on-card-disconnected]}
|
||||
[{:keys [db]} _]
|
||||
(log/debug "[hardwallet] card disconnected")
|
||||
{:db (assoc-in db [:hardwallet :card-connected?] false)})
|
||||
(log/debug "[keycard] card disconnected")
|
||||
{:db (assoc-in db [:keycard :card-connected?] false)})
|
||||
|
||||
(fx/defn on-register-card-events
|
||||
{:events [:hardwallet.callback/on-register-card-events]}
|
||||
{:events [:keycard.callback/on-register-card-events]}
|
||||
[{:keys [db]} listeners]
|
||||
{:db (update-in db [:hardwallet :listeners] merge listeners)})
|
||||
{:db (update-in db [:keycard :listeners] merge listeners)})
|
|
@ -0,0 +1,70 @@
|
|||
(ns status-im.keycard.core-test)
|
||||
|
||||
;;TODO re-enable after fixing keycard flow
|
||||
#_(deftest process-pin-input
|
||||
(testing "start entering PIN"
|
||||
(is (= {:db {:keycard {:pin {:original [1]
|
||||
:confirmation []
|
||||
:status nil
|
||||
:enter-step :original}}}}
|
||||
(keycard/process-pin-input {:db {:keycard {:pin {:original [1]
|
||||
:confirmation []
|
||||
:enter-step :original}}}}))))
|
||||
(testing "first 6 numbers entered"
|
||||
(is (= {:db {:keycard {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation []
|
||||
:status nil
|
||||
:enter-step :confirmation}}}}
|
||||
(keycard/process-pin-input {:db {:keycard {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation []
|
||||
:enter-step :original}}}}))))
|
||||
(testing "confirmation entered"
|
||||
(is (= {:db {:keycard {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 6]
|
||||
:current [1 1 1 1 1 1]
|
||||
:enter-step :confirmation
|
||||
:status :verifying}
|
||||
:card-connected? true}}
|
||||
:keycard/change-pin {:new-pin "123456"
|
||||
:current-pin "111111"
|
||||
:pairing nil}}
|
||||
(keycard/process-pin-input {:db {:keycard {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 6]
|
||||
:current [1 1 1 1 1 1]
|
||||
:enter-step :confirmation}
|
||||
:card-connected? true}}}))))
|
||||
|
||||
(testing "confirmation doesn't match"
|
||||
(is (= {:db {:keycard {:pin {:original []
|
||||
:confirmation []
|
||||
:enter-step :original
|
||||
:error-label :t/pin-mismatch
|
||||
:status :error}}}}
|
||||
(keycard/process-pin-input {:db {:keycard {:pin {:original [1 2 3 4 5 6]
|
||||
:confirmation [1 2 3 4 5 7]
|
||||
:enter-step :confirmation}}}})))))
|
||||
|
||||
#_(deftest on-generate-and-load-key-success
|
||||
(is (= (select-keys
|
||||
(get-in
|
||||
(keycard/on-generate-and-load-key-success
|
||||
{:random-guid-generator (constantly "")
|
||||
:signing-phrase ""
|
||||
:status ""
|
||||
:db {}}
|
||||
#js {"whisper-private-key" "f342f3ef17ce86abfa92b912b3a108a4546cfc687fd8e0f02fedf87a60ee4c0f"
|
||||
"whisper-public-key" "04de2e21f1642ebee03b9aa4bf1936066124cc89967eaf269544c9b90c539fd5c980166a897d06dd4d3732b38116239f63c89395a8d73eac72881fab802010cb56"
|
||||
"encryption-public-key" "04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8"
|
||||
"whisper-address" "87df2285f90b71221fab6267b7cb37532fedbb1f"
|
||||
"wallet-address" "7e92236392a850980d00d0cd2a4b92886bd7fe7b"})
|
||||
[:db :keycard :multiaccount])
|
||||
[:whisper-private-key
|
||||
:whisper-public-key
|
||||
:encryption-public-key
|
||||
:wallet-address
|
||||
:whisper-address]))
|
||||
{:whisper-private-key "f342f3ef17ce86abfa92b912b3a108a4546cfc687fd8e0f02fedf87a60ee4c0f"
|
||||
:whisper-public-key "0x04de2e21f1642ebee03b9aa4bf1936066124cc89967eaf269544c9b90c539fd5c980166a897d06dd4d3732b38116239f63c89395a8d73eac72881fab802010cb56"
|
||||
:encryption-public-key "04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8"
|
||||
:whisper-address "87df2285f90b71221fab6267b7cb37532fedbb1f"
|
||||
:wallet-address "7e92236392a850980d00d0cd2a4b92886bd7fe7b"}))
|
|
@ -1,23 +1,23 @@
|
|||
(ns status-im.hardwallet.delete-key
|
||||
(ns status-im.keycard.delete-key
|
||||
(:require [status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
[status-im.keycard.common :as common]))
|
||||
|
||||
(fx/defn on-delete-success
|
||||
{:events [:hardwallet.callback/on-delete-success]}
|
||||
{:events [:keycard.callback/on-delete-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [key-uid (get-in db [:multiaccount :key-uid])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :multiaccounts/multiaccounts dissoc key-uid)
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(assoc-in [:hardwallet :application-info] nil)
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
(assoc-in [:keycard :secrets] nil)
|
||||
(assoc-in [:keycard :application-info] nil)
|
||||
(assoc-in [:keycard :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
;;FIXME delete multiaccount
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-reseted)}}
|
||||
|
@ -25,14 +25,14 @@
|
|||
(multiaccounts.logout/logout))))
|
||||
|
||||
(fx/defn on-delete-error
|
||||
{:events [:hardwallet.callback/on-delete-error]}
|
||||
{:events [:keycard.callback/on-delete-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] delete error" error)
|
||||
(log/debug "[keycard] delete error" error)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil})
|
||||
:hardwallet/get-application-info nil
|
||||
{:db (assoc-in db [:keycard :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil})
|
||||
:keycard/get-application-info nil
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
(common/clear-on-card-connected)
|
||||
|
@ -45,35 +45,35 @@
|
|||
|
||||
(fx/defn delete-card
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
(let [key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
multiaccount-key-uid (get-in db [:multiaccount :key-uid])]
|
||||
(if (and key-uid
|
||||
(= key-uid multiaccount-key-uid))
|
||||
{:hardwallet/delete nil}
|
||||
{:keycard/delete nil}
|
||||
(common/unauthorized-operation cofx))))
|
||||
|
||||
(fx/defn navigate-to-reset-card-screen
|
||||
{:events [:hardwallet/navigate-to-reset-card-screen]}
|
||||
{:events [:keycard/navigate-to-reset-card-screen]}
|
||||
[cofx]
|
||||
(navigation/navigate-to-cofx cofx :reset-card nil))
|
||||
|
||||
(fx/defn reset-card-next-button-pressed
|
||||
{:events [:keycard-settings.ui/reset-card-next-button-pressed]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:hardwallet :reset-card :disabled?] true)
|
||||
:dispatch [:hardwallet/proceed-to-reset-card]})
|
||||
{:db (assoc-in db [:keycard :reset-card :disabled?] true)
|
||||
:dispatch [:keycard/proceed-to-reset-card]})
|
||||
|
||||
(fx/defn proceed-to-reset-card
|
||||
{:events [:hardwallet/proceed-to-reset-card]}
|
||||
{:events [:keycard/proceed-to-reset-card]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin-retry-counter (get-in db [:hardwallet :application-info :pin-retry-counter])
|
||||
(let [pin-retry-counter (get-in db [:keycard :application-info :pin-retry-counter])
|
||||
enter-step (if (zero? pin-retry-counter) :puk :current)]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :hardwallet/remove-key-with-unpair})}
|
||||
(common/set-on-card-connected :hardwallet/navigate-to-enter-pin-screen)
|
||||
{:db (assoc-in db [:keycard :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :keycard/remove-key-with-unpair})}
|
||||
(common/set-on-card-connected :keycard/navigate-to-enter-pin-screen)
|
||||
(common/navigate-to-enter-pin-screen))))
|
|
@ -0,0 +1,45 @@
|
|||
(ns status-im.keycard.export-key
|
||||
(:require [status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.keycard.wallet :as wallet]
|
||||
[status-im.keycard.common :as common]))
|
||||
|
||||
(fx/defn on-export-key-error
|
||||
{:events [:keycard.callback/on-export-key-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[keycard] export key error" error)
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(cond tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
(common/set-on-card-connected :wallet.accounts/generate-new-keycard-account))
|
||||
|
||||
(re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (update-in db [:keycard :pin] merge {:status :error
|
||||
:enter-step :export-key
|
||||
:puk []
|
||||
:current []
|
||||
:original []
|
||||
:confirmation []
|
||||
:sign []
|
||||
:export-key []
|
||||
:error-label :t/pin-mismatch})}
|
||||
(common/hide-connection-sheet)
|
||||
(common/get-application-info (common/get-pairing db) nil))
|
||||
|
||||
:else
|
||||
(fx/merge cofx
|
||||
(common/show-wrong-keycard-alert true)
|
||||
(common/clear-pin)
|
||||
(common/hide-connection-sheet)))))
|
||||
|
||||
(fx/defn on-export-key-success
|
||||
{:events [:keycard.callback/on-export-key-success]}
|
||||
[{:keys [db] :as cofx} pubkey]
|
||||
(let [callback-fn (get-in db [:keycard :on-export-success])]
|
||||
(fx/merge cofx
|
||||
{:dispatch (callback-fn pubkey)}
|
||||
(wallet/hide-pin-sheet)
|
||||
(common/clear-pin)
|
||||
(common/hide-connection-sheet))))
|
|
@ -1,101 +1,101 @@
|
|||
(ns status-im.hardwallet.fx
|
||||
(ns status-im.keycard.fx
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.hardwallet.card :as card]
|
||||
[status-im.keycard.card :as card]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.platform :as platform]
|
||||
["react-native" :refer (AsyncStorage BackHandler)]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/get-application-info
|
||||
:keycard/get-application-info
|
||||
card/get-application-info)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/check-nfc-support
|
||||
:keycard/check-nfc-support
|
||||
card/check-nfc-support)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/check-nfc-enabled
|
||||
:keycard/check-nfc-enabled
|
||||
card/check-nfc-enabled)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/open-nfc-settings
|
||||
:keycard/open-nfc-settings
|
||||
card/open-nfc-settings)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/install-applet-and-init-card
|
||||
:keycard/install-applet-and-init-card
|
||||
card/install-applet-and-init-card)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/init-card
|
||||
:keycard/init-card
|
||||
card/init-card)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/register-card-events
|
||||
:keycard/register-card-events
|
||||
card/register-card-events)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-event-listeners
|
||||
:keycard/remove-event-listeners
|
||||
card/remove-event-listeners)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/pair
|
||||
:keycard/pair
|
||||
card/pair)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/generate-and-load-key
|
||||
:keycard/generate-and-load-key
|
||||
card/generate-and-load-key)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/unblock-pin
|
||||
:keycard/unblock-pin
|
||||
card/unblock-pin)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/verify-pin
|
||||
:keycard/verify-pin
|
||||
card/verify-pin)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/change-pin
|
||||
:keycard/change-pin
|
||||
card/change-pin)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/unpair
|
||||
:keycard/unpair
|
||||
card/unpair)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/delete
|
||||
:keycard/delete
|
||||
card/delete)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-key
|
||||
:keycard/remove-key
|
||||
card/remove-key)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-key-with-unpair
|
||||
:keycard/remove-key-with-unpair
|
||||
card/remove-key-with-unpair)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/export-key
|
||||
:keycard/export-key
|
||||
card/export-key)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/unpair-and-delete
|
||||
:keycard/unpair-and-delete
|
||||
card/unpair-and-delete)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/get-keys
|
||||
:keycard/get-keys
|
||||
card/get-keys)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/sign
|
||||
:keycard/sign
|
||||
card/sign)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/sign-typed-data
|
||||
:keycard/sign-typed-data
|
||||
card/sign-typed-data)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/login-with-keycard
|
||||
:keycard/login-with-keycard
|
||||
card/login)
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -103,39 +103,39 @@
|
|||
card/send-transaction-with-signature)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/persist-pairings
|
||||
:keycard/persist-pairings
|
||||
(fn [pairings]
|
||||
(.. AsyncStorage
|
||||
(setItem "status-keycard-pairings" (types/serialize pairings)))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/retrieve-pairings
|
||||
:keycard/retrieve-pairings
|
||||
(fn []
|
||||
(when platform/android?
|
||||
(.. AsyncStorage
|
||||
(getItem "status-keycard-pairings")
|
||||
(then #(re-frame/dispatch [:hardwallet.callback/on-retrieve-pairings-success
|
||||
(then #(re-frame/dispatch [:keycard.callback/on-retrieve-pairings-success
|
||||
(types/deserialize %)]))))))
|
||||
|
||||
;; TODO: Should act differently on different views
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/listen-to-hardware-back-button
|
||||
:keycard/listen-to-hardware-back-button
|
||||
;;NOTE: not done in view because effect should happen under different conditions and is not dependent on
|
||||
;;particular screen to be loaded. An fx is easier to re-use and test.
|
||||
(fn []
|
||||
(re-frame/dispatch [:hardwallet/add-listener-to-hardware-back-button
|
||||
(re-frame/dispatch [:keycard/add-listener-to-hardware-back-button
|
||||
(.addEventListener BackHandler "hardwareBackPress"
|
||||
(fn []
|
||||
(re-frame/dispatch [:hardwallet/back-button-pressed])
|
||||
(re-frame/dispatch [:keycard/back-button-pressed])
|
||||
true))])))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/remove-listener-to-hardware-back-button
|
||||
:keycard/remove-listener-to-hardware-back-button
|
||||
(fn [^js listener]
|
||||
(.remove listener)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/generate-name-and-photo
|
||||
:keycard/generate-name-and-photo
|
||||
(fn [{:keys [public-key on-success]}]
|
||||
(status/gfycat-identicon-async
|
||||
public-key
|
||||
|
@ -144,5 +144,5 @@
|
|||
[on-success whisper-name photo-path])))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:hardwallet/save-multiaccount-and-login
|
||||
:keycard/save-multiaccount-and-login
|
||||
card/save-multiaccount-and-login)
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.hardwallet.ios-keycard
|
||||
(:require [status-im.hardwallet.keycard :as keycard]))
|
||||
(ns status-im.keycard.ios-keycard
|
||||
(:require [status-im.keycard.keycard :as keycard]))
|
||||
|
||||
(defrecord IOSKeycard []
|
||||
keycard/Keycard
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.hardwallet.keycard)
|
||||
(ns status-im.keycard.keycard)
|
||||
|
||||
(defprotocol Keycard
|
||||
(check-nfc-support [this args])
|
|
@ -1,13 +1,13 @@
|
|||
(ns status-im.hardwallet.login
|
||||
(ns status-im.keycard.login
|
||||
(:require [status-im.ethereum.core :as ethereum]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.types :as types]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.hardwallet.recovery :as recovery]
|
||||
[status-im.hardwallet.onboarding :as onboarding]
|
||||
status-im.hardwallet.fx
|
||||
[status-im.keycard.common :as common]
|
||||
[status-im.keycard.recovery :as recovery]
|
||||
[status-im.keycard.onboarding :as onboarding]
|
||||
status-im.keycard.fx
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.signing.core :as signing.core]))
|
||||
|
||||
|
@ -40,14 +40,14 @@
|
|||
{:events [:keycard.login.ui/remember-me-changed]}
|
||||
[{:keys [db] :as cofx} value]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :remember-me?] value)}))
|
||||
{:db (assoc-in db [:keycard :remember-me?] value)}))
|
||||
|
||||
(fx/defn login-pair-card-pressed
|
||||
{:events [:keycard.login.ui/pair-card-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(log/debug "[hardwallet] load-pair-card-pressed")
|
||||
(log/debug "[keycard] load-pair-card-pressed")
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :login)}
|
||||
{:db (assoc-in db [:keycard :flow] :login)}
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pair nil)))
|
||||
|
||||
(fx/defn frozen-keycard-popup
|
||||
|
@ -59,14 +59,14 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc db :hardwallet/new-account-sheet? false)}
|
||||
{:db (assoc db :keycard/new-account-sheet? false)}
|
||||
(signing.core/discard)
|
||||
(fn [{:keys [db]}]
|
||||
{:db (-> db
|
||||
(dissoc :popover/popover)
|
||||
(update-in [:hardwallet :pin] dissoc
|
||||
(update-in [:keycard :pin] dissoc
|
||||
:reset :puk)
|
||||
(update-in [:hardwallet :pin] assoc
|
||||
(update-in [:keycard :pin] assoc
|
||||
:enter-step :reset
|
||||
:error nil
|
||||
:status nil))})
|
||||
|
@ -80,16 +80,16 @@
|
|||
[{:keys [db]}]
|
||||
{:db (-> db
|
||||
(dissoc :popover/popover)
|
||||
(update :hardwallet dissoc :setup-step))})
|
||||
(update :keycard dissoc :setup-step))})
|
||||
|
||||
(fx/defn login-with-keycard
|
||||
{:events [:hardwallet/login-with-keycard]}
|
||||
{:events [:keycard/login-with-keycard]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [:pin-retry-counter :puk-retry-counter]
|
||||
:as application-info}
|
||||
(get-in db [:hardwallet :application-info])
|
||||
(get-in db [:keycard :application-info])
|
||||
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :key-uid])])
|
||||
multiaccount-key-uid (get multiaccount :key-uid)
|
||||
multiaccount-mismatch? (or (nil? multiaccount)
|
||||
|
@ -132,16 +132,16 @@
|
|||
(fx/defn proceed-to-login
|
||||
{:events [::login-after-reset]}
|
||||
[cofx]
|
||||
(log/debug "[hardwallet] proceed-to-login")
|
||||
(log/debug "[keycard] proceed-to-login")
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:sheet-options {:on-cancel [::common/cancel-sheet-confirm]}
|
||||
:on-card-connected :hardwallet/get-application-info
|
||||
:on-card-read :hardwallet/login-with-keycard
|
||||
:handler (common/get-application-info nil :hardwallet/login-with-keycard)}))
|
||||
:on-card-connected :keycard/get-application-info
|
||||
:on-card-read :keycard/login-with-keycard
|
||||
:handler (common/get-application-info nil :keycard/login-with-keycard)}))
|
||||
|
||||
(fx/defn on-hardwallet-keychain-keys
|
||||
{:events [:multiaccounts.login.callback/get-hardwallet-keys-success]}
|
||||
(fx/defn on-keycard-keychain-keys
|
||||
{:events [:multiaccounts.login.callback/get-keycard-keys-success]}
|
||||
[{:keys [db] :as cofx} key-uid [encryption-public-key whisper-private-key :as creds]]
|
||||
(if (nil? creds)
|
||||
(navigation/navigate-to-cofx cofx :keycard-login-pin nil)
|
||||
|
@ -154,18 +154,18 @@
|
|||
:whisper-private-key whisper-private-key}]
|
||||
{:db
|
||||
(-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(assoc-in [:hardwallet :pin :login] [])
|
||||
(assoc-in [:hardwallet :multiaccount]
|
||||
(assoc-in [:keycard :pin :status] nil)
|
||||
(assoc-in [:keycard :pin :login] [])
|
||||
(assoc-in [:keycard :multiaccount]
|
||||
(update account-data :whisper-public-key ethereum/normalized-hex))
|
||||
(assoc-in [:hardwallet :flow] nil)
|
||||
(assoc-in [:keycard :flow] nil)
|
||||
(update :multiaccounts/login assoc
|
||||
:password encryption-public-key
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path
|
||||
:name name
|
||||
:save-password? true))
|
||||
:hardwallet/login-with-keycard
|
||||
:keycard/login-with-keycard
|
||||
{:multiaccount-data multiaccount-data
|
||||
:password encryption-public-key
|
||||
:chat-key whisper-private-key}})))
|
|
@ -1,13 +1,13 @@
|
|||
(ns status-im.hardwallet.mnemonic
|
||||
(ns status-im.keycard.mnemonic
|
||||
(:require [status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
status-im.hardwallet.fx))
|
||||
[status-im.keycard.common :as common]
|
||||
status-im.keycard.fx))
|
||||
|
||||
(fx/defn set-mnemonic
|
||||
[{:keys [db] :as cofx}]
|
||||
(log/debug "[hardwallet] set-mnemonic")
|
||||
(log/debug "[keycard] set-mnemonic")
|
||||
(let [selected-id (get-in db [:intro-wizard :selected-id])
|
||||
mnemonic (reduce
|
||||
(fn [_ {:keys [id mnemonic]}]
|
||||
|
@ -18,18 +18,18 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :recovery-phrase)
|
||||
(assoc-in [:hardwallet :secrets :mnemonic] mnemonic))}
|
||||
(assoc-in [:keycard :setup-step] :recovery-phrase)
|
||||
(assoc-in [:keycard :secrets :mnemonic] mnemonic))}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-replace :keycard-onboarding-recovery-phrase nil))))
|
||||
|
||||
(fx/defn load-loading-keys-screen
|
||||
{:events [:hardwallet.ui/recovery-phrase-confirm-pressed
|
||||
:hardwallet/load-loading-keys-screen]}
|
||||
{:events [:keycard.ui/recovery-phrase-confirm-pressed
|
||||
:keycard/load-loading-keys-screen]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :loading-keys)}
|
||||
{:db (assoc-in db [:keycard :setup-step] :loading-keys)}
|
||||
(common/show-connection-sheet
|
||||
{:on-card-connected :hardwallet/load-loading-keys-screen
|
||||
:handler (common/dispatch-event :hardwallet/generate-and-load-key)})))
|
||||
{:on-card-connected :keycard/load-loading-keys-screen
|
||||
:handler (common/dispatch-event :keycard/generate-and-load-key)})))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.hardwallet.nfc)
|
||||
(ns status-im.keycard.nfc)
|
||||
|
||||
(def is-nfc-supported? (atom nil))
|
||||
|
|
@ -1,62 +1,62 @@
|
|||
(ns status-im.hardwallet.onboarding
|
||||
(ns status-im.keycard.onboarding
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.hardwallet.mnemonic :as mnemonic]
|
||||
[status-im.keycard.common :as common]
|
||||
[status-im.keycard.mnemonic :as mnemonic]
|
||||
[taoensso.timbre :as log]
|
||||
status-im.hardwallet.fx
|
||||
status-im.keycard.fx
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(fx/defn begin-setup-button-pressed
|
||||
{:keys [:hardwallet.ui/begin-setup-button-pressed]}
|
||||
{:keys [:keycard.ui/begin-setup-button-pressed]}
|
||||
[{:keys [db]}]
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :pin)
|
||||
(assoc-in [:hardwallet :pin :enter-step] :original)
|
||||
(assoc-in [:hardwallet :pin :original] [])
|
||||
(assoc-in [:hardwallet :pin :confirmation] []))})
|
||||
(assoc-in [:keycard :setup-step] :pin)
|
||||
(assoc-in [:keycard :pin :enter-step] :original)
|
||||
(assoc-in [:keycard :pin :original] [])
|
||||
(assoc-in [:keycard :pin :confirmation] []))})
|
||||
|
||||
(fx/defn start-installation
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [card-state (get-in db [:hardwallet :card-state])
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :original]))]
|
||||
(let [card-state (get-in db [:keycard :card-state])
|
||||
pin (common/vector->string (get-in db [:keycard :pin :original]))]
|
||||
(log/debug "start-installation: card-state" card-state)
|
||||
(case card-state
|
||||
|
||||
:pre-init
|
||||
{:hardwallet/init-card pin}
|
||||
{:keycard/init-card pin}
|
||||
|
||||
(do
|
||||
(log/debug (str "Cannot start keycard installation from state: " card-state))
|
||||
(fx/merge cofx
|
||||
{:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
(navigation/navigate-to-cofx :hardwallet-authentication-method nil))))))
|
||||
(navigation/navigate-to-cofx :keycard-authentication-method nil))))))
|
||||
|
||||
(fx/defn load-preparing-screen
|
||||
{:events [:hardwallet/load-preparing-screen]}
|
||||
{:events [:keycard/load-preparing-screen]}
|
||||
[cofx]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:sheet-options {:on-cancel [::cancel-pressed]}
|
||||
:on-card-connected :hardwallet/load-preparing-screen
|
||||
:on-card-connected :keycard/load-preparing-screen
|
||||
:handler start-installation}))
|
||||
|
||||
(fx/defn load-pairing-screen
|
||||
{:events [:hardwallet/load-pairing-screen
|
||||
{:events [:keycard/load-pairing-screen
|
||||
:keycard.onboarding.puk-code.ui/confirm-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :pairing)}
|
||||
{:db (assoc-in db [:keycard :setup-step] :pairing)}
|
||||
(common/show-connection-sheet
|
||||
{:sheet-options {:on-cancel [::cancel-pressed]}
|
||||
:on-card-connected :hardwallet/load-pairing-screen
|
||||
:handler (common/dispatch-event :hardwallet/pair)})))
|
||||
:on-card-connected :keycard/load-pairing-screen
|
||||
:handler (common/dispatch-event :keycard/pair)})))
|
||||
|
||||
(fx/defn puk-code-next-pressed
|
||||
{:events [:keycard.onboarding.puk-code.ui/next-pressed]}
|
||||
|
@ -70,15 +70,15 @@
|
|||
|
||||
(fx/defn load-finishing-screen
|
||||
{:events [:keycard.onboarding.recovery-phrase-confirm-word2.ui/next-pressed
|
||||
:hardwallet/load-finishing-screen]}
|
||||
:keycard/load-finishing-screen]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-step] :loading-keys)}
|
||||
{:db (assoc-in db [:keycard :setup-step] :loading-keys)}
|
||||
(common/show-connection-sheet
|
||||
{:sheet-options {:on-cancel [::cancel-pressed]}
|
||||
:on-card-connected :hardwallet/load-finishing-screen
|
||||
:handler (common/dispatch-event :hardwallet/generate-and-load-key)})))
|
||||
:on-card-connected :keycard/load-finishing-screen
|
||||
:handler (common/dispatch-event :keycard/generate-and-load-key)})))
|
||||
|
||||
(fx/defn recovery-phrase-learn-more-pressed
|
||||
{:events [:keycard.onboarding.recovery-phrase.ui/learn-more-pressed]}
|
||||
|
@ -87,7 +87,7 @@
|
|||
|
||||
(fx/defn recovery-phrase-next-pressed
|
||||
{:events [:keycard.onboarding.recovery-phrase.ui/next-pressed
|
||||
:hardwallet.ui/recovery-phrase-next-button-pressed]}
|
||||
:keycard.ui/recovery-phrase-next-button-pressed]}
|
||||
[_]
|
||||
{:ui/show-confirmation {:title (i18n/label :t/keycard-recovery-phrase-confirmation-title)
|
||||
:content (i18n/label :t/keycard-recovery-phrase-confirmation-text)
|
||||
|
@ -98,18 +98,18 @@
|
|||
|
||||
(fx/defn recovery-phrase-start-confirmation
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [mnemonic (get-in db [:hardwallet :secrets :mnemonic])
|
||||
(let [mnemonic (get-in db [:keycard :secrets :mnemonic])
|
||||
[word1 word2] (shuffle (map-indexed vector (clojure.string/split mnemonic #" ")))
|
||||
word1 (zipmap [:idx :word] word1)
|
||||
word2 (zipmap [:idx :word] word2)]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :recovery-phrase-confirm-word1)
|
||||
(assoc-in [:hardwallet :recovery-phrase :step] :word1)
|
||||
(assoc-in [:hardwallet :recovery-phrase :confirm-error] nil)
|
||||
(assoc-in [:hardwallet :recovery-phrase :input-word] nil)
|
||||
(assoc-in [:hardwallet :recovery-phrase :word1] word1)
|
||||
(assoc-in [:hardwallet :recovery-phrase :word2] word2))}
|
||||
(assoc-in [:keycard :setup-step] :recovery-phrase-confirm-word1)
|
||||
(assoc-in [:keycard :recovery-phrase :step] :word1)
|
||||
(assoc-in [:keycard :recovery-phrase :confirm-error] nil)
|
||||
(assoc-in [:keycard :recovery-phrase :input-word] nil)
|
||||
(assoc-in [:keycard :recovery-phrase :word1] word1)
|
||||
(assoc-in [:keycard :recovery-phrase :word2] word2))}
|
||||
(common/remove-listener-to-hardware-back-button))))
|
||||
|
||||
(fx/defn recovery-phrase-confirm-pressed
|
||||
|
@ -122,10 +122,10 @@
|
|||
(fx/defn recovery-phrase-next-word
|
||||
[{:keys [db]}]
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :recovery-phrase :step] :word2)
|
||||
(assoc-in [:hardwallet :recovery-phrase :confirm-error] nil)
|
||||
(assoc-in [:hardwallet :recovery-phrase :input-word] nil)
|
||||
(assoc-in [:hardwallet :setup-step] :recovery-phrase-confirm-word2))})
|
||||
(assoc-in [:keycard :recovery-phrase :step] :word2)
|
||||
(assoc-in [:keycard :recovery-phrase :confirm-error] nil)
|
||||
(assoc-in [:keycard :recovery-phrase :input-word] nil)
|
||||
(assoc-in [:keycard :setup-step] :recovery-phrase-confirm-word2))})
|
||||
|
||||
(fx/defn recovery-phrase-confirm-word-back-pressed
|
||||
{:events [:keycard.onboarding.recovery-phrase-confirm-word.ui/back-pressed]}
|
||||
|
@ -136,15 +136,15 @@
|
|||
|
||||
(fx/defn proceed-with-generating-key
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin (get-in db [:hardwallet :secrets :pin]
|
||||
(common/vector->string (get-in db [:hardwallet :pin :current])))]
|
||||
(let [pin (get-in db [:keycard :secrets :pin]
|
||||
(common/vector->string (get-in db [:keycard :pin :current])))]
|
||||
(if (empty? pin)
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin] {:enter-step :current
|
||||
:on-verified :hardwallet/generate-and-load-key
|
||||
:current []})
|
||||
(assoc-in [:hardwallet :setup-step] :loading-keys))}
|
||||
(assoc-in [:keycard :pin] {:enter-step :current
|
||||
:on-verified :keycard/generate-and-load-key
|
||||
:current []})
|
||||
(assoc-in [:keycard :setup-step] :loading-keys))}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-pin nil))
|
||||
(load-finishing-screen cofx))))
|
||||
|
||||
|
@ -152,33 +152,33 @@
|
|||
{:events [:keycard.onboarding.recovery-phrase-confirm-word.ui/next-pressed
|
||||
:keycard.onboarding.recovery-phrase-confirm-word.ui/input-submitted]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [step (get-in db [:hardwallet :recovery-phrase :step])
|
||||
input-word (get-in db [:hardwallet :recovery-phrase :input-word])
|
||||
{:keys [word]} (get-in db [:hardwallet :recovery-phrase step])]
|
||||
(let [step (get-in db [:keycard :recovery-phrase :step])
|
||||
input-word (get-in db [:keycard :recovery-phrase :input-word])
|
||||
{:keys [word]} (get-in db [:keycard :recovery-phrase step])]
|
||||
(if (= word input-word)
|
||||
(if (= (:view-id db) :keycard-onboarding-recovery-phrase-confirm-word1)
|
||||
(fx/merge cofx
|
||||
(recovery-phrase-next-word)
|
||||
(navigation/navigate-replace :keycard-onboarding-recovery-phrase-confirm-word2 nil))
|
||||
(proceed-with-generating-key cofx))
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
{:db (assoc-in db [:keycard :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
|
||||
(fx/defn recovery-phrase-confirm-word-input-changed
|
||||
{:events [:keycard.onboarding.recovery-phrase-confirm-word.ui/input-changed]}
|
||||
[{:keys [db]} input]
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :input-word] input)})
|
||||
{:db (assoc-in db [:keycard :recovery-phrase :input-word] input)})
|
||||
|
||||
(fx/defn pair-code-input-changed
|
||||
{:events [:keycard.onboarding.pair.ui/input-changed]}
|
||||
[{:keys [db]} input]
|
||||
{:db (assoc-in db [:hardwallet :secrets :password] input)})
|
||||
{:db (assoc-in db [:keycard :secrets :password] input)})
|
||||
|
||||
(fx/defn keycard-option-pressed
|
||||
{:events [:onboarding.ui/keycard-option-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [flow (get-in db [:hardwallet :flow])]
|
||||
(let [flow (get-in db [:keycard :flow])]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/check-nfc-enabled nil}
|
||||
{:keycard/check-nfc-enabled nil}
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-intro nil)
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))))
|
||||
|
@ -187,74 +187,74 @@
|
|||
{:events [:keycard/start-onboarding-flow]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :create)
|
||||
:hardwallet/check-nfc-enabled nil}
|
||||
{:db (assoc-in db [:keycard :flow] :create)
|
||||
:keycard/check-nfc-enabled nil}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
|
||||
|
||||
(fx/defn open-nfc-settings-pressed
|
||||
{:events [:keycard.onboarding.nfc-on/open-nfc-settings-pressed]}
|
||||
[_]
|
||||
{:hardwallet/open-nfc-settings nil})
|
||||
{:keycard/open-nfc-settings nil})
|
||||
|
||||
(defn- show-recover-confirmation []
|
||||
{:ui/show-confirmation {:title (i18n/label :t/are-you-sure?)
|
||||
:content (i18n/label :t/are-you-sure-description)
|
||||
:confirm-button-text (clojure.string/upper-case (i18n/label :t/yes))
|
||||
:cancel-button-text (i18n/label :t/see-it-again)
|
||||
:on-accept #(re-frame/dispatch [:hardwallet.ui/recovery-phrase-confirm-pressed])
|
||||
:on-cancel #(re-frame/dispatch [:hardwallet.ui/recovery-phrase-cancel-pressed])}})
|
||||
:on-accept #(re-frame/dispatch [:keycard.ui/recovery-phrase-confirm-pressed])
|
||||
:on-cancel #(re-frame/dispatch [:keycard.ui/recovery-phrase-cancel-pressed])}})
|
||||
|
||||
(fx/defn recovery-phrase-confirm-word
|
||||
{:events [:hardwallet.ui/recovery-phrase-confirm-word-next-button-pressed]}
|
||||
{:events [:keycard.ui/recovery-phrase-confirm-word-next-button-pressed]}
|
||||
[{:keys [db]}]
|
||||
(let [step (get-in db [:hardwallet :recovery-phrase :step])
|
||||
input-word (get-in db [:hardwallet :recovery-phrase :input-word])
|
||||
{:keys [word]} (get-in db [:hardwallet :recovery-phrase step])]
|
||||
(let [step (get-in db [:keycard :recovery-phrase :step])
|
||||
input-word (get-in db [:keycard :recovery-phrase :input-word])
|
||||
{:keys [word]} (get-in db [:keycard :recovery-phrase step])]
|
||||
(if (= word input-word)
|
||||
(if (= step :word1)
|
||||
(recovery-phrase-next-word db)
|
||||
(show-recover-confirmation))
|
||||
{:db (assoc-in db [:hardwallet :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
{:db (assoc-in db [:keycard :recovery-phrase :confirm-error] (i18n/label :t/wrong-word))})))
|
||||
|
||||
(fx/defn recovery-phrase-next-button-pressed
|
||||
[{:keys [db] :as cofx}]
|
||||
(if (= (get-in db [:hardwallet :flow]) :create)
|
||||
(if (= (get-in db [:keycard :flow]) :create)
|
||||
(recovery-phrase-start-confirmation cofx)
|
||||
(let [mnemonic (get-in db [:multiaccounts/recover :passphrase])]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :secrets :mnemonic] mnemonic)}
|
||||
{:db (assoc-in db [:keycard :secrets :mnemonic] mnemonic)}
|
||||
(mnemonic/load-loading-keys-screen)))))
|
||||
|
||||
(fx/defn on-install-applet-and-init-card-success
|
||||
{:events [:hardwallet.callback/on-install-applet-and-init-card-success
|
||||
:hardwallet.callback/on-init-card-success]}
|
||||
{:events [:keycard.callback/on-install-applet-and-init-card-success
|
||||
:keycard.callback/on-init-card-success]}
|
||||
[{:keys [db] :as cofx} secrets]
|
||||
(let [secrets' (js->clj secrets :keywordize-keys true)]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/get-application-info nil
|
||||
{:keycard/get-application-info nil
|
||||
:db (-> db
|
||||
(assoc-in [:hardwallet :card-state] :init)
|
||||
(assoc-in [:hardwallet :setup-step] :secret-keys)
|
||||
(update-in [:hardwallet :secrets] merge secrets'))}
|
||||
(assoc-in [:keycard :card-state] :init)
|
||||
(assoc-in [:keycard :setup-step] :secret-keys)
|
||||
(update-in [:keycard :secrets] merge secrets'))}
|
||||
(common/hide-connection-sheet)
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-replace :keycard-onboarding-puk-code nil))))
|
||||
|
||||
(fx/defn on-install-applet-and-init-card-error
|
||||
{:events [:hardwallet.callback/on-install-applet-and-init-card-error
|
||||
:hardwallet.callback/on-init-card-error]}
|
||||
{:events [:keycard.callback/on-install-applet-and-init-card-error
|
||||
:keycard.callback/on-init-card-error]}
|
||||
[{:keys [db] :as cofx} {:keys [code error]}]
|
||||
(log/debug "[hardwallet] install applet and init card error: " error)
|
||||
(log/debug "[keycard] install applet and init card error: " error)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
||||
(common/set-on-card-connected :hardwallet/load-preparing-screen)
|
||||
{:db (assoc-in db [:keycard :setup-error] error)}
|
||||
(common/set-on-card-connected :keycard/load-preparing-screen)
|
||||
(common/process-error code error)))
|
||||
|
||||
(fx/defn generate-and-load-key
|
||||
{:events [:hardwallet/generate-and-load-key]}
|
||||
{:events [:keycard/generate-and-load-key]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [pairing pin]}
|
||||
(get-in db [:hardwallet :secrets])
|
||||
(get-in db [:keycard :secrets])
|
||||
|
||||
{:keys [selected-id multiaccounts]}
|
||||
(:intro-wizard db)
|
||||
|
@ -268,9 +268,9 @@
|
|||
recovery-mnemonic (get-in db [:intro-wizard :passphrase])
|
||||
mnemonic (or (:mnemonic multiaccount)
|
||||
recovery-mnemonic)
|
||||
pin' (or pin (common/vector->string (get-in db [:hardwallet :pin :current])))]
|
||||
pin' (or pin (common/vector->string (get-in db [:keycard :pin :current])))]
|
||||
(fx/merge cofx
|
||||
{:hardwallet/generate-and-load-key
|
||||
{:keycard/generate-and-load-key
|
||||
{:mnemonic mnemonic
|
||||
:pairing pairing
|
||||
:pin pin'}})))
|
||||
|
@ -281,16 +281,16 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(update :hardwallet
|
||||
(update :keycard
|
||||
dissoc :secrets :card-state :multiaccount-wallet-address
|
||||
:multiaccount-whisper-public-key
|
||||
:application-info)
|
||||
(assoc-in [:hardwallet :setup-step] :begin)
|
||||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||
(assoc-in [:keycard :setup-step] :begin)
|
||||
(assoc-in [:keycard :pin :on-verified] nil))}
|
||||
(common/show-connection-sheet
|
||||
{:on-card-connected :hardwallet/get-application-info
|
||||
:on-card-read :hardwallet/check-card-state
|
||||
:handler (common/get-application-info nil :hardwallet/check-card-state)})))
|
||||
{:on-card-connected :keycard/get-application-info
|
||||
:on-card-read :keycard/check-card-state
|
||||
:handler (common/get-application-info nil :keycard/check-card-state)})))
|
||||
|
||||
(fx/defn cancel-confirm
|
||||
{:events [::cancel-confirm]}
|
|
@ -1,10 +1,10 @@
|
|||
(ns status-im.hardwallet.real-keycard
|
||||
(ns status-im.keycard.real-keycard
|
||||
(:require ["react-native-status-keycard" :default status-keycard]
|
||||
["react-native" :as rn]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.hardwallet.keycard :as keycard]
|
||||
[status-im.keycard.keycard :as keycard]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defonce event-emitter (.-DeviceEventEmitter rn))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.hardwallet.recovery
|
||||
(ns status-im.keycard.recovery
|
||||
(:require [status-im.navigation :as navigation]
|
||||
[status-im.utils.datetime :as utils.datetime]
|
||||
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
|
@ -6,8 +6,8 @@
|
|||
[re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
status-im.hardwallet.fx
|
||||
[status-im.keycard.common :as common]
|
||||
status-im.keycard.fx
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
|
@ -15,37 +15,37 @@
|
|||
[status-im.utils.platform :as platform]))
|
||||
|
||||
(fx/defn pair* [_ password]
|
||||
{:hardwallet/pair {:password password}})
|
||||
{:keycard/pair {:password password}})
|
||||
|
||||
(fx/defn pair
|
||||
{:events [:hardwallet/pair]}
|
||||
{:events [:keycard/pair]}
|
||||
[cofx]
|
||||
(let [{:keys [password]} (get-in cofx [:db :hardwallet :secrets])]
|
||||
(let [{:keys [password]} (get-in cofx [:db :keycard :secrets])]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:on-card-connected :hardwallet/pair
|
||||
{:on-card-connected :keycard/pair
|
||||
:handler (pair* password)})))
|
||||
|
||||
(fx/defn pair-code-next-button-pressed
|
||||
{:events [:keycard.onboarding.pair.ui/input-submitted
|
||||
:hardwallet.ui/pair-code-next-button-pressed
|
||||
:keycard.ui/pair-code-next-button-pressed
|
||||
:keycard.onboarding.pair.ui/next-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pairing (get-in db [:hardwallet :secrets :pairing])
|
||||
paired-on (get-in db [:hardwallet :secrets :paired-on] (utils.datetime/timestamp))]
|
||||
(let [pairing (get-in db [:keycard :secrets :pairing])
|
||||
paired-on (get-in db [:keycard :secrets :paired-on] (utils.datetime/timestamp))]
|
||||
(fx/merge cofx
|
||||
(if pairing
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :import-multiaccount)
|
||||
(assoc-in [:hardwallet :secrets :paired-on] paired-on))}
|
||||
(assoc-in [:keycard :setup-step] :import-multiaccount)
|
||||
(assoc-in [:keycard :secrets :paired-on] paired-on))}
|
||||
(pair)))))
|
||||
|
||||
(fx/defn load-pair-screen
|
||||
[{:keys [db] :as cofx}]
|
||||
(log/debug "[hardwallet] load-pair-screen")
|
||||
(log/debug "[keycard] load-pair-screen")
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] :pair))
|
||||
(assoc-in [:keycard :setup-step] :pair))
|
||||
:dispatch [:bottom-sheet/hide]}
|
||||
(common/listen-to-hardware-back-button)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-pair nil)))
|
||||
|
@ -54,15 +54,15 @@
|
|||
{:events [:recovery.ui/keycard-storage-selected]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :recovery)}
|
||||
{:db (assoc-in db [:keycard :flow] :recovery)}
|
||||
(navigation/navigate-to-cofx :keycard-recovery-enter-mnemonic nil)))
|
||||
|
||||
(fx/defn start-import-flow
|
||||
{:events [::recover-with-keycard-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :import)
|
||||
:hardwallet/check-nfc-enabled nil}
|
||||
{:db (assoc-in db [:keycard :flow] :import)
|
||||
:keycard/check-nfc-enabled nil}
|
||||
(bottom-sheet/hide-bottom-sheet)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-intro nil)))
|
||||
|
||||
|
@ -75,8 +75,8 @@
|
|||
{:events [:recovery.ui/keycard-option-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :recovery)
|
||||
:hardwallet/check-nfc-enabled nil}
|
||||
{:db (assoc-in db [:keycard :flow] :recovery)
|
||||
:keycard/check-nfc-enabled nil}
|
||||
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
|
||||
|
||||
(fx/defn cancel-confirm
|
||||
|
@ -102,23 +102,23 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(update :hardwallet
|
||||
(update :keycard
|
||||
dissoc :secrets :card-state :multiaccount-wallet-address
|
||||
:multiaccount-whisper-public-key
|
||||
:application-info)
|
||||
(assoc-in [:hardwallet :setup-step] :begin)
|
||||
(assoc-in [:hardwallet :pin :on-verified] nil))}
|
||||
(assoc-in [:keycard :setup-step] :begin)
|
||||
(assoc-in [:keycard :pin :on-verified] nil))}
|
||||
(common/show-connection-sheet
|
||||
{:on-card-connected :hardwallet/get-application-info
|
||||
:on-card-read :hardwallet/check-card-state
|
||||
{:on-card-connected :keycard/get-application-info
|
||||
:on-card-read :keycard/check-card-state
|
||||
:sheet-options {:on-cancel [::cancel-pressed]}
|
||||
:handler (common/get-application-info nil :hardwallet/check-card-state)})))
|
||||
:handler (common/get-application-info nil :keycard/check-card-state)})))
|
||||
|
||||
(fx/defn recovery-success-finish-pressed
|
||||
{:events [:keycard.recovery.success/finish-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (update db :hardwallet dissoc
|
||||
{:db (update db :keycard dissoc
|
||||
:multiaccount-wallet-address
|
||||
:multiaccount-whisper-public-key)}
|
||||
(navigation/navigate-to-cofx (if platform/android?
|
||||
|
@ -128,13 +128,13 @@
|
|||
{:events [:keycard.recovery.no-key.ui/generate-key-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :flow] :create)
|
||||
:hardwallet/check-nfc-enabled nil}
|
||||
{:db (assoc-in db [:keycard :flow] :create)
|
||||
:keycard/check-nfc-enabled nil}
|
||||
(multiaccounts.create/intro-wizard)))
|
||||
|
||||
(fx/defn create-keycard-multiaccount
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{{:keys [multiaccount secrets flow]} :hardwallet} db
|
||||
(let [{{:keys [multiaccount secrets flow]} :keycard} db
|
||||
{:keys [address
|
||||
name
|
||||
photo-path
|
||||
|
@ -159,12 +159,12 @@
|
|||
;; if a name is still `nil` we have to generate it before multiaccount's
|
||||
;; creation otherwise spec validation will fail
|
||||
(if (nil? name)
|
||||
{:hardwallet/generate-name-and-photo
|
||||
{:keycard/generate-name-and-photo
|
||||
{:public-key whisper-public-key
|
||||
:on-success ::on-name-and-photo-generated}}
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :setup-step] nil)
|
||||
(assoc-in [:keycard :setup-step] nil)
|
||||
(dissoc :intro-wizard))}
|
||||
(multiaccounts.create/on-multiaccount-created
|
||||
{:derived {constants/path-wallet-root-keyword
|
||||
|
@ -193,14 +193,14 @@
|
|||
:notifications-settings :welcome) nil))))))
|
||||
|
||||
(fx/defn on-generate-and-load-key-success
|
||||
{:events [:hardwallet.callback/on-generate-and-load-key-success]
|
||||
{:events [:keycard.callback/on-generate-and-load-key-success]
|
||||
:interceptors [(re-frame/inject-cofx :random-guid-generator)
|
||||
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]}
|
||||
[{:keys [db random-guid-generator] :as cofx} data]
|
||||
(let [account-data (js->clj data :keywordize-keys true)]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :multiaccount]
|
||||
(assoc-in [:keycard :multiaccount]
|
||||
(-> account-data
|
||||
(update :address ethereum/normalized-hex)
|
||||
(update :whisper-address ethereum/normalized-hex)
|
||||
|
@ -210,53 +210,53 @@
|
|||
(update :whisper-public-key ethereum/normalized-hex)
|
||||
(update :wallet-public-key ethereum/normalized-hex)
|
||||
(update :wallet-root-public-key ethereum/normalized-hex)
|
||||
(update :instance-uid #(get-in db [:hardwallet :multiaccount :instance-uid] %))))
|
||||
(assoc-in [:hardwallet :multiaccount-wallet-address] (:wallet-address account-data))
|
||||
(assoc-in [:hardwallet :multiaccount-whisper-public-key] (:whisper-public-key account-data))
|
||||
(assoc-in [:hardwallet :application-info :key-uid]
|
||||
(update :instance-uid #(get-in db [:keycard :multiaccount :instance-uid] %))))
|
||||
(assoc-in [:keycard :multiaccount-wallet-address] (:wallet-address account-data))
|
||||
(assoc-in [:keycard :multiaccount-whisper-public-key] (:whisper-public-key account-data))
|
||||
(assoc-in [:keycard :application-info :key-uid]
|
||||
(ethereum/normalized-hex (:key-uid account-data)))
|
||||
(update :hardwallet dissoc :recovery-phrase)
|
||||
(update-in [:hardwallet :secrets] dissoc :pin :puk :password)
|
||||
(update :keycard dissoc :recovery-phrase)
|
||||
(update-in [:keycard :secrets] dissoc :pin :puk :password)
|
||||
(assoc :multiaccounts/new-installation-id (random-guid-generator))
|
||||
(update-in [:hardwallet :secrets] dissoc :mnemonic))}
|
||||
(update-in [:keycard :secrets] dissoc :mnemonic))}
|
||||
(common/remove-listener-to-hardware-back-button)
|
||||
(common/hide-connection-sheet)
|
||||
(create-keycard-multiaccount))))
|
||||
|
||||
(fx/defn on-generate-and-load-key-error
|
||||
{:events [:hardwallet.callback/on-generate-and-load-key-error]}
|
||||
{:events [:keycard.callback/on-generate-and-load-key-error]}
|
||||
[{:keys [db] :as cofx} {:keys [error code]}]
|
||||
(log/debug "[hardwallet] generate and load key error: " error)
|
||||
(log/debug "[keycard] generate and load key error: " error)
|
||||
(when-not (common/tag-lost? error)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :setup-error] error)}
|
||||
(common/set-on-card-connected :hardwallet/load-loading-keys-screen)
|
||||
{:db (assoc-in db [:keycard :setup-error] error)}
|
||||
(common/set-on-card-connected :keycard/load-loading-keys-screen)
|
||||
(common/process-error code error))))
|
||||
|
||||
(fx/defn import-multiaccount
|
||||
{:events [:hardwallet/import-multiaccount]}
|
||||
{:events [:keycard/import-multiaccount]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [pairing]} (get-in db [:hardwallet :secrets])
|
||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
(let [{:keys [pairing]} (get-in db [:keycard :secrets])
|
||||
instance-uid (get-in db [:keycard :application-info :instance-uid])
|
||||
key-uid (get-in db [:keycard :application-info :key-uid])
|
||||
pairing' (or pairing (common/get-pairing db key-uid))
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :import-multiaccount]))]
|
||||
pin (common/vector->string (get-in db [:keycard :pin :import-multiaccount]))]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :multiaccount :instance-uid] instance-uid)
|
||||
(assoc-in [:hardwallet :secrets] {:pairing pairing'
|
||||
:paired-on (utils.datetime/timestamp)}))
|
||||
:hardwallet/get-keys {:pairing pairing'
|
||||
:pin pin
|
||||
:on-success :hardwallet.callback/on-generate-and-load-key-success}})))
|
||||
(assoc-in [:keycard :multiaccount :instance-uid] instance-uid)
|
||||
(assoc-in [:keycard :secrets] {:pairing pairing'
|
||||
:paired-on (utils.datetime/timestamp)}))
|
||||
:keycard/get-keys {:pairing pairing'
|
||||
:pin pin
|
||||
:on-success :keycard.callback/on-generate-and-load-key-success}})))
|
||||
|
||||
(fx/defn load-recovering-key-screen
|
||||
{:events [:hardwallet/load-recovering-key-screen]}
|
||||
{:events [:keycard/load-recovering-key-screen]}
|
||||
[cofx]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:on-card-connected :hardwallet/load-recovering-key-screen
|
||||
:handler (common/dispatch-event :hardwallet/import-multiaccount)}))
|
||||
{:on-card-connected :keycard/load-recovering-key-screen
|
||||
:handler (common/dispatch-event :keycard/import-multiaccount)}))
|
||||
|
||||
(fx/defn on-name-and-photo-generated
|
||||
{:events [::on-name-and-photo-generated]
|
||||
|
@ -265,7 +265,7 @@
|
|||
[{:keys [db] :as cofx} whisper-name photo-path]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (update-in db [:hardwallet :multiaccount]
|
||||
{:db (update-in db [:keycard :multiaccount]
|
||||
(fn [multiacc]
|
||||
(assoc multiacc
|
||||
:name whisper-name
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.hardwallet.sign
|
||||
(ns status-im.keycard.sign
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
|
@ -6,21 +6,21 @@
|
|||
[status-im.utils.money :as money]
|
||||
[status-im.utils.types :as types]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.keycard.common :as common]
|
||||
[clojure.string :as clojure.string]))
|
||||
|
||||
(fx/defn sign
|
||||
{:events [:hardwallet/sign]}
|
||||
{:events [:keycard/sign]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [card-connected? (get-in db [:hardwallet :card-connected?])
|
||||
(let [card-connected? (get-in db [:keycard :card-connected?])
|
||||
pairing (common/get-pairing db)
|
||||
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 [:keycard :application-info :instance-uid])
|
||||
keycard-match? (= keycard-instance-uid instance-uid)
|
||||
hash (get-in db [:hardwallet :hash])
|
||||
data (get-in db [:hardwallet :data])
|
||||
typed? (get-in db [:hardwallet :typed?])
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))
|
||||
hash (get-in db [:keycard :hash])
|
||||
data (get-in db [:keycard :data])
|
||||
typed? (get-in db [:keycard :typed?])
|
||||
pin (common/vector->string (get-in db [:keycard :pin :sign]))
|
||||
from (get-in db [:signing/tx :from :address])
|
||||
path (reduce
|
||||
(fn [_ {:keys [address path]}]
|
||||
|
@ -31,17 +31,17 @@
|
|||
(if (and card-connected?
|
||||
keycard-match?)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] true)
|
||||
(assoc-in [:hardwallet :pin :status] :verifying))
|
||||
:hardwallet/sign {:hash (ethereum/naked-address hash)
|
||||
:data data
|
||||
:pairing pairing
|
||||
:typed? typed?
|
||||
:pin pin
|
||||
:path path}}
|
||||
(assoc-in [:keycard :card-read-in-progress?] true)
|
||||
(assoc-in [:keycard :pin :status] :verifying))
|
||||
:keycard/sign {:hash (ethereum/naked-address hash)
|
||||
:data data
|
||||
:pairing pairing
|
||||
:typed? typed?
|
||||
:pin pin
|
||||
:path path}}
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
||||
(common/set-on-card-connected :hardwallet/sign)
|
||||
(common/set-on-card-connected :keycard/sign)
|
||||
(when-not keycard-match?
|
||||
(common/show-wrong-keycard-alert card-connected?))))))
|
||||
|
||||
|
@ -52,36 +52,36 @@
|
|||
ethereum/normalized-hex))
|
||||
|
||||
(fx/defn sign-message
|
||||
{:events [:hardwallet/sign-message]}
|
||||
{:events [:keycard/sign-message]}
|
||||
[{:keys [db] :as cofx} params result]
|
||||
(let [{:keys [result error]} (types/json->clj result)
|
||||
on-success #(re-frame/dispatch [:hardwallet/on-sign-message-success params
|
||||
on-success #(re-frame/dispatch [:keycard/on-sign-message-success params
|
||||
(normalize-signature %)])
|
||||
hash (ethereum/naked-address result)
|
||||
card-connected? (get-in db [:hardwallet :card-connected?])
|
||||
card-connected? (get-in db [:keycard :card-connected?])
|
||||
pairing (common/get-pairing db)
|
||||
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 [:keycard :application-info :instance-uid])
|
||||
keycard-match? (= multiaccount-keycard-instance-uid instance-uid)
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))]
|
||||
pin (common/vector->string (get-in db [:keycard :pin :sign]))]
|
||||
(if (and card-connected?
|
||||
keycard-match?)
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] true)
|
||||
(assoc-in [:hardwallet :pin :status] :verifying))
|
||||
:hardwallet/sign {:hash (ethereum/naked-address hash)
|
||||
:data (:data params)
|
||||
:pairing pairing
|
||||
:pin pin
|
||||
:on-success on-success}}
|
||||
{:db (-> db
|
||||
(assoc-in [:keycard :card-read-in-progress?] true)
|
||||
(assoc-in [:keycard :pin :status] :verifying))
|
||||
:keycard/sign {:hash (ethereum/naked-address hash)
|
||||
:data (:data params)
|
||||
:pairing pairing
|
||||
:pin pin
|
||||
:on-success on-success}}
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
||||
(common/set-on-card-connected :hardwallet/sign)
|
||||
(common/set-on-card-connected :keycard/sign)
|
||||
(when-not keycard-match?
|
||||
(common/show-wrong-keycard-alert card-connected?))))))
|
||||
|
||||
(fx/defn on-sign-message-success
|
||||
{:events [:hardwallet/on-sign-message-success]}
|
||||
{:events [:keycard/on-sign-message-success]}
|
||||
[{:keys [db] :as cofx} {:keys [tx-hash message-id chat-id value contract]} signature]
|
||||
(fx/merge
|
||||
cofx
|
||||
|
@ -91,40 +91,40 @@
|
|||
[:sign/send-transaction-message chat-id value contract tx-hash signature])
|
||||
:signing/show-transaction-result nil
|
||||
:db (-> db
|
||||
(assoc-in [:hardwallet :pin :sign] [])
|
||||
(assoc-in [:hardwallet :pin :status] nil))}
|
||||
(assoc-in [:keycard :pin :sign] [])
|
||||
(assoc-in [:keycard :pin :status] nil))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/get-application-info (common/get-pairing db) nil)
|
||||
(common/hide-connection-sheet)))
|
||||
|
||||
(fx/defn sign-typed-data
|
||||
{:events [:hardwallet/sign-typed-data]}
|
||||
{:events [:keycard/sign-typed-data]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [card-connected? (get-in db [:hardwallet :card-connected?])
|
||||
hash (get-in db [:hardwallet :hash])]
|
||||
(let [card-connected? (get-in db [:keycard :card-connected?])
|
||||
hash (get-in db [:keycard :hash])]
|
||||
(if card-connected?
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :card-read-in-progress?] true)
|
||||
(assoc-in [:keycard :card-read-in-progress?] true)
|
||||
(assoc-in [:signing/sign :keycard-step] :signing))
|
||||
:hardwallet/sign-typed-data {:hash (ethereum/naked-address hash)}}
|
||||
:keycard/sign-typed-data {:hash (ethereum/naked-address hash)}}
|
||||
(fx/merge cofx
|
||||
(common/set-on-card-connected :hardwallet/sign-typed-data)
|
||||
(common/set-on-card-connected :keycard/sign-typed-data)
|
||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}))))
|
||||
|
||||
(fx/defn fetch-currency-symbol-on-success
|
||||
{:events [:hardwallet/fetch-currency-symbol-on-success]}
|
||||
{:events [:keycard/fetch-currency-symbol-on-success]}
|
||||
[{:keys [db] :as cofx} currency]
|
||||
{:db (assoc-in db [:signing/sign :formatted-data :message :formatted-currency] currency)})
|
||||
|
||||
(fx/defn fetch-currency-decimals-on-success
|
||||
{:events [:hardwallet/fetch-currency-decimals-on-success]}
|
||||
{:events [:keycard/fetch-currency-decimals-on-success]}
|
||||
[{:keys [db] :as cofx} decimals]
|
||||
{:db (update-in db [:signing/sign :formatted-data :message]
|
||||
#(assoc % :formatted-amount (.dividedBy ^js (money/bignumber (:amount %))
|
||||
(money/bignumber (money/from-decimal decimals)))))})
|
||||
|
||||
(fx/defn store-hash-and-sign-typed
|
||||
{:events [:hardwallet/store-hash-and-sign-typed]}
|
||||
{:events [:keycard/store-hash-and-sign-typed]}
|
||||
[{:keys [db] :as cofx} result]
|
||||
(let [{:keys [result error]} (types/json->clj result)
|
||||
message (get-in db [:signing/sign :formatted-data :message])
|
||||
|
@ -134,26 +134,26 @@
|
|||
:method "decimals()"
|
||||
:outputs ["uint8"]
|
||||
:on-success (fn [[decimals]]
|
||||
(re-frame/dispatch [:hardwallet/fetch-currency-decimals-on-success decimals]))})
|
||||
(re-frame/dispatch [:keycard/fetch-currency-decimals-on-success decimals]))})
|
||||
|
||||
(json-rpc/eth-call {:contract currency-contract
|
||||
:method "symbol()"
|
||||
:outputs ["string"]
|
||||
:on-success (fn [[currency]]
|
||||
(re-frame/dispatch [:hardwallet/fetch-currency-symbol-on-success currency]))}))
|
||||
(re-frame/dispatch [:keycard/fetch-currency-symbol-on-success currency]))}))
|
||||
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :hash] result)}
|
||||
{:db (assoc-in db [:keycard :hash] result)}
|
||||
sign-typed-data)))
|
||||
|
||||
(fx/defn prepare-to-sign
|
||||
{:events [:hardwallet/prepare-to-sign]}
|
||||
{:events [:keycard/prepare-to-sign]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pairing (common/get-pairing db)]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:on-card-connected :hardwallet/prepare-to-sign
|
||||
:handler (common/get-application-info pairing :hardwallet/sign)})))
|
||||
{:on-card-connected :keycard/prepare-to-sign
|
||||
:handler (common/get-application-info pairing :keycard/sign)})))
|
||||
|
||||
(fx/defn sign-message-completed
|
||||
[_ signature]
|
||||
|
@ -165,24 +165,24 @@
|
|||
{:send-transaction-with-signature data})
|
||||
|
||||
(fx/defn on-sign-success
|
||||
{:events [:hardwallet.callback/on-sign-success]}
|
||||
{:events [:keycard.callback/on-sign-success]}
|
||||
[{:keys [db] :as cofx} signature]
|
||||
(log/debug "[hardwallet] sign success: " signature)
|
||||
(log/debug "[keycard] sign success: " signature)
|
||||
(let [signature-json (types/clj->json {:result (normalize-signature signature)})
|
||||
transaction (get-in db [:hardwallet :transaction])
|
||||
transaction (get-in db [:keycard :transaction])
|
||||
tx-obj (select-keys transaction [:from :to :value :gas :gasPrice :command? :chat-id :message-id])
|
||||
command? (:command? transaction)]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :hash] nil)
|
||||
(assoc-in [:hardwallet :transaction] nil))}
|
||||
(assoc-in [:keycard :hash] nil)
|
||||
(assoc-in [:keycard :transaction] nil))}
|
||||
(when-not command?
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :sign] [])
|
||||
(assoc-in [:hardwallet :pin :status] nil))}
|
||||
(assoc-in [:keycard :pin :sign] [])
|
||||
(assoc-in [:keycard :pin :status] nil))}
|
||||
(common/clear-on-card-connected)
|
||||
(common/get-application-info (common/get-pairing db) nil)
|
||||
(common/hide-connection-sheet))))
|
||||
|
@ -194,19 +194,19 @@
|
|||
(sign-message-completed signature-json)))))
|
||||
|
||||
(fx/defn on-sign-error
|
||||
{:events [:hardwallet.callback/on-sign-error]}
|
||||
{:events [:keycard.callback/on-sign-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] sign error: " error)
|
||||
(log/debug "[keycard] sign error: " error)
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))
|
||||
pin-retries (get-in db [:hardwallet :application-info :pin-retry-counter])]
|
||||
pin-retries (get-in db [:keycard :application-info :pin-retry-counter])]
|
||||
(when-not tag-was-lost?
|
||||
(if (re-matches common/pin-mismatch-error (:error error))
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :application-info :pin-retry-counter] (dec pin-retries))
|
||||
(update-in [:hardwallet :pin] merge {:status :error
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})
|
||||
(assoc-in [:keycard :application-info :pin-retry-counter] (dec pin-retries))
|
||||
(update-in [:keycard :pin] merge {:status :error
|
||||
:sign []
|
||||
:error-label :t/pin-mismatch})
|
||||
(assoc-in [:signing/sign :keycard-step] :pin))}
|
||||
(common/hide-connection-sheet)
|
||||
(common/get-application-info (common/get-pairing db) nil)
|
|
@ -1,9 +1,9 @@
|
|||
(ns status-im.hardwallet.simulated-keycard
|
||||
(ns status-im.keycard.simulated-keycard
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[re-frame.db :as re-frame.db]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.hardwallet.keycard :as keycard]
|
||||
[status-im.keycard.keycard :as keycard]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.utils :as utils]
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.hardwallet.test-menu
|
||||
(ns status-im.keycard.test-menu
|
||||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.hardwallet.simulated-keycard :as simulated-keycard]))
|
||||
[status-im.keycard.simulated-keycard :as simulated-keycard]))
|
||||
|
||||
(defn button [label accessibility-label handler]
|
||||
[react/view
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.hardwallet.unpair
|
||||
(ns status-im.keycard.unpair
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
||||
|
@ -6,7 +6,7 @@
|
|||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.hardwallet.common :as common]))
|
||||
[status-im.keycard.common :as common]))
|
||||
|
||||
(fx/defn unpair-card-pressed
|
||||
{:events [:keycard-settings.ui/unpair-card-pressed]}
|
||||
|
@ -21,32 +21,32 @@
|
|||
(fx/defn unpair-card-confirmed
|
||||
{:events [:keycard-settings.ui/unpair-card-confirmed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pin-retry-counter (get-in db [:hardwallet :application-info :pin-retry-counter])
|
||||
(let [pin-retry-counter (get-in db [:keycard :application-info :pin-retry-counter])
|
||||
enter-step (if (zero? pin-retry-counter) :puk :current)]
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :hardwallet/unpair})}
|
||||
{:db (assoc-in db [:keycard :pin] {:enter-step enter-step
|
||||
:current []
|
||||
:puk []
|
||||
:status nil
|
||||
:error-label nil
|
||||
:on-verified :keycard/unpair})}
|
||||
(common/navigate-to-enter-pin-screen))))
|
||||
|
||||
(fx/defn unpair
|
||||
{:events [:hardwallet/unpair]}
|
||||
{:events [:keycard/unpair]}
|
||||
[{:keys [db]}]
|
||||
(let [pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
||||
(let [pin (common/vector->string (get-in db [:keycard :pin :current]))
|
||||
pairing (common/get-pairing db)]
|
||||
{:hardwallet/unpair {:pin pin
|
||||
:pairing pairing}}))
|
||||
{:keycard/unpair {:pin pin
|
||||
:pairing pairing}}))
|
||||
|
||||
(fx/defn unpair-and-delete
|
||||
{:events [:hardwallet/unpair-and-delete]}
|
||||
{:events [:keycard/unpair-and-delete]}
|
||||
[{:keys [db]}]
|
||||
(let [pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
||||
(let [pin (common/vector->string (get-in db [:keycard :pin :current]))
|
||||
pairing (common/get-pairing db)]
|
||||
{:hardwallet/unpair-and-delete {:pin pin
|
||||
:pairing pairing}}))
|
||||
{:keycard/unpair-and-delete {:pin pin
|
||||
:pairing pairing}}))
|
||||
|
||||
(fx/defn remove-pairing-from-multiaccount
|
||||
[cofx {:keys [remove-instance-uid?]}]
|
||||
|
@ -60,18 +60,18 @@
|
|||
:keycard-instance-uid nil {}))))
|
||||
|
||||
(fx/defn on-unpair-success
|
||||
{:events [:hardwallet.callback/on-unpair-success]}
|
||||
{:events [:keycard.callback/on-unpair-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
pairings (get-in db [:hardwallet :pairings])]
|
||||
(let [instance-uid (get-in db [:keycard :application-info :instance-uid])
|
||||
pairings (get-in db [:keycard :pairings])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(update-in [:hardwallet :pairings] dissoc (keyword instance-uid))
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:hardwallet/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
(assoc-in [:keycard :secrets] nil)
|
||||
(update-in [:keycard :pairings] dissoc (keyword instance-uid))
|
||||
(assoc-in [:keycard :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:keycard/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-unpaired)}}
|
||||
(common/clear-on-card-connected)
|
||||
|
@ -79,51 +79,51 @@
|
|||
(navigation/navigate-to-cofx :keycard-settings nil))))
|
||||
|
||||
(fx/defn on-unpair-error
|
||||
{:events [:hardwallet.callback/on-unpair-error]}
|
||||
{:events [:keycard.callback/on-unpair-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] unpair error" error)
|
||||
(log/debug "[keycard] unpair error" error)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil})
|
||||
:hardwallet/get-application-info nil
|
||||
{:db (assoc-in db [:keycard :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil})
|
||||
:keycard/get-application-info nil
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-to-cofx :keycard-settings nil)))
|
||||
|
||||
(fx/defn remove-key-with-unpair
|
||||
{:events [:hardwallet/remove-key-with-unpair]}
|
||||
{:events [:keycard/remove-key-with-unpair]}
|
||||
[cofx]
|
||||
(common/show-connection-sheet
|
||||
cofx
|
||||
{:on-card-connected :hardwallet/remove-key-with-unpair
|
||||
{:on-card-connected :keycard/remove-key-with-unpair
|
||||
:handler
|
||||
(fn [{:keys [db]}]
|
||||
(let [pin (common/vector->string (get-in db [:hardwallet :pin :current]))
|
||||
(let [pin (common/vector->string (get-in db [:keycard :pin :current]))
|
||||
pairing (common/get-pairing db)]
|
||||
{:hardwallet/remove-key-with-unpair
|
||||
{:keycard/remove-key-with-unpair
|
||||
{:pin pin
|
||||
:pairing pairing}}))}))
|
||||
|
||||
(fx/defn on-remove-key-success
|
||||
{:events [:hardwallet.callback/on-remove-key-success]}
|
||||
{:events [:keycard.callback/on-remove-key-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [key-uid (get-in db [:multiaccount :key-uid])
|
||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
pairings (get-in db [:hardwallet :pairings])]
|
||||
instance-uid (get-in db [:keycard :application-info :instance-uid])
|
||||
pairings (get-in db [:keycard :pairings])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :multiaccounts/multiaccounts dissoc key-uid)
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(update-in [:hardwallet :pairings] dissoc (keyword instance-uid))
|
||||
(assoc-in [:hardwallet :whisper-public-key] nil)
|
||||
(assoc-in [:hardwallet :wallet-address] nil)
|
||||
(assoc-in [:hardwallet :application-info] nil)
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:hardwallet/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
(assoc-in [:keycard :secrets] nil)
|
||||
(update-in [:keycard :pairings] dissoc (keyword instance-uid))
|
||||
(assoc-in [:keycard :whisper-public-key] nil)
|
||||
(assoc-in [:keycard :wallet-address] nil)
|
||||
(assoc-in [:keycard :application-info] nil)
|
||||
(assoc-in [:keycard :pin] {:status nil
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:keycard/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
;;FIXME delete multiaccount
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-reseted)}}
|
||||
|
@ -131,13 +131,13 @@
|
|||
(multiaccounts.logout/logout))))
|
||||
|
||||
(fx/defn on-remove-key-error
|
||||
{:events [:hardwallet.callback/on-remove-key-error]}
|
||||
{:events [:keycard.callback/on-remove-key-error]}
|
||||
[{:keys [db] :as cofx} error]
|
||||
(log/debug "[hardwallet] remove key error" error)
|
||||
(log/debug "[keycard] remove key error" error)
|
||||
(let [tag-was-lost? (common/tag-lost? (:error error))]
|
||||
(fx/merge cofx
|
||||
(if tag-was-lost?
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:hardwallet :pin :status] nil)}
|
||||
(common/set-on-card-connected :hardwallet/remove-key-with-unpair))
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
(common/set-on-card-connected :keycard/remove-key-with-unpair))
|
||||
(common/show-wrong-keycard-alert true)))))
|
|
@ -1,20 +1,20 @@
|
|||
(ns status-im.hardwallet.wallet
|
||||
(ns status-im.keycard.wallet
|
||||
(:require [status-im.ethereum.core :as ethereum]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.keycard.common :as common]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.utils.hex :as utils.hex]))
|
||||
|
||||
(fx/defn show-pin-sheet
|
||||
{:events [:hardwallet/new-account-pin-sheet]}
|
||||
{:events [:keycard/new-account-pin-sheet]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] :export-key)
|
||||
(update-in [:hardwallet :pin] dissoc :export-key)
|
||||
(assoc :hardwallet/new-account-sheet? true))}))
|
||||
(assoc-in [:keycard :pin :enter-step] :export-key)
|
||||
(update-in [:keycard :pin] dissoc :export-key)
|
||||
(assoc :keycard/new-account-sheet? true))}))
|
||||
|
||||
(fx/defn verify-pin-with-delay
|
||||
[cofx]
|
||||
|
@ -24,20 +24,20 @@
|
|||
:dispatch [:wallet.accounts/verify-pin]}]})
|
||||
|
||||
(fx/defn hide-pin-sheet
|
||||
{:events [:hardwallet/new-account-pin-sheet-hide]}
|
||||
{:events [:keycard/new-account-pin-sheet-hide]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc db :hardwallet/new-account-sheet? false)})
|
||||
{:db (assoc db :keycard/new-account-sheet? false)})
|
||||
|
||||
(fx/defn generate-new-keycard-account
|
||||
{:events [:wallet.accounts/generate-new-keycard-account]}
|
||||
[{:keys [db]}]
|
||||
(let [path-num (inc (get-in db [:multiaccount :latest-derived-path]))
|
||||
path (str constants/path-wallet-root "/" path-num)
|
||||
pin (common/vector->string (get-in db [:hardwallet :pin :export-key]))
|
||||
pin (common/vector->string (get-in db [:keycard :pin :export-key]))
|
||||
pairing (common/get-pairing db)]
|
||||
{:db
|
||||
(assoc-in
|
||||
db [:hardwallet :on-export-success]
|
||||
db [:keycard :on-export-success]
|
||||
#(vector :wallet.accounts/account-stored
|
||||
(let [public-key (utils.hex/normalize-hex %)]
|
||||
{;; Strip leading 04 prefix denoting uncompressed key format
|
||||
|
@ -48,7 +48,7 @@
|
|||
:public-key (str "0x" public-key)
|
||||
:path path})))
|
||||
|
||||
:hardwallet/export-key {:pin pin :pairing pairing :path path}}))
|
||||
:keycard/export-key {:pin pin :pairing pairing :path path}}))
|
||||
|
||||
(fx/defn verify-pin
|
||||
{:events [:wallet.accounts/verify-pin]}
|
||||
|
@ -58,4 +58,4 @@
|
|||
{:pin-step :export-key
|
||||
:on-card-connected :wallet.accounts/verify-pin
|
||||
:on-success :wallet.accounts/generate-new-keycard-account
|
||||
:on-failure :hardwallet/new-account-pin-sheet}))
|
||||
:on-failure :keycard/new-account-pin-sheet}))
|
|
@ -5,7 +5,7 @@
|
|||
[status-im.data-store.settings :as data-store.settings]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.hardwallet.nfc :as nfc]
|
||||
[status-im.keycard.nfc :as nfc]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.multiaccounts.db :as db]
|
||||
[status-im.native-module.core :as status]
|
||||
|
@ -103,7 +103,7 @@
|
|||
{:events [:multiaccounts.create.ui/intro-wizard]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:db (update db :hardwallet dissoc :flow)}
|
||||
{:db (update db :keycard dissoc :flow)}
|
||||
(prepare-intro-wizard)
|
||||
(navigation/navigate-to-cofx :create-multiaccount-generate-key nil)))
|
||||
|
||||
|
@ -232,7 +232,7 @@
|
|||
|
||||
(fx/defn save-multiaccount-and-login-with-keycard
|
||||
[_ args]
|
||||
{:hardwallet/save-multiaccount-and-login args})
|
||||
{:keycard/save-multiaccount-and-login args})
|
||||
|
||||
(fx/defn save-account-and-login
|
||||
[_ key-uid multiaccount-data password settings node-config accounts-data]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.hardwallet.common :as hardwallet.common]
|
||||
[status-im.keycard.common :as keycard.common]
|
||||
[status-im.fleet.core :as fleet]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
|
@ -70,7 +70,7 @@
|
|||
{:db (-> db
|
||||
(assoc-in [:multiaccounts/login :processing] true)
|
||||
(dissoc :intro-wizard)
|
||||
(update :hardwallet dissoc :flow))
|
||||
(update :keycard dissoc :flow))
|
||||
::login [key-uid
|
||||
(types/clj->json {:name name
|
||||
:key-uid key-uid
|
||||
|
@ -79,10 +79,10 @@
|
|||
|
||||
(fx/defn finish-keycard-setup
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [flow (get-in db [:hardwallet :flow])]
|
||||
(let [flow (get-in db [:keycard :flow])]
|
||||
(when flow
|
||||
(fx/merge cofx
|
||||
{:db (update db :hardwallet dissoc :flow)}
|
||||
{:db (update db :keycard dissoc :flow)}
|
||||
(if (= :import flow)
|
||||
(navigation/navigate-to-cofx :intro-stack {:screen :keycard-recovery-success})
|
||||
(navigation/navigate-to-cofx (if platform/android?
|
||||
|
@ -251,7 +251,7 @@
|
|||
(initialize-wallet accounts nil))))
|
||||
|
||||
(defn- keycard-setup? [cofx]
|
||||
(boolean (get-in cofx [:db :hardwallet :flow])))
|
||||
(boolean (get-in cofx [:db :keycard :flow])))
|
||||
|
||||
(fx/defn multiaccount-login-success
|
||||
[{:keys [db now] :as cofx}]
|
||||
|
@ -267,7 +267,7 @@
|
|||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :connectivity/ui-status-properties)
|
||||
(update :hardwallet dissoc
|
||||
(update :keycard dissoc
|
||||
:on-card-read
|
||||
:card-read-in-progress?
|
||||
:pin
|
||||
|
@ -320,9 +320,9 @@
|
|||
cofx
|
||||
(when keycard-account?
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] :login)
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(assoc-in [:hardwallet :pin :login] []))})
|
||||
(assoc-in [:keycard :pin :enter-step] :login)
|
||||
(assoc-in [:keycard :pin :status] nil)
|
||||
(assoc-in [:keycard :pin :login] []))})
|
||||
(if keycard-account?
|
||||
(navigation/navigate-to-cofx :intro-stack {:screen :keycard-login-pin})
|
||||
(navigation/navigate-to-cofx :intro-stack {:screen :login}))))))
|
||||
|
@ -333,7 +333,7 @@
|
|||
(log/debug "[login] get-credentials"
|
||||
"keycard-multiacc?" keycard-multiaccount?)
|
||||
(if keycard-multiaccount?
|
||||
(keychain/get-hardwallet-keys cofx key-uid)
|
||||
(keychain/get-keycard-keys cofx key-uid)
|
||||
(keychain/get-user-password cofx key-uid))))
|
||||
|
||||
(fx/defn get-auth-method-success
|
||||
|
@ -354,8 +354,8 @@
|
|||
(= auth-method keychain/auth-method-password)
|
||||
(get-credentials % key-uid)
|
||||
(and keycard-multiaccount?
|
||||
(get-in db [:hardwallet :card-connected?]))
|
||||
(hardwallet.common/get-application-info % nil nil))
|
||||
(get-in db [:keycard :card-connected?]))
|
||||
(keycard.common/get-application-info % nil nil))
|
||||
(open-login-callback nil))))
|
||||
|
||||
(fx/defn biometric-auth-done
|
||||
|
|
|
@ -41,14 +41,14 @@
|
|||
(testing "login with keycard"
|
||||
(let [wpk "c56c7ac797c27b3790ce02c2459e9957c5d20d7a2c55320535526ce9e4dcbbef"
|
||||
epk "04f43da85ff1c333f3e7277b9ac4df92c9120fbb251f1dede7d41286e8c055acfeb845f6d2654821afca25da119daff9043530b296ee0e28e202ba92ec5842d617"
|
||||
db {:hardwallet {:multiaccount {:encryption-public-key epk
|
||||
:whisper-private-key wpk
|
||||
:wallet-address "83278851e290d2488b6add2a257259f5741a3b7d"
|
||||
:whisper-public-key "0x04491c1272149d7fa668afa45968c9914c0661641ace7dbcbc585c15070257840a0b4b1f71ce66c2147e281e1a44d6231b4731a26f6cc0a49e9616bbc7fc2f1a93"
|
||||
:whisper-address "b8bec30855ff20c2ddab32282e2b2c8c8baca70d"}}}
|
||||
db {:keycard {:multiaccount {:encryption-public-key epk
|
||||
:whisper-private-key wpk
|
||||
:wallet-address "83278851e290d2488b6add2a257259f5741a3b7d"
|
||||
:whisper-public-key "0x04491c1272149d7fa668afa45968c9914c0661641ace7dbcbc585c15070257840a0b4b1f71ce66c2147e281e1a44d6231b4731a26f6cc0a49e9616bbc7fc2f1a93"
|
||||
:whisper-address "b8bec30855ff20c2ddab32282e2b2c8c8baca70d"}}}
|
||||
result (login.core/login {:db db})]
|
||||
(is (= (-> result (get :hardwallet/login-with-keycard) keys count)
|
||||
(is (= (-> result (get :keycard/login-with-keycard) keys count)
|
||||
3))
|
||||
(is (= (get-in result [:hardwallet/login-with-keycard :whisper-private-key wpk])))
|
||||
(is (= (get-in result [:hardwallet/login-with-keycard :encryption-public-key epk])))
|
||||
(is (fn? (get-in result [:hardwallet/login-with-keycard :on-result]))))))
|
||||
(is (= (get-in result [:keycard/login-with-keycard :whisper-private-key wpk])))
|
||||
(is (= (get-in result [:keycard/login-with-keycard :encryption-public-key epk])))
|
||||
(is (fn? (get-in result [:keycard/login-with-keycard :on-result]))))))
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.mnemonic :as mnemonic]
|
||||
[status-im.hardwallet.nfc :as nfc]
|
||||
[status-im.keycard.nfc :as nfc]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
||||
[status-im.native-module.core :as status]
|
||||
|
@ -171,7 +171,7 @@
|
|||
:encrypt-with-password? true
|
||||
:back-action :intro-wizard/navigate-back
|
||||
:forward-action :multiaccounts.recover/enter-phrase-next-pressed})
|
||||
(update :hardwallet dissoc :flow))}
|
||||
(update :keycard dissoc :flow))}
|
||||
(bottom-sheet/hide-bottom-sheet)
|
||||
(navigation/navigate-to-cofx :recover-multiaccount-enter-phrase nil)))
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
:keys-dark (js/require "../resources/images/ui/keys-dark.jpg")
|
||||
:lock (js/require "../resources/images/ui/lock.png")
|
||||
:tribute-to-talk (js/require "../resources/images/ui/tribute-to-talk.png")
|
||||
:hardwallet-card (js/require "../resources/images/ui/hardwallet-card.png")
|
||||
:keycard-card (js/require "../resources/images/ui/hardwallet-card.png")
|
||||
:keycard-lock (js/require "../resources/images/ui/keycard-lock.png")
|
||||
:keycard (js/require "../resources/images/ui/keycard.png")
|
||||
:keycard-logo (js/require "../resources/images/ui/keycard-logo.png")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[status-im.ethereum.eip55 :as eip55]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.ethereum.tokens :as tokens]
|
||||
[status-im.hardwallet.common :as hardwallet.common]
|
||||
[status-im.keycard.common :as keycard.common]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.signing.keycard :as signing.keycard]
|
||||
|
@ -197,7 +197,7 @@
|
|||
(when pinless?
|
||||
(signing.keycard/hash-message {:data data
|
||||
:typed? true
|
||||
:on-completed #(re-frame/dispatch [:hardwallet/store-hash-and-sign-typed %])})))
|
||||
:on-completed #(re-frame/dispatch [:keycard/store-hash-and-sign-typed %])})))
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc updated-db
|
||||
|
@ -260,13 +260,13 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (dissoc db :signing/tx :signing/sign)}
|
||||
(if (hardwallet.common/keycard-multiaccount? db)
|
||||
(if (keycard.common/keycard-multiaccount? db)
|
||||
(signing.keycard/hash-message
|
||||
{:data data
|
||||
:on-completed
|
||||
(fn [hash]
|
||||
(re-frame/dispatch
|
||||
[:hardwallet/sign-message
|
||||
[:keycard/sign-message
|
||||
{:tx-hash transaction-hash
|
||||
:message-id message-id
|
||||
:chat-id chat-id
|
||||
|
@ -350,11 +350,11 @@
|
|||
(let [{:keys [on-error]} (get-in db [:signing/tx])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
(assoc-in [:keycard :pin :status] nil)
|
||||
(dissoc :signing/tx :signing/sign))}
|
||||
(check-queue)
|
||||
(hardwallet.common/hide-connection-sheet)
|
||||
(hardwallet.common/clear-pin)
|
||||
(keycard.common/hide-connection-sheet)
|
||||
(keycard.common/clear-pin)
|
||||
#(when on-error
|
||||
{:dispatch (conj on-error "transaction was cancelled by user")}))))
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
{:events [:signing.keycard.callback/hash-message-completed]}
|
||||
[{:keys [db]} data typed? result]
|
||||
(let [{:keys [result error]} (types/json->clj result)]
|
||||
{:db (update db :hardwallet assoc
|
||||
{:db (update db :keycard assoc
|
||||
:hash result
|
||||
:typed? typed?
|
||||
:data data)}))
|
||||
|
@ -78,9 +78,9 @@
|
|||
[{:keys [db]} original-tx result]
|
||||
(let [{:keys [transaction hash]} (:result (types/json->clj result))]
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :transaction]
|
||||
(assoc-in [:keycard :transaction]
|
||||
(merge original-tx transaction))
|
||||
(assoc-in [:hardwallet :hash] hash))}))
|
||||
(assoc-in [:keycard :hash] hash))}))
|
||||
|
||||
(fx/defn sign-with-keycard
|
||||
{:events [:signing.ui/sign-with-keycard-pressed]}
|
||||
|
@ -89,7 +89,7 @@
|
|||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :enter-step] :sign)
|
||||
(assoc-in [:keycard :pin :enter-step] :sign)
|
||||
(assoc-in [:signing/sign :type] :keycard)
|
||||
(assoc-in [:signing/sign :keycard-step] :pin))}
|
||||
#(if message
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
[status-im.wallet.db :as wallet.db]
|
||||
[status-im.wallet.utils :as wallet.utils]
|
||||
status-im.ui.screens.keycard.subs
|
||||
status-im.ui.screens.hardwallet.settings.subs
|
||||
status-im.ui.screens.hardwallet.pin.subs
|
||||
status-im.ui.screens.hardwallet.setup.subs))
|
||||
status-im.ui.screens.keycard.settings.subs
|
||||
status-im.ui.screens.keycard.pin.subs
|
||||
status-im.ui.screens.keycard.setup.subs))
|
||||
|
||||
;; TOP LEVEL ===========================================================================================================
|
||||
|
||||
|
@ -177,7 +177,7 @@
|
|||
(reg-root-key-sub :popover/popover :popover/popover)
|
||||
(reg-root-key-sub :add-account :add-account)
|
||||
|
||||
(reg-root-key-sub :keycard :hardwallet)
|
||||
(reg-root-key-sub :keycard :keycard)
|
||||
|
||||
(reg-root-key-sub :auth-method :auth-method)
|
||||
|
||||
|
@ -188,7 +188,7 @@
|
|||
(reg-root-key-sub ::pagination-info :pagination-info)
|
||||
|
||||
;; keycard
|
||||
(reg-root-key-sub :hardwallet/new-account-sheet? :hardwallet/new-account-sheet?)
|
||||
(reg-root-key-sub :keycard/new-account-sheet? :keycard/new-account-sheet?)
|
||||
|
||||
;;GENERAL ==============================================================================================================
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
(ns status-im.ui.screens.hardwallet.pin.subs
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/original-pin
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :original])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/login-pin
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :login])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-confirmation
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :confirmation])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-enter-step
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :enter-step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-operation
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :operation])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-data
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin
|
||||
:<- [:hardwallet/pin-data]
|
||||
:<- [:hardwallet/pin-enter-step]
|
||||
(fn [[pin-data step]]
|
||||
(get pin-data step)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-status
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :status])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-error-label
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :pin :error-label])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/frozen-card?
|
||||
(fn [db]
|
||||
(let [{:keys [pin-retry-counter]}
|
||||
(get-in db [:hardwallet :application-info])]
|
||||
(zero? pin-retry-counter))))
|
|
@ -1,105 +0,0 @@
|
|||
(ns status-im.ui.screens.hardwallet.setup.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[clojure.string :as string]
|
||||
[status-im.ethereum.core :as ethereum]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-setup-step
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :setup-step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-card-state
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :card-state])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-flow
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :flow])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-flow-steps
|
||||
(fn [db]
|
||||
(case (get-in db [:hardwallet :flow])
|
||||
:recovery "2"
|
||||
"3")))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-pair-code
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :secrets :password])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-recovery-phrase-word
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet
|
||||
:recovery-phrase
|
||||
(get-in db [:hardwallet :recovery-phrase :step])])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-recovery-phrase-input-word
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :recovery-phrase :input-word])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-recovery-phrase-confirm-error
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :recovery-phrase :confirm-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-recovery-phrase-step
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :recovery-phrase :step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-secrets
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :secrets])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-puk-code
|
||||
(fn [db]
|
||||
(->> (get-in db [:hardwallet :secrets :puk])
|
||||
(partition 4)
|
||||
(map clojure.string/join)
|
||||
(clojure.string/join " "))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-setup-error
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :setup-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-mnemonic
|
||||
(fn [db]
|
||||
(map-indexed vector
|
||||
(partition 3
|
||||
(map-indexed vector (clojure.string/split
|
||||
(get-in db [:hardwallet :secrets :mnemonic])
|
||||
#" "))))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-application-info
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :application-info])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-application-info-error
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :application-info-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-multiaccount
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :multiaccount])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-multiaccount-wallet-address
|
||||
(fn [db]
|
||||
(str "0x" (get-in db [:hardwallet :multiaccount-wallet-address]))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet-multiaccount-whisper-public-key
|
||||
(fn [db]
|
||||
(ethereum/normalized-hex (get-in db [:hardwallet :multiaccount-whisper-public-key]))))
|
|
@ -102,9 +102,8 @@
|
|||
{:accessibility-label (keyword (str "select-storage-" type))
|
||||
:on-press #(re-frame/dispatch
|
||||
[:intro-wizard/on-key-storage-selected
|
||||
(if (and config/hardwallet-enabled?
|
||||
(or platform/android?
|
||||
config/keycard-test-menu-enabled?))
|
||||
(if (or platform/android?
|
||||
config/keycard-test-menu-enabled?)
|
||||
type
|
||||
:default)])}
|
||||
[react/view (assoc (styles/list-item selected?)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.hardwallet.authentication-method.styles
|
||||
(ns status-im.ui.screens.keycard.authentication-method.styles
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def container
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.hardwallet.authentication-method.views
|
||||
(ns status-im.ui.screens.keycard.authentication-method.views
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.react-native.resources :as resources]
|
||||
|
@ -8,7 +8,7 @@
|
|||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.styles :as components.styles]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.hardwallet.authentication-method.styles
|
||||
[status-im.ui.screens.keycard.authentication-method.styles
|
||||
:as
|
||||
styles]))
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
title]]
|
||||
[vector-icons/icon :main-icons/next {:color colors/gray}]]])
|
||||
|
||||
(defn hardwallet-authentication-method []
|
||||
(defn keycard-authentication-method []
|
||||
[react/view styles/container
|
||||
[react/view components.styles/flex
|
||||
[topbar/topbar]
|
||||
|
@ -41,4 +41,4 @@
|
|||
:on-press #(re-frame/dispatch [:onboarding.ui/keycard-option-pressed])}]
|
||||
[authentication-method-row {:title (i18n/label :t/password)
|
||||
:icon :main-icons/password
|
||||
:on-press #(re-frame/dispatch [:hardwallet.ui/password-option-pressed])}]]]])
|
||||
:on-press #(re-frame/dispatch [:keycard.ui/password-option-pressed])}]]]])
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.ui.screens.keycard.components.keycard-animation
|
||||
(:require [reagent.core :as reagent]
|
||||
[status-im.hardwallet.card :as keycard-nfc]
|
||||
[status-im.keycard.card :as keycard-nfc]
|
||||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.components.animation :as animation]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
(ns status-im.ui.screens.hardwallet.frozen-card.view
|
||||
(ns status-im.ui.screens.keycard.frozen-card.view
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
[quo.core :as quo]
|
||||
[status-im.hardwallet.login :as login]
|
||||
[status-im.keycard.login :as login]
|
||||
[status-im.i18n :as i18n]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
(:title params)]])
|
||||
(when (:header params)
|
||||
[(:header params)])
|
||||
(if @(re-frame/subscribe [:hardwallet/nfc-enabled?])
|
||||
(if @(re-frame/subscribe [:keycard/nfc-enabled?])
|
||||
[card-sync-flow {:connected? connected?
|
||||
:params (select-keys params [:state-translations])
|
||||
:on-card-disconnected
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.ui.screens.keycard.onboarding.views
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.hardwallet.onboarding :as hardwallet.onboarding]
|
||||
[status-im.keycard.onboarding :as keycard.onboarding]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.toolbar :as bottom-toolbar]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
|
@ -10,14 +10,14 @@
|
|||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.components.tooltip.views :as tooltip]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[quo.core :as quo]
|
||||
[status-im.constants :as constants])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||
|
||||
(defview intro []
|
||||
(letsubs [flow [:hardwallet-flow]]
|
||||
(letsubs [flow [:keycard-flow]]
|
||||
[react/view styles/container
|
||||
[topbar/topbar]
|
||||
[react/view {:flex 1
|
||||
|
@ -89,14 +89,14 @@
|
|||
(i18n/label :t/begin-set-up)]]]]))
|
||||
|
||||
(defview puk-code []
|
||||
(letsubs [secrets [:hardwallet-secrets]
|
||||
steps [:hardwallet-flow-steps]
|
||||
puk-code [:hardwallet-puk-code]]
|
||||
(letsubs [secrets [:keycard-secrets]
|
||||
steps [:keycard-flow-steps]
|
||||
puk-code [:keycard-puk-code]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::keycard.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}
|
||||
|
@ -180,18 +180,18 @@
|
|||
(i18n/label :t/next)]}]]]]))
|
||||
|
||||
(defview pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
enter-step [:hardwallet/pin-enter-step]
|
||||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
steps [:hardwallet-flow-steps]
|
||||
(letsubs [pin [:keycard/pin]
|
||||
enter-step [:keycard/pin-enter-step]
|
||||
status [:keycard/pin-status]
|
||||
error-label [:keycard/pin-error-label]
|
||||
steps [:keycard-flow-steps]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
setup-step [:hardwallet-setup-step]]
|
||||
setup-step [:keycard-setup-step]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::keycard.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
(when-not (= setup-step :loading-keys)
|
||||
|
@ -232,12 +232,12 @@
|
|||
(i18n/label :t/you-will-need-this-code)]])]]))
|
||||
|
||||
(defview recovery-phrase []
|
||||
(letsubs [mnemonic [:hardwallet-mnemonic]]
|
||||
(letsubs [mnemonic [:keycard-mnemonic]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::keycard.onboarding/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
[react/text {:style {:color colors/gray}}
|
||||
|
@ -294,15 +294,15 @@
|
|||
(i18n/label :t/confirm)]}]]]))
|
||||
|
||||
(defview recovery-phrase-confirm-word []
|
||||
(letsubs [word [:hardwallet-recovery-phrase-word]
|
||||
input-word [:hardwallet-recovery-phrase-input-word]
|
||||
error [:hardwallet-recovery-phrase-confirm-error]]
|
||||
(letsubs [word [:keycard-recovery-phrase-word]
|
||||
input-word [:keycard-recovery-phrase-input-word]
|
||||
error [:keycard-recovery-phrase-confirm-error]]
|
||||
(let [{:keys [idx]} word]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [::hardwallet.onboarding/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::keycard.onboarding/cancel-pressed])
|
||||
:accessibility-label :cancel-keycard-setup
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.hardwallet.pin.styles
|
||||
(ns status-im.ui.screens.keycard.pin.styles
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def pin-container
|
|
@ -0,0 +1,56 @@
|
|||
(ns status-im.ui.screens.keycard.pin.subs
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/original-pin
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :original])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/login-pin
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :login])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-confirmation
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :confirmation])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-enter-step
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :enter-step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-operation
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :operation])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-data
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin
|
||||
:<- [:keycard/pin-data]
|
||||
:<- [:keycard/pin-enter-step]
|
||||
(fn [[pin-data step]]
|
||||
(get pin-data step)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-status
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :status])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/pin-error-label
|
||||
(fn [db]
|
||||
(get-in db [:keycard :pin :error-label])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard/frozen-card?
|
||||
(fn [db]
|
||||
(let [{:keys [pin-retry-counter]}
|
||||
(get-in db [:keycard :application-info])]
|
||||
(zero? pin-retry-counter))))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.hardwallet.pin.views
|
||||
(ns status-im.ui.screens.keycard.pin.views
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
|
@ -7,7 +7,7 @@
|
|||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.hardwallet.pin.styles :as styles]
|
||||
[status-im.ui.screens.keycard.pin.styles :as styles]
|
||||
[status-im.ui.components.checkbox.view :as checkbox]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.utils.utils :as utils]
|
||||
|
@ -19,7 +19,7 @@
|
|||
(defn numpad-button [n step enabled? small-screen?]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(when enabled?
|
||||
(re-frame/dispatch [:hardwallet.ui/pin-numpad-button-pressed n step]))}
|
||||
(re-frame/dispatch [:keycard.ui/pin-numpad-button-pressed n step]))}
|
||||
[react/view (styles/numpad-button small-screen?)
|
||||
[react/text {:style styles/numpad-button-text}
|
||||
n]]])
|
||||
|
@ -40,7 +40,7 @@
|
|||
[numpad-button 0 step enabled? small-screen?]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(when enabled?
|
||||
(re-frame/dispatch [:hardwallet.ui/pin-numpad-delete-button-pressed step]))}
|
||||
(re-frame/dispatch [:keycard.ui/pin-numpad-delete-button-pressed step]))}
|
||||
[react/view (styles/numpad-delete-button small-screen?)
|
||||
[vector-icons/icon :main-icons/backspace {:color colors/blue}]]]]])
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
|||
{:checked? save-password?
|
||||
:style {:margin-right 10}
|
||||
:on-value-change #(re-frame/dispatch [:multiaccounts/save-password %])}]
|
||||
[react/text (i18n/label :t/hardwallet-dont-ask-card)]])))
|
||||
[react/text (i18n/label :t/keycard-dont-ask-card)]])))
|
||||
|
||||
(defn bezier-easing []
|
||||
(.bezier ^js animation/easing 0.77, 0.000, 0.175, 1))
|
||||
|
@ -231,12 +231,12 @@
|
|||
(def puk-retries 5)
|
||||
|
||||
(defview enter-pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
step [:hardwallet/pin-enter-step]
|
||||
status [:hardwallet/pin-status]
|
||||
pin-retry-counter [:hardwallet/pin-retry-counter]
|
||||
puk-retry-counter [:hardwallet/puk-retry-counter]
|
||||
error-label [:hardwallet/pin-error-label]]
|
||||
(letsubs [pin [:keycard/pin]
|
||||
step [:keycard/pin-enter-step]
|
||||
status [:keycard/pin-status]
|
||||
pin-retry-counter [:keycard/pin-retry-counter]
|
||||
puk-retry-counter [:keycard/puk-retry-counter]
|
||||
error-label [:keycard/pin-error-label]]
|
||||
(let [;; TODO(rasom): retarded hack to prevent state mess on opening pin
|
||||
;; sheet on another tab and returning back to this screen. Should be
|
||||
;; properly rewritten so that different instances of pin-view do not
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.ui.screens.keycard.recovery.views
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.hardwallet.recovery :as hardwallet.recovery]
|
||||
[status-im.keycard.recovery :as keycard.recovery]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.components.react :as react]
|
||||
|
@ -10,7 +10,7 @@
|
|||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.tooltip.views :as tooltip]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[status-im.utils.core :as utils.core]
|
||||
[status-im.utils.gfycat.core :as gfy]
|
||||
|
@ -68,16 +68,16 @@
|
|||
(i18n/label :t/keycard-recovery-intro-button-text)]]]])
|
||||
|
||||
(defview pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
(letsubs [pin [:keycard/pin]
|
||||
status [:keycard/pin-status]
|
||||
error-label [:keycard/pin-error-label]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
retry-counter [:hardwallet/retry-counter]]
|
||||
retry-counter [:keycard/retry-counter]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
[toolbar/nav-text
|
||||
{:handler #(re-frame/dispatch [::hardwallet.recovery/cancel-pressed])
|
||||
{:handler #(re-frame/dispatch [::keycard.recovery/cancel-pressed])
|
||||
:style {:padding-left 21}}
|
||||
(i18n/label :t/cancel)]
|
||||
(when-not (#{:frozen-card :blocked-card} status)
|
||||
|
@ -110,9 +110,9 @@
|
|||
:step :import-multiaccount}]])]))
|
||||
|
||||
(defview pair []
|
||||
(letsubs [pair-code [:hardwallet-pair-code]
|
||||
error [:hardwallet-setup-error]
|
||||
{:keys [free-pairing-slots]} [:hardwallet-application-info]]
|
||||
(letsubs [pair-code [:keycard-pair-code]
|
||||
error [:keycard-setup-error]
|
||||
{:keys [free-pairing-slots]} [:keycard-application-info]]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
{:transparent? true}
|
||||
|
@ -163,8 +163,8 @@
|
|||
(i18n/label :t/pair-card)]}]]]))
|
||||
|
||||
(defview success []
|
||||
(letsubs [address [:hardwallet-multiaccount-wallet-address]
|
||||
whisper-public-key [:hardwallet-multiaccount-whisper-public-key]]
|
||||
(letsubs [address [:keycard-multiaccount-wallet-address]
|
||||
whisper-public-key [:keycard-multiaccount-whisper-public-key]]
|
||||
[react/view styles/container
|
||||
[topbar/topbar {:navigation :none}]
|
||||
[react/view {:flex 1
|
||||
|
@ -210,7 +210,7 @@
|
|||
(i18n/label :t/finish)]]]]))
|
||||
|
||||
(defview no-key []
|
||||
(letsubs [card-state [:hardwallet-card-state]]
|
||||
(letsubs [card-state [:keycard-card-state]]
|
||||
[react/view styles/container
|
||||
[topbar/topbar {:navigation :none}]
|
||||
[react/view {:flex 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.ui.screens.hardwallet.settings.subs
|
||||
(ns status-im.ui.screens.keycard.settings.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.hardwallet.common :as common]
|
||||
[status-im.keycard.common :as common]
|
||||
[status-im.utils.datetime :as utils.datetime]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
@ -15,26 +15,26 @@
|
|||
(get-in db [:multiaccount :keycard-pairing])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/pin-retry-counter
|
||||
:keycard/pin-retry-counter
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :application-info :pin-retry-counter])))
|
||||
(get-in db [:keycard :application-info :pin-retry-counter])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/puk-retry-counter
|
||||
:keycard/puk-retry-counter
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :application-info :puk-retry-counter])))
|
||||
(get-in db [:keycard :application-info :puk-retry-counter])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/retry-counter
|
||||
:<- [:hardwallet/pin-retry-counter]
|
||||
:<- [:hardwallet/puk-retry-counter]
|
||||
:keycard/retry-counter
|
||||
:<- [:keycard/pin-retry-counter]
|
||||
:<- [:keycard/puk-retry-counter]
|
||||
(fn [[pin puk]]
|
||||
(if (zero? pin) puk pin)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-reset-card-disabled?
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :reset-card :disabled?] false)))
|
||||
(get-in db [:keycard :reset-card :disabled?] false)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-multiaccount?
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.hardwallet.settings.views
|
||||
(ns status-im.ui.screens.keycard.settings.views
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.i18n :as i18n]
|
||||
|
@ -9,7 +9,7 @@
|
|||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ui.screens.keycard.views :as keycard.views]
|
||||
[status-im.hardwallet.common :as hardwallet.common]))
|
||||
[status-im.keycard.common :as keycard.common]))
|
||||
|
||||
(defn- activity-indicator [loading?]
|
||||
(when loading?
|
||||
|
@ -64,14 +64,14 @@
|
|||
|
||||
(defview keycard-settings []
|
||||
(letsubs [paired-on [:keycard-paired-on]
|
||||
puk-retry-counter [:hardwallet/puk-retry-counter]
|
||||
puk-retry-counter [:keycard/puk-retry-counter]
|
||||
pairing [:keycard-multiaccount-pairing]]
|
||||
[react/view {:flex 1}
|
||||
[topbar/topbar {:title :t/status-keycard}]
|
||||
[react/scroll-view {:flex 1}
|
||||
[react/view {:margin-top 47
|
||||
:align-items :center}
|
||||
[react/image {:source (resources/get-image :hardwallet-card)
|
||||
[react/image {:source (resources/get-image :keycard-card)
|
||||
:style {:width 255
|
||||
:height 160}}]
|
||||
(when paired-on
|
||||
|
@ -112,6 +112,6 @@
|
|||
(defn reset-pin []
|
||||
[keycard.views/login-pin
|
||||
{:back-button-handler
|
||||
::hardwallet.common/navigate-to-keycard-settings
|
||||
::keycard.common/navigate-to-keycard-settings
|
||||
:hide-login-actions? true
|
||||
:default-enter-step :reset}])
|
|
@ -0,0 +1,105 @@
|
|||
(ns status-im.ui.screens.keycard.setup.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[clojure.string :as string]
|
||||
[status-im.ethereum.core :as ethereum]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-setup-step
|
||||
(fn [db]
|
||||
(get-in db [:keycard :setup-step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-card-state
|
||||
(fn [db]
|
||||
(get-in db [:keycard :card-state])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-flow
|
||||
(fn [db]
|
||||
(get-in db [:keycard :flow])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-flow-steps
|
||||
(fn [db]
|
||||
(case (get-in db [:keycard :flow])
|
||||
:recovery "2"
|
||||
"3")))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-pair-code
|
||||
(fn [db]
|
||||
(get-in db [:keycard :secrets :password])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-recovery-phrase-word
|
||||
(fn [db]
|
||||
(get-in db [:keycard
|
||||
:recovery-phrase
|
||||
(get-in db [:keycard :recovery-phrase :step])])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-recovery-phrase-input-word
|
||||
(fn [db]
|
||||
(get-in db [:keycard :recovery-phrase :input-word])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-recovery-phrase-confirm-error
|
||||
(fn [db]
|
||||
(get-in db [:keycard :recovery-phrase :confirm-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-recovery-phrase-step
|
||||
(fn [db]
|
||||
(get-in db [:keycard :recovery-phrase :step])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-secrets
|
||||
(fn [db]
|
||||
(get-in db [:keycard :secrets])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-puk-code
|
||||
(fn [db]
|
||||
(->> (get-in db [:keycard :secrets :puk])
|
||||
(partition 4)
|
||||
(map clojure.string/join)
|
||||
(clojure.string/join " "))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-setup-error
|
||||
(fn [db]
|
||||
(get-in db [:keycard :setup-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-mnemonic
|
||||
(fn [db]
|
||||
(map-indexed vector
|
||||
(partition 3
|
||||
(map-indexed vector (clojure.string/split
|
||||
(get-in db [:keycard :secrets :mnemonic])
|
||||
#" "))))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-application-info
|
||||
(fn [db]
|
||||
(get-in db [:keycard :application-info])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-application-info-error
|
||||
(fn [db]
|
||||
(get-in db [:keycard :application-info-error])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-multiaccount
|
||||
(fn [db]
|
||||
(get-in db [:keycard :multiaccount])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-multiaccount-wallet-address
|
||||
(fn [db]
|
||||
(str "0x" (get-in db [:keycard :multiaccount-wallet-address]))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:keycard-multiaccount-whisper-public-key
|
||||
(fn [db]
|
||||
(ethereum/normalized-hex (get-in db [:keycard :multiaccount-whisper-public-key]))))
|
|
@ -2,11 +2,11 @@
|
|||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/nfc-enabled?
|
||||
:keycard/nfc-enabled?
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :nfc-enabled?])))
|
||||
(get-in db [:keycard :nfc-enabled?])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:hardwallet/card-read-in-progress?
|
||||
:keycard/card-read-in-progress?
|
||||
(fn [db]
|
||||
(get-in db [:hardwallet :card-read-in-progress?] false)))
|
||||
(get-in db [:keycard :card-read-in-progress?] false)))
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.screens.chat.photos :as photos]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.hardwallet.login :as hardwallet.login]
|
||||
[status-im.ui.screens.hardwallet.frozen-card.view :as frozen-card.view])
|
||||
[status-im.keycard.login :as keycard.login]
|
||||
[status-im.ui.screens.keycard.frozen-card.view :as frozen-card.view])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||
|
||||
;; NOTE(Ferossgp): Seems like it should be in popover
|
||||
|
@ -205,7 +205,7 @@
|
|||
[react/view {:flex-direction :row
|
||||
:height 52}
|
||||
[quo/button {:on-press #(re-frame/dispatch
|
||||
[::hardwallet.login/login-after-reset])}
|
||||
[::keycard.login/login-after-reset])}
|
||||
(i18n/label :t/open)]]])])
|
||||
|
||||
(defn frozen-card []
|
||||
|
@ -260,14 +260,14 @@
|
|||
hide-login-actions?
|
||||
default-enter-step]
|
||||
:or {default-enter-step :login}}]
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
enter-step [:hardwallet/pin-enter-step]
|
||||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
(letsubs [pin [:keycard/pin]
|
||||
enter-step [:keycard/pin-enter-step]
|
||||
status [:keycard/pin-status]
|
||||
error-label [:keycard/pin-error-label]
|
||||
login-multiaccount [:multiaccounts/login]
|
||||
multiaccount [:multiaccount]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
retry-counter [:hardwallet/retry-counter]]
|
||||
retry-counter [:keycard/retry-counter]]
|
||||
(let [{:keys [name] :as account} (or login-multiaccount multiaccount)
|
||||
;; TODO(rasom): this hack fixes state mess when more then two
|
||||
;; pin-view instances are used at the same time. Should be properly
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
|
||||
[status-im.hardwallet.recovery :as hardwallet]
|
||||
[status-im.hardwallet.nfc :as nfc]
|
||||
[status-im.keycard.recovery :as keycard]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
|
@ -52,14 +51,11 @@
|
|||
:accessibility-label :enter-seed-phrase-button
|
||||
:icon :main-icons/text
|
||||
:on-press #(hide-sheet-and-dispatch [::multiaccounts.recover/enter-phrase-pressed])}]
|
||||
(when (and config/hardwallet-enabled?
|
||||
(or platform/android?
|
||||
config/keycard-test-menu-enabled?)
|
||||
(nfc/nfc-supported?))
|
||||
(when (or platform/android?
|
||||
config/keycard-test-menu-enabled?)
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/recover-with-keycard)
|
||||
:disabled (not config/hardwallet-enabled?)
|
||||
:accessibility-label :recover-with-keycard-button
|
||||
:icon [react/view {:border-width 1
|
||||
:border-radius 20
|
||||
|
@ -71,7 +67,7 @@
|
|||
:height 40}
|
||||
[react/image {:source (resources/get-image :keycard-logo-blue)
|
||||
:style {:width 24 :height 24}}]]
|
||||
:on-press #(hide-sheet-and-dispatch [::hardwallet/recover-with-keycard-pressed])}])]])
|
||||
:on-press #(hide-sheet-and-dispatch [::keycard/recover-with-keycard-pressed])}])]])
|
||||
|
||||
(def bottom-sheet
|
||||
{:content bottom-sheet-view})
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
[status-im.ui.screens.signing.views :as signing]
|
||||
[status-im.ui.screens.biometric.views :as biometric]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.screens.hardwallet.frozen-card.view :as frozen-card]))
|
||||
[status-im.ui.screens.keycard.frozen-card.view :as frozen-card]))
|
||||
|
||||
(defn hide-panel-anim
|
||||
[bottom-anim-value alpha-value window-height]
|
||||
|
|
|
@ -139,7 +139,6 @@
|
|||
:on-press #(re-frame/dispatch [:navigate-to :sync-settings])}]
|
||||
(when (and (or platform/android?
|
||||
config/keycard-test-menu-enabled?)
|
||||
config/hardwallet-enabled?
|
||||
keycard-pairing)
|
||||
[quo/list-item
|
||||
{:icon :main-icons/keycard
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
[status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding]
|
||||
[status-im.ui.screens.keycard.recovery.views :as keycard.recovery]
|
||||
[status-im.ui.screens.keycard.views :as keycard]
|
||||
[status-im.ui.screens.hardwallet.authentication-method.views
|
||||
[status-im.ui.screens.keycard.authentication-method.views
|
||||
:as
|
||||
hardwallet.authentication]
|
||||
keycard.authentication]
|
||||
[status-im.ui.screens.routing.core :as navigation]))
|
||||
|
||||
(defonce stack (navigation/create-stack))
|
||||
|
@ -97,8 +97,8 @@
|
|||
:component keycard.recovery/no-key}
|
||||
{:name :keycard-recovery-pin
|
||||
:component keycard.recovery/pin}
|
||||
{:name :hardwallet-authentication-method
|
||||
:component hardwallet.authentication/hardwallet-authentication-method}
|
||||
{:name :keycard-authentication-method
|
||||
:component keycard.authentication/keycard-authentication-method}
|
||||
{:name :keycard-login-pin
|
||||
:component keycard/login-pin}
|
||||
{:name :keycard-blank
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
[status-im.ui.screens.fleet-settings.views :as fleet-settings]
|
||||
[status-im.ui.screens.profile.seed.views :as profile.seed]
|
||||
[status-im.ui.screens.profile.tribute-to-talk.views :as tr-to-talk]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as hardwallet.pin]
|
||||
[status-im.ui.screens.hardwallet.settings.views :as hardwallet.settings]
|
||||
[status-im.ui.screens.keycard.pin.views :as keycard.pin]
|
||||
[status-im.ui.screens.keycard.settings.views :as keycard.settings]
|
||||
[status-im.ui.components.tabbar.styles :as tabbar.styles]
|
||||
[status-im.ui.screens.routing.core :as navigation]
|
||||
[status-im.ui.screens.appearance.views :as appearance]))
|
||||
|
@ -120,10 +120,10 @@
|
|||
|
||||
;; KEYCARD
|
||||
{:name :keycard-settings
|
||||
:component hardwallet.settings/keycard-settings}
|
||||
:component keycard.settings/keycard-settings}
|
||||
{:name :reset-card
|
||||
:component hardwallet.settings/reset-card}
|
||||
:component keycard.settings/reset-card}
|
||||
{:name :keycard-pin
|
||||
:component hardwallet.settings/reset-pin}
|
||||
:component keycard.settings/reset-pin}
|
||||
{:name :enter-pin-settings
|
||||
:component hardwallet.pin/enter-pin}]])
|
||||
:component keycard.pin/enter-pin}]])
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[status-im.ui.components.copyable-text :as copyable-text]
|
||||
[status-im.wallet.utils :as wallet.utils]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.hardwallet.common :as hardwallet.common]
|
||||
[status-im.keycard.common :as keycard.common]
|
||||
[status-im.ui.screens.keycard.keycard-interaction :as keycard-sheet]
|
||||
[status-im.ui.components.chat-icon.screen :as chat-icon]
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
|
@ -19,7 +19,7 @@
|
|||
[quo.core :as quo]
|
||||
[status-im.ui.screens.signing.styles :as styles]
|
||||
[status-im.react-native.resources :as resources]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.pin.views :as pin.views]
|
||||
[status-im.ui.components.bottom-panel.views :as bottom-panel]
|
||||
[status-im.utils.utils :as utils]
|
||||
[reagent.core :as reagent]
|
||||
|
@ -95,12 +95,12 @@
|
|||
(i18n/label :t/cancel)]]])
|
||||
|
||||
(views/defview keycard-pin-view []
|
||||
(views/letsubs [pin [:hardwallet/pin]
|
||||
(views/letsubs [pin [:keycard/pin]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
enter-step [:hardwallet/pin-enter-step]
|
||||
status [:hardwallet/pin-status]
|
||||
retry-counter [:hardwallet/retry-counter]]
|
||||
error-label [:keycard/pin-error-label]
|
||||
enter-step [:keycard/pin-enter-step]
|
||||
status [:keycard/pin-status]
|
||||
retry-counter [:keycard/retry-counter]]
|
||||
(let [enter-step (or enter-step :sign)]
|
||||
[react/view
|
||||
[pin.views/pin-view
|
||||
|
@ -215,8 +215,8 @@
|
|||
(let [message (:message formatted-data)]
|
||||
[react/view (assoc (styles/message) :padding-vertical 16)
|
||||
[keycard-sheet/connect-keycard
|
||||
{:on-connect ::hardwallet.common/on-card-connected
|
||||
:on-disconnect ::hardwallet.common/on-card-disconnected
|
||||
{:on-connect ::keycard.common/on-card-connected
|
||||
:on-disconnect ::keycard.common/on-card-disconnected
|
||||
:connected? connected?
|
||||
:on-cancel #(re-frame/dispatch [:signing.ui/cancel-is-pressed])
|
||||
:params
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
status-im.ui.screens.wallet.collectibles.superrare.views
|
||||
status-im.ui.screens.wallet.collectibles.kudos.views
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.hardwallet.test-menu :as hardwallet.test-menu]
|
||||
[status-im.keycard.test-menu :as keycard.test-menu]
|
||||
[quo.core :as quo]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.reloader :as reloader]))
|
||||
|
@ -120,4 +120,4 @@
|
|||
(when debug?
|
||||
[reloader/reload-view @reloader/cnt])
|
||||
(when config/keycard-test-menu-enabled?
|
||||
[hardwallet.test-menu/test-menu])]])}))
|
||||
[keycard.test-menu/test-menu])]])}))
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
[status-im.ui.screens.wallet.accounts.styles :as styles]
|
||||
[status-im.utils.utils :as utils.utils]
|
||||
[status-im.wallet.utils :as wallet.utils]
|
||||
[status-im.hardwallet.login :as hardwallet.login])
|
||||
[status-im.keycard.login :as keycard.login])
|
||||
(:require-macros [status-im.utils.views :as views]))
|
||||
|
||||
(views/defview account-card [{:keys [name color address type] :as account}]
|
||||
|
@ -130,7 +130,7 @@
|
|||
(views/letsubs [currency [:wallet/currency]
|
||||
portfolio-value [:portfolio-value]
|
||||
empty-balances? [:empty-balances?]
|
||||
frozen-card? [:hardwallet/frozen-card?]
|
||||
frozen-card? [:keycard/frozen-card?]
|
||||
{:keys [mnemonic]} [:multiaccount]]
|
||||
[reanimated/view {:style (styles/container {:minimized minimized})}
|
||||
(when (or
|
||||
|
@ -140,7 +140,7 @@
|
|||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch
|
||||
(if frozen-card?
|
||||
[::hardwallet.login/reset-pin]
|
||||
[::keycard.login/reset-pin]
|
||||
[:navigate-to :profile-stack {:screen :backup-seed
|
||||
:initial false}]))}
|
||||
[react/view {:flex-direction :row
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns status-im.ui.screens.wallet.add-new.views
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
|
||||
[status-im.ui.screens.keycard.pin.views :as pin.views]
|
||||
[status-im.i18n :as i18n]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
|
@ -126,16 +126,16 @@
|
|||
(re-frame/dispatch [:set-in [:add-account :private-key] (security/mask-data %)]))}]])])
|
||||
|
||||
(defview pin []
|
||||
(letsubs [pin [:hardwallet/pin]
|
||||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
retry-counter [:hardwallet/retry-counter]]
|
||||
(letsubs [pin [:keycard/pin]
|
||||
status [:keycard/pin-status]
|
||||
error-label [:keycard/pin-error-label]
|
||||
retry-counter [:keycard/retry-counter]]
|
||||
[react/keyboard-avoiding-view {:style {:flex 1}}
|
||||
[topbar/topbar
|
||||
{:navigation :none
|
||||
:accessories
|
||||
[{:label :t/cancel
|
||||
:handler #(re-frame/dispatch [:hardwallet/new-account-pin-sheet-hide])}]}]
|
||||
:handler #(re-frame/dispatch [:keycard/new-account-pin-sheet-hide])}]}]
|
||||
[pin.views/pin-view
|
||||
{:pin pin
|
||||
:status status
|
||||
|
@ -146,7 +146,7 @@
|
|||
:step :export-key}]]))
|
||||
|
||||
(defn pin-sheet []
|
||||
(let [show-sheet? @(re-frame/subscribe [:hardwallet/new-account-sheet?])
|
||||
(let [show-sheet? @(re-frame/subscribe [:keycard/new-account-sheet?])
|
||||
{window-height :height} @(re-frame/subscribe [:dimensions/window])]
|
||||
[bottom-panel/bottom-panel
|
||||
show-sheet?
|
||||
|
@ -183,7 +183,7 @@
|
|||
:on-press
|
||||
(if (and keycard?
|
||||
(not= type :watch))
|
||||
#(re-frame/dispatch [:hardwallet/new-account-pin-sheet
|
||||
#(re-frame/dispatch [:keycard/new-account-pin-sheet
|
||||
{:view {:content pin
|
||||
:height 256}}])
|
||||
#(re-frame/dispatch [:wallet.accounts/add-new-account
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
(def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0")))
|
||||
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
||||
(def snoopy-enabled? (enabled? (get-config :SNOOPY 0)))
|
||||
(def hardwallet-enabled? (enabled? (get-config :HARDWALLET_ENABLED 0)))
|
||||
(def dev-build? (enabled? (get-config :DEV_BUILD 0)))
|
||||
(def erc20-contract-warnings-enabled? (enabled? (get-config :ERC20_CONTRACT_WARNINGS)))
|
||||
(def tr-to-talk-enabled? (enabled? (get-config :TRIBUTE_TO_TALK 0)))
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
(get-credentials key-uid #(if % (callback (security/mask-data (.-password ^js %))) (callback nil)))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-hardwallet-keys
|
||||
:keychain/get-keycard-keys
|
||||
(fn [[key-uid callback]]
|
||||
(get-credentials
|
||||
key-uid
|
||||
|
@ -176,7 +176,7 @@
|
|||
"but you will have to login again next time you launch it."))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/save-hardwallet-keys
|
||||
:keychain/save-keycard-keys
|
||||
(fn [[key-uid encryption-public-key whisper-private-key]]
|
||||
(save-credentials
|
||||
key-uid
|
||||
|
@ -211,22 +211,22 @@
|
|||
#(re-frame/dispatch
|
||||
[:multiaccounts.login.callback/get-user-password-success % key-uid])]})
|
||||
|
||||
(fx/defn get-hardwallet-keys
|
||||
(fx/defn get-keycard-keys
|
||||
[_ key-uid]
|
||||
{:keychain/get-hardwallet-keys
|
||||
{:keychain/get-keycard-keys
|
||||
[key-uid
|
||||
#(re-frame/dispatch
|
||||
[:multiaccounts.login.callback/get-hardwallet-keys-success key-uid %])]})
|
||||
[:multiaccounts.login.callback/get-keycard-keys-success key-uid %])]})
|
||||
|
||||
(fx/defn save-user-password
|
||||
[_ key-uid password]
|
||||
{:keychain/save-user-password [key-uid password]})
|
||||
|
||||
(fx/defn save-hardwallet-keys
|
||||
(fx/defn save-keycard-keys
|
||||
[_ key-uid encryption-public-key whisper-private-key]
|
||||
{:keychain/save-hardwallet-keys [key-uid
|
||||
encryption-public-key
|
||||
whisper-private-key]})
|
||||
{:keychain/save-keycard-keys [key-uid
|
||||
encryption-public-key
|
||||
whisper-private-key]})
|
||||
(fx/defn save-auth-method
|
||||
[{:keys [db]} key-uid method]
|
||||
{:db (assoc db :auth-method method)
|
||||
|
|
Loading…
Reference in New Issue