Root keys named :wallet/... moved as nested under :wallet root key (#19152)
This commit is contained in:
parent
459bf1621a
commit
e4997a2088
|
@ -282,10 +282,11 @@
|
||||||
(filter #(string/starts-with? (or (:ens-name %) "") input) contacts))]
|
(filter #(string/starts-with? (or (:ens-name %) "") input) contacts))]
|
||||||
(if (and input (empty? result))
|
(if (and input (empty? result))
|
||||||
(rf/dispatch [:wallet/search-ens input chain-id cb ".stateofus.eth"])
|
(rf/dispatch [:wallet/search-ens input chain-id cb ".stateofus.eth"])
|
||||||
{:db (assoc db
|
{:db (-> db
|
||||||
:wallet/local-suggestions
|
(assoc-in [:wallet :ui :search-address :local-suggestions]
|
||||||
(map #(assoc % :type item-types/saved-address) result)
|
(map #(assoc % :type item-types/saved-address) result))
|
||||||
:wallet/valid-ens-or-address? (not-empty result))}))))
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?]
|
||||||
|
(not-empty result)))}))))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/search-ens
|
(rf/reg-event-fx :wallet/search-ens
|
||||||
(fn [_ [input chain-id cb domain]]
|
(fn [_ [input chain-id cb domain]]
|
||||||
|
@ -303,62 +304,67 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/set-ens-address
|
(rf/reg-event-fx :wallet/set-ens-address
|
||||||
(fn [{:keys [db]} [result ens]]
|
(fn [{:keys [db]} [result ens]]
|
||||||
{:db (assoc db
|
{:db
|
||||||
:wallet/local-suggestions (if result
|
(-> db
|
||||||
[{:type item-types/address
|
(assoc-in [:wallet :ui :search-address :local-suggestions]
|
||||||
:ens ens
|
(if result
|
||||||
:address (eip55/address->checksum result)
|
[{:type item-types/address
|
||||||
:networks [:ethereum :optimism]}]
|
:ens ens
|
||||||
[])
|
:address (eip55/address->checksum result)
|
||||||
:wallet/valid-ens-or-address? (boolean result))}))
|
:networks [:ethereum :optimism]}]
|
||||||
|
[]))
|
||||||
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?]
|
||||||
|
(boolean result)))}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/fetch-address-suggestions
|
(rf/reg-event-fx :wallet/fetch-address-suggestions
|
||||||
(fn [{:keys [db]} [_address]]
|
(fn [{:keys [db]} [_address]]
|
||||||
{:db (assoc db
|
{:db (-> db
|
||||||
:wallet/local-suggestions nil
|
(assoc-in [:wallet :ui :search-address :local-suggestions] nil)
|
||||||
:wallet/valid-ens-or-address? false)}))
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/ens-validation-success
|
(rf/reg-event-fx :wallet/ens-validation-success
|
||||||
(fn [{:keys [db]} [_ens]]
|
(fn [{:keys [db]} [_ens]]
|
||||||
{:db (assoc db
|
{:db (-> db
|
||||||
:wallet/local-suggestions nil
|
(assoc-in [:wallet :ui :search-address :local-suggestions] nil)
|
||||||
:wallet/valid-ens-or-address? true)}))
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] true))}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/address-validation-success
|
(rf/reg-event-fx :wallet/address-validation-success
|
||||||
(fn [{:keys [db]} [_]]
|
(fn [{:keys [db]} [_]]
|
||||||
{:db (assoc db :wallet/valid-ens-or-address? true)}))
|
{:db (assoc-in db [:wallet :ui :search-address :valid-ens-or-address?] true)}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/validate-address
|
(rf/reg-event-fx :wallet/validate-address
|
||||||
(fn [{:keys [db]} [address]]
|
(fn [{:keys [db]} [address]]
|
||||||
(let [current-timeout (get db :wallet/search-timeout)
|
(let [current-timeout (get-in db [:wallet :ui :search-address :search-timeout])
|
||||||
timeout (background-timer/set-timeout
|
timeout (background-timer/set-timeout
|
||||||
#(rf/dispatch [:wallet/address-validation-success address])
|
#(rf/dispatch [:wallet/address-validation-success address])
|
||||||
2000)]
|
2000)]
|
||||||
(background-timer/clear-timeout current-timeout)
|
(background-timer/clear-timeout current-timeout)
|
||||||
{:db (assoc db
|
{:db (-> db
|
||||||
:wallet/valid-ens-or-address? false
|
(assoc-in [:wallet :ui :search-address :search-timeout] timeout)
|
||||||
:wallet/search-timeout timeout)})))
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/validate-ens
|
(rf/reg-event-fx :wallet/validate-ens
|
||||||
(fn [{:keys [db]} [ens]]
|
(fn [{:keys [db]} [ens]]
|
||||||
(let [current-timeout (get db :wallet/search-timeout)
|
(let [current-timeout (get-in db [:wallet :ui :search-address :search-timeout])
|
||||||
timeout (background-timer/set-timeout
|
timeout (background-timer/set-timeout
|
||||||
#(rf/dispatch [:wallet/ens-validation-success ens])
|
#(rf/dispatch [:wallet/ens-validation-success ens])
|
||||||
2000)]
|
2000)]
|
||||||
(background-timer/clear-timeout current-timeout)
|
(background-timer/clear-timeout current-timeout)
|
||||||
{:db (assoc db
|
{:db (-> db
|
||||||
:wallet/valid-ens-or-address? false
|
(assoc-in [:wallet :ui :search-address :search-timeout] timeout)
|
||||||
:wallet/search-timeout timeout)})))
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/clean-local-suggestions
|
(rf/reg-event-fx :wallet/clean-local-suggestions
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
(let [current-timeout (get db :wallet/search-timeout)]
|
(let [current-timeout (get-in db [:wallet :ui :search-address :search-timeout])]
|
||||||
(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 (-> db
|
||||||
|
(assoc-in [:wallet :ui :search-address :local-suggestions] [])
|
||||||
|
(assoc-in [:wallet :ui :search-address :valid-ens-or-address?] false))})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/clean-ens-or-address-validation
|
(rf/reg-event-fx :wallet/clean-ens-or-address-validation
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
{:db (assoc db :wallet/valid-ens-or-address? false)}))
|
{:db (assoc-in db [:wallet :ui :search-address :valid-ens-or-address?] false)}))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
||||||
|
|
|
@ -156,8 +156,6 @@
|
||||||
|
|
||||||
;;wallet
|
;;wallet
|
||||||
(reg-root-key-sub :wallet :wallet)
|
(reg-root-key-sub :wallet :wallet)
|
||||||
(reg-root-key-sub :wallet/local-suggestions :wallet/local-suggestions)
|
|
||||||
(reg-root-key-sub :wallet/valid-ens-or-address? :wallet/valid-ens-or-address?)
|
|
||||||
|
|
||||||
;;debug
|
;;debug
|
||||||
(when js/goog.DEBUG
|
(when js/goog.DEBUG
|
||||||
|
|
|
@ -267,3 +267,18 @@
|
||||||
:wallet/transactions
|
:wallet/transactions
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
:-> :transactions)
|
:-> :transactions)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/search-address
|
||||||
|
:<- [:wallet/ui]
|
||||||
|
:-> :search-address)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/local-suggestions
|
||||||
|
:<- [:wallet/search-address]
|
||||||
|
:-> :local-suggestions)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/valid-ens-or-address?
|
||||||
|
:<- [:wallet/search-address]
|
||||||
|
:-> :valid-ens-or-address?)
|
||||||
|
|
|
@ -516,3 +516,22 @@
|
||||||
(is
|
(is
|
||||||
(= keypairs
|
(= keypairs
|
||||||
(rf/sub [sub-name])))))
|
(rf/sub [sub-name])))))
|
||||||
|
|
||||||
|
(def local-suggestions ["a" "b"])
|
||||||
|
|
||||||
|
(h/deftest-sub :wallet/local-suggestions
|
||||||
|
[sub-name]
|
||||||
|
(testing "returns local suggestions:"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in % [:wallet :ui :search-address :local-suggestions] local-suggestions))
|
||||||
|
(is
|
||||||
|
(= local-suggestions
|
||||||
|
(rf/sub [sub-name])))))
|
||||||
|
|
||||||
|
(h/deftest-sub :wallet/valid-ens-or-address?
|
||||||
|
[sub-name]
|
||||||
|
(testing "returns local suggestions:"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in % [:wallet :ui :search-address :valid-ens-or-address?] true))
|
||||||
|
(is
|
||||||
|
(rf/sub [sub-name]))))
|
||||||
|
|
Loading…
Reference in New Issue