From a03cc3c3ab4c2bd4650323dade335dd66f68932a Mon Sep 17 00:00:00 2001 From: Shivek Khurana Date: Tue, 2 Apr 2024 12:25:28 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20methods=20for=20fetching=20an?= =?UTF-8?q?d=20saving=20addresses=20(#19356)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ➕ Add methods for fetching and saving addresses * 🔨 Fix RPC calls but get addresses not working * 🔨 Fix rpc call * 🧰 Fix lint, and change var names --- src/status_im/contexts/wallet/events.cljs | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 8f2e62ee6a..105941c937 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}]}))