fix_: Adding own address as saved addresses (#20839)

This commit:

- prevents the user from saving their wallet address as the saved address
- fixes button not capturing taps when the keyboard is open in saved address flows

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2024-07-24 19:46:59 +05:30 committed by GitHub
parent c6a63e30b2
commit 4989c92780
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 46 deletions

View File

@ -7,6 +7,7 @@
[react-native.safe-area :as safe-area]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.validation :as validation]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
@ -18,20 +19,21 @@
(defn- validate-input
[account-addresses saved-addresses user-input]
(let [[_ address-without-prefix] (utils/split-prefix-and-address user-input)]
(cond
(string/blank? user-input)
nil
(contains? saved-addresses user-input)
(contains? saved-addresses address-without-prefix)
:existing-saved-address
(contains? account-addresses user-input)
(contains? account-addresses address-without-prefix)
:own-account
(not
(or (validation/eth-address? user-input)
(validation/ens-name? user-input)))
:invalid-address-or-ens))
:invalid-address-or-ens)))
(defn- address-input
[{:keys [input-value on-change-text paste-into-input clear-input]}]
@ -93,8 +95,9 @@
(defn- existing-saved-address
[{:keys [address]}]
(let [{:keys [name customization-color chain-short-names ens ens?]}
(rf/sub [:wallet/saved-address-by-address address])]
(let [[_ address-without-prefix] (utils/split-prefix-and-address address)
{:keys [name customization-color chain-short-names ens ens?]}
(rf/sub [:wallet/saved-address-by-address address-without-prefix])]
[rn/view {:style style/existing-saved-address-container}
[quo/text
{:size :paragraph-1
@ -105,7 +108,7 @@
{:blur? true
:active-state? true
:user-props {:name name
:address (str chain-short-names address)
:address (str chain-short-names address-without-prefix)
:ens (when ens? ens)
:customization-color customization-color
:blur? true}
@ -169,6 +172,7 @@
[quo/overlay {:type :shell}
[floating-button-page/view
{:footer-container-padding 0
:keyboard-should-persist-taps :handled
:header [quo/page-nav
{:type :no-title
:icon-name :i/close

View File

@ -106,6 +106,7 @@
[quo/overlay {:type :shell}
[floating-button-page/view
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
:keyboard-should-persist-taps :handled
:header [quo/page-nav
{:type :no-title
:background :blur