The select assets screen is shown when token is going to be sent which available on both watch-only and regular account #19745 (#20050)
This commit is contained in:
parent
158ed083da
commit
47f6bda563
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [accounts (rf/sub [:wallet/accounts-without-watched-accounts])]
|
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])]
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:footer-container-padding 0
|
{:footer-container-padding 0
|
||||||
:header [account-switcher/view
|
:header [account-switcher/view
|
||||||
|
|
|
@ -141,7 +141,6 @@
|
||||||
(let [on-close (fn []
|
(let [on-close (fn []
|
||||||
(rf/dispatch [:wallet/clean-scanned-address])
|
(rf/dispatch [:wallet/clean-scanned-address])
|
||||||
(rf/dispatch [:wallet/clean-local-suggestions])
|
(rf/dispatch [:wallet/clean-local-suggestions])
|
||||||
(rf/dispatch [:wallet/clean-selected-token])
|
|
||||||
(rf/dispatch [:wallet/clean-selected-collectible])
|
(rf/dispatch [:wallet/clean-selected-collectible])
|
||||||
(rf/dispatch [:wallet/clean-send-address])
|
(rf/dispatch [:wallet/clean-send-address])
|
||||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||||
|
|
|
@ -120,6 +120,11 @@
|
||||||
:available-balance (utils/calculate-total-token-balance token)
|
:available-balance (utils/calculate-total-token-balance token)
|
||||||
:total-balance (utils/calculate-total-token-balance token enabled-from-chain-ids)))))
|
:total-balance (utils/calculate-total-token-balance token enabled-from-chain-ids)))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/wallet-send-token-symbol
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :token-symbol)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/wallet-send-disabled-from-chain-ids
|
:wallet/wallet-send-disabled-from-chain-ids
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
|
@ -400,6 +405,19 @@
|
||||||
(fn [accounts]
|
(fn [accounts]
|
||||||
(remove :watch-only? accounts)))
|
(remove :watch-only? accounts)))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/accounts-with-current-asset
|
||||||
|
:<- [:wallet/accounts-without-watched-accounts]
|
||||||
|
:<- [:wallet/wallet-send-token-symbol]
|
||||||
|
:<- [:wallet/wallet-send-token]
|
||||||
|
(fn [[accounts token-symbol token]]
|
||||||
|
(let [asset-symbol (or token-symbol (:symbol token))]
|
||||||
|
(if asset-symbol
|
||||||
|
(filter (fn [account]
|
||||||
|
(some #(= (:symbol %) asset-symbol) (:tokens account)))
|
||||||
|
accounts)
|
||||||
|
accounts))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/current-viewing-account-token-values
|
:wallet/current-viewing-account-token-values
|
||||||
:<- [:wallet/current-viewing-account]
|
:<- [:wallet/current-viewing-account]
|
||||||
|
|
|
@ -12,6 +12,14 @@
|
||||||
(use-fixtures :each
|
(use-fixtures :each
|
||||||
{:before #(reset! rf-db/app-db {})})
|
{:before #(reset! rf-db/app-db {})})
|
||||||
|
|
||||||
|
(def ^:private accounts-with-tokens
|
||||||
|
{:0x1 {:tokens [{:symbol "ETH"} {:symbol "SNT"}]
|
||||||
|
:network-preferences-names #{}
|
||||||
|
:customization-color nil}
|
||||||
|
:0x2 {:tokens [{:symbol "SNT"}]
|
||||||
|
:network-preferences-names #{}
|
||||||
|
:customization-color nil}})
|
||||||
|
|
||||||
(def tokens-0x1
|
(def tokens-0x1
|
||||||
[{:decimals 1
|
[{:decimals 1
|
||||||
:symbol "ETH"
|
:symbol "ETH"
|
||||||
|
@ -456,6 +464,46 @@
|
||||||
:tokens tokens-0x2})
|
:tokens tokens-0x2})
|
||||||
(rf/sub [sub-name])))))
|
(rf/sub [sub-name])))))
|
||||||
|
|
||||||
|
(h/deftest-sub :wallet/accounts-with-current-asset
|
||||||
|
[sub-name]
|
||||||
|
(testing "returns the accounts list with the current asset using token-symbol"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(-> %
|
||||||
|
(assoc-in [:wallet :accounts] accounts-with-tokens)
|
||||||
|
(assoc-in [:wallet :ui :send :token-symbol] "ETH")))
|
||||||
|
(let [result (rf/sub [sub-name])]
|
||||||
|
(is (match? result
|
||||||
|
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
|
||||||
|
:network-preferences-names #{}
|
||||||
|
:customization-color nil}]))))
|
||||||
|
|
||||||
|
(testing "returns the accounts list with the current asset using token"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(-> %
|
||||||
|
(assoc-in [:wallet :accounts] accounts-with-tokens)
|
||||||
|
(assoc-in [:wallet :ui :send :token] {:symbol "ETH"})))
|
||||||
|
(let [result (rf/sub [sub-name])]
|
||||||
|
(is (match? result
|
||||||
|
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
|
||||||
|
:network-preferences-names #{}
|
||||||
|
:customization-color nil}]))))
|
||||||
|
|
||||||
|
(testing
|
||||||
|
"returns the full accounts list with the current asset using token-symbol if each account has the asset"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(-> %
|
||||||
|
(assoc-in [:wallet :accounts] accounts-with-tokens)
|
||||||
|
(assoc-in [:wallet :ui :send :token-symbol] "SNT")))
|
||||||
|
(let [result (rf/sub [sub-name])]
|
||||||
|
(is (match? result (vals accounts-with-tokens)))))
|
||||||
|
|
||||||
|
(testing "returns the accounts list when there is no current asset"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(-> %
|
||||||
|
(assoc-in [:wallet :accounts] accounts-with-tokens)))
|
||||||
|
(let [result (rf/sub [sub-name])]
|
||||||
|
(is (match? result (vals accounts-with-tokens))))))
|
||||||
|
|
||||||
(h/deftest-sub :wallet/network-preference-details
|
(h/deftest-sub :wallet/network-preference-details
|
||||||
[sub-name]
|
[sub-name]
|
||||||
(testing "returns current viewing account address"
|
(testing "returns current viewing account address"
|
||||||
|
|
Loading…
Reference in New Issue