diff --git a/src/status_im/contexts/wallet/send/input_amount/controller.cljs b/src/status_im/contexts/wallet/send/input_amount/controller.cljs index 3a55b694e2..35df38480f 100644 --- a/src/status_im/contexts/wallet/send/input_amount/controller.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/controller.cljs @@ -1,5 +1,7 @@ (ns status-im.contexts.wallet.send.input-amount.controller (:require + [clojure.string :as string] + [status-im.constants :as constants] [status-im.contexts.wallet.common.utils :as utils] [status-im.contexts.wallet.send.input-amount.controlled-input-logic :as controlled-input-logic] [utils.money :as money] @@ -83,6 +85,14 @@ 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? [sender-network-values] (every? (fn [{:keys [total-amount]}] @@ -248,16 +258,15 @@ total-amount-receiver conversion-rate))) -#_(rf/reg-sub :send-input-amount-screen/owned-eth-balance-is-zero? - :<- [:send-input-amount-screen/currency-information] - :<- [:wallet/total-amount-in-to-chains] - (fn [[{:keys [conversion-rate token-symbol]} - total-amount-receiver]] - (let [owned-eth-token (rf/sub [:wallet/token-by-symbol - (string/upper-case - constants/mainnet-short-name) - enabled-from-chain-ids])]) - )) +(rf/reg-sub :send-input-amount-screen/owned-eth-balance-is-zero? + :<- [:send-input-amount-screen/enabled-from-chain-ids] + (fn [enabled-from-chain-ids + ] + (let [owned-eth-token (rf/sub [:wallet/token-by-symbol + (string/upper-case + constants/mainnet-short-name) + enabled-from-chain-ids])] + (money/equal-to (:total-balance owned-eth-token) 0)))) (rf/reg-sub :send-input-amount-screen/fee-formatted :<- [:send-input-amount-screen/routes-information] @@ -282,8 +291,8 @@ :<- [:send-input-amount-screen/recipient-gets-amount] :<- [:send-input-amount-screen/max-decimals] :<- [: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/owned-eth-balance-is-zero?] (fn [[{:keys [crypto-currency? token-input-value] :as controller} {:keys [fiat-currency token-symbol token] :as currency-information} @@ -307,8 +316,8 @@ recipient-gets-amount max-decimals fee-formatted - enabled-from-chain-ids - from-enabled-networks]] + from-enabled-networks + owned-eth-balance-is-zero?]] {:crypto-currency? crypto-currency? :fiat-currency fiat-currency :token token @@ -339,8 +348,8 @@ :fee-formatted fee-formatted :sending-to-unpreferred-networks? sending-to-unpreferred-networks? :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?})) diff --git a/src/status_im/contexts/wallet/send/input_amount/view.cljs b/src/status_im/contexts/wallet/send/input_amount/view.cljs index 240adb3047..bd444f801a 100644 --- a/src/status_im/contexts/wallet/send/input_amount/view.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/view.cljs @@ -9,7 +9,6 @@ [status-im.constants :as constants] [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.utils :as utils] [status-im.contexts.wallet.send.input-amount.controller] [status-im.contexts.wallet.send.input-amount.style :as style] [status-im.contexts.wallet.send.routes.view :as routes] @@ -20,7 +19,6 @@ [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.money :as money] - [utils.number :as number] [utils.re-frame :as rf])) #_{:navigation-system [view-id @@ -242,9 +240,10 @@ fee-formatted sending-to-unpreferred-networks? 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]) + ;; from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks]) view-id (rf/sub [:view-id]) active-screen? (= view-id current-screen-id) bottom (safe-area/get-bottom) @@ -254,10 +253,6 @@ {:content (fn [] [select-asset-bottom-sheet])}]) should-try-again? (and (not upper-limit-exceeded?) no-routes-found?) 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 (or no-routes-found? upper-limit-exceeded?) (not-empty sender-network-values) @@ -267,9 +262,7 @@ (money/equal-to (money/bignumber input-value) (money/bignumber upper-limit)) - (money/equal-to (:total-balance - owned-eth-token) - 0))) + owned-eth-balance-is-zero?)) show-no-routes? (and (or no-routes-found? upper-limit-exceeded?) (not-empty sender-network-values) @@ -314,6 +307,7 @@ {:icon-name :i/arrow-left :on-press #(rf/dispatch [:navigate-back]) :switcher-type :select-account}] + (tap> from-enabled-networks) [quo/token-input {:container-style style/input-container :token-symbol token-symbol