diff --git a/src/status_im/ui/screens/db.cljs b/src/status_im/ui/screens/db.cljs index ee0ee54c74..28883bbb4d 100644 --- a/src/status_im/ui/screens/db.cljs +++ b/src/status_im/ui/screens/db.cljs @@ -112,7 +112,6 @@ :my-profile/profile :my-profile/default-name :wallet/request-transaction - :wallet/send-transaction :networks/selected-network :networks/networks :node/after-start diff --git a/src/status_im/ui/screens/wallet/send/db.cljs b/src/status_im/ui/screens/wallet/send/db.cljs index fa42f5f006..0c63149acd 100644 --- a/src/status_im/ui/screens/wallet/send/db.cljs +++ b/src/status_im/ui/screens/wallet/send/db.cljs @@ -19,9 +19,11 @@ (spec/def ::camera-permitted? boolean?) (spec/def ::in-progress? boolean?) (spec/def ::from-chat? (spec/nilable boolean?)) +(spec/def ::signing-error (spec/nilable string?)) (spec/def :wallet/send-transaction (allowed-keys :opt-un [::amount ::to-address ::to-name ::amount-error ::password ::waiting-signal? ::signing? ::id ::later? ::camera-dimensions ::camera-flashlight ::in-progress? - ::wrong-password? ::camera-permitted? ::from-chat?])) + ::wrong-password? ::camera-permitted? ::from-chat? + ::signing-error])) diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index 515a82856b..1203ec6f0b 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -40,10 +40,12 @@ (assoc-in [:wallet :send-transaction :amount] amount) (assoc-in [:wallet :send-transaction :amount-error] error))}))) -(def ^:private clear-send-properties {:id nil +(def ^:private clear-send-properties {:id nil + :signing-error nil + :signing? false :wrong-password? false :waiting-signal? false - :from-chat? false}) + :from-chat? false}) (handlers/register-handler-fx ::transaction-completed @@ -55,7 +57,7 @@ (update-in [:wallet :transactions-unsigned] dissoc id) (update-in [:wallet :send-transaction] merge clear-send-properties)) :dispatch [:navigate-to :wallet-transaction-sent]} - {:db db'})))) + {:db (assoc-in db' [:wallet :send-transaction :signing-error] error)})))) (defn on-transactions-completed [raw-results] (let [results (:results (types/json->clj raw-results))] @@ -69,7 +71,7 @@ db' (assoc-in db [:wallet :send-transaction :in-progress?] false) has-error? (and error (string? error) (not (string/blank? error)))] (if has-error? - {:db db'} + {:db (assoc-in db' [:wallet :send-transaction :signing-error] error)} {:db (-> db' (update-in [:wallet :transactions-unsigned] dissoc id) (update-in [:wallet :send-transaction] merge clear-send-properties)) @@ -96,13 +98,14 @@ :wallet/sign-transaction (fn [{{:keys [web3] :accounts/keys [accounts current-account-id] :as db} :db} [_ later?]] - (let [{:keys [amount id password to-address]} (get-in db [:wallet :send-transaction])] + (let [db' (assoc-in db [:wallet :send-transaction :wrong-password?] false) + {:keys [amount id password to-address]} (get-in db [:wallet :send-transaction])] (if id {::accept-transaction {:id id :password password :on-completed on-transactions-completed} - :db (assoc-in db [:wallet :send-transaction :in-progress?] true)} - {:db (update-in db [:wallet :send-transaction] assoc + :db (assoc-in db' [:wallet :send-transaction :in-progress?] true)} + {:db (update-in db' [:wallet :send-transaction] assoc :waiting-signal? true :later? later? :in-progress? true) @@ -145,6 +148,7 @@ (fn [{:keys [db]} _] {:db (update-in db [:wallet :send-transaction] assoc :signing? false + :signing-error nil :wrong-password? false)})) (handlers/register-handler-fx diff --git a/src/status_im/ui/screens/wallet/send/subs.cljs b/src/status_im/ui/screens/wallet/send/subs.cljs index 6dc4639d61..5345785ea5 100644 --- a/src/status_im/ui/screens/wallet/send/subs.cljs +++ b/src/status_im/ui/screens/wallet/send/subs.cljs @@ -29,6 +29,11 @@ (fn [send-transaction] (:wrong-password? send-transaction))) +(re-frame/reg-sub :wallet.send/signing-error + :<- [::send-transaction] + (fn [send-transaction] + (:signing-error send-transaction))) + (re-frame/reg-sub :wallet.send/sign-password-enabled? :<- [::send-transaction] (fn [{:keys [password]}] diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index ed4431f535..03f0a34003 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -35,6 +35,7 @@ (defview sign-panel [] (letsubs [account [:get-current-account] wrong-password? [:wallet.send/wrong-password?] + signing-error [:wallet.send/signing-error] signing-phrase (:signing-phrase @account) bottom-value (animation/create-value -250) opacity-value (animation/create-value 0)] @@ -52,9 +53,10 @@ :placeholder-text-color "#939ba1" :on-change-text #(re-frame/dispatch [:wallet.send/set-password %]) :style send.styles/password}]]] - (when wrong-password? - [components/tooltip (i18n/label :t/wrong-password)])])) - + (when (or wrong-password? signing-error) + [components/tooltip (if wrong-password? + (i18n/label :t/wrong-password) + signing-error)])])) ;; "Cancel" and "Sign Transaction >" buttons, signing with password (defview signing-buttons [cancel-handler sign-handler in-progress?] diff --git a/src/status_im/ui/screens/wallet/transactions/events.cljs b/src/status_im/ui/screens/wallet/transactions/events.cljs index 66f71e8477..d6fb7c1084 100644 --- a/src/status_im/ui/screens/wallet/transactions/events.cljs +++ b/src/status_im/ui/screens/wallet/transactions/events.cljs @@ -67,8 +67,7 @@ {:db (update-in db [:wallet :transactions-unsigned] dissoc id) :dispatch [:set-chat-ui-props {:validation-messages nil}]} - ;;NO ERROR, TIMEOUT or DEFAULT ERROR - (merge - {:db (update-in db [:wallet :transactions-unsigned] dissoc id)} - (when (and message_id (= current-account-address transaction-initiator-address)) - {:dispatch [:set-chat-ui-props {:validation-messages error_message}]})))))) + constants/send-transaction-timeout-error-code + {:db (update-in db [:wallet :transactions-unsigned] dissoc id)} + + nil)))) \ No newline at end of file