From aeba0722f8715dd3a9d6a0cf8f6fec0138356d7b Mon Sep 17 00:00:00 2001 From: Omar Basem Date: Tue, 19 Dec 2023 10:42:36 +0400 Subject: [PATCH] review --- .../components/drawers/drawer_top/view.cljs | 3 ++- .../contexts/wallet/common/utils.cljs | 10 ++++++++++ .../contexts/wallet/common/utils_test.cljs | 18 ++++++++++++++++++ .../contexts/wallet/receive/view.cljs | 12 +++++------- 4 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/status_im2/contexts/wallet/common/utils_test.cljs diff --git a/src/quo/components/drawers/drawer_top/view.cljs b/src/quo/components/drawers/drawer_top/view.cljs index d775d2d47e4e..b76fc09fce00 100644 --- a/src/quo/components/drawers/drawer_top/view.cljs +++ b/src/quo/components/drawers/drawer_top/view.cljs @@ -160,7 +160,8 @@ [rn/view {:style style/title-container} [text/text {:size :heading-2 - :weight :semi-bold} + :weight :semi-bold + :style {:color (when blur? colors/white)}} title] (when title-icon [icons/icon title-icon diff --git a/src/status_im2/contexts/wallet/common/utils.cljs b/src/status_im2/contexts/wallet/common/utils.cljs index 4f8b80907ec6..c1adf3ca0268 100644 --- a/src/status_im2/contexts/wallet/common/utils.cljs +++ b/src/status_im2/contexts/wallet/common/utils.cljs @@ -1,5 +1,6 @@ (ns status-im2.contexts.wallet.common.utils (:require [clojure.string :as string] + [status-im2.common.qr-codes.view :as qr-codes] [status-im2.constants :as constants] [utils.money :as money] [utils.number])) @@ -86,3 +87,12 @@ (defn calculate-fiat-change [fiat-value change-pct-24hour] (money/bignumber (* fiat-value (/ change-pct-24hour (+ 100 change-pct-24hour))))) + +(defn get-wallet-qr + [{:keys [wallet-type selected-networks address]}] + (if (= wallet-type :wallet-multichain) + (as-> selected-networks $ + (map qr-codes/get-network-short-name-url $) + (apply str $) + (str $ address)) + address)) diff --git a/src/status_im2/contexts/wallet/common/utils_test.cljs b/src/status_im2/contexts/wallet/common/utils_test.cljs new file mode 100644 index 000000000000..e78733f72d67 --- /dev/null +++ b/src/status_im2/contexts/wallet/common/utils_test.cljs @@ -0,0 +1,18 @@ +(ns status-im2.contexts.wallet.common.utils-test + (:require [clojure.test :refer :all] + [status-im2.contexts.wallet.common.utils :as utils])) + +(defn test-get-wallet-qr + (testing "Test get-wallet-qr function" + (let [wallet-multichain {:wallet-type :wallet-multichain + :selected-networks [:ethereum :optimism] + :address "x000"} + wallet-singlechain {:wallet-type :wallet-singlechain + :selected-networks [:ethereum :optimism] + :address "x000"}] + + (is (= (utils/get-wallet-qr wallet-multichain) + "eth:opt:x000")) + + (is (= (utils/get-wallet-qr wallet-singlechain) + "x000"))))) diff --git a/src/status_im2/contexts/wallet/receive/view.cljs b/src/status_im2/contexts/wallet/receive/view.cljs index 3e7772b83d94..a4bbd1943f22 100644 --- a/src/status_im2/contexts/wallet/receive/view.cljs +++ b/src/status_im2/contexts/wallet/receive/view.cljs @@ -12,7 +12,8 @@ [status-im2.contexts.wallet.receive.style :as style] [utils.i18n :as i18n] [utils.image-server :as image-server] - [utils.re-frame :as rf])) + [utils.re-frame :as rf] + [status-im2.contexts.wallet.common.utils :as utils])) (def id-to-network {constants/mainnet-chain-id :ethereum @@ -56,12 +57,9 @@ (fn [] (let [{:keys [address color emoji] :as account} (rf/sub [:wallet/current-viewing-account]) share-title (str (:name account) " " (i18n/label :t/address)) - qr-url (if (= @wallet-type :wallet-multichain) - (as-> @selected-networks $ - (map qr-codes/get-network-short-name-url $) - (apply str $) - (str $ address)) - address) + qr-url (utils/get-wallet-qr {:wallet-type @wallet-type + :selected-networks @selected-networks + :address address}) qr-media-server-uri (image-server/get-qr-image-uri-for-any-url {:url qr-url :port (rf/sub [:mediaserver/port])