[#9206] fix wrong ping handling on signing messages

This commit is contained in:
Roman Volosovskyi 2019-11-10 15:40:06 +02:00
parent a6a65ec0e4
commit a39ae15d99
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 23 additions and 21 deletions

View File

@ -913,7 +913,7 @@
:utils/show-popup {:title (i18n/label :t/error) :utils/show-popup {:title (i18n/label :t/error)
:content (i18n/label :t/cannot-read-card)}} :content (i18n/label :t/cannot-read-card)}}
(navigation/navigate-to-cofx :keycard-connection-lost nil)) (navigation/navigate-to-cofx :keycard-connection-lost nil))
(show-wrong-keycard-alert cofx true))))) (show-wrong-keycard-alert true)))))
(fx/defn on-delete-success (fx/defn on-delete-success
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -1117,7 +1117,7 @@
setup? (boolean (get-in db [:hardwallet :setup-step]))] setup? (boolean (get-in db [:hardwallet :setup-step]))]
(log/debug "[hardwallet] verify pin error" error) (log/debug "[hardwallet] verify pin error" error)
(fx/merge cofx (fx/merge cofx
(if tag-was-lost? (when tag-was-lost?
(fx/merge cofx (fx/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:hardwallet :on-card-connected] :hardwallet/verify-pin) (assoc-in [:hardwallet :on-card-connected] :hardwallet/verify-pin)
@ -1140,7 +1140,7 @@
(when-not setup? (when-not setup?
(navigation/navigate-to-cofx :enter-pin-settings nil)) (navigation/navigate-to-cofx :enter-pin-settings nil))
(get-application-info (get-pairing db) nil)) (get-application-info (get-pairing db) nil))
(show-wrong-keycard-alert cofx true)))))) (show-wrong-keycard-alert true))))))
(fx/defn on-change-pin-success (fx/defn on-change-pin-success
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -1186,7 +1186,7 @@
:error-label :t/pin-mismatch})} :error-label :t/pin-mismatch})}
(navigation/navigate-to-cofx :enter-pin-settings nil) (navigation/navigate-to-cofx :enter-pin-settings nil)
(get-application-info (get-pairing db) nil)) (get-application-info (get-pairing db) nil))
(show-wrong-keycard-alert cofx true)))))) (show-wrong-keycard-alert true))))))
(fx/defn on-unpair-success (fx/defn on-unpair-success
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -1800,7 +1800,7 @@
(if (= flow :import) (if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-pin nil) (navigation/navigate-to-cofx :keycard-recovery-pin nil)
(navigation/navigate-to-cofx :keycard-login-pin nil))) (navigation/navigate-to-cofx :keycard-login-pin nil)))
(show-wrong-keycard-alert cofx true))))) (show-wrong-keycard-alert true)))))
(fx/defn send-transaction-with-signature (fx/defn send-transaction-with-signature
[_ data] [_ data]
@ -1842,20 +1842,22 @@
(log/debug "[hardwallet] sign error: " error) (log/debug "[hardwallet] sign error: " error)
(let [tag-was-lost? (= "Tag was lost." (:error error))] (let [tag-was-lost? (= "Tag was lost." (:error error))]
(fx/merge cofx (fx/merge cofx
(if tag-was-lost? (when tag-was-lost?
(fx/merge cofx (fn [{:keys [db] :as cofx}]
{:db (-> db (fx/merge cofx
(assoc-in [:hardwallet :on-card-connected] :hardwallet/prepare-to-sign) {:db (-> db
(assoc-in [:hardwallet :pin :status] nil) (assoc-in [:hardwallet :on-card-connected] :hardwallet/prepare-to-sign)
(assoc-in [:signing/sign :keycard-step] :connect)) (assoc-in [:hardwallet :pin :status] nil)
:utils/show-popup {:title (i18n/label :t/error) (assoc-in [:signing/sign :keycard-step] :connect))
:content (i18n/label :t/cannot-read-card)}})) :utils/show-popup {:title (i18n/label :t/error)
:content (i18n/label :t/cannot-read-card)}})))
(if (re-matches pin-mismatch-error (:error error)) (if (re-matches pin-mismatch-error (:error error))
(fx/merge cofx (fn [{:keys [db] :as cofx}]
{:db (-> db (fx/merge cofx
(update-in [:hardwallet :pin] merge {:status :error {:db (-> db
:sign [] (update-in [:hardwallet :pin] merge {:status :error
:error-label :t/pin-mismatch}) :sign []
(assoc-in [:signing/sign :keycard-step] :pin))} :error-label :t/pin-mismatch})
(get-application-info (get-pairing db) nil)) (assoc-in [:signing/sign :keycard-step] :pin))}
(show-wrong-keycard-alert cofx true))))) (get-application-info (get-pairing db) nil)))
(show-wrong-keycard-alert true)))))