chore: clean up wallet reframe root keys (#18730)

This commit is contained in:
Jamie Caprani 2024-02-14 12:29:35 +00:00 committed by GitHub
parent f762cdcf9b
commit 83523b1923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 7 deletions

View File

@ -148,12 +148,12 @@
(rf/defn scan-address-success
{:events [:wallet/scan-address-success]}
[{:keys [db]} address]
{:db (assoc db :wallet/scanned-address address)})
{:db (assoc-in db [:wallet :ui :scanned-address] address)})
(rf/defn clean-scanned-address
{:events [:wallet/clean-scanned-address]}
[{:keys [db]}]
{:db (dissoc db :wallet/scanned-address :wallet/send-address)})
{:db (update-in db [:wallet :ui] dissoc :scanned-address)})
(rf/reg-event-fx :wallet/create-derived-addresses
(fn [{:keys [db]} [{:keys [sha3-pwd path]} on-success]]

View File

@ -10,15 +10,16 @@
(deftest scan-address-success
(let [db {}]
(testing "scan-address-success"
(let [expected-db {:wallet/scanned-address address}
(let [expected-db {:wallet {:ui {:scanned-address address}}}
effects (events/scan-address-success {:db db} address)
result-db (:db effects)]
(is (match? result-db expected-db))))))
(deftest clean-scanned-address
(let [db {:wallet/scanned-address address}]
(let [db {:wallet {:ui {:scanned-address address}}}]
(testing "clean-scanned-address"
(let [expected-db {:wallet {:ui {:send nil}}}
(let [expected-db {:wallet {:ui {:send nil
:scanned-address nil}}}
effects (events/clean-scanned-address {:db db})
result-db (:db effects)]
(is (match? result-db expected-db))))))

View File

@ -156,8 +156,6 @@
;;wallet
(reg-root-key-sub :wallet :wallet)
(reg-root-key-sub :wallet/scanned-address :wallet/scanned-address)
(reg-root-key-sub :wallet/create-account :wallet/create-account)
(reg-root-key-sub :wallet/local-suggestions :wallet/local-suggestions)
(reg-root-key-sub :wallet/valid-ens-or-address? :wallet/valid-ens-or-address?)

View File

@ -28,6 +28,11 @@
:<- [:wallet]
:-> :ui)
(rf/reg-sub
:wallet/scanned-address
:<- [:wallet/ui]
:-> :scanned-address)
(rf/reg-sub
:wallet/tokens-loading?
:<- [:wallet/ui]