fix: non supported network warning is shown on the bridge flow (#20098)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
7e4f55450b
commit
52aaee0bd1
|
@ -17,6 +17,7 @@
|
||||||
:padding-vertical 8
|
:padding-vertical 8
|
||||||
:border-radius 12
|
:border-radius 12
|
||||||
:height 56
|
:height 56
|
||||||
|
:opacity (if (= state :disabled) 0.3 1)
|
||||||
:background-color (background-color state customization-color theme)})
|
:background-color (background-color state customization-color theme)})
|
||||||
|
|
||||||
(def info
|
(def info
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
[:fiat-value :string]
|
[:fiat-value :string]
|
||||||
[:token-value :string]
|
[:token-value :string]
|
||||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||||
[:state {:optional true} [:enum :pressed :active :default]]
|
[:state {:optional true} [:enum :pressed :active :disabled :default]]
|
||||||
[:on-press {:optional true} [:maybe fn?]]]]]
|
[:on-press {:optional true} [:maybe fn?]]]]]
|
||||||
:any])
|
:any])
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@
|
||||||
internal-state (if pressed? :pressed state)]
|
internal-state (if pressed? :pressed state)]
|
||||||
[rn/pressable
|
[rn/pressable
|
||||||
{:style (style/container internal-state customization-color theme)
|
{:style (style/container internal-state customization-color theme)
|
||||||
:on-press-in on-press-in
|
:on-press-in (when-not (= state :disabled) on-press-in)
|
||||||
:on-press-out on-press-out
|
:on-press-out (when-not (= state :disabled) on-press-out)
|
||||||
:on-press on-press
|
:on-press (when-not (= state :disabled) on-press)
|
||||||
:accessibility-label :network-list}
|
:accessibility-label :network-list}
|
||||||
[info props]
|
[info props]
|
||||||
[values props]]))
|
[values props]]))
|
||||||
|
|
|
@ -8,44 +8,49 @@
|
||||||
[status-im.contexts.wallet.bridge.bridge-to.style :as style]
|
[status-im.contexts.wallet.bridge.bridge-to.style :as style]
|
||||||
[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.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
|
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn- bridge-token-component
|
(defn- bridge-token-component
|
||||||
[]
|
[]
|
||||||
(fn [{:keys [chain-id network-name]} token]
|
(fn [{:keys [chain-id network-name]} {:keys [networks] :as token}]
|
||||||
(let [network (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
(let [network (rf/sub [:wallet/network-details-by-chain-id chain-id])
|
||||||
currency (rf/sub [:profile/currency])
|
currency (rf/sub [:profile/currency])
|
||||||
currency-symbol (rf/sub [:profile/currency-symbol])
|
currency-symbol (rf/sub [:profile/currency-symbol])
|
||||||
balance (utils/calculate-total-token-balance token [chain-id])
|
balance (utils/calculate-total-token-balance token [chain-id])
|
||||||
crypto-value (utils/get-standard-crypto-format token balance)
|
crypto-value (utils/get-standard-crypto-format token balance)
|
||||||
fiat-value (utils/calculate-token-fiat-value
|
fiat-value (utils/calculate-token-fiat-value
|
||||||
{:currency currency
|
{:currency currency
|
||||||
:balance balance
|
:balance balance
|
||||||
:token token})
|
:token token})
|
||||||
fiat-formatted (utils/get-standard-fiat-format crypto-value currency-symbol fiat-value)]
|
fiat-formatted (utils/get-standard-fiat-format crypto-value
|
||||||
|
currency-symbol
|
||||||
|
fiat-value)
|
||||||
|
token-available-on-network? (network-utils/token-available-on-network? networks chain-id)]
|
||||||
[quo/network-list
|
[quo/network-list
|
||||||
{:label (name network-name)
|
{:label (name network-name)
|
||||||
:network-image (quo.resources/get-network (:network-name network))
|
:network-image (quo.resources/get-network (:network-name network))
|
||||||
:token-value (str crypto-value " " (:symbol token))
|
:token-value (str crypto-value " " (:symbol token))
|
||||||
:fiat-value fiat-formatted
|
:fiat-value fiat-formatted
|
||||||
|
:state (if token-available-on-network? :default :disabled)
|
||||||
:on-press #(rf/dispatch [:wallet/select-bridge-network
|
:on-press #(rf/dispatch [:wallet/select-bridge-network
|
||||||
{:network-chain-id chain-id
|
{:network-chain-id chain-id
|
||||||
:stack-id :screen/wallet.bridge-to}])}])))
|
:stack-id :screen/wallet.bridge-to}])}])))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [send-bridge-data (rf/sub [:wallet/wallet-send])
|
(let [network-details (rf/sub [:wallet/network-details])
|
||||||
network-details (rf/sub [:wallet/network-details])
|
|
||||||
account (rf/sub [:wallet/current-viewing-account])
|
account (rf/sub [:wallet/current-viewing-account])
|
||||||
token (:token send-bridge-data)
|
token (rf/sub [:wallet/wallet-send-token])
|
||||||
token-symbol (:symbol token)
|
token-symbol (:symbol token)
|
||||||
tokens (:tokens account)
|
tokens (:tokens account)
|
||||||
mainnet (first network-details)
|
mainnet (first network-details)
|
||||||
layer-2-networks (rest network-details)
|
layer-2-networks (rest network-details)
|
||||||
account-token (some #(when (= token-symbol (:symbol %)) %) tokens)
|
account-token (some #(when (= token-symbol (:symbol %)) %) tokens)
|
||||||
|
account-token (when account-token (assoc account-token :networks (:networks token)))
|
||||||
bridge-to-title (i18n/label :t/bridge-to
|
bridge-to-title (i18n/label :t/bridge-to
|
||||||
{:name (string/upper-case (str (:name token)))})]
|
{:name (string/upper-case (str token-symbol))})]
|
||||||
[rn/view
|
[rn/view
|
||||||
[account-switcher/view
|
[account-switcher/view
|
||||||
{:on-press #(rf/dispatch [:navigate-back])
|
{:on-press #(rf/dispatch [:navigate-back])
|
||||||
|
|
|
@ -125,3 +125,9 @@
|
||||||
(string/join ", "))
|
(string/join ", "))
|
||||||
formatted-text (string/replace network-names last-comma-followed-by-text-to-end-regex " and ")]
|
formatted-text (string/replace network-names last-comma-followed-by-text-to-end-regex " and ")]
|
||||||
formatted-text))
|
formatted-text))
|
||||||
|
|
||||||
|
(defn token-available-on-network?
|
||||||
|
[token-networks chain-id]
|
||||||
|
(let [token-networks-ids (mapv #(:chain-id %) token-networks)
|
||||||
|
token-networks-ids-set (set token-networks-ids)]
|
||||||
|
(contains? token-networks-ids-set chain-id)))
|
||||||
|
|
|
@ -95,7 +95,8 @@
|
||||||
:related-chain-id 1
|
:related-chain-id 1
|
||||||
:layer 1}]
|
:layer 1}]
|
||||||
:wallet/wallet-send-enabled-from-chain-ids [1]
|
:wallet/wallet-send-enabled-from-chain-ids [1]
|
||||||
:wallet/wallet-send-amount nil})
|
:wallet/wallet-send-amount nil
|
||||||
|
:wallet/wallet-send-tx-type :tx/send})
|
||||||
|
|
||||||
(h/describe "Send > input amount screen"
|
(h/describe "Send > input amount screen"
|
||||||
(h/setup-restorable-re-frame)
|
(h/setup-restorable-re-frame)
|
||||||
|
|
|
@ -251,9 +251,11 @@
|
||||||
[:wallet/wallet-send-sender-network-values])
|
[:wallet/wallet-send-sender-network-values])
|
||||||
receiver-network-values (rf/sub
|
receiver-network-values (rf/sub
|
||||||
[:wallet/wallet-send-receiver-network-values])
|
[:wallet/wallet-send-receiver-network-values])
|
||||||
token-not-supported-in-receiver-networks? (every? #(= (:type %) :not-available)
|
tx-type (rf/sub [:wallet/wallet-send-tx-type])
|
||||||
(filter #(not= (:type %) :add)
|
token-not-supported-in-receiver-networks? (and (not= tx-type :tx/bridge)
|
||||||
receiver-network-values))
|
(->> receiver-network-values
|
||||||
|
(remove #(= (:type %) :add))
|
||||||
|
(every? #(= (:type %) :not-available))))
|
||||||
suggested-routes (rf/sub [:wallet/wallet-send-suggested-routes])
|
suggested-routes (rf/sub [:wallet/wallet-send-suggested-routes])
|
||||||
routes (when suggested-routes
|
routes (when suggested-routes
|
||||||
(or (:best suggested-routes) []))
|
(or (:best suggested-routes) []))
|
||||||
|
|
|
@ -160,6 +160,11 @@
|
||||||
:<- [:wallet/wallet-send]
|
:<- [:wallet/wallet-send]
|
||||||
:-> :network-links)
|
:-> :network-links)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/wallet-send-tx-type
|
||||||
|
:<- [:wallet/wallet-send]
|
||||||
|
:-> :tx-type)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/keypairs
|
:wallet/keypairs
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
|
|
Loading…
Reference in New Issue