handle signing error
This commit is contained in:
parent
4062eed675
commit
e1d655789d
|
@ -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
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}]
|
||||
|
|
|
@ -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?]
|
||||
|
|
|
@ -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))))
|
Loading…
Reference in New Issue