Skip to content

Commit

Permalink
ENS Validation update
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Javid <[email protected]>
  • Loading branch information
smohamedjavid committed Jun 7, 2024
1 parent 393fcb0 commit b1ff41a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style]
[status-im.contexts.wallet.common.validation :as validation]
[utils.debounce :as debounce]
[utils.ens.core :as ens-utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand All @@ -31,7 +30,7 @@

(not
(or (validation/eth-address? user-input)
(ens-utils/is-valid-eth-name? user-input)))
(validation/ens-name? user-input)))
:invalid-address-or-ens))

(defn- address-input
Expand Down Expand Up @@ -119,7 +118,7 @@
[ens-address set-ens-address] (rn/use-state "")
[error set-error] (rn/use-state nil)
error? (some? error)
ens-name? (ens-utils/is-valid-eth-name? address-or-ens)
ens-name? (validation/ens-name? address-or-ens)
address (if ens-name? ens-address address-or-ens)
button-disabled? (or (string/blank? address-or-ens)
(and ens-name? (string/blank? ens-address))
Expand All @@ -142,7 +141,7 @@
(set-error (validate (string/lower-case trimmed-value)))
(set-address-or-ens trimmed-value)
(set-ens-address "")
(when (ens-utils/is-valid-eth-name? trimmed-value)
(when (validation/ens-name? trimmed-value)
(debounce/debounce-and-dispatch
[:wallet/resolve-ens
{:ens new-value
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/common/validation.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns status-im.contexts.wallet.common.validation
(:require [status-im.constants :as constants]))

(defn ens-name? [s] (re-find constants/regx-ens s))
(defn ens-name? [s] (boolean (re-find constants/regx-ens s)))
(defn eth-address? [s] (re-find constants/regx-multichain-address s))
(defn private-key? [s] (re-find constants/regx-private-key s))
1 change: 0 additions & 1 deletion src/utils/ens/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@
[ens-name]
(and ens-name
(string? ens-name)
(not (string/includes? ens-name " "))
(string/ends-with? ens-name ".eth")))

0 comments on commit b1ff41a

Please sign in to comment.