[#21132] fix: add on-success callback
This commit is contained in:
parent
48f0af4d36
commit
bb0847f463
|
@ -2,7 +2,6 @@
|
||||||
(:require [cljs-bean.core :as bean]
|
(:require [cljs-bean.core :as bean]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
[re-frame.core :as rf]
|
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.wallet.wallet-connect.utils.data-store :as
|
[status-im.contexts.wallet.wallet-connect.utils.data-store :as
|
||||||
data-store]
|
data-store]
|
||||||
|
@ -11,6 +10,7 @@
|
||||||
[status-im.contexts.wallet.wallet-connect.utils.transactions :as transactions]
|
[status-im.contexts.wallet.wallet-connect.utils.transactions :as transactions]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]
|
||||||
[utils.transforms :as transforms]))
|
[utils.transforms :as transforms]))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
|
@ -37,7 +37,9 @@
|
||||||
(assoc-in [:wallet-connect/current-request :response-sent?] false))
|
(assoc-in [:wallet-connect/current-request :response-sent?] false))
|
||||||
:fx [(condp = method
|
:fx [(condp = method
|
||||||
constants/wallet-connect-eth-send-transaction-method
|
constants/wallet-connect-eth-send-transaction-method
|
||||||
[:dispatch [:wallet-connect/process-eth-send-transaction]]
|
[:dispatch
|
||||||
|
[:wallet-connect/process-eth-send-transaction
|
||||||
|
{:on-success (fn [] (rf/dispatch [:wallet-connect/show-request-modal]))}]]
|
||||||
|
|
||||||
constants/wallet-connect-eth-sign-method
|
constants/wallet-connect-eth-sign-method
|
||||||
[:dispatch [:wallet-connect/process-eth-sign]]
|
[:dispatch [:wallet-connect/process-eth-sign]]
|
||||||
|
@ -82,7 +84,7 @@
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/prepare-transaction-success
|
:wallet-connect/prepare-transaction-success
|
||||||
(fn [{:keys [db]} [prepared-tx chain-id refetch?]]
|
(fn [{:keys [db]} [prepared-tx chain-id]]
|
||||||
(let [{:keys [tx-args]} prepared-tx
|
(let [{:keys [tx-args]} prepared-tx
|
||||||
tx (bean/->clj tx-args)
|
tx (bean/->clj tx-args)
|
||||||
address (-> tx :from string/lower-case)
|
address (-> tx :from string/lower-case)
|
||||||
|
@ -94,12 +96,11 @@
|
||||||
:raw-data prepared-tx
|
:raw-data prepared-tx
|
||||||
:transaction tx
|
:transaction tx
|
||||||
:chain-id chain-id
|
:chain-id chain-id
|
||||||
:display-data display-data)
|
:display-data display-data)})))
|
||||||
:fx [(when-not refetch? [:dispatch [:wallet-connect/show-request-modal]])]})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet-connect/process-eth-send-transaction
|
:wallet-connect/process-eth-send-transaction
|
||||||
(fn [{:keys [db]} [refetch?]]
|
(fn [{:keys [db]} [{:keys [on-success]}]]
|
||||||
(let [event (data-store/get-db-current-request-event db)
|
(let [event (data-store/get-db-current-request-event db)
|
||||||
tx (-> event data-store/get-request-params first)
|
tx (-> event data-store/get-request-params first)
|
||||||
chain-id (-> event
|
chain-id (-> event
|
||||||
|
@ -109,8 +110,10 @@
|
||||||
{:fx [[:effects.wallet-connect/prepare-transaction
|
{:fx [[:effects.wallet-connect/prepare-transaction
|
||||||
{:tx tx
|
{:tx tx
|
||||||
:chain-id chain-id
|
:chain-id chain-id
|
||||||
:on-success #(rf/dispatch [:wallet-connect/prepare-transaction-success % chain-id
|
:on-success (fn [data]
|
||||||
refetch?])
|
(rf/dispatch [:wallet-connect/prepare-transaction-success data chain-id])
|
||||||
|
(when on-success
|
||||||
|
(rf/call-continuation on-success)))
|
||||||
:on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]}))))
|
:on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
(defn- refetch-transaction
|
(defn- refetch-transaction
|
||||||
[]
|
[]
|
||||||
(rf/dispatch [:wallet-connect/process-eth-send-transaction true]))
|
(rf/dispatch [:wallet-connect/process-eth-send-transaction]))
|
||||||
|
|
||||||
(def tabs-data
|
(def tabs-data
|
||||||
[{:id :tab/data :label (i18n/label :t/data)}
|
[{:id :tab/data :label (i18n/label :t/data)}
|
||||||
|
|
Loading…
Reference in New Issue