diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 8f2e62ee6a5..105941c937e 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -3,6 +3,7 @@ [clojure.string :as string] [react-native.background-timer :as background-timer] [react-native.platform :as platform] + [status-im.constants :as constants] [status-im.contexts.wallet.accounts.add-account.address-to-watch.events] [status-im.contexts.wallet.common.utils :as utils] [status-im.contexts.wallet.data-store :as data-store] @@ -439,3 +440,34 @@ :type :negative :text (i18n/label :t/provider-is-down {:chains chain-names}) :duration 10000}]]])}))) + +(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 + (fn [_ [{:keys [on-success on-error]}]] + {:json-rpc/call + [{:method "wakuext_getSavedAddresses" + :on-success on-success + :on-error on-error}]}))