Fix(wallet): address validation (#20674)

* fix(wallet): address validation (#20674)
This commit is contained in:
Omar Basem 2024-07-09 15:59:48 +04:00 committed by GitHub
parent a2178951d7
commit f70a743a8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 4 deletions

View File

@ -362,11 +362,19 @@
(rf/reg-event-fx :wallet/address-validation-success
(fn [{:keys [db]}]
{:db (assoc-in db [:wallet :ui :search-address :valid-ens-or-address?] true)}))
{:db (update-in db
[:wallet :ui :search-address]
assoc
:valid-ens-or-address? true
:loading? false)}))
(rf/reg-event-fx :wallet/address-validation-failed
(fn [{:keys [db]}]
{:db (assoc-in db [:wallet :ui :search-address :valid-ens-or-address?] false)}))
{:db (update-in db
[:wallet :ui :search-address]
assoc
:valid-ens-or-address? false
:loading? false)}))
(rf/reg-event-fx :wallet/clean-local-suggestions
(fn [{:keys [db]}]
@ -374,6 +382,10 @@
(assoc-in [:wallet :ui :search-address :local-suggestions] [])
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))}))
(rf/reg-event-fx :wallet/searching-address
(fn [{:keys [db]}]
{:db (assoc-in db [:wallet :ui :search-address :loading?] true)}))
(rf/reg-event-fx
:wallet/navigate-to-chain-explorer-from-bottom-sheet
(fn [_ [explorer-link address]]

View File

@ -76,6 +76,7 @@
300)))
:on-change-text (fn [text]
(rf/dispatch [:wallet/clean-local-suggestions])
(rf/dispatch [:wallet/searching-address])
(validate-address text)
(reset! input-value text))
:valid-ens-or-address? valid-ens-or-address?}])))
@ -182,7 +183,8 @@
input-focused? (reagent/atom false)]
(fn []
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))]
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))
searching-address? (rf/sub [:wallet/searching-address?])]
[floating-button-page/view
{:content-container-style {:flex 1}
:footer-container-padding 0
@ -198,7 +200,7 @@
:title-accessibility-label :title-label}]
[address-input input-value input-focused?]
[quo/divider-line]
(when (and (not valid-ens-or-address?) (> (count @input-value) 0))
(when (and (not valid-ens-or-address?) (> (count @input-value) 0) (not searching-address?))
[rn/view {:style {:padding 20}}
[quo/info-message
{:status :error

View File

@ -595,6 +595,11 @@
:<- [:wallet/search-address]
:-> :valid-ens-or-address?)
(rf/reg-sub
:wallet/searching-address?
:<- [:wallet/search-address]
:-> :loading?)
(rf/reg-sub
:wallet/aggregated-fiat-balance-per-chain
:<- [:wallet/aggregated-tokens]