diff --git a/src/quo/components/wallet/summary_info/view.cljs b/src/quo/components/wallet/summary_info/view.cljs index 375321770d..00d8d17984 100644 --- a/src/quo/components/wallet/summary_info/view.cljs +++ b/src/quo/components/wallet/summary_info/view.cljs @@ -30,8 +30,8 @@ (defn networks [values theme] (let [{:keys [ethereum optimism arbitrum]} values - show-optimism? (pos? optimism) - show-arbitrum? (pos? arbitrum)] + show-optimism? (and optimism (pos? (:amount optimism))) + show-arbitrum? (and arbitrum (pos? (:amount arbitrum)))] [rn/view {:style style/networks-container :accessibility-label :networks} diff --git a/src/quo/foundations/resources.cljs b/src/quo/foundations/resources.cljs index 94859e9302..0ddba9bae9 100644 --- a/src/quo/foundations/resources.cljs +++ b/src/quo/foundations/resources.cljs @@ -35,6 +35,7 @@ (def ^:private networks {:arbitrum (js/require "../resources/images/networks/Arbitrum.png") :ethereum (js/require "../resources/images/networks/Ethereum.png") + :mainnet (js/require "../resources/images/networks/Ethereum.png") :gnosis (js/require "../resources/images/networks/Gnosis.png") :hermez (js/require "../resources/images/networks/Hermez.png") :optimism (js/require "../resources/images/networks/Optimism.png") diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 483d13d7fc..36fafde387 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -429,7 +429,11 @@ (def ^:const optimism-short-name "opt") (def ^:const arbitrum-short-name "arb1") -(def ^:const mainnet-network-name :ethereum) +(def ^:const mainnet-abbreviated-name "Eth.") +(def ^:const optimism-abbreviated-name "Opt.") +(def ^:const arbitrum-abbreviated-name "Arb1.") + +(def ^:const mainnet-network-name :mainnet) (def ^:const optimism-network-name :optimism) (def ^:const arbitrum-network-name :arbitrum) diff --git a/src/status_im/contexts/wallet/account/bridge_send/view.cljs b/src/status_im/contexts/wallet/account/bridge_send/view.cljs index beb755ebf5..7005b45059 100644 --- a/src/status_im/contexts/wallet/account/bridge_send/view.cljs +++ b/src/status_im/contexts/wallet/account/bridge_send/view.cljs @@ -11,9 +11,10 @@ [] [rn/view {:style style/bridge-send-wrapper} [input-amount/view - {:button-one-label (i18n/label :t/confirm-bridge) - :button-one-props {:icon-left :i/bridge} - :on-navigate-back (fn [] - (rf/dispatch [:navigate-back-within-stack :wallet-bridge-send]))}]]) + {:current-screen-id :wallet-bridge-send + :button-one-label (i18n/label :t/confirm-bridge) + :button-one-props {:icon-left :i/bridge} + :on-navigate-back (fn [] + (rf/dispatch [:navigate-back-within-stack :wallet-bridge-send]))}]]) (def view (quo.theme/with-theme view-internal)) diff --git a/src/status_im/contexts/wallet/common/utils/send.cljs b/src/status_im/contexts/wallet/common/utils/send.cljs index 025b9a1a85..548d409f50 100644 --- a/src/status_im/contexts/wallet/common/utils/send.cljs +++ b/src/status_im/contexts/wallet/common/utils/send.cljs @@ -16,3 +16,7 @@ (let [gas-price (money/bignumber (get gas-fees :gas-price)) total-gas-fee (money/mul gas-amount gas-price)] (money/with-precision (money/div total-gas-fee billion) 10))))) + +(defn calculate-full-route-gas-fee + [route] + (reduce money/add (map calculate-gas-fee route))) diff --git a/src/status_im/contexts/wallet/send/events.cljs b/src/status_im/contexts/wallet/send/events.cljs index ef0f369643..8d4107653e 100644 --- a/src/status_im/contexts/wallet/send/events.cljs +++ b/src/status_im/contexts/wallet/send/events.cljs @@ -25,9 +25,7 @@ (fn [{:keys [db]} [suggested-routes timestamp]] (when (= (get-in db [:wallet :ui :send :suggested-routes-call-timestamp]) timestamp) (let [suggested-routes-data (cske/transform-keys csk/->kebab-case suggested-routes) - chosen-route (->> suggested-routes-data - :best - first)] + chosen-route (:best suggested-routes-data)] {:db (-> db (assoc-in [:wallet :ui :send :suggested-routes] suggested-routes-data) (assoc-in [:wallet :ui :send :route] chosen-route) @@ -99,7 +97,17 @@ (rf/reg-event-fx :wallet/clean-selected-token (fn [{:keys [db]}] - {:db (assoc-in db [:wallet :ui :send :token] nil)})) + {:db (update-in db [:wallet :ui :send] dissoc :token :type)})) + +(rf/reg-event-fx :wallet/clean-selected-collectible + (fn [{:keys [db]}] + (let [type (get-in db [:wallet :ui :send :type])] + {:db (update-in db + [:wallet :ui :send] + dissoc + :collectible + :amount + (when (= type :collecible) :type))}))) (rf/reg-event-fx :wallet/send-select-collectible (fn [{:keys [db]} [{:keys [collectible stack-id]}]] @@ -244,7 +252,7 @@ (rf/reg-event-fx :wallet/send-transaction (fn [{:keys [db]} [sha3-pwd]] - (let [route (get-in db [:wallet :ui :send :route]) + (let [route (first (get-in db [:wallet :ui :send :route])) from-address (get-in db [:wallet :current-viewing-account-address]) token (get-in db [:wallet :ui :send :token]) collectible (get-in db [:wallet :ui :send :collectible]) diff --git a/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs b/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs index bb03e6d492..5e46d0098a 100644 --- a/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs @@ -43,14 +43,14 @@ :total-balance 100 :market-values-per-currency {:usd {:price 10}}} :wallet/wallet-send-loading-suggested-routes? false - :wallet/wallet-send-route {:from {:chainid 1 - :native-currency-symbol "ETH"} - :to {:chain-id 1 - :native-currency-symbol "ETH"} - :gas-amount "23487" - :gas-fees {:base-fee "32.325296406" - :max-priority-fee-per-gas "0.011000001" - :eip1559-enabled true}} + :wallet/wallet-send-route [{:from {:chainid 1 + :native-currency-symbol "ETH"} + :to {:chain-id 1 + :native-currency-symbol "ETH"} + :gas-amount "23487" + :gas-fees {:base-fee "32.325296406" + :max-priority-fee-per-gas "0.011000001" + :eip1559-enabled true}}] :wallet/wallet-send-suggested-routes {:candidates []} :wallet/wallet-send-selected-networks [] :navigation/current-screen-id :wallet-send-input-amount 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 b5de6419f2..d02725ed28 100644 --- a/src/status_im/contexts/wallet/send/input_amount/view.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/view.cljs @@ -129,6 +129,7 @@ on-navigate-back :on-navigate-back button-one-label :button-one-label button-one-props :button-one-props + current-screen-id :current-screen-id initial-crypto-currency? :initial-crypto-currency? :or {initial-crypto-currency? true}}] (let [_ (rn/dismiss-keyboard!) @@ -172,11 +173,11 @@ (reagent/flush)))) on-navigate-back on-navigate-back fetch-routes (fn [input-num-value current-limit-amount] - (let [current-screen-id (rf/sub [:navigation/current-screen-id])] + (let [nav-current-screen-id (rf/sub [:navigation/current-screen-id])] ; this check is to prevent effect being triggered when screen is ; loaded but not being shown to the user (deep in the navigation ; stack) and avoid undesired behaviors - (when (= current-screen-id :wallet-send-input-amount) + (when (= nav-current-screen-id current-screen-id) (if-not (or (empty? @input-value) (<= input-num-value 0) (> input-num-value current-limit-amount)) @@ -187,7 +188,7 @@ handle-on-confirm (fn [] (rf/dispatch [:wallet/send-select-amount {:amount @input-value - :stack-id :wallet-send-input-amount}])) + :stack-id current-screen-id}])) selection-change (fn [selection] ;; `reagent/flush` is needed to properly propagate the ;; input cursor state. Since this is a controlled @@ -218,6 +219,7 @@ :currency current-currency}) input-num-value (parse-double @input-value) confirm-disabled? (or (nil? route) + (empty? route) (empty? @input-value) (<= input-num-value 0) (> input-num-value current-limit)) @@ -226,7 +228,8 @@ (get-in route [:from :native-currency-symbol])) native-token (when native-currency-symbol (rf/sub [:wallet/token-by-symbol native-currency-symbol])) - fee-in-native-token (when-not confirm-disabled? (send-utils/calculate-gas-fee route)) + fee-in-native-token (when-not confirm-disabled? + (send-utils/calculate-full-route-gas-fee route)) fee-in-crypto-formatted (when fee-in-native-token (utils/get-standard-crypto-format native-token fee-in-native-token)) @@ -280,7 +283,7 @@ :token token :input-value @input-value :fetch-routes #(fetch-routes % current-limit)}] - (when (or loading-routes? route) + (when (or loading-routes? (seq route)) [estimated-fees {:loading-suggested-routes? loading-routes? :fees fee-formatted diff --git a/src/status_im/contexts/wallet/send/select_address/view.cljs b/src/status_im/contexts/wallet/send/select_address/view.cljs index e376a37d10..d715900899 100644 --- a/src/status_im/contexts/wallet/send/select_address/view.cljs +++ b/src/status_im/contexts/wallet/send/select_address/view.cljs @@ -131,6 +131,7 @@ (rf/dispatch [:wallet/clean-scanned-address]) (rf/dispatch [:wallet/clean-local-suggestions]) (rf/dispatch [:wallet/clean-selected-token]) + (rf/dispatch [:wallet/clean-selected-collectible]) (rf/dispatch [:wallet/clean-send-address]) (rf/dispatch [:wallet/select-address-tab nil]) (rf/dispatch [:navigate-back])) diff --git a/src/status_im/contexts/wallet/send/send_amount/view.cljs b/src/status_im/contexts/wallet/send/send_amount/view.cljs index c435eafdd4..856ba7e2bb 100644 --- a/src/status_im/contexts/wallet/send/send_amount/view.cljs +++ b/src/status_im/contexts/wallet/send/send_amount/view.cljs @@ -8,9 +8,11 @@ (defn- view-internal [] [input-amount/view - {:button-one-label (i18n/label :t/confirm) - :on-navigate-back (fn [] - (rf/dispatch [:wallet/clean-selected-token]) - (rf/dispatch [:navigate-back-within-stack :wallet-send-input-amount]))}]) + {:current-screen-id :wallet-send-input-amount + :button-one-label (i18n/label :t/confirm) + :on-navigate-back (fn [] + (rf/dispatch [:wallet/clean-selected-token]) + (rf/dispatch [:wallet/clean-selected-collectible]) + (rf/dispatch [:navigate-back-within-stack :wallet-send-input-amount]))}]) (def view (quo.theme/with-theme view-internal)) diff --git a/src/status_im/contexts/wallet/send/transaction_confirmation/view.cljs b/src/status_im/contexts/wallet/send/transaction_confirmation/view.cljs index 3de81ba39c..e382441814 100644 --- a/src/status_im/contexts/wallet/send/transaction_confirmation/view.cljs +++ b/src/status_im/contexts/wallet/send/transaction_confirmation/view.cljs @@ -1,7 +1,9 @@ (ns status-im.contexts.wallet.send.transaction-confirmation.view (:require [clojure.string :as string] + [legacy.status-im.utils.hex :as utils.hex] [legacy.status-im.utils.utils :as utils] + [native-module.core :as native-module] [quo.core :as quo] [quo.theme :as quo.theme] [react-native.core :as rn] @@ -10,73 +12,168 @@ [status-im.common.standard-authentication.core :as standard-auth] [status-im.contexts.wallet.send.transaction-confirmation.style :as style] [utils.i18n :as i18n] + [utils.money :as money] [utils.re-frame :as rf] [utils.security.core :as security])) (defn- transaction-title - [{:keys [token-symbol amount account to-address image-url collectible?]}] - [rn/view {:style style/content-container} - [rn/view {:style {:flex-direction :row}} - [quo/text - {:size :heading-1 - :weight :semi-bold - :style style/title-container - :accessibility-label :send-label} - (i18n/label :t/send)] - [quo/summary-tag - {:token (if collectible? "" token-symbol) - :label (str amount " " token-symbol) - :type (if collectible? :collectible :token) - :image-source (if collectible? image-url :eth)}]] - [rn/view - {:style {:flex-direction :row - :margin-top 4}} - [quo/text - {:size :heading-1 - :weight :semi-bold - :style style/title-container - :accessibility-label :send-label} - (i18n/label :t/from)] - [quo/summary-tag - {:label (:name account) - :type :account - :emoji (:emoji account) - :customization-color (:color account)}]] - [rn/view - {:style {:flex-direction :row - :margin-top 4}} - [quo/text - {:size :heading-1 - :weight :semi-bold - :style style/title-container - :accessibility-label :send-label} - (i18n/label :t/to)] - [quo/summary-tag - {:type :address - :label (utils/get-shortened-address to-address)}]]]) + [{:keys [token-symbol amount account to-address route to-network image-url transaction-type + collectible?]}] + (let [to-network-name (:network-name to-network) + to-network-color (if (= to-network-name :mainnet) :ethereum to-network-name)] + [rn/view {:style style/content-container} + [rn/view {:style {:flex-direction :row}} + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (if (= transaction-type :bridge) + (i18n/label :t/bridge) + (i18n/label :t/send))] + [quo/summary-tag + {:token (if collectible? "" token-symbol) + :label (str amount " " token-symbol) + :type (if collectible? :collectible :token) + :image-source (if collectible? image-url :eth)}]] + (if (= transaction-type :bridge) + (map-indexed + (fn [idx path] + (let [from-network (:from path) + chain-id (:chain-id from-network) + network (rf/sub [:wallet/network-details-by-chain-id + chain-id]) + network-name (:network-name network) + network-name-text (name network-name) + network-name-capitalized (when (seq network-name-text) + (string/capitalize network-name-text)) + network-color (if (= network-name :mainnet) :ethereum network-name)] + [rn/view + {:style {:flex-direction :row + :margin-top 4}} + (if (zero? idx) + [:<> + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (i18n/label :t/from)] + [quo/summary-tag + {:label network-name-capitalized + :type :network + :image-source (:source network) + :customization-color network-color}]] + [:<> + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (str (i18n/label :t/and) " ")] + [quo/summary-tag + {:label network-name-capitalized + :type :network + :image-source (:source network) + :customization-color network-color}]])])) + route) + [rn/view + {:style {:flex-direction :row + :margin-top 4}} + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (i18n/label :t/from)] + [quo/summary-tag + {:label (:name account) + :type :account + :emoji (:emoji account) + :customization-color (:color account)}]]) + [rn/view + {:style {:flex-direction :row + :margin-top 4}} + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (i18n/label :t/to)] + (if (= transaction-type :bridge) + [quo/summary-tag + {:type :network + :image-source (:source to-network) + :label (string/capitalize (name (:network-name to-network))) + :customization-color to-network-color}] + [quo/summary-tag + {:type :address + :label (utils/get-shortened-address to-address)}])] + (when (= transaction-type :bridge) + [rn/view + {:style {:flex-direction :row + :margin-top 4}} + [quo/text + {:size :heading-1 + :weight :semi-bold + :style style/title-container + :accessibility-label :send-label} + (i18n/label :t/in)] + [quo/summary-tag + {:label (:name account) + :type :account + :emoji (:emoji account) + :customization-color (:color account)}]])])) (defn- user-summary - [{:keys [amount token-symbol account-props theme label accessibility-label summary-type]}] - [rn/view - {:style {:padding-horizontal 20 - :padding-bottom 16}} - [quo/text - {:size :paragraph-2 - :weight :medium - :style (style/section-label theme) - :accessibility-label accessibility-label} - label] - [quo/summary-info - {:type summary-type - :networks? true - :values {:ethereum {:amount amount - :token-symbol token-symbol}} - :account-props account-props}]]) + [{:keys [token-symbol token-decimals account-props route to? theme label accessibility-label + summary-type]}] + (letfn [(merge-sum [a b] + (merge-with money/add a b))] + (let [network-amounts + (reduce (fn [acc path] + (let [network (if to? (:to path) (:from path)) + chain-id (:chain-id network) + amount-hex (if to? (:amount-in path) (:amount-out path)) + amount-units (native-module/hex-to-number + (utils.hex/normalize-hex amount-hex)) + amount (money/with-precision + (if (= token-symbol "ETH") + (money/wei->ether amount-units) + (money/token->unit amount-units + token-decimals)) + 6) + network-details (rf/sub [:wallet/network-details-by-chain-id chain-id]) + network-name (:network-name network-details) + network-name (if (= network-name :mainnet) :ethereum network-name)] + (merge-sum acc {network-name amount}))) + {} + route) + network-values + (reduce-kv (fn [acc k v] + (assoc acc k {:amount v :token-symbol token-symbol})) + {} + network-amounts)] + [rn/view + {:style {:padding-horizontal 20 + :padding-bottom 16}} + [quo/text + {:size :paragraph-2 + :weight :medium + :style (style/section-label theme) + :accessibility-label accessibility-label} + label] + [quo/summary-info + {:type summary-type + :networks? true + :values network-values + :account-props account-props}]]))) (defn- transaction-details - [{:keys [estimated-time-min max-fees token-symbol amount to-address route theme]}] + [{:keys [estimated-time-min max-fees token-symbol amount to-address to-network route transaction-type + theme]}] (let [currency-symbol (rf/sub [:profile/currency-symbol]) - route-loaded? (some? route) + route-loaded? (and route (seq route)) loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])] [rn/view {:style style/details-title-container} @@ -129,7 +226,10 @@ :label :none :status :default :size :small - :title (i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)}) + :title (if (= transaction-type :bridge) + (i18n/label :t/bridged-to + {:network (:abbreviated-name to-network)}) + (i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)})) :subtitle (str amount " " token-symbol)}]] :else [quo/text {:style {:align-self :center}} @@ -137,7 +237,10 @@ (defn- view-internal [_] - (let [on-close #(rf/dispatch [:navigate-back-within-stack :wallet-select-asset])] + (let [on-close (fn [] + (rf/dispatch [:navigate-back-within-stack :wallet-transaction-confirmation]) + (rf/dispatch [:wallet/clean-suggested-routes]) + (rf/dispatch [:wallet/clean-selected-collectible]))] (fn [{:keys [theme]}] (let [send-transaction-data (rf/sub [:wallet/wallet-send]) token (:token send-transaction-data) @@ -151,14 +254,19 @@ [(:name collectible-data) (str (:name collection-data) " #" collectible-id)])) (:symbol token)) + token-decimals (if collectible 0 (:decimals token)) image-url (when collectible (:image-url collectible-data)) amount (:amount send-transaction-data) route (:route send-transaction-data) - estimated-time-min (:estimated-time route) + transaction-type (:type send-transaction-data) + estimated-time-min (reduce + (map :estimated-time route)) max-fees "-" to-address (:to-address send-transaction-data) account (rf/sub [:wallet/current-viewing-account]) account-color (:color account) + bridge-to-chain-id (:bridge-to-chain-id send-transaction-data) + bridge-to-network (when bridge-to-chain-id + (rf/sub [:wallet/network-details-by-chain-id bridge-to-chain-id])) from-account-props {:customization-color account-color :size 32 :emoji (:emoji account) @@ -176,15 +284,13 @@ :on-press on-close :margin-top (safe-area/get-top) :background :blur - :accessibility-label :top-bar - :right-side [{:icon-name :i/advanced - :on-press #(js/alert - "to be implemented") - :accessibility-label :advanced-options}]}] - :footer (when route + :accessibility-label :top-bar}] + :footer (when (and route (seq route)) [standard-auth/slide-button {:size :size-48 - :track-text (i18n/label :t/slide-to-send) + :track-text (if (= transaction-type :bridge) + (i18n/label :t/slide-to-bridge) + (i18n/label :t/slide-to-send)) :container-style {:z-index 2} :customization-color account-color :on-auth-success #(rf/dispatch @@ -196,27 +302,38 @@ :customization-color (:color account)} [rn/view [transaction-title - {:token-symbol token-symbol - :amount amount - :account account - :to-address to-address - :image-url image-url - :collectible? (some? collectible)}] + {:token-symbol token-symbol + :amount amount + :account account + :to-address to-address + :route route + :to-network bridge-to-network + :image-url image-url + :transaction-type transaction-type + :collectible? (some? collectible)}] [user-summary - {:amount amount - :token-symbol token-symbol + {:token-symbol token-symbol + :token-decimals token-decimals :summary-type :status-account :accessibility-label :summary-from-label :label (i18n/label :t/from-capitalized) + :route route + :to? false :account-props from-account-props :theme theme}] [user-summary - {:amount amount - :token-symbol token-symbol - :summary-type :account + {:token-symbol token-symbol + :token-decimals token-decimals + :summary-type (if (= transaction-type :bridge) + :status-account + :account) :accessibility-label :summary-to-label :label (i18n/label :t/to-capitalized) - :account-props user-props + :account-props (if (= transaction-type :bridge) + from-account-props + user-props) + :route route + :to? true :theme theme}] [transaction-details {:estimated-time-min estimated-time-min @@ -224,7 +341,9 @@ :token-symbol token-symbol :amount amount :to-address to-address + :to-network bridge-to-network :theme theme - :route route}]]]])))) + :route route + :transaction-type transaction-type}]]]])))) (def view (quo.theme/with-theme view-internal)) diff --git a/src/status_im/subs/wallet/networks.cljs b/src/status_im/subs/wallet/networks.cljs index 0d1c5c9d22..017c048ecb 100644 --- a/src/status_im/subs/wallet/networks.cljs +++ b/src/status_im/subs/wallet/networks.cljs @@ -16,19 +16,22 @@ (get networks (if test-networks-enabled? :test :prod)))) (def mainnet-network-details - {:source (resources/get-network constants/mainnet-network-name) - :short-name constants/mainnet-short-name - :network-name constants/mainnet-network-name}) + {:source (resources/get-network constants/mainnet-network-name) + :short-name constants/mainnet-short-name + :network-name constants/mainnet-network-name + :abbreviated-name constants/mainnet-abbreviated-name}) (def arbitrum-network-details - {:source (resources/get-network constants/arbitrum-network-name) - :short-name constants/arbitrum-short-name - :network-name constants/arbitrum-network-name}) + {:source (resources/get-network constants/arbitrum-network-name) + :short-name constants/arbitrum-short-name + :network-name constants/arbitrum-network-name + :abbreviated-name constants/arbitrum-abbreviated-name}) (def optimism-network-details - {:source (resources/get-network constants/optimism-network-name) - :short-name constants/optimism-short-name - :network-name constants/optimism-network-name}) + {:source (resources/get-network constants/optimism-network-name) + :short-name constants/optimism-short-name + :network-name constants/optimism-network-name + :abbreviated-name constants/optimism-abbreviated-name}) (defn get-network-details [chain-id] diff --git a/src/status_im/subs/wallet/networks_test.cljs b/src/status_im/subs/wallet/networks_test.cljs index feef9a07ec..564202f283 100644 --- a/src/status_im/subs/wallet/networks_test.cljs +++ b/src/status_im/subs/wallet/networks_test.cljs @@ -10,7 +10,8 @@ (def network-data {:test [{:test? true :short-name "eth" - :network-name :ethereum + :network-name :mainnet + :abbreviated-name "Eth." :related-chain-id 1 :chain-id 3 :layer 1} @@ -41,16 +42,20 @@ [sub-name] (testing "returns data with prod" (swap! rf-db/app-db assoc-in [:wallet :networks] network-data) - (is (= [{:network-name :ethereum - :short-name "eth" - :chain-id 1 - :layer 1} - {:network-name :arbitrum - :short-name "arb1" - :chain-id 42161 - :layer 2} - {:network-name :optimism - :short-name "opt" - :chain-id 10 - :layer 2}] - (map #(dissoc % :source :related-chain-id) (rf/sub [sub-name])))))) + (is + (= [{:network-name :mainnet + :short-name "eth" + :chain-id 1 + :abbreviated-name "Eth." + :layer 1} + {:network-name :arbitrum + :short-name "arb1" + :abbreviated-name "Arb1." + :chain-id 42161 + :layer 2} + {:network-name :optimism + :short-name "opt" + :abbreviated-name "Opt." + :chain-id 10 + :layer 2}] + (map #(dissoc % :source :related-chain-id) (rf/sub [sub-name])))))) diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index 3f31c97b47..32d8623978 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -88,6 +88,11 @@ :<- [:wallet/wallet-send] :-> :suggested-routes) +(rf/reg-sub + :wallet/wallet-bridge-to-chain-id + :<- [:wallet/wallet-send] + :-> :bridge-to-chain-id) + (rf/reg-sub :wallet/watch-address-activity-state :<- [:wallet/ui] diff --git a/src/status_im/subs/wallet/wallet_test.cljs b/src/status_im/subs/wallet/wallet_test.cljs index 0917c40f1a..45e79edd20 100644 --- a/src/status_im/subs/wallet/wallet_test.cljs +++ b/src/status_im/subs/wallet/wallet_test.cljs @@ -183,7 +183,7 @@ :color :blue :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 0 :clock 1698945829328 :created-at 1698928839000 @@ -205,7 +205,7 @@ :color :purple :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 1 :clock 1698945829328 :created-at 1698928839000 @@ -269,7 +269,7 @@ :color :blue :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 0 :clock 1698945829328 :created-at 1698928839000 @@ -326,7 +326,7 @@ :color :blue :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 0 :clock 1698945829328 :created-at 1698928839000 @@ -383,7 +383,7 @@ :customization-color :blue :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 0 :clock 1698945829328 :created-at 1698928839000 @@ -406,7 +406,7 @@ :customization-color :purple :hidden false :prod-preferred-chain-ids #{1 10 42161} - :network-preferences-names #{:ethereum :arbitrum :optimism} + :network-preferences-names #{:mainnet :arbitrum :optimism} :position 1 :clock 1698945829328 :created-at 1698928839000 @@ -427,17 +427,20 @@ (assoc-in [:wallet :networks] network-data))) (is (match? [{:short-name "eth" - :network-name :ethereum + :network-name :mainnet + :abbreviated-name "Eth." :chain-id 1 :related-chain-id nil :layer 1} {:short-name "arb1" :network-name :arbitrum + :abbreviated-name "Arb1." :chain-id 42161 :related-chain-id nil :layer 2} {:short-name "opt" :network-name :optimism + :abbreviated-name "Opt." :chain-id 10 :related-chain-id nil :layer 2}] @@ -474,11 +477,11 @@ (= [(-> accounts (get "0x1") (assoc :customization-color :blue) - (assoc :network-preferences-names #{:ethereum :arbitrum :optimism})) + (assoc :network-preferences-names #{:mainnet :arbitrum :optimism})) (-> accounts (get "0x2") (assoc :customization-color :purple) - (assoc :network-preferences-names #{:ethereum :arbitrum :optimism})) + (assoc :network-preferences-names #{:mainnet :arbitrum :optimism})) (-> accounts (get "0x3") (assoc :customization-color :magenta) diff --git a/translations/en.json b/translations/en.json index 25a20fcedf..c0895469ce 100644 --- a/translations/en.json +++ b/translations/en.json @@ -2519,5 +2519,7 @@ "keypair-name": "Keypair name", "keypair-name-description": "Name keypair for your own personal reference", "keypair-name-input-placeholder": "Collectibles account, Old vault....", - "goerli-testnet-toggle-confirmation": "Are you sure you want to toggle Goerli? This will log you out and you will have to login again." + "goerli-testnet-toggle-confirmation": "Are you sure you want to toggle Goerli? This will log you out and you will have to login again.", + "bridged-to": "Bridged to {{network}}", + "slide-to-bridge": "Slide to bridge" }