Transaction approval
This commit is contained in:
parent
4b08052f39
commit
49d368ebfb
|
@ -10,7 +10,7 @@
|
|||
|
||||
(defn enabled? [v] (= "1" v))
|
||||
|
||||
(goog-define INFURA_TOKEN "2a8db7e5dd1b414a896f2a0f73de18f9")
|
||||
(goog-define INFURA_TOKEN "")
|
||||
(goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9")
|
||||
(goog-define STATUS_BUILD_PROXY_USER "")
|
||||
(goog-define STATUS_BUILD_PROXY_PASSWORD "")
|
||||
|
|
|
@ -701,10 +701,14 @@
|
|||
(fn [{:keys [db]}
|
||||
[{sent-transactions :sentTransactions
|
||||
send-details :sendDetails}]]
|
||||
(if (get-in db [:wallet :ui :swap])
|
||||
{:fx [(if-let [error-response (:errorResponse send-details)]
|
||||
[:dispatch [:wallet.swap/transaction-failure error-response]]
|
||||
[:dispatch [:wallet.swap/transaction-success sent-transactions]])]}
|
||||
{:fx [(if-let [error-response (:errorResponse send-details)]
|
||||
[:dispatch [:wallet/transaction-failure error-response]]
|
||||
[:dispatch [:wallet/transaction-success sent-transactions]])]})))
|
||||
(let [swap? (get-in db [:wallet :ui :swap])]
|
||||
{:fx [[:dispatch
|
||||
(if-let [error-response (:errorResponse send-details)]
|
||||
[(if swap?
|
||||
:wallet.swap/transaction-failure
|
||||
:wallet/transaction-failure)
|
||||
error-response]
|
||||
[(if swap?
|
||||
:wallet.swap/transaction-success
|
||||
:wallet/transaction-success)
|
||||
sent-transactions])]]})))
|
||||
|
|
|
@ -575,44 +575,6 @@
|
|||
:from-locked-amounts {}}}}})
|
||||
(is (match? expected-db (:db (dispatch [event-id suggested-routes timestamp]))))))
|
||||
|
||||
(h/deftest-event :wallet/transactions-sent-signal-received
|
||||
[event-id dispatch]
|
||||
(let [sent-transactions [{:amount "0x0"
|
||||
:fromAddress "0x1"
|
||||
:fromChain 1
|
||||
:fromToken "SNT"
|
||||
:hash "0x112233"
|
||||
:toAddress "0x2"
|
||||
:toChain 1
|
||||
:toToken "SNT"}
|
||||
{:amount "0x0"
|
||||
:fromAddress "0x1"
|
||||
:fromChain 1
|
||||
:fromToken "SNT"
|
||||
:hash "0x445566"
|
||||
:toAddress "0x2"
|
||||
:toChain 2
|
||||
:toToken "SNT"}]
|
||||
expected-result {:db {:wallet {:ui {:send {:transaction-ids
|
||||
["0x112233"
|
||||
"0x445566"]}
|
||||
:just-completed-transaction? true}
|
||||
:transactions [{:status :pending
|
||||
:id "0x112233"
|
||||
:chain-id 1}
|
||||
{:status :pending
|
||||
:id "0x445566"
|
||||
:chain-id 2}]}}
|
||||
:fx [[:dispatch [:wallet/end-transaction-flow]]
|
||||
[:dispatch-later
|
||||
[{:ms 2000
|
||||
:dispatch [:wallet/stop-and-clean-suggested-routes]}]]
|
||||
[:dispatch-later
|
||||
[{:ms 2000
|
||||
:dispatch [:wallet/clean-just-completed-transaction]}]]]}]
|
||||
(is (match? expected-result
|
||||
(dispatch [event-id {:sentTransactions sent-transactions}])))))
|
||||
|
||||
(h/deftest-event :wallet/select-from-account
|
||||
[event-id dispatch]
|
||||
(let [stack-id :screen/stack
|
||||
|
|
|
@ -389,14 +389,24 @@
|
|||
:previous_token (:symbol asset-to-receive)
|
||||
:new_token (:symbol asset-to-pay)}]]]})))
|
||||
|
||||
;; TODO(alwx):
|
||||
(rf/reg-event-fx
|
||||
:wallet.swap/approve
|
||||
(fn [{:keys [db]}]
|
||||
(let [last-request-uuid (get-in db [:wallet :ui :swap :last-request-uuid])
|
||||
max-slippage (get-in db [:wallet :ui :swap :max-slippage])]
|
||||
{:fx [[:dispatch
|
||||
[:wallet/build-transactions-from-route
|
||||
{:request-uuid last-request-uuid
|
||||
:slippage max-slippage}]]
|
||||
[:dispatch [:open-modal :screen/wallet.swap-set-spending-cap]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet.swap/review-swap
|
||||
(fn [{:keys [db]}]
|
||||
(let [last-request-uuid (get-in db [:wallet :ui :swap :last-request-uuid])
|
||||
max-slippage (get-in db [:wallet :ui :swap :max-slippage])]
|
||||
{:db (-> db
|
||||
(update-in [:wallet :ui :send] dissoc :transaction-for-signing))
|
||||
(update-in [:wallet :ui :swap] dissoc :transaction-for-signing))
|
||||
:fx [[:dispatch
|
||||
[:wallet/build-transactions-from-route
|
||||
{:request-uuid last-request-uuid
|
||||
|
@ -456,9 +466,12 @@
|
|||
:receive-token-symbol token-id-to
|
||||
:receive-amount receive-amount
|
||||
:swap-chain-id swap-chain-id}))]]
|
||||
[:dispatch [:wallet.swap/end-transaction-flow]]
|
||||
(when approval-required?
|
||||
;; dismiss the spending cap dialog if the transaction needs to be approved
|
||||
[:dispatch [:dismiss-modal :screen/wallet.swap-set-spending-cap]])
|
||||
(when-not approval-required?
|
||||
[:dispatch [:wallet.swap/end-flow]])
|
||||
;; just end the whole transaction flow if no approval needed
|
||||
[:dispatch [:wallet.swap/end-transaction-flow]])
|
||||
(when-not approval-required?
|
||||
[:dispatch-later
|
||||
{:ms 500
|
||||
|
|
|
@ -488,7 +488,7 @@
|
|||
:on-max-press on-max-press
|
||||
:input-focused? pay-input-focused?
|
||||
:on-token-press #(rf/dispatch [:show-bottom-sheet {:content pay-token-bottom-sheet}])
|
||||
:on-approve-press #(rf/dispatch [:open-modal :screen/wallet.swap-set-spending-cap])
|
||||
:on-approve-press #(rf/dispatch [:wallet.swap/approve])
|
||||
:on-input-focus (fn []
|
||||
(when platform/android? (rf/dispatch [:dismiss-keyboard]))
|
||||
(set-pay-input-focused? true))}]
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
(ns status-im.contexts.wallet.swap.swap-proposal.style)
|
||||
|
||||
(def container
|
||||
{:flex 1})
|
|
@ -1,27 +0,0 @@
|
|||
(ns status-im.contexts.wallet.swap.swap-proposal.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.contexts.wallet.sheets.slippage-settings.view :as slippage-settings]
|
||||
[status-im.contexts.wallet.swap.swap-proposal.style :as style]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [max-slippage (rf/sub [:wallet/swap-max-slippage])]
|
||||
[rn/view {:style style/container}
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:show-bottom-sheet
|
||||
{:content slippage-settings/view}])}
|
||||
(str "Edit Slippage: " max-slippage "%")]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:navigate-to-within-stack
|
||||
[:screen/wallet.swap-confirmation :screen/wallet.swap-propasal]])}
|
||||
"Swap confirmation"]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:open-modal :screen/wallet.swap-set-spending-cap])}
|
||||
"Set spending cap"]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:navigate-to-within-stack
|
||||
[:screen/wallet.setup-swap :screen/wallet.swap-propasal]])}
|
||||
"Setup swap"]]))
|
|
@ -138,7 +138,6 @@
|
|||
[status-im.contexts.wallet.swap.set-spending-cap.view :as wallet-swap-set-spending-cap]
|
||||
[status-im.contexts.wallet.swap.setup-swap.view :as wallet-swap-setup-swap]
|
||||
[status-im.contexts.wallet.swap.swap-confirmation.view :as wallet-swap-confirmation]
|
||||
[status-im.contexts.wallet.swap.swap-proposal.view :as wallet-swap-propasal]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.send-transaction.view :as
|
||||
wallet-connect-send-transaction]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.session-proposal.view :as
|
||||
|
@ -642,12 +641,6 @@
|
|||
:insets {:bottom? true}}
|
||||
:component wallet-swap-setup-swap/view}
|
||||
|
||||
{:name :screen/wallet.swap-propasal
|
||||
:metrics {:track? true
|
||||
:alias-id :wallet-swap.swap-proposal}
|
||||
:options {:insets {:top? true}}
|
||||
:component wallet-swap-propasal/view}
|
||||
|
||||
{:name :screen/wallet.swap-set-spending-cap
|
||||
:metrics {:track? true
|
||||
:alias-id :wallet-swap.set-spending-cap}
|
||||
|
|
Loading…
Reference in New Issue