diff --git a/src/status_im/models/wallet.cljs b/src/status_im/models/wallet.cljs index bb5f8e0239..25c773befd 100644 --- a/src/status_im/models/wallet.cljs +++ b/src/status_im/models/wallet.cljs @@ -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)) diff --git a/src/status_im/ui/screens/wallet/send/events.cljs b/src/status_im/ui/screens/wallet/send/events.cljs index ea5cc2e3ae..f7fe366ea5 100644 --- a/src/status_im/ui/screens/wallet/send/events.cljs +++ b/src/status_im/ui/screens/wallet/send/events.cljs @@ -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)] diff --git a/src/status_im/utils/ethereum/contracts.cljs b/src/status_im/utils/ethereum/contracts.cljs index e4197f9e15..200f70a10f 100644 --- a/src/status_im/utils/ethereum/contracts.cljs +++ b/src/status_im/utils/ethereum/contracts.cljs @@ -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)