fix: ENS regex not being used to detect an ENS on address input (#18626)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
c70646bd5c
commit
ae7ee33f00
|
@ -61,24 +61,30 @@
|
||||||
value (reagent/atom "")
|
value (reagent/atom "")
|
||||||
focused? (atom false)]
|
focused? (atom false)]
|
||||||
(fn [{:keys [scanned-value theme blur? on-change-text on-blur on-focus on-clear on-scan
|
(fn [{:keys [scanned-value theme blur? on-change-text on-blur on-focus on-clear on-scan
|
||||||
on-detect-ens on-detect-address address-regex valid-ens-or-address?
|
on-detect-ens on-detect-address on-detect-unclassified address-regex ens-regex
|
||||||
container-style]}]
|
valid-ens-or-address? container-style]}]
|
||||||
(let [on-change (fn [text]
|
(let [on-change (fn [text]
|
||||||
(when (not= @value text)
|
(when (not= @value text)
|
||||||
(let [address? (when address-regex
|
(let [address? (when address-regex
|
||||||
(boolean (re-matches address-regex text)))]
|
(boolean (re-matches address-regex text)))
|
||||||
|
ens? (when ens-regex
|
||||||
|
(boolean (re-matches ens-regex text)))]
|
||||||
(if (> (count text) 0)
|
(if (> (count text) 0)
|
||||||
(reset! status :typing)
|
(reset! status :typing)
|
||||||
(reset! status :active))
|
(reset! status :active))
|
||||||
(reset! value text)
|
(reset! value text)
|
||||||
(when on-change-text
|
(when on-change-text
|
||||||
(on-change-text text))
|
(on-change-text text))
|
||||||
(when (and on-detect-ens (> (count text) 0))
|
(when (and on-detect-ens ens?)
|
||||||
(reset! status :loading)
|
(reset! status :loading)
|
||||||
(on-detect-ens text #(reset! status :typing)))
|
(on-detect-ens text #(reset! status :typing)))
|
||||||
(when (and address? on-detect-address)
|
(when (and address? on-detect-address)
|
||||||
(reset! status :loading)
|
(reset! status :loading)
|
||||||
(on-detect-address text)))))
|
(on-detect-address text))
|
||||||
|
(when (and (not address?)
|
||||||
|
(not ens?)
|
||||||
|
on-detect-unclassified)
|
||||||
|
(on-detect-unclassified text)))))
|
||||||
on-paste (fn []
|
on-paste (fn []
|
||||||
(clipboard/get-string
|
(clipboard/get-string
|
||||||
(fn [clipboard]
|
(fn [clipboard]
|
||||||
|
|
|
@ -313,6 +313,10 @@
|
||||||
(background-timer/clear-timeout current-timeout)
|
(background-timer/clear-timeout current-timeout)
|
||||||
{:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)})))
|
{:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :wallet/clean-ens-or-address-validation
|
||||||
|
(fn [{:keys [db]}]
|
||||||
|
{:db (assoc db :wallet/valid-ens-or-address? false)}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/get-address-details-success
|
(rf/reg-event-fx :wallet/get-address-details-success
|
||||||
(fn [{:keys [db]} [{:keys [hasActivity]}]]
|
(fn [{:keys [db]} [{:keys [hasActivity]}]]
|
||||||
{:db (assoc-in db
|
{:db (assoc-in db
|
||||||
|
|
|
@ -32,27 +32,29 @@
|
||||||
chain-id (rf/sub [:chain-id])
|
chain-id (rf/sub [:chain-id])
|
||||||
contacts (rf/sub [:contacts/active])]
|
contacts (rf/sub [:contacts/active])]
|
||||||
[quo/address-input
|
[quo/address-input
|
||||||
{:on-focus #(reset! input-focused? true)
|
{:on-focus #(reset! input-focused? true)
|
||||||
:on-blur #(reset! input-focused? false)
|
:on-blur #(reset! input-focused? false)
|
||||||
:on-scan (fn []
|
:on-scan (fn []
|
||||||
(rn/dismiss-keyboard!)
|
(rn/dismiss-keyboard!)
|
||||||
(rf/dispatch [:wallet/clean-scanned-address])
|
(rf/dispatch [:wallet/clean-scanned-address])
|
||||||
(rf/dispatch [:open-modal :scan-address]))
|
(rf/dispatch [:open-modal :scan-address]))
|
||||||
:ens-regex constants/regx-ens
|
:ens-regex constants/regx-ens
|
||||||
:scanned-value (or (when recipient-plain-address? send-address) scanned-address)
|
:scanned-value (or (when recipient-plain-address? send-address) scanned-address)
|
||||||
:address-regex constants/regx-multichain-address
|
:address-regex constants/regx-multichain-address
|
||||||
:on-detect-address #(debounce/debounce-and-dispatch
|
:on-detect-address #(debounce/debounce-and-dispatch
|
||||||
[:wallet/validate-address %]
|
[:wallet/validate-address %]
|
||||||
300)
|
300)
|
||||||
:on-detect-ens (fn [text cb]
|
:on-detect-ens (fn [text cb]
|
||||||
(debounce/debounce-and-dispatch
|
(debounce/debounce-and-dispatch
|
||||||
[:wallet/find-ens text contacts chain-id cb]
|
[:wallet/find-ens text contacts chain-id cb]
|
||||||
300))
|
300))
|
||||||
:on-change-text (fn [text]
|
:on-detect-unclassified #(when valid-ens-or-address?
|
||||||
(when (empty? text)
|
(rf/dispatch [:wallet/clean-ens-or-address-validation]))
|
||||||
(rf/dispatch [:wallet/clean-local-suggestions]))
|
:on-change-text (fn [text]
|
||||||
(reset! input-value text))
|
(when (empty? text)
|
||||||
:valid-ens-or-address? valid-ens-or-address?}])))
|
(rf/dispatch [:wallet/clean-local-suggestions]))
|
||||||
|
(reset! input-value text))
|
||||||
|
:valid-ens-or-address? valid-ens-or-address?}])))
|
||||||
|
|
||||||
(defn- ens-linked-address
|
(defn- ens-linked-address
|
||||||
[{:keys [address networks theme]}]
|
[{:keys [address networks theme]}]
|
||||||
|
|
Loading…
Reference in New Issue