-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ποΈ Connect getSavedAddresses RPC to show or hide save address button (#β¦
β¦19508) * ποΈ Connect getSavedAddresses - The save button will not show if the address is already saved * βοΈ Fix PR reviews * ποΈ Remove code from wallet events ns
- Loading branch information
1 parent
f0026b4
commit d0374d9
Showing
6 changed files
with
71 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns status-im.contexts.wallet.events.saved-addresses | ||
(:require | ||
[status-im.constants :as constants] | ||
[utils.re-frame :as rf])) | ||
|
||
(rf/reg-event-fx | ||
:wallet/save-address | ||
(fn [_ | ||
[{:keys [address name customization-color on-success on-error chain-short-names ens test?] | ||
:or {on-success (fn []) | ||
on-error (fn []) | ||
name "" | ||
ens "" | ||
test? false | ||
;; the chain short names should be a string like eth: or eth:arb:opt: | ||
chain-short-names (str constants/mainnet-short-name ":")}}]] | ||
(let [address-to-save {:address address | ||
:name name | ||
:color-id customization-color | ||
:ens ens | ||
:is-test test? | ||
:chain-short-names chain-short-names}] | ||
{:json-rpc/call | ||
[{:method "wakuext_upsertSavedAddress" | ||
:params [address-to-save] | ||
:on-success on-success | ||
:on-error on-error}]}))) | ||
|
||
(rf/reg-event-fx | ||
:wallet/get-saved-addresses-success | ||
(fn [{:keys [db]} [saved-addresses]] | ||
{:db (assoc-in db [:wallet :saved-addresses] saved-addresses)})) | ||
|
||
(rf/reg-event-fx | ||
:wallet/get-saved-addresses-error | ||
(fn [{:keys [db]} [err]] | ||
{:db (assoc db [:wallet :get-saved-addresses-error] err)})) | ||
|
||
(rf/reg-event-fx | ||
:wallet/get-saved-addresses | ||
(fn [_ _] | ||
{:json-rpc/call | ||
[{:method "wakuext_getSavedAddresses" | ||
:on-success [:wallet/get-saved-addresses-success] | ||
:on-error [:wallet/get-saved-addresses-error]}]})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(ns status-im.subs.wallet.saved-addresses | ||
(:require | ||
[re-frame.core :as rf])) | ||
|
||
(rf/reg-sub | ||
:wallet/saved-addresses | ||
:<- [:wallet] | ||
:-> :saved-addresses) | ||
|
||
(rf/reg-sub | ||
:wallet/address-saved? | ||
:<- [:wallet] | ||
(fn [wallet [address]] | ||
(some #(= address (:address %)) | ||
(:saved-addresses wallet)))) |