Fix(wallet): address validation (#20674)
* fix(wallet): address validation (#20674)
This commit is contained in:
parent
a2178951d7
commit
f70a743a8c
|
@ -362,11 +362,19 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/address-validation-success
|
(rf/reg-event-fx :wallet/address-validation-success
|
||||||
(fn [{:keys [db]}]
|
(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
|
(rf/reg-event-fx :wallet/address-validation-failed
|
||||||
(fn [{:keys [db]}]
|
(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
|
(rf/reg-event-fx :wallet/clean-local-suggestions
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
|
@ -374,6 +382,10 @@
|
||||||
(assoc-in [:wallet :ui :search-address :local-suggestions] [])
|
(assoc-in [:wallet :ui :search-address :local-suggestions] [])
|
||||||
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))}))
|
(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
|
(rf/reg-event-fx
|
||||||
:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
||||||
(fn [_ [explorer-link address]]
|
(fn [_ [explorer-link address]]
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
300)))
|
300)))
|
||||||
:on-change-text (fn [text]
|
:on-change-text (fn [text]
|
||||||
(rf/dispatch [:wallet/clean-local-suggestions])
|
(rf/dispatch [:wallet/clean-local-suggestions])
|
||||||
|
(rf/dispatch [:wallet/searching-address])
|
||||||
(validate-address text)
|
(validate-address text)
|
||||||
(reset! input-value text))
|
(reset! input-value text))
|
||||||
:valid-ens-or-address? valid-ens-or-address?}])))
|
:valid-ens-or-address? valid-ens-or-address?}])))
|
||||||
|
@ -182,7 +183,8 @@
|
||||||
input-focused? (reagent/atom false)]
|
input-focused? (reagent/atom false)]
|
||||||
(fn []
|
(fn []
|
||||||
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
|
(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
|
[floating-button-page/view
|
||||||
{:content-container-style {:flex 1}
|
{:content-container-style {:flex 1}
|
||||||
:footer-container-padding 0
|
:footer-container-padding 0
|
||||||
|
@ -198,7 +200,7 @@
|
||||||
:title-accessibility-label :title-label}]
|
:title-accessibility-label :title-label}]
|
||||||
[address-input input-value input-focused?]
|
[address-input input-value input-focused?]
|
||||||
[quo/divider-line]
|
[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}}
|
[rn/view {:style {:padding 20}}
|
||||||
[quo/info-message
|
[quo/info-message
|
||||||
{:status :error
|
{:status :error
|
||||||
|
|
|
@ -595,6 +595,11 @@
|
||||||
:<- [:wallet/search-address]
|
:<- [:wallet/search-address]
|
||||||
:-> :valid-ens-or-address?)
|
:-> :valid-ens-or-address?)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/searching-address?
|
||||||
|
:<- [:wallet/search-address]
|
||||||
|
:-> :loading?)
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/aggregated-fiat-balance-per-chain
|
:wallet/aggregated-fiat-balance-per-chain
|
||||||
:<- [:wallet/aggregated-tokens]
|
:<- [:wallet/aggregated-tokens]
|
||||||
|
|
Loading…
Reference in New Issue