From dccc81db7b63e303ca5be07580297fba728708b6 Mon Sep 17 00:00:00 2001 From: Goran Jovic Date: Wed, 13 Mar 2019 16:28:26 +0100 Subject: [PATCH] bug #7724 - correctly showing password errors for sign message Signed-off-by: Goran Jovic --- .../ui/screens/wallet/send/events.cljs | 21 ++++++++++++++----- .../ui/screens/wallet/sign_message/views.cljs | 6 ++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index 968fe2a9a8..bcec42f850 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -80,17 +80,23 @@ ;; SIGN MESSAGE (handlers/register-handler-fx :wallet/sign-message - (fn [_ [_ typed? screen-params]] + (fn [_ [_ typed? screen-params password-error-cb]] (let [{:keys [data from password]} screen-params] (if typed? {::sign-typed-data {:data data :password password :account from - :on-completed #(re-frame/dispatch [::sign-message-completed screen-params (types/json->clj %)])}} + :on-completed #(re-frame/dispatch [::sign-message-completed + screen-params + (types/json->clj %) + password-error-cb])}} {::sign-message {:params {:data data :password (security/safe-unmask-data password) :account from} - :on-completed #(re-frame/dispatch [::sign-message-completed screen-params (types/json->clj %)])}})))) + :on-completed #(re-frame/dispatch [::sign-message-completed + screen-params + (types/json->clj %) + password-error-cb])}})))) ;; SEND TRANSACTION CALLBACK (handlers/register-handler-fx @@ -116,14 +122,19 @@ :amount amount-text :tx-hash result}]})))))) +(re-frame/reg-fx + :show-sign-message-error + (fn [[password-error-cb]] + (password-error-cb))) + ;; SIGN MESSAGE CALLBACK (handlers/register-handler-fx ::sign-message-completed - (fn [{:keys [db now] :as cofx} [_ {:keys [on-result id method]} {:keys [result error]}]] + (fn [{:keys [db now] :as cofx} [_ {:keys [on-result id method]} {:keys [result error]} password-error-cb]] (let [db' (assoc-in db [:wallet :send-transaction :in-progress?] false)] (if error ;; ERROR - (models.wallet/handle-transaction-error (assoc cofx :db db') error) + {:show-sign-message-error [password-error-cb]} ;; RESULT (if on-result {:dispatch (conj on-result id result method)}))))) diff --git a/src/status_im/ui/screens/wallet/sign_message/views.cljs b/src/status_im/ui/screens/wallet/sign_message/views.cljs index 2d949f073c..3bf8831cb8 100644 --- a/src/status_im/ui/screens/wallet/sign_message/views.cljs +++ b/src/status_im/ui/screens/wallet/sign_message/views.cljs @@ -56,7 +56,7 @@ opacity-value (animation/create-value 0)] {:component-did-mount #(send.animations/animate-sign-panel opacity-value bottom-value)} [react/animated-view {:style (styles/animated-sign-panel bottom-value)} - (when (:wrong-password? value-atom) + (when (:wrong-password? @value-atom) [tooltip/tooltip (i18n/label :t/wrong-password) styles/password-error-tooltip]) [react/animated-view {:style (styles/sign-panel opacity-value)} [react/view styles/spinner-container @@ -104,7 +104,9 @@ nil]]]] [enter-password-buttons value-atom false #(re-frame/dispatch [:wallet/discard-transaction-navigate-back]) - #(re-frame/dispatch [:wallet/sign-message typed? (merge screen-params @value-atom)]) + #(re-frame/dispatch [:wallet/sign-message typed? (merge screen-params @value-atom) + (fn [] + (swap! value-atom assoc :wrong-password? true))]) :t/transactions-sign] [password-input-panel value-atom :t/signing-message-phrase-description false] (when in-progress?