Props removed from view and moved to subscriptions
This commit is contained in:
parent
1be5be1ff9
commit
9f7cc76daf
|
@ -1,5 +1,7 @@
|
||||||
(ns status-im.contexts.wallet.send.input-amount.controller
|
(ns status-im.contexts.wallet.send.input-amount.controller
|
||||||
(:require
|
(:require
|
||||||
|
[clojure.string :as string]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.send.input-amount.controlled-input-logic :as controlled-input-logic]
|
[status-im.contexts.wallet.send.input-amount.controlled-input-logic :as controlled-input-logic]
|
||||||
[utils.money :as money]
|
[utils.money :as money]
|
||||||
|
@ -83,6 +85,14 @@
|
||||||
send-enabled-networks)))
|
send-enabled-networks)))
|
||||||
|
|
||||||
|
|
||||||
|
#_(comment
|
||||||
|
(inc 1)
|
||||||
|
(rf/sub [:wallet/wallet-send])
|
||||||
|
(rf/sub [:send-input-amount-screen/from-enabled-networks])
|
||||||
|
(rf/sub [:wallet/wallet-send-tx-type])
|
||||||
|
(rf/sub [:wallet/wallet-send-enabled-networks])
|
||||||
|
(rf/sub [:wallet/bridge-from-networks]))
|
||||||
|
|
||||||
(defn- every-network-value-is-zero?
|
(defn- every-network-value-is-zero?
|
||||||
[sender-network-values]
|
[sender-network-values]
|
||||||
(every? (fn [{:keys [total-amount]}]
|
(every? (fn [{:keys [total-amount]}]
|
||||||
|
@ -248,16 +258,15 @@
|
||||||
total-amount-receiver
|
total-amount-receiver
|
||||||
conversion-rate)))
|
conversion-rate)))
|
||||||
|
|
||||||
#_(rf/reg-sub :send-input-amount-screen/owned-eth-balance-is-zero?
|
(rf/reg-sub :send-input-amount-screen/owned-eth-balance-is-zero?
|
||||||
:<- [:send-input-amount-screen/currency-information]
|
:<- [:send-input-amount-screen/enabled-from-chain-ids]
|
||||||
:<- [:wallet/total-amount-in-to-chains]
|
(fn [enabled-from-chain-ids
|
||||||
(fn [[{:keys [conversion-rate token-symbol]}
|
]
|
||||||
total-amount-receiver]]
|
(let [owned-eth-token (rf/sub [:wallet/token-by-symbol
|
||||||
(let [owned-eth-token (rf/sub [:wallet/token-by-symbol
|
(string/upper-case
|
||||||
(string/upper-case
|
constants/mainnet-short-name)
|
||||||
constants/mainnet-short-name)
|
enabled-from-chain-ids])]
|
||||||
enabled-from-chain-ids])])
|
(money/equal-to (:total-balance owned-eth-token) 0))))
|
||||||
))
|
|
||||||
|
|
||||||
(rf/reg-sub :send-input-amount-screen/fee-formatted
|
(rf/reg-sub :send-input-amount-screen/fee-formatted
|
||||||
:<- [:send-input-amount-screen/routes-information]
|
:<- [:send-input-amount-screen/routes-information]
|
||||||
|
@ -282,8 +291,8 @@
|
||||||
:<- [:send-input-amount-screen/recipient-gets-amount]
|
:<- [:send-input-amount-screen/recipient-gets-amount]
|
||||||
:<- [:send-input-amount-screen/max-decimals]
|
:<- [:send-input-amount-screen/max-decimals]
|
||||||
:<- [:send-input-amount-screen/fee-formatted]
|
:<- [:send-input-amount-screen/fee-formatted]
|
||||||
:<- [:send-input-amount-screen/enabled-from-chain-ids]
|
|
||||||
:<- [:send-input-amount-screen/from-enabled-networks]
|
:<- [:send-input-amount-screen/from-enabled-networks]
|
||||||
|
:<- [:send-input-amount-screen/owned-eth-balance-is-zero?]
|
||||||
(fn
|
(fn
|
||||||
[[{:keys [crypto-currency? token-input-value] :as controller}
|
[[{:keys [crypto-currency? token-input-value] :as controller}
|
||||||
{:keys [fiat-currency token-symbol token] :as currency-information}
|
{:keys [fiat-currency token-symbol token] :as currency-information}
|
||||||
|
@ -307,8 +316,8 @@
|
||||||
recipient-gets-amount
|
recipient-gets-amount
|
||||||
max-decimals
|
max-decimals
|
||||||
fee-formatted
|
fee-formatted
|
||||||
enabled-from-chain-ids
|
from-enabled-networks
|
||||||
from-enabled-networks]]
|
owned-eth-balance-is-zero?]]
|
||||||
{:crypto-currency? crypto-currency?
|
{:crypto-currency? crypto-currency?
|
||||||
:fiat-currency fiat-currency
|
:fiat-currency fiat-currency
|
||||||
:token token
|
:token token
|
||||||
|
@ -339,8 +348,8 @@
|
||||||
:fee-formatted fee-formatted
|
:fee-formatted fee-formatted
|
||||||
:sending-to-unpreferred-networks? sending-to-unpreferred-networks?
|
:sending-to-unpreferred-networks? sending-to-unpreferred-networks?
|
||||||
:no-routes-found? no-routes-found?
|
:no-routes-found? no-routes-found?
|
||||||
:enabled-from-chain-ids enabled-from-chain-ids
|
:from-enabled-networks from-enabled-networks
|
||||||
:from-enabled-networks from-enabled-networks}))
|
:owned-eth-balance-is-zero? owned-eth-balance-is-zero?}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||||
[status-im.contexts.wallet.common.asset-list.view :as asset-list]
|
[status-im.contexts.wallet.common.asset-list.view :as asset-list]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
|
||||||
[status-im.contexts.wallet.send.input-amount.controller]
|
[status-im.contexts.wallet.send.input-amount.controller]
|
||||||
[status-im.contexts.wallet.send.input-amount.style :as style]
|
[status-im.contexts.wallet.send.input-amount.style :as style]
|
||||||
[status-im.contexts.wallet.send.routes.view :as routes]
|
[status-im.contexts.wallet.send.routes.view :as routes]
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
[utils.debounce :as debounce]
|
[utils.debounce :as debounce]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.money :as money]
|
[utils.money :as money]
|
||||||
[utils.number :as number]
|
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
#_{:navigation-system [view-id
|
#_{:navigation-system [view-id
|
||||||
|
@ -242,9 +240,10 @@
|
||||||
fee-formatted
|
fee-formatted
|
||||||
sending-to-unpreferred-networks?
|
sending-to-unpreferred-networks?
|
||||||
no-routes-found?
|
no-routes-found?
|
||||||
enabled-from-chain-ids
|
from-enabled-networks
|
||||||
from-enabled-networks]
|
owned-eth-balance-is-zero?]
|
||||||
:as state} (rf/sub [:send-input-amount-screen/data])
|
:as state} (rf/sub [:send-input-amount-screen/data])
|
||||||
|
;; from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
||||||
view-id (rf/sub [:view-id])
|
view-id (rf/sub [:view-id])
|
||||||
active-screen? (= view-id current-screen-id)
|
active-screen? (= view-id current-screen-id)
|
||||||
bottom (safe-area/get-bottom)
|
bottom (safe-area/get-bottom)
|
||||||
|
@ -254,10 +253,6 @@
|
||||||
{:content (fn [] [select-asset-bottom-sheet])}])
|
{:content (fn [] [select-asset-bottom-sheet])}])
|
||||||
should-try-again? (and (not upper-limit-exceeded?) no-routes-found?)
|
should-try-again? (and (not upper-limit-exceeded?) no-routes-found?)
|
||||||
current-address (rf/sub [:wallet/current-viewing-account-address])
|
current-address (rf/sub [:wallet/current-viewing-account-address])
|
||||||
owned-eth-token (rf/sub [:wallet/token-by-symbol
|
|
||||||
(string/upper-case
|
|
||||||
constants/mainnet-short-name)
|
|
||||||
enabled-from-chain-ids])
|
|
||||||
not-enough-asset? (and
|
not-enough-asset? (and
|
||||||
(or no-routes-found? upper-limit-exceeded?)
|
(or no-routes-found? upper-limit-exceeded?)
|
||||||
(not-empty sender-network-values)
|
(not-empty sender-network-values)
|
||||||
|
@ -267,9 +262,7 @@
|
||||||
(money/equal-to
|
(money/equal-to
|
||||||
(money/bignumber input-value)
|
(money/bignumber input-value)
|
||||||
(money/bignumber upper-limit))
|
(money/bignumber upper-limit))
|
||||||
(money/equal-to (:total-balance
|
owned-eth-balance-is-zero?))
|
||||||
owned-eth-token)
|
|
||||||
0)))
|
|
||||||
show-no-routes? (and
|
show-no-routes? (and
|
||||||
(or no-routes-found? upper-limit-exceeded?)
|
(or no-routes-found? upper-limit-exceeded?)
|
||||||
(not-empty sender-network-values)
|
(not-empty sender-network-values)
|
||||||
|
@ -314,6 +307,7 @@
|
||||||
{:icon-name :i/arrow-left
|
{:icon-name :i/arrow-left
|
||||||
:on-press #(rf/dispatch [:navigate-back])
|
:on-press #(rf/dispatch [:navigate-back])
|
||||||
:switcher-type :select-account}]
|
:switcher-type :select-account}]
|
||||||
|
(tap> from-enabled-networks)
|
||||||
[quo/token-input
|
[quo/token-input
|
||||||
{:container-style style/input-container
|
{:container-style style/input-container
|
||||||
:token-symbol token-symbol
|
:token-symbol token-symbol
|
||||||
|
|
Loading…
Reference in New Issue