diff --git a/src/status_im/contexts/wallet/common/utils/networks.cljs b/src/status_im/contexts/wallet/common/utils/networks.cljs index 6d60bc8d46..b363d4f3d6 100644 --- a/src/status_im/contexts/wallet/common/utils/networks.cljs +++ b/src/status_im/contexts/wallet/common/utils/networks.cljs @@ -7,6 +7,7 @@ [utils.number])) (def ^:private last-comma-followed-by-text-to-end-regex #",\s(?=[^,]+$)") +(def ^:private max-network-prefixes 2) (def id->network {constants/ethereum-mainnet-chain-id constants/mainnet-network-name @@ -185,3 +186,11 @@ :related-chain-id related-chain-id :layer layer))) (sort-by (juxt :layer :short-name)))) + +(defn format-address + [address network-preferences] + (let [short-names (map network->short-name network-preferences) + prefix (when (<= (count short-names) max-network-prefixes) + (short-names->network-preference-prefix short-names)) + transformed-address (str prefix address)] + transformed-address)) diff --git a/src/status_im/contexts/wallet/swap/events.cljs b/src/status_im/contexts/wallet/swap/events.cljs index 5c5afde024..46bbf28ef4 100644 --- a/src/status_im/contexts/wallet/swap/events.cljs +++ b/src/status_im/contexts/wallet/swap/events.cljs @@ -537,7 +537,7 @@ (fn [{:keys [db]} [account]] (let [asset-to-pay (get-in db [:wallet :ui :swap :asset-to-pay]) asset-to-receive (get-in db [:wallet :ui :swap :asset-to-receive])] - {:fx [[:dispatch [:navigate-back]] + {:fx [[:dispatch [:dismiss-modal :screen/wallet.swap-select-account]] [:dispatch [:wallet.swap/start {:asset-to-pay asset-to-pay diff --git a/src/status_im/subs/wallet/networks.cljs b/src/status_im/subs/wallet/networks.cljs index 28184a0756..3685d45fa0 100644 --- a/src/status_im/subs/wallet/networks.cljs +++ b/src/status_im/subs/wallet/networks.cljs @@ -4,8 +4,6 @@ [utils.money :as money] [utils.number :as number])) -(def max-network-prefixes 2) - (re-frame/reg-sub :wallet/networks :<- [:wallet] @@ -53,12 +51,7 @@ (re-frame/reg-sub :wallet/account-address (fn [_ [_ address network-preferences]] - (let [short-names (map network-utils/network->short-name network-preferences) - prefix (when (<= (count short-names) max-network-prefixes) - (network-utils/short-names->network-preference-prefix - short-names)) - transformed-address (str prefix address)] - transformed-address))) + (network-utils/format-address address network-preferences))) (re-frame/reg-sub :wallet/network-values diff --git a/src/status_im/subs/wallet/swap.cljs b/src/status_im/subs/wallet/swap.cljs index 9b9ccb2957..c040dcf909 100644 --- a/src/status_im/subs/wallet/swap.cljs +++ b/src/status_im/subs/wallet/swap.cljs @@ -3,6 +3,7 @@ [re-frame.core :as rf] [status-im.constants :as constants] [status-im.contexts.wallet.common.utils :as utils] + [status-im.contexts.wallet.common.utils.networks :as network-utils] [status-im.contexts.wallet.send.utils :as send-utils] [utils.money :as money] [utils.number :as number])) @@ -326,8 +327,8 @@ (let [tokens (:tokens account) filtered-tokens (filter #(= (:symbol %) token-symbol) tokens) asset-pay-balance (utils/calculate-total-token-balance filtered-tokens) - formatted-address @(rf/subscribe [:wallet/account-address (:address account) - (:network-preferences-names account)])] + formatted-address (network-utils/format-address (:address account) + (:network-preferences-names account))] (assoc account :formatted-address formatted-address :asset-pay-balance (utils/sanitized-token-amount-to-display