mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-13 18:25:45 +00:00
[fix] wallet on-error dispatch
the code to dispatch an event on transaction error was not working this fixes it Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
fa18f3b746
commit
c4f719352e
@ -160,22 +160,23 @@
|
||||
(update :gas-price str)
|
||||
(dissoc :message-id :id :gas)))))
|
||||
|
||||
(defn handle-transaction-error [{:keys [db]} {:keys [code message]}]
|
||||
(fx/defn handle-transaction-error
|
||||
[{:keys [db] :as cofx} {:keys [code message]}]
|
||||
(let [{:keys [on-error]} (get-in db [:wallet :send-transaction])]
|
||||
(case code
|
||||
|
||||
;;WRONG PASSWORD
|
||||
constants/send-transaction-err-decrypt
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction :wrong-password?] true))}
|
||||
|
||||
(fx/merge {:db (-> db
|
||||
(assoc-in [:wallet :transactions-queue] nil)
|
||||
(assoc-in [:wallet :send-transaction] {}))}
|
||||
{:wallet/show-transaction-error message}
|
||||
(navigation/navigate-back)
|
||||
(when on-error
|
||||
{:dispatch (conj on-error message)})))))
|
||||
(fx/merge cofx
|
||||
(merge {:db (-> db
|
||||
(assoc-in [:wallet :transactions-queue] nil)
|
||||
(assoc-in [:wallet :send-transaction] {}))
|
||||
:wallet/show-transaction-error message}
|
||||
(when on-error
|
||||
{:dispatch (conj on-error message)}))
|
||||
navigation/navigate-back))))
|
||||
|
||||
(defn clear-error-message [db error-type]
|
||||
(update-in db [:wallet :errors] dissoc error-type))
|
||||
|
@ -114,7 +114,7 @@
|
||||
:wallet.callback/transaction-completed
|
||||
[(re-frame/inject-cofx :random-id-generator)]
|
||||
(fn [{:keys [db now] :as cofx} [_ {:keys [result error]}]]
|
||||
(let [{:keys [id method public-key to symbol amount-text on-result
|
||||
(let [{:keys [id method public-key to symbol amount-text on-result on-error
|
||||
send-transaction-message?]}
|
||||
(get-in db [:wallet :send-transaction])
|
||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
|
||||
|
@ -40,7 +40,7 @@
|
||||
callback)))
|
||||
|
||||
(fx/defn call
|
||||
[{:keys [db] :as cofx} {:keys [contract method params callback on-result]}]
|
||||
[{:keys [db] :as cofx} {:keys [contract method params callback on-result on-error details]}]
|
||||
(let [chain-keyword (-> (get-in db [:account/account :networks (:network db)])
|
||||
ethereum/network->chain-keyword)
|
||||
contract-address (get-in contracts [contract :address chain-keyword])]
|
||||
@ -51,13 +51,15 @@
|
||||
(if write?
|
||||
(wallet/open-sign-transaction-flow
|
||||
cofx
|
||||
{:to contract-address
|
||||
:data data
|
||||
:id "approve"
|
||||
:symbol :ETH
|
||||
:method "eth_sendTransaction"
|
||||
:amount (money/bignumber 0)
|
||||
:on-result on-result})
|
||||
(merge {:to contract-address
|
||||
:data data
|
||||
:id "approve"
|
||||
:symbol :ETH
|
||||
:method "eth_sendTransaction"
|
||||
:amount (money/bignumber 0)
|
||||
:on-result on-result
|
||||
:on-error on-error}
|
||||
details))
|
||||
{::call {:address contract-address
|
||||
:data data
|
||||
:callback #(callback (if (empty? return-params)
|
||||
|
Loading…
x
Reference in New Issue
Block a user