From 2b6e782e809089e1ede2f3779d80f309862dcb62 Mon Sep 17 00:00:00 2001 From: Ulises Manuel <90291778+ulisesmac@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:19:41 -0600 Subject: [PATCH] fix(wallet): Remove redirection to send flow when the user scans an address QR code (#20979) --- .../sheets/scanned_wallet_address.cljs | 58 ++++++++++++------- src/test_helpers/unit.cljs | 5 +- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/status_im/contexts/shell/qr_reader/sheets/scanned_wallet_address.cljs b/src/status_im/contexts/shell/qr_reader/sheets/scanned_wallet_address.cljs index c334f2994e..b801ae6e7c 100644 --- a/src/status_im/contexts/shell/qr_reader/sheets/scanned_wallet_address.cljs +++ b/src/status_im/contexts/shell/qr_reader/sheets/scanned_wallet_address.cljs @@ -1,33 +1,47 @@ (ns status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address (:require [quo.core :as quo] - [status-im.contexts.wallet.common.utils :as utils] - [status-im.contexts.wallet.common.utils.networks :as network-utils] + [react-native.clipboard :as clipboard] [status-im.feature-flags :as ff] [utils.i18n :as i18n] [utils.re-frame :as rf])) +(defn- copy-address + [address] + (clipboard/set-string address) + (rf/dispatch [:toasts/upsert + {:type :positive + :text (i18n/label :t/address-copied)}])) + +#_(defn- send-to-address + [address] + (let [[_ split-address] (network-utils/split-network-full-address address)] + (rf/dispatch + [:wallet/select-send-address + {:address address + :recipient {:recipient-type :address + :label (utils/get-shortened-address split-address)} + :stack-id :wallet-select-address + :start-flow? true}]))) + (defn view [address] - (let [[_ splitted-address] (network-utils/split-network-full-address address)] - [:<> - [quo/drawer-top - {:title address - :type :address}] - [quo/action-drawer - [[{:icon :i/send + [:<> + [quo/drawer-top {:title address :type :address}] + [quo/action-drawer + [[{:icon :i/copy + :accessibility-label :send-asset + :label (i18n/label :t/copy-address) + :on-press #(copy-address address)} + ;; Originally, the flow went to the send flow, but it has been removed to avoid bugs, + ;; please check https://github.com/status-im/status-mobile/issues/20972 for more context + ;; The previous code has been commented out to be reintroduced in the future easily. + #_{:icon :i/send :accessibility-label :send-asset :label (i18n/label :t/send-to-this-address) - :on-press (fn [] - (rf/dispatch [:wallet/select-send-address - {:address address - :recipient {:recipient-type :address - :label (utils/get-shortened-address - splitted-address)} - :stack-id :wallet-select-address - :start-flow? true}]))} - (when (ff/enabled? :ff/wallet.saved-addresses) - {:icon :i/save - :accessibility-label :save-address - :label (i18n/label :t/save-address) - :on-press #(js/alert "feature not implemented")})]]]])) + :on-press #(send-to-address address)} + (when (ff/enabled? :ff/wallet.saved-addresses) + {:icon :i/save + :accessibility-label :save-address + :label (i18n/label :t/save-address) + :on-press #(js/alert "feature not implemented")})]]]]) diff --git a/src/test_helpers/unit.cljs b/src/test_helpers/unit.cljs index 821e121d9b..661ba88dcd 100644 --- a/src/test_helpers/unit.cljs +++ b/src/test_helpers/unit.cljs @@ -12,9 +12,10 @@ [re-frame.events :as rf-events] [re-frame.registrar :as rf-registrar] [re-frame.subs :as rf-subs] - [taoensso.timbre :as log] ;; We must require this namespace to register the custom cljs.test - ;; directive `match-strict?`. + [taoensso.timbre :as log] test-helpers.matchers)) +;; We must require `test-helpers.matchers` this namespace to register the custom cljs.test +;; directive `match-strict?`. (defn db "A simple wrapper to get the latest value from the app db."