From ac2780e577d328f56654780c5cb189e59b2ad4e1 Mon Sep 17 00:00:00 2001 From: Goran Jovic Date: Thu, 21 Jun 2018 11:40:46 +0200 Subject: [PATCH] bug #4876 - cleaning up succesful and failed dapp transactions and added stricter check for chat wallet onboarding Signed-off-by: Julien Eluard --- src/status_im/ui/screens/accounts/events.cljs | 6 ++++-- src/status_im/ui/screens/wallet/send/events.cljs | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/status_im/ui/screens/accounts/events.cljs b/src/status_im/ui/screens/accounts/events.cljs index df4a2431bd..bf623664a2 100644 --- a/src/status_im/ui/screens/accounts/events.cljs +++ b/src/status_im/ui/screens/accounts/events.cljs @@ -184,10 +184,12 @@ (accounts.utils/account-update {:dev-mode? dev-mode} cofx))) (defn wallet-set-up-passed [db cofx] - (let [transaction (seq (get-in db [:wallet :send-transaction]))] + (let [transaction (get-in db [:wallet :send-transaction])] (merge {:db (navigation/navigate-back db)} - (when transaction + (when (and (seq transaction) + (not (:in-progress? transaction)) + (:from-chat? transaction)) {:dispatch [:navigate-to :wallet-send-transaction-chat]})))) (handlers/register-handler-fx diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index 28de52986b..4f4fa72167 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -119,6 +119,8 @@ :signing? false :wrong-password? false :waiting-signal? false + :from-chat? false + :in-progress? false :password nil}) (defn on-transactions-completed [raw-results] @@ -213,6 +215,11 @@ (= modal :wallet-send-transaction-modal) (= modal :wallet-sign-message-modal)))) +(defn handle-failed-tx [cofx error_message] + (-> cofx + (assoc ::show-transaction-error error_message) + (update-in [:db :wallet] dissoc :send-transaction))) + ;;TRANSACTION FAILED signal from status-go (handlers/register-handler-fx :sign-request-failed @@ -232,7 +239,7 @@ (update-in [:wallet :send-transaction] merge clear-send-properties)) :dispatch [:navigate-back]} (= method constants/web3-send-transaction) - (assoc ::show-transaction-error error_message)) + (handle-failed-tx error_message)) {:db (update-in db [:wallet :transactions-unsigned] dissoc id)}))))) (defn prepare-unconfirmed-transaction [db now hash id]