handle signing error
This commit is contained in:
parent
4062eed675
commit
e1d655789d
|
@ -112,7 +112,6 @@
|
||||||
:my-profile/profile
|
:my-profile/profile
|
||||||
:my-profile/default-name
|
:my-profile/default-name
|
||||||
:wallet/request-transaction
|
:wallet/request-transaction
|
||||||
:wallet/send-transaction
|
|
||||||
:networks/selected-network
|
:networks/selected-network
|
||||||
:networks/networks
|
:networks/networks
|
||||||
:node/after-start
|
:node/after-start
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
(spec/def ::camera-permitted? boolean?)
|
(spec/def ::camera-permitted? boolean?)
|
||||||
(spec/def ::in-progress? boolean?)
|
(spec/def ::in-progress? boolean?)
|
||||||
(spec/def ::from-chat? (spec/nilable boolean?))
|
(spec/def ::from-chat? (spec/nilable boolean?))
|
||||||
|
(spec/def ::signing-error (spec/nilable string?))
|
||||||
|
|
||||||
(spec/def :wallet/send-transaction (allowed-keys
|
(spec/def :wallet/send-transaction (allowed-keys
|
||||||
:opt-un [::amount ::to-address ::to-name ::amount-error ::password
|
:opt-un [::amount ::to-address ::to-name ::amount-error ::password
|
||||||
::waiting-signal? ::signing? ::id ::later?
|
::waiting-signal? ::signing? ::id ::later?
|
||||||
::camera-dimensions ::camera-flashlight ::in-progress?
|
::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] amount)
|
||||||
(assoc-in [:wallet :send-transaction :amount-error] error))})))
|
(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
|
:wrong-password? false
|
||||||
:waiting-signal? false
|
:waiting-signal? false
|
||||||
:from-chat? false})
|
:from-chat? false})
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
::transaction-completed
|
::transaction-completed
|
||||||
|
@ -55,7 +57,7 @@
|
||||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||||
:dispatch [:navigate-to :wallet-transaction-sent]}
|
:dispatch [:navigate-to :wallet-transaction-sent]}
|
||||||
{:db db'}))))
|
{:db (assoc-in db' [:wallet :send-transaction :signing-error] error)}))))
|
||||||
|
|
||||||
(defn on-transactions-completed [raw-results]
|
(defn on-transactions-completed [raw-results]
|
||||||
(let [results (:results (types/json->clj raw-results))]
|
(let [results (:results (types/json->clj raw-results))]
|
||||||
|
@ -69,7 +71,7 @@
|
||||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)
|
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)
|
||||||
has-error? (and error (string? error) (not (string/blank? error)))]
|
has-error? (and error (string? error) (not (string/blank? error)))]
|
||||||
(if has-error?
|
(if has-error?
|
||||||
{:db db'}
|
{:db (assoc-in db' [:wallet :send-transaction :signing-error] error)}
|
||||||
{:db (-> db'
|
{:db (-> db'
|
||||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||||
|
@ -96,13 +98,14 @@
|
||||||
:wallet/sign-transaction
|
:wallet/sign-transaction
|
||||||
(fn [{{:keys [web3]
|
(fn [{{:keys [web3]
|
||||||
:accounts/keys [accounts current-account-id] :as db} :db} [_ later?]]
|
: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
|
(if id
|
||||||
{::accept-transaction {:id id
|
{::accept-transaction {:id id
|
||||||
:password password
|
:password password
|
||||||
:on-completed on-transactions-completed}
|
:on-completed on-transactions-completed}
|
||||||
:db (assoc-in db [:wallet :send-transaction :in-progress?] true)}
|
:db (assoc-in db' [:wallet :send-transaction :in-progress?] true)}
|
||||||
{:db (update-in db [:wallet :send-transaction] assoc
|
{:db (update-in db' [:wallet :send-transaction] assoc
|
||||||
:waiting-signal? true
|
:waiting-signal? true
|
||||||
:later? later?
|
:later? later?
|
||||||
:in-progress? true)
|
:in-progress? true)
|
||||||
|
@ -145,6 +148,7 @@
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
{:db (update-in db [:wallet :send-transaction] assoc
|
{:db (update-in db [:wallet :send-transaction] assoc
|
||||||
:signing? false
|
:signing? false
|
||||||
|
:signing-error nil
|
||||||
:wrong-password? false)}))
|
:wrong-password? false)}))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
(fn [send-transaction]
|
(fn [send-transaction]
|
||||||
(:wrong-password? 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?
|
(re-frame/reg-sub :wallet.send/sign-password-enabled?
|
||||||
:<- [::send-transaction]
|
:<- [::send-transaction]
|
||||||
(fn [{:keys [password]}]
|
(fn [{:keys [password]}]
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
(defview sign-panel []
|
(defview sign-panel []
|
||||||
(letsubs [account [:get-current-account]
|
(letsubs [account [:get-current-account]
|
||||||
wrong-password? [:wallet.send/wrong-password?]
|
wrong-password? [:wallet.send/wrong-password?]
|
||||||
|
signing-error [:wallet.send/signing-error]
|
||||||
signing-phrase (:signing-phrase @account)
|
signing-phrase (:signing-phrase @account)
|
||||||
bottom-value (animation/create-value -250)
|
bottom-value (animation/create-value -250)
|
||||||
opacity-value (animation/create-value 0)]
|
opacity-value (animation/create-value 0)]
|
||||||
|
@ -52,9 +53,10 @@
|
||||||
:placeholder-text-color "#939ba1"
|
:placeholder-text-color "#939ba1"
|
||||||
:on-change-text #(re-frame/dispatch [:wallet.send/set-password %])
|
:on-change-text #(re-frame/dispatch [:wallet.send/set-password %])
|
||||||
:style send.styles/password}]]]
|
:style send.styles/password}]]]
|
||||||
(when wrong-password?
|
(when (or wrong-password? signing-error)
|
||||||
[components/tooltip (i18n/label :t/wrong-password)])]))
|
[components/tooltip (if wrong-password?
|
||||||
|
(i18n/label :t/wrong-password)
|
||||||
|
signing-error)])]))
|
||||||
|
|
||||||
;; "Cancel" and "Sign Transaction >" buttons, signing with password
|
;; "Cancel" and "Sign Transaction >" buttons, signing with password
|
||||||
(defview signing-buttons [cancel-handler sign-handler in-progress?]
|
(defview signing-buttons [cancel-handler sign-handler in-progress?]
|
||||||
|
|
|
@ -67,8 +67,7 @@
|
||||||
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)
|
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)
|
||||||
:dispatch [:set-chat-ui-props {:validation-messages nil}]}
|
:dispatch [:set-chat-ui-props {:validation-messages nil}]}
|
||||||
|
|
||||||
;;NO ERROR, TIMEOUT or DEFAULT ERROR
|
constants/send-transaction-timeout-error-code
|
||||||
(merge
|
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)}
|
||||||
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)}
|
|
||||||
(when (and message_id (= current-account-address transaction-initiator-address))
|
nil))))
|
||||||
{:dispatch [:set-chat-ui-props {:validation-messages error_message}]}))))))
|
|
Loading…
Reference in New Issue