-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#10203] Endless spinner when sending two TX in a batch in Dapp
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
- Loading branch information
1 parent
aebe68f
commit cc70a7e
Showing
9 changed files
with
92 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(ns status-im.wallet.prices | ||
(:require [re-frame.core :as re-frame] | ||
[status-im.utils.fx :as fx] | ||
[status-im.utils.prices :as prices] | ||
[status-im.ethereum.core :as ethereum] | ||
[status-im.ethereum.tokens :as tokens] | ||
[status-im.wallet.utils :as wallet.utils] | ||
[status-im.constants :as constants] | ||
[clojure.set :as set] | ||
[taoensso.timbre :as log])) | ||
|
||
(defn assoc-error-message [db error-type err] | ||
(assoc-in db [:wallet :errors error-type] (or err :unknown-error))) | ||
|
||
(defn clear-error-message [db error-type] | ||
(update-in db [:wallet :errors] dissoc error-type)) | ||
|
||
(defn tokens-symbols | ||
[visible-token-symbols all-tokens] | ||
(set/difference (set visible-token-symbols) | ||
(set (map :symbol (tokens/nfts-for all-tokens))))) | ||
|
||
(re-frame/reg-fx | ||
:wallet/get-prices | ||
(fn [{:keys [from to mainnet? success-event error-event chaos-mode?]}] | ||
(prices/get-prices from | ||
to | ||
mainnet? | ||
#(re-frame/dispatch [success-event %]) | ||
#(re-frame/dispatch [error-event %]) | ||
chaos-mode?))) | ||
|
||
(fx/defn on-update-prices-success | ||
{:events [::update-prices-success]} | ||
[{:keys [db]} prices] | ||
{:db (assoc db | ||
:prices prices | ||
:prices-loading? false)}) | ||
|
||
(fx/defn on-update-prices-fail | ||
{:events [::update-prices-fail]} | ||
[{:keys [db]} err] | ||
(log/debug "Unable to get prices: " err) | ||
{:db (-> db | ||
(assoc-error-message :prices-update :error-unable-to-get-prices) | ||
(assoc :prices-loading? false))}) | ||
|
||
(fx/defn update-prices | ||
{:events [:wallet.ui/pull-to-refresh]} | ||
[{{:keys [network-status :wallet/all-tokens] | ||
{:keys [currency chaos-mode? :wallet/visible-tokens] | ||
:or {currency :usd}} :multiaccount :as db} :db}] | ||
(let [chain (ethereum/chain-keyword db) | ||
mainnet? (= :mainnet chain) | ||
assets (get visible-tokens chain #{}) | ||
tokens (tokens-symbols assets all-tokens) | ||
currency (get constants/currencies currency)] | ||
(when (not= network-status :offline) | ||
{:wallet/get-prices | ||
{:from (if mainnet? | ||
(conj tokens "ETH") | ||
[(-> (tokens/native-currency chain) | ||
(wallet.utils/exchange-symbol))]) | ||
:to [(:code currency)] | ||
:mainnet? mainnet? | ||
:success-event ::update-prices-success | ||
:error-event ::update-prices-fail | ||
:chaos-mode? chaos-mode?} | ||
|
||
:db | ||
(-> db | ||
(clear-error-message :prices-update) | ||
(assoc :prices-loading? true))}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters