diff --git a/src/status_im/keycard/backup_key.cljs b/src/status_im/keycard/backup_key.cljs index cd27e1e616..e2dbab210f 100644 --- a/src/status_im/keycard/backup_key.cljs +++ b/src/status_im/keycard/backup_key.cljs @@ -7,31 +7,39 @@ [status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.recover.core :as multiaccounts.recover] [status-im.navigation :as navigation] + [status-im.signing.core :as signing.core] [taoensso.timbre :as log])) -(fx/defn recovery-card-pressed - {:events [:keycard-settings.ui/recovery-card-pressed]} - [{:keys [db] :as cofx} checked?] - (fx/merge cofx - {:db (assoc-in db [:keycard :factory-reset-card?] true)} - (utils/show-confirmation {:title (i18n/label :t/keycard-recover-title) - :content (i18n/label :t/keycard-recover-text) - :confirm-button-text (i18n/label :t/yes) - :cancel-button-text (i18n/label :t/no) - :on-accept #(re-frame/dispatch [:keycard-settings.ui/backup-card-pressed]) - :on-cancel #()}))) - (fx/defn backup-card-pressed {:events [:keycard-settings.ui/backup-card-pressed]} - [{:keys [db] :as cofx}] + [{:keys [db] :as cofx} backup-type] (log/debug "[keycard] start backup") (fx/merge cofx {:db (-> db - (assoc-in [:keycard :creating-backup?] true))} + (assoc-in [:keycard :creating-backup?] backup-type))} (if (multiaccounts.model/logged-in? cofx) (navigation/navigate-to-cofx :seed-phrase nil) (navigation/navigate-to-cofx :key-storage-stack {:screen :seed-phrase})))) +(fx/defn recovery-card-pressed + {:events [:keycard-settings.ui/recovery-card-pressed]} + [{:keys [db] :as cofx} show-warning] + (fx/merge cofx + {:db (-> db + ;setting pin-retry-counter is a workaround for the way the PIN view decides if it should accept PUK or PIN + (assoc-in [:keycard :application-info :pin-retry-counter] 3) + (assoc-in [:keycard :factory-reset-card?] true) + (dissoc :popover/popover))} + (signing.core/discard) + (if show-warning + (utils/show-confirmation {:title (i18n/label :t/keycard-recover-title) + :content (i18n/label :t/keycard-recover-text) + :confirm-button-text (i18n/label :t/yes) + :cancel-button-text (i18n/label :t/no) + :on-accept #(re-frame/dispatch [:keycard-settings.ui/backup-card-pressed :recovery-card]) + :on-cancel #()}) + (backup-card-pressed :recovery-card)))) + (fx/defn start-keycard-backup {:events [::start-keycard-backup]} [{:keys [db] :as cofx}] diff --git a/src/status_im/keycard/recovery.cljs b/src/status_im/keycard/recovery.cljs index e0a1908250..5e0480ba4c 100644 --- a/src/status_im/keycard/recovery.cljs +++ b/src/status_im/keycard/recovery.cljs @@ -209,12 +209,14 @@ {:name :keycard-login-pin}]}}]}))) (fx/defn on-backup-success - [{:keys [db] :as cofx}] + [{:keys [db] :as cofx} backup-type] (fx/merge cofx - {:utils/show-popup {:title (i18n/label :t/keycard-backup-success-title) - :content (i18n/label :t/keycard-backup-success-body)}} + {:utils/show-popup {:title (i18n/label (if (= backup-type :recovery-card) + :t/keycard-access-reset :t/keycard-backup-success-title)) + :content (i18n/label (if (= backup-type :recovery-card) + :t/keycard-can-use-with-new-passcode :t/keycard-backup-success-body))}} (if (multiaccounts.model/logged-in? cofx) - (navigation/navigate-to-cofx :keycard-settings nil) + (navigation/navigate-to-cofx :profile-stack {:screen :keycard-settings}) (return-to-keycard-login)))) (fx/defn on-generate-and-load-key-success @@ -249,7 +251,7 @@ (update-in [:keycard :secrets] dissoc :mnemonic))} (common/remove-listener-to-hardware-back-button) (common/hide-connection-sheet) - (if backup? (on-backup-success) (create-keycard-multiaccount))))) + (if backup? (on-backup-success backup?) (create-keycard-multiaccount))))) (fx/defn on-generate-and-load-key-error {:events [:keycard.callback/on-generate-and-load-key-error]} diff --git a/src/status_im/ui/screens/keycard/frozen_card/view.cljs b/src/status_im/ui/screens/keycard/frozen_card/view.cljs index 2cc6820f82..340bc4a4ea 100644 --- a/src/status_im/ui/screens/keycard/frozen_card/view.cljs +++ b/src/status_im/ui/screens/keycard/frozen_card/view.cljs @@ -36,6 +36,10 @@ [quo/button {:on-press #(re-frame/dispatch [::login/reset-pin])} (i18n/label :t/keycard-is-frozen-reset)]] + [react/view {:style {:margin-top 24}} + [quo/button + {:on-press #(re-frame/dispatch [:keycard-settings.ui/recovery-card-pressed false])} + (i18n/label :t/keycard-is-frozen-factory-reset)]] (when show-dismiss-button? [react/view {:margin-top 24} [quo/button diff --git a/src/status_im/ui/screens/keycard/settings/views.cljs b/src/status_im/ui/screens/keycard/settings/views.cljs index 2c202874d2..8811548ebe 100644 --- a/src/status_im/ui/screens/keycard/settings/views.cljs +++ b/src/status_im/ui/screens/keycard/settings/views.cljs @@ -107,7 +107,7 @@ :size :small :title (i18n/label :t/keycard-backup) :accessibility-label "create-backup-keycard" - :on-press #(re-frame/dispatch [:keycard-settings.ui/backup-card-pressed])}] + :on-press #(re-frame/dispatch [:keycard-settings.ui/backup-card-pressed :backup-card])}] ;; TODO(rasom): uncomment this when unpairing will be enabled ;; https://github.com/status-im/status-react/issues/9227 #_[quo/list-item {:icon :main-icons/close diff --git a/src/status_im/ui/screens/keycard/views.cljs b/src/status_im/ui/screens/keycard/views.cljs index beb6b67aaa..28bc446be7 100644 --- a/src/status_im/ui/screens/keycard/views.cljs +++ b/src/status_im/ui/screens/keycard/views.cljs @@ -1,6 +1,7 @@ (ns status-im.ui.screens.keycard.views (:require [re-frame.core :as re-frame] [reagent.core :as reagent] + [clojure.string :as string] [status-im.i18n.i18n :as i18n] [status-im.multiaccounts.core :as multiaccounts] [status-im.react-native.resources :as resources] @@ -240,11 +241,11 @@ [react/nested-text {:style {:color colors/gray :text-align :center}} - (i18n/label :t/keycard-is-blocked-instructions) - [{} " "] - [{:style {:color colors/blue} - :on-press #(.openURL ^js react/linking "https://status.im/faq/#keycard")} - (i18n/label :t/learn-more)]]]]) + (i18n/label :t/keycard-is-blocked-instructions)] + [react/view {:style {:margin-top 24}} + [quo/button + {:on-press #(re-frame/dispatch [:keycard-settings.ui/recovery-card-pressed false])} + (i18n/label :t/keycard-is-frozen-factory-reset)]]]]) (defview login-pin [{:keys [back-button-handler hide-login-actions? @@ -320,14 +321,14 @@ :number-of-lines 1 :ellipsize-mode :middle} name]]] - [react/touchable-highlight {:on-press #(re-frame/dispatch [:keycard-settings.ui/recovery-card-pressed])} + [react/touchable-highlight {:on-press #(re-frame/dispatch [:keycard-settings.ui/recovery-card-pressed (boolean login-multiaccount)])} [react/view {:flex-direction :row :align-items :center :justify-content :center} [react/text {:style {:text-align :center :margin-bottom (if small-screen? 8 12) :color colors/blue}} - (i18n/label :t/keycard-recover)]]] + (string/lower-case (i18n/label (if login-multiaccount :t/keycard-recover :t/keycard-is-frozen-factory-reset)))]]] (cond (= :after-unblocking status) [access-is-reset diff --git a/translations/en.json b/translations/en.json index 83604d1c17..5aae46e219 100644 --- a/translations/en.json +++ b/translations/en.json @@ -750,12 +750,13 @@ "keycard-redeem-tx-desc": "Tap the card to sign and receive assets", "keycard-unauthorized-operation": "You're unauthorized to perform this operation.\n Please tap valid card and try again.", "keycard-is-frozen-title": "Keycard is frozen", - "keycard-is-frozen-details": "To protect your assets, your card is frozen. Reset card access to unlock keys and send transactions. Create a new passcode and enter your PUK to access your account(s) on this card", - "keycard-is-frozen-reset": "Reset card access", + "keycard-is-frozen-details": "To protect your assets, your card is frozen. Reset your card to unfreeze it and be able to send transactions. You can do this with your PUK or your mnemonic.", + "keycard-is-frozen-reset": "Reset with PUK", + "keycard-is-frozen-factory-reset": "Reset with mnemonic", "your-card-is-frozen": "Your Keycard is frozen. Reset card access", "keycard-is-blocked-title": "Keycard is blocked", "keycard-is-blocked-details": "You can no longer use this card to access or sign for this account. There have been too many failed passcode and PUK attempts.", - "keycard-is-blocked-instructions": "To access your account reinstall Status and use a new Keycard, use a different wallet or reset Keycard manually.", + "keycard-is-blocked-instructions": "To access your account you will need to factory reset your card. Tap the button below to start the procedure, you will need your mnemonic.", "language": "Language", "learn-more": "Learn more", "learn-more-about-keycard": "Learn more about Keycard",